Skip to content

fix: align posthog-android to core's major with a Gradle constraint - #974

Merged
turnipdabeets merged 1 commit into
chore/v4-remove-deprecatedfrom
chore/v4-version-constraints
Nov 12, 2026
Merged

turnipdabeets merged 1 commit into
chore/v4-remove-deprecatedfrom
chore/v4-version-constraints

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Stacked on #871.

An app can end up with core posthog 7.x next to posthog-android 3.x, for example by declaring com.posthog:posthog directly or getting it from another library. posthog-android 3.x then calls core APIs that 7.0 removes, and the app crashes with NoSuchMethodError as soon as it builds PostHogAndroidConfig, because the old PostHogConfig constructor is gone. We can't fix that in 3.x code that's already published, and it fails in the app's own config call before any SDK code we control runs.

This PR publishes a Gradle dependency constraint from core to com.posthog:posthog-android at the matching major (<androidVersion major>.0.0, so 4.0.0 at release). The constraint doesn't add posthog-android to anyone's dependencies. It only applies when posthog-android is already there, and then Gradle upgrades it to 4.x instead of shipping the broken combination. Server SDK users aren't affected.

The other direction is already safe:

  • posthog-android 4.0 pulls core 7, and Gradle picks the highest version, so core can't stay on 6.x unless an app forces it.
  • The released posthog-android-surveys-compose 0.5.0 (built against posthog-android 3.75.1) links cleanly against 4.0, so it needs no constraint for now.

Limits:

  • Only Gradle builds read the constraint (from Gradle Module Metadata), which covers practically every Android app. In the POM it shows up as a dependencyManagement entry, which Maven doesn't apply to consumers.
  • An app that forces versions with strictly gets a build-time resolution error instead of a runtime crash.

💚 How did you test it?

  • Bytecode linkage check. A scratch script checked every com/posthog member reference in the published AARs against jars built from this branch:

    • posthog-android 3.76.2 against core 7: 33 missing references, including PostHogConfig.<init>. This confirms the crash.
    • posthog-android-surveys-compose 0.5.0 against android 4 + core 7: 0 missing.
    • Control: 3.76.2 against core 6.48.2 had no real misses.
  • End-to-end resolution. I published core 7.0.0 and posthog-android 4.0.0 from this branch to a scratch Maven repo, then resolved releaseRuntimeClasspath in a throwaway AGP 8.9.1 library:

    Consumer declares Resolves to
    posthog-android:3.76.2 + posthog:7.0.0 posthog-android:3.76.2 -> 4.0.0 (dependencyInsight: "By constraint: posthog-android must match the major of the core posthog artifact")
    posthog-android:4.0.0 + posthog-android-surveys-compose:0.5.0 android 4.0.0, core 7.0.0
    posthog-android:3.76.2 only (control) unchanged, core 6.48.1
  • Checked the generated module.json and POM for the constraint. :posthog-server's runtime classpath doesn't include posthog-android, the lockfiles don't change, and spotlessCheck passes.

  • I didn't add a committed test. A check that the build file declares the constraint would only restate the build file, and the useful check (resolving against published artifacts) needs a separate consumer build.

📝 Checklist

  • All commits are signed (see Commit signing)
  • 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.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file. Added a bullet to the shared .changeset/android-v4-major.md.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code (Opus 5.5) did the investigation and the change. We started by checking the claim that mixing 4.0 and 3.x packages crashes the app. The .api dumps leave out @PostHogInternal members that are still public in bytecode, so the binary-compatibility verdicts come from the bytecode linkage check, not the API diff. I considered and dropped a matching constraint from posthog-android to surveys-compose, since today's surveys-compose release is binary-compatible with 4.0. A runtime version guard was also ruled out, because the crash happens in the app's own config construction before SDK code runs.

🤖 Generated with Claude Code

posthog-android 3.x calls core APIs that 7.0 removes, so an app that pins
core 7.x next to posthog-android 3.x crashes with NoSuchMethodError when it
builds PostHogAndroidConfig. Publish a constraint from core to posthog-android
at the matching major so Gradle upgrades posthog-android instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turnipdabeets turnipdabeets self-assigned this Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-11-12T18:29:08.684748+00:00
Duration: 474559ms

✅ 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 ✅ 301ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 24ms
Required Headers.Has Authorization Bearer Header ✅ 27ms
Required Headers.Has Content Type Json ✅ 25ms
Required Headers.Has Posthog Sdk Info Format ✅ 22ms
Required Headers.Has Posthog Attempt Header ✅ 22ms
Required Headers.Has Posthog Request Id ✅ 18ms
Required Headers.Has Posthog Request Timestamp ✅ 22ms
Required Headers.Has User Agent ✅ 21ms
Body Format.Body Has Created At And Batch ✅ 23ms
Body Format.No Api Key In Body ✅ 22ms
Body Format.No Sent At In Body ✅ 17ms
Event Format.Event Has Required Root Fields ✅ 17ms
Event Format.Event Uuid Is Valid ✅ 18ms
Event Format.Event Timestamp Is Rfc3339 ✅ 16ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 21ms
Event Format.Distinct Id Is String ✅ 16ms
Event Format.Distinct Id At Root Not Properties ✅ 19ms
Event Format.Custom Properties Preserved ✅ 18ms
Event Format.Set Properties Preserved ✅ 19ms
Event Format.Set Once Properties Preserved ✅ 18ms
Event Format.Groups Properties Preserved ✅ 17ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 23ms
Event Format.Event Has Required Root Fields Batch ✅ 25ms
Event Format.Event Uuid Is Valid Batch ✅ 24ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 22ms
Event Format.Distinct Id Is String Batch ✅ 20ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 20ms
Event Format.Custom Properties Preserved Batch ✅ 24ms
Event Format.Set Properties Preserved Batch ✅ 23ms
Event Format.Set Once Properties Preserved Batch ✅ 18ms
Event Format.Groups Properties Preserved Batch ✅ 24ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 33ms
Batch Behavior.Multiple Events In Single Batch ✅ 27ms
Batch Behavior.Batch Envelope Smoke ✅ 31ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 13ms
Batch Behavior.Flush At Triggers Batch ✅ 1019ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 17ms
Deduplication.Generates Unique Uuids ✅ 32ms
Deduplication.Different Events Same Content Different Uuids ✅ 25ms
Deduplication.Preserves Uuid On Retry ✅ 7015ms
Deduplication.Preserves Timestamp On Retry ✅ 7017ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7021ms
Deduplication.No Duplicate Events In Batch ✅ 26ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 14ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 12020ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 7014ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2027ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 7014ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 14ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 16ms
Response Format Validation.Success No Retry After When All Ok ✅ 19ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2008ms
Response Format Validation.Success No Retry After When Drop Only ✅ 17ms
Response Format Validation.Response Echoes Request Id ✅ 11ms
Retry Behavior.Retries On 408 ✅ 7013ms
Retry Behavior.Retries On 500 ✅ 7014ms
Retry Behavior.Retries On 503 ✅ 7019ms
Retry Behavior.Retries On 504 ✅ 7011ms
Retry Behavior.Retries On 404 ✅ 6016ms
Retry Behavior.Retries On 429 ✅ 7016ms
Retry Behavior.Retries On 502 ✅ 7015ms
Retry Behavior.Retryable Errors Have Retry After ✅ 4011ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10026ms
Retry Behavior.Does Not Retry On 400 ✅ 4017ms
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 ✅ 4017ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4014ms
Retry Behavior.Implements Backoff ✅ 14025ms
Partial Batch Handling.Handles 200 Full Success ✅ 2017ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3023ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3017ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 3019ms
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 ✅ 7013ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7013ms
Partial Batch Handling.Partial Retry Request Id Preserved ✅ 7016ms
Partial Batch Handling.Respects Retry After On Partial ✅ 7023ms
Partial Batch Handling.Unknown Result Treated As Terminal ✅ 3019ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 3022ms
Compression.Sends Gzip Content Encoding ✅ 12ms
Compression.No Content Encoding When Disabled ✅ 10ms
Compression.Compressed Body Is Decompressible ✅ 11ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4014ms
Event Options.Cookieless Mode Override ✅ 12ms
Event Options.Disable Skew Correction Override ✅ 10ms
Event Options.Process Person Profile Override ✅ 10ms
Event Options.Product Tour Id Override ✅ 11ms
Event Options.Unset Options Omitted ✅ 11ms
Event Options.Options Override In Batch ✅ 13ms
Event Options.Unknown Option Passes Through ✅ 13ms
Event Options.Option Value Is Not Converted ✅ 15ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 14ms
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 ✅ 12ms
Property Layers.Caller Property Beats Registered Property ✅ 13ms
Property Layers.Before Send Runs Last ✅ 15ms
Fail Open.Empty Api Key Sends Nothing ✅ 3010ms
Fail Open.Personal Api Key Sends Nothing ✅ 3010ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 13ms

Capture_Ai_V1 Tests

✅ 110/110 tests passed

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

Feature_Flags Tests

✅ 17/17 tests passed

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

@turnipdabeets
turnipdabeets marked this pull request as ready for review November 12, 2026 19:08
@turnipdabeets
turnipdabeets requested a review from a team as a code owner November 12, 2026 19:08
@veria-ai

veria-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved.

The disclosed dependency and publishing changes enter risky territory, covered by the current-head independent review reported in the trusted context. No unresolved substantive concerns or other refusal grounds were found.

  • Author wrote 0% of the modified lines and has 39 merged PRs in these paths (familiarity MODERATE).
  • PostHog Review (Standard) reviewed the current head: no findings.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 10L, 1F substantive, 11L/2F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (11L, 2F, two-areas, fix)
stamphog 2.8.0 .stamphog/policy.yml @ 5b113b7 · reviewed head 5b113b7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant