Skip to content

fix(android): fail the build when posthog-android would be raised to 4.x - #728

Closed
turnipdabeets wants to merge 1 commit into
mainfrom
fix/android-strict-posthog-android-range
Closed

turnipdabeets wants to merge 1 commit into
mainfrom
fix/android-strict-posthog-android-range

Conversation

@turnipdabeets

@turnipdabeets turnipdabeets commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

posthog_flutter 5.x declares com.posthog:posthog-android:[3.75.0,4.0.0). A plain Gradle range isn't a ceiling: when anything else in the app asks for posthog-android 4.x, Gradle picks the highest version and the app ships posthog-android 4.0. The plugin is compiled in its own Gradle project against 3.x, so the build succeeds and the app crashes at runtime on APIs 4.0 removes, for example PostHogOnFeatureFlags during Posthog().setup and RRStyle in the replay snapshot path.

Ways an app gets there once posthog-android 4.0 ships:

This makes the range strictly '[3.75.0,4.0.0)', so those builds fail at dependency resolution with Gradle's "Cannot find a version of 'com.posthog:posthog-android' that satisfies the version constraints", naming this plugin's dependency path, instead of crashing at runtime. Apps that only use the plugin resolve the same 3.x version as before.

Only apps that update to this 5.x release get the check. posthog_flutter 6 gets the same change on its 4.x range in #729.

💚 How did you test it?

Locally, with posthog-android 4.0.0 and core 7.0.0 built from PostHog/posthog-android#871 and published to a scratch Maven repo, in a throwaway flutter create app on this branch's plugin (path dependency):

App dependencies Before (5.60.2) This branch
plugin only builds, posthog-android 3.76.2 builds, posthog-android 3.76.2
plus com.posthog:posthog:7.0.0 builds; app gets posthog-android 4.0.0 while the plugin compiled against 3.76.2 build fails at resolution
plus com.posthog:posthog-android:4.0.0 builds, same mismatch build fails at resolution
  • flutter build apk --debug in example/ builds.
  • :posthog_flutter:testDebugUnitTest: 75 tests, 0 failures.
  • The runtime crash itself wasn't reproduced on a device. The removed APIs were found by compiling the plugin against posthog-android 4.0.0.

📝 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 (posthog_flutter patch)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code (Claude Opus 5.5) found this while testing the posthog-android 4.0 release: a wrapper check showed the 5.x plugin builds next to core 7 and only fails at runtime. strictly was chosen over a prefer pin so the plugin keeps picking up 3.x patch releases without edits. No added test: the behavior is Gradle dependency resolution in a consuming app, which the plugin's unit tests can't exercise.

🤖 Generated with Claude Code

The plugin's posthog-android range was a plain range, so Gradle raised it to
4.0 when the app or another library asked for 4.x (for example core posthog
7.x or posthog-server 2.25). The plugin, compiled against 3.x, then crashed at
runtime on APIs 4.0 removes. A strict range makes that a resolution error.

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

Copy link
Copy Markdown
Contributor

posthog-flutter Compliance Report

Date: 2026-11-12 21:07:10 UTC
Duration: 96483ms

✅ All Tests Passed!

45/45 tests passed


Capture Tests

✅ 29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 126ms
Format Validation.Event Has Uuid ✅ 113ms
Format Validation.Event Has Lib Properties ✅ 111ms
Format Validation.Distinct Id Is String ✅ 113ms
Format Validation.Token Is Present ✅ 122ms
Format Validation.Custom Properties Preserved ✅ 113ms
Format Validation.Event Has Timestamp ✅ 112ms
Retry Behavior.Retries On 503 ✅ 5323ms
Retry Behavior.Does Not Retry On 400 ✅ 2113ms
Retry Behavior.Does Not Retry On 401 ✅ 2113ms
Retry Behavior.Respects Retry After Header ✅ 8120ms
Retry Behavior.Implements Backoff ✅ 15435ms
Retry Behavior.Retries On 500 ✅ 5219ms
Retry Behavior.Retries On 502 ✅ 5219ms
Retry Behavior.Retries On 504 ✅ 5220ms
Retry Behavior.Max Retries Respected ✅ 15438ms
Deduplication.Generates Unique Uuids ✅ 115ms
Deduplication.Preserves Uuid On Retry ✅ 5216ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 10329ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 5224ms
Deduplication.No Duplicate Events In Batch ✅ 116ms
Deduplication.Different Events Have Different Uuids ✅ 111ms
Compression.Sends Gzip When Enabled ✅ 111ms
Batch Format.Uses Proper Batch Structure ✅ 110ms
Batch Format.Flush With No Events Sends Nothing ✅ 106ms
Batch Format.Multiple Events Batched Together ✅ 117ms
Error Handling.Does Not Retry On 403 ✅ 2111ms
Error Handling.Does Not Retry On 413 ✅ 2114ms
Error Handling.Retries On 408 ✅ 5220ms

Feature_Flags Tests

✅ 16/16 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 9ms
Request Payload.Flags Request Uses V2 Query Param ✅ 6ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 5ms
Request Payload.Flags Request Omits Authorization Header ✅ 5ms
Request Payload.Token In Flags Body Matches Init ✅ 6ms
Request Payload.Groups Round Trip ✅ 5ms
Request Payload.Groups Default To Empty Object ✅ 6ms
Request Payload.Person Properties Distinct Id Auto Populated When Caller Omits It ✅ 6ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 5ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 6ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 5ms
Request Lifecycle.No Flags Request On Init Alone ✅ 2ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 108ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 11ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 5ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 110ms

@turnipdabeets
turnipdabeets marked this pull request as ready for review November 12, 2026 23:08
@turnipdabeets
turnipdabeets requested a review from a team as a code owner November 12, 2026 23: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

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.

1 participant