Skip to content

fix: keep $lib and $lib_version on capture v1 events - #942

Merged
turnipdabeets merged 1 commit into
chore/v4-remove-deprecatedfrom
fix/v4-keep-lib-props
Nov 5, 2026
Merged

turnipdabeets merged 1 commit into
chore/v4-remove-deprecatedfrom
fix/v4-keep-lib-props

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Capture v1 currently deletes $lib/$lib_version from each event before sending, and PostHog fills them from the PostHog-Sdk-Info header. That header carries the SDK version running at send time, so an event queued offline and sent after an app update gets the new version. 4.0 also sends events 3.x left on disk, so those get labeled 4.0.

Per the capture v1 thread, we're keeping per-event $lib/$lib_version and having ingestion store them as sent. This PR stops deleting them in captureV1Json (PostHogApi.kt), so 4.0 sends them like 3.x did. They stay visible and changeable in beforeSend.

Until capture-rs stops overwriting them from the header, PostHog stores the same values as before this PR. The behavior changes once that backend change lands.

Docs: removed the breaking-change entry from the changeset and the "SDK identity" section and checklist line from docs/migration-3.x-to-4.0.md, since 3.x behavior is back.

💚 How did you test it?

  • PostHogCaptureV1Test: the event queued on disk by 3.x now keeps $lib_version: 3.20.0 when sent; the root-fields test keeps the event's own values. The minimal $feature_flag_called key set gains $lib/$lib_version.
  • Re-recorded batch-request.json: all 5 events now carry $lib/$lib_version (the rest of that diff is lines moving).
  • With the old code put back, the changed tests fail; with this change they pass.
  • ./gradlew apiCheck spotlessCheck :posthog:test :posthog-android:testReleaseUnitTest :posthog-server:test passes.

📝 Checklist

  • All commits are signed
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

  • Claude Code (Claude Opus 5.5). Scope kept to the send step; the SDK already sets $lib/$lib_version at capture time, so no new injection point.
  • Removed the docs entry rather than rewording it, because the SDK now matches 3.x.

🤖 Generated with Claude Code

An event queued before an SDK upgrade keeps the version that captured it instead of getting the running version from PostHog-Sdk-Info.
@turnipdabeets turnipdabeets self-assigned this Nov 5, 2026
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-11-05T19:23:33.941125+00:00
Duration: 477502ms

✅ All Tests Passed!

232/232 tests passed


Capture_V1 Tests

✅ 105/105 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 420ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 31ms
Required Headers.Has Authorization Bearer Header ✅ 29ms
Required Headers.Has Content Type Json ✅ 30ms
Required Headers.Has Posthog Sdk Info Format ✅ 31ms
Required Headers.Has Posthog Attempt Header ✅ 26ms
Required Headers.Has Posthog Request Id ✅ 29ms
Required Headers.Has Posthog Request Timestamp ✅ 27ms
Required Headers.Has User Agent ✅ 35ms
Body Format.Body Has Created At And Batch ✅ 27ms
Body Format.No Api Key In Body ✅ 25ms
Body Format.No Sent At In Body ✅ 21ms
Event Format.Event Has Required Root Fields ✅ 23ms
Event Format.Event Uuid Is Valid ✅ 26ms
Event Format.Event Timestamp Is Rfc3339 ✅ 22ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 25ms
Event Format.Distinct Id Is String ✅ 22ms
Event Format.Distinct Id At Root Not Properties ✅ 26ms
Event Format.Custom Properties Preserved ✅ 30ms
Event Format.Set Properties Preserved ✅ 25ms
Event Format.Set Once Properties Preserved ✅ 25ms
Event Format.Groups Properties Preserved ✅ 25ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 30ms
Event Format.Event Has Required Root Fields Batch ✅ 28ms
Event Format.Event Uuid Is Valid Batch ✅ 30ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 26ms
Event Format.Distinct Id Is String Batch ✅ 27ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 30ms
Event Format.Custom Properties Preserved Batch ✅ 29ms
Event Format.Set Properties Preserved Batch ✅ 28ms
Event Format.Set Once Properties Preserved Batch ✅ 28ms
Event Format.Groups Properties Preserved Batch ✅ 25ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 32ms
Batch Behavior.Multiple Events In Single Batch ✅ 32ms
Batch Behavior.Batch Envelope Smoke ✅ 31ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 14ms
Batch Behavior.Flush At Triggers Batch ✅ 1029ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 19ms
Deduplication.Generates Unique Uuids ✅ 40ms
Deduplication.Different Events Same Content Different Uuids ✅ 23ms
Deduplication.Preserves Uuid On Retry ✅ 7015ms
Deduplication.Preserves Timestamp On Retry ✅ 7016ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7024ms
Deduplication.No Duplicate Events In Batch ✅ 35ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 17ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 12028ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 7015ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2027ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 7015ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 18ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 24ms
Response Format Validation.Success No Retry After When All Ok ✅ 20ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2011ms
Response Format Validation.Success No Retry After When Drop Only ✅ 19ms
Response Format Validation.Response Echoes Request Id ✅ 18ms
Retry Behavior.Retries On 408 ✅ 7017ms
Retry Behavior.Retries On 500 ✅ 7016ms
Retry Behavior.Retries On 503 ✅ 7024ms
Retry Behavior.Retries On 504 ✅ 7015ms
Retry Behavior.Retries On 404 ✅ 7017ms
Retry Behavior.Retries On 429 ✅ 7015ms
Retry Behavior.Retries On 502 ✅ 7018ms
Retry Behavior.Retryable Errors Have Retry After ✅ 4013ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10018ms
Retry Behavior.Does Not Retry On 400 ✅ 4023ms
Retry Behavior.Does Not Retry On 401 ✅ 4016ms
Retry Behavior.Does Not Retry On 402 ✅ 4018ms
Retry Behavior.Does Not Retry On 413 ✅ 4019ms
Retry Behavior.Does Not Retry On 415 ✅ 4022ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4018ms
Retry Behavior.Implements Backoff ✅ 14017ms
Partial Batch Handling.Handles 200 Full Success ✅ 2019ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3025ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3022ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 3022ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7015ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7015ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7014ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7015ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7015ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7017ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7023ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3021ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 3024ms
Compression.Sends Gzip Content Encoding ✅ 14ms
Compression.No Content Encoding When Disabled ✅ 13ms
Compression.Compressed Body Is Decompressible ✅ 13ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4016ms
Event Options.Cookieless Mode Override ✅ 15ms
Event Options.Disable Skew Correction Override ✅ 12ms
Event Options.Process Person Profile Override ✅ 13ms
Event Options.Product Tour Id Override ✅ 14ms
Event Options.Unset Options Omitted ✅ 14ms
Event Options.Options Override In Batch ✅ 25ms
Event Options.Unknown Option Passes Through ✅ 17ms
Event Options.Option Value Is Not Converted ✅ 16ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 15ms
Event Options.Option Wins Over Legacy Property ✅ 13ms
Event Options.Legacy Property Fills Unset Option ✅ 15ms
Event Options.Null Option Falls Back To Legacy Property ✅ 14ms
Property Layers.Caller Property Beats Registered Property ✅ 13ms
Property Layers.Before Send Runs Last ✅ 16ms
Fail Open.Empty Api Key Sends Nothing ✅ 3012ms
Fail Open.Personal Api Key Sends Nothing ✅ 3012ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 14ms

Capture_Ai_V1 Tests

✅ 110/110 tests passed

View Details
Test Status Duration
Endpoint And Method.Targets V1 Endpoint ✅ 15ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 12ms
Endpoint And Method.Capture Does Not Reroute Ai Named Events ✅ 12ms
Endpoint And Method.Capture Ai Does Not Reroute Non Ai Events ✅ 14ms
Lane Isolation.Failing Ai Lane Does Not Delay Analytics ✅ 7021ms
Required Headers.Has Authorization Bearer Header ✅ 16ms
Required Headers.Has Content Type Json ✅ 16ms
Required Headers.Has Posthog Sdk Info Format ✅ 16ms
Required Headers.Has Posthog Attempt Header ✅ 16ms
Required Headers.Has Posthog Request Id ✅ 15ms
Required Headers.Has Posthog Request Timestamp ✅ 14ms
Required Headers.Has User Agent ✅ 14ms
Body Format.Body Has Created At And Batch ✅ 15ms
Body Format.No Api Key In Body ✅ 17ms
Body Format.No Sent At In Body ✅ 18ms
Event Format.Event Has Required Root Fields ✅ 22ms
Event Format.Event Uuid Is Valid ✅ 19ms
Event Format.Event Timestamp Is Rfc3339 ✅ 18ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 27ms
Event Format.Distinct Id Is String ✅ 17ms
Event Format.Distinct Id At Root Not Properties ✅ 17ms
Event Format.Custom Properties Preserved ✅ 15ms
Event Format.Set Properties Preserved ✅ 14ms
Event Format.Set Once Properties Preserved ✅ 16ms
Event Format.Groups Properties Preserved ✅ 14ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 16ms
Event Format.Event Has Required Root Fields Batch ✅ 22ms
Event Format.Event Uuid Is Valid Batch ✅ 24ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 23ms
Event Format.Distinct Id Is String Batch ✅ 20ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 19ms
Event Format.Custom Properties Preserved Batch ✅ 21ms
Event Format.Set Properties Preserved Batch ✅ 22ms
Event Format.Set Once Properties Preserved Batch ✅ 22ms
Event Format.Groups Properties Preserved Batch ✅ 31ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 21ms
Batch Behavior.Multiple Events In Single Batch ✅ 27ms
Batch Behavior.Batch Envelope Smoke ✅ 23ms
Batch Behavior.Flush At Triggers Batch ✅ 1015ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 15ms
Deduplication.Generates Unique Uuids ✅ 27ms
Deduplication.Different Events Same Content Different Uuids ✅ 16ms
Deduplication.Preserves Uuid On Retry ✅ 7013ms
Deduplication.Preserves Timestamp On Retry ✅ 7015ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7016ms
Deduplication.No Duplicate Events In Batch ✅ 25ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 12ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 12019ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 7015ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2021ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 7014ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 13ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 19ms
Response Format Validation.Success No Retry After When All Ok ✅ 16ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2009ms
Response Format Validation.Success No Retry After When Drop Only ✅ 17ms
Response Format Validation.Response Echoes Request Id ✅ 13ms
Retry Behavior.Retries On 408 ✅ 7014ms
Retry Behavior.Retries On 500 ✅ 7014ms
Retry Behavior.Retries On 503 ✅ 7020ms
Retry Behavior.Retries On 504 ✅ 7014ms
Retry Behavior.Retries On 404 ✅ 7015ms
Retry Behavior.Retries On 429 ✅ 6012ms
Retry Behavior.Retries On 502 ✅ 7015ms
Retry Behavior.Retryable Errors Have Retry After ✅ 4012ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10022ms
Retry Behavior.Does Not Retry On 400 ✅ 4015ms
Retry Behavior.Does Not Retry On 401 ✅ 4015ms
Retry Behavior.Does Not Retry On 402 ✅ 4017ms
Retry Behavior.Does Not Retry On 413 ✅ 4015ms
Retry Behavior.Does Not Retry On 415 ✅ 4016ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4017ms
Retry Behavior.Implements Backoff ✅ 14025ms
Partial Batch Handling.Handles 200 Full Success ✅ 2015ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3027ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3018ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 3020ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7015ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7015ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7013ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7010ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7014ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7014ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7020ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3019ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 3024ms
Compression.Sends Gzip Content Encoding ✅ 16ms
Compression.No Content Encoding When Disabled ✅ 15ms
Compression.Compressed Body Is Decompressible ✅ 17ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4016ms
Event Options.Cookieless Mode Override ✅ 14ms
Event Options.Disable Skew Correction Override ✅ 11ms
Event Options.Process Person Profile Override ✅ 13ms
Event Options.Product Tour Id Override ✅ 14ms
Event Options.Unset Options Omitted ✅ 12ms
Event Options.Options Override In Batch ✅ 17ms
Event Options.Unknown Option Passes Through ✅ 13ms
Event Options.Option Value Is Not Converted ✅ 13ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 13ms
Event Options.Option Wins Over Legacy Property ✅ 14ms
Event Options.Legacy Property Fills Unset Option ✅ 12ms
Event Options.Null Option Falls Back To Legacy Property ✅ 13ms
Event Size.Event Over Ceiling Is Not Sent ✅ 3357ms
Event Size.Over Ceiling Drop Is Reported Or Logged Without Content ✅ 2072ms
Event Size.Batches Close Before Byte Target ✅ 6068ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 16ms
Property Layers.Caller Property Beats Registered Property ✅ 14ms
Property Layers.Before Send Runs Last ✅ 14ms
Fail Open.Empty Api Key Sends Nothing ✅ 1009ms
Fail Open.Personal Api Key Sends Nothing ✅ 1010ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 28ms
Request Payload.Flags Request Uses V2 Query Param ✅ 16ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 15ms
Request Payload.Flags Request Omits Authorization Header ✅ 15ms
Request Payload.Token In Flags Body Matches Init ✅ 14ms
Request Payload.Groups Round Trip ✅ 14ms
Request Payload.Groups Default To Empty Object ✅ 16ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 18ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 13ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 17ms
Request Lifecycle.No Flags Request On Init Alone ✅ 5ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 14ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 21ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 13ms
Retry Behavior.Retries Flags On 502 ✅ 316ms
Retry Behavior.Retries Flags On 504 ✅ 316ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 15ms

@turnipdabeets
turnipdabeets merged commit a2b3c67 into chore/v4-remove-deprecated Nov 5, 2026
12 checks passed
@turnipdabeets
turnipdabeets deleted the fix/v4-keep-lib-props branch November 5, 2026 22:58
gewenyu99 added a commit that referenced this pull request Nov 6, 2026
Rebuilt from docs/migration-3.x-to-4.0.md on chore/v4-remove-deprecated,
which dropped the SDK identity section (#942) and added the custom
httpClient paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
gewenyu99 added a commit that referenced this pull request Nov 11, 2026
)

* docs: generate the SDK reference for 3.x

Generated by bin/docs_scripts/generate_markdown.py.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs: generate the experimental SDK reference for 4.x

Generated by bin/docs_scripts/generate_markdown.py --major 4 --experimental from feat/v4-capture-v1 (PRs #871 and #881), with the capability tags applied on top. Adds the 3.x to 4.0 migration guide page.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

* docs: regenerate the Android references from Dokka's HTML

The 4.x page and migration guide come from chore/v4-remove-deprecated (the 4.0
branch) with the capability tags and getting-started applied. Both still need to
land there.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: regenerate the Android references with braces kept in code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: regenerate the Android references from docs/capabilities.json

The 3.x pages lose only the blank line the stripped capability tags left behind. The 4.x page also
moves captureAi to Capture AI and onFeatureFlags to On feature flags, which the map's "next"
entries add.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: regenerate the Android references after review fixes

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: regenerate the Android migration page from the current 4.0 guide

Rebuilt from docs/migration-3.x-to-4.0.md on chore/v4-remove-deprecated,
which dropped the SDK identity section (#942) and added the custom
httpClient paragraph.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: regenerate the Android migration page from the current 4.0 guide

Rebuilt from docs/migration-3.x-to-4.0.md on chore/v4-remove-deprecated,
which now covers the missing-flag response, posthog-server 2.25 and retry scope.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: regenerate the Android 4.x page from chore/v4-remove-deprecated

Picks up the branch's feature flag doc comment fixes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: regenerate the references with the getting-started intro

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants