Skip to content

feat: add disableGeoIp configuration - #971

Merged
marandaneto merged 2 commits into
mainfrom
feat/disable-geoip
Nov 13, 2026
Merged

marandaneto merged 2 commits into
mainfrom
feat/disable-geoip

Conversation

@marandaneto

@marandaneto marandaneto commented Nov 12, 2026 •

Copy link
Copy Markdown
Member

💡 Motivation and Context

Android apps cannot disable server-side GeoIP enrichment through SDK configuration. Flutter currently needs an Android workaround that marks events but does not cover feature flag requests. iOS already exposes disableGeoIp.

Closes #562. Supports the Flutter integration.

Add PostHogConfig.disableGeoIp, inherited by PostHogAndroidConfig, with a default of false. When enabled, both stateful and stateless analytics events carry $geoip_disable: true, and feature flag requests send geoip_disable: true. The event marker takes precedence over caller properties, matching iOS, but beforeSend can still change it. Replay snapshots do not receive the marker. Minimized $feature_flag_called events retain it.

The event and request markers follow the capture spec. Existing explicit overrides in the internal flags API remain supported.

💚 How did you test it?

  • Confirmed four regression tests failed before wiring the option into events, flags requests, and the minimized-event allowlist, then passed after implementation.
  • Reproduced the stateless omission on 05e58433: two new tests failed because hooks saw missing or caller-supplied markers. The same tests pass after fixing the stateless builder. The three-test suite uses the public factory and real HTTP batching to cover capture, identify, alias, group, exception, and flag exposure events, defaults, caller precedence, and hooks that replace or remove the marker.
  • JAVA_HOME=<JDK 17> make testJava: all 1,109 core tests passed.
  • ./gradlew :posthog-android:testReleaseUnitTest --tests 'com.posthog.android.PostHogAndroidConfigTest': all 10 tests passed.
  • make checkFormat and git diff --check passed.
  • make api regenerated the API dump. API checks passed for posthog, posthog-android, and posthog-server.

The initial full core run used JDK 21 and hit the pinned Byte Buddy version's unsupported-JDK error. The complete rerun passed on JDK 17, matching CI. No manual device testing was performed.

📝 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

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented with the Pi coding agent using shell tools, GitHub CLI, Gradle, and pnpm in a dedicated worktree. The human directed Android parity with iOS. The option is inherited from core configuration without changing constructors. Pi session 01a1d05e-f658-73bd-a9c4-f36980c33245 is local and has no public link.

The diff-scoped cleanup and test authoring audit found no actionable issues. Review feedback identified that stateless capture uses a separate property builder. A follow-up commit applies the same marker there after merging caller properties and before hooks. Autoreview with Claude Opus 5.5 reviewed commit b803d6db6e10d2ad5e6f916bbe3ca6486715ba4d against origin/main and reported no findings. Human review is required before merging.

@marandaneto marandaneto self-assigned this Nov 12, 2026
@marandaneto
marandaneto marked this pull request as ready for review November 12, 2026 15:49
@marandaneto
marandaneto requested a review from a team as a code owner November 12, 2026 15:49
@veria-ai

veria-ai Bot commented Nov 12, 2026 •

Copy link
Copy Markdown

PR overview

All previously flagged issues have been addressed. No open security concerns remain on this pull request.

Fixed/addressed: 1 · PR risk: 0/10

Reviews

@posthog posthog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

PostHog Review · Standard · reviewed 05e5843: 1 Must fix.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-11-13 08:24:37 UTC
Duration: 118402ms

✅ All Tests Passed!

46/46 tests passed


Capture Tests

✅ 29/29 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 401ms
Format Validation.Event Has Uuid ✅ 25ms
Format Validation.Event Has Lib Properties ✅ 29ms
Format Validation.Distinct Id Is String ✅ 28ms
Format Validation.Token Is Present ✅ 28ms
Format Validation.Custom Properties Preserved ✅ 27ms
Format Validation.Event Has Timestamp ✅ 29ms
Retry Behavior.Retries On 503 ✅ 7025ms
Retry Behavior.Does Not Retry On 400 ✅ 4024ms
Retry Behavior.Does Not Retry On 401 ✅ 4022ms
Retry Behavior.Respects Retry After Header ✅ 7029ms
Retry Behavior.Implements Backoff ✅ 17025ms
Retry Behavior.Retries On 500 ✅ 7019ms
Retry Behavior.Retries On 502 ✅ 7019ms
Retry Behavior.Retries On 504 ✅ 7015ms
Retry Behavior.Max Retries Respected ✅ 17034ms
Deduplication.Generates Unique Uuids ✅ 45ms
Deduplication.Preserves Uuid On Retry ✅ 7017ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 12026ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7018ms
Deduplication.No Duplicate Events In Batch ✅ 33ms
Deduplication.Different Events Have Different Uuids ✅ 25ms
Compression.Sends Gzip When Enabled ✅ 19ms
Batch Format.Uses Proper Batch Structure ✅ 19ms
Batch Format.Flush With No Events Sends Nothing ✅ 12ms
Batch Format.Multiple Events Batched Together ✅ 34ms
Error Handling.Does Not Retry On 403 ✅ 4020ms
Error Handling.Does Not Retry On 413 ✅ 4022ms
Error Handling.Retries On 408 ✅ 5032ms

Feature_Flags Tests

✅ 17/17 tests passed

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

@dustinbyrne dustinbyrne left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Stateful/Android capture, flags handling and release metadata look consistent. The new setting is still ignored by the supported core stateless event pipeline; consider covering that path and adding its regression test before approval.

AI-assisted review.

@dustinbyrne
dustinbyrne requested a review from a team November 12, 2026 21:03

@ioannisj ioannisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🤖 An AI agent wrote this on behalf of @ioannisj.

No findings. I went through where $geoip_disable gets set for stateful and stateless events, the flags request default and the minimized $feature_flag_called allowlist, and it lines up with posthog-js and posthog-ios.

@marandaneto
marandaneto merged commit cad8645 into main Nov 13, 2026
17 checks passed
@marandaneto
marandaneto deleted the feat/disable-geoip branch November 13, 2026 08:51
turnipdabeets added a commit that referenced this pull request Nov 13, 2026
- Move "Upgrade your dependencies" and "Upgrade posthog-server" to During:
  both come down to declaring posthog-android 4.0.0.
- Give the PostHogStateless break its own During section and checklist item.
- Drop "Check timestamps and IDs": nothing in it changes but the request ID
  header, which the proxy section covers.
- Say what staying on capture costs for $ai_* events, scope the intro to
  analytics and AI events, and say why follow ups can wait.
- disableGeoIp exists now (main's #971), so the guide no longer says there's
  no GeoIP setting. Name the real remote config path.
- Regenerate references/posthog-android-migration.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
turnipdabeets added a commit that referenced this pull request Nov 13, 2026
…ange (#973)

* docs: sort the Android 4.0.0 migration guide by when you make each change

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

* docs: keep the 4.0.0 guide's table cells to one value

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

* docs: move the posthog.com Android SDK page into the reference

The posthog.com Android SDK page redirects to this reference once
4.0.0 ships, so its setup, how-to, and configuration sections now live
in docs/getting-started.md.

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

* docs: title a single migration guide's page with its H1

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 2eeb772)

* docs: publish the root MIGRATION.md as the migration page

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit f7650a7)

* Revert "docs: move the posthog.com Android SDK page into the reference"

This reverts commit 0e67e30.

* docs: add the Android facts from the retired posthog.com page that no other page has

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

* docs: move the Android one-API facts from getting-started into KDoc

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

* docs: preserve Android tracing setup

* docs: name the SDK in versions, cut self-hosted notes, and split dashes and semicolons

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

* docs: address review on the reordered 4.0 migration guide

- Move "Upgrade your dependencies" and "Upgrade posthog-server" to During:
  both come down to declaring posthog-android 4.0.0.
- Give the PostHogStateless break its own During section and checklist item.
- Drop "Check timestamps and IDs": nothing in it changes but the request ID
  header, which the proxy section covers.
- Say what staying on capture costs for $ai_* events, scope the intro to
  analytics and AI events, and say why follow ups can wait.
- disableGeoIp exists now (main's #971), so the guide no longer says there's
  no GeoIP setting. Name the real remote config path.
- Regenerate references/posthog-android-migration.md.

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

* docs: say flush doesn't block, and register persists across app restarts

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

* docs: pass the migration page generator one guide

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

* docs: point the copy page button at posthog.com and reword the change categories

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

* docs: restore the self-hosted note on serving capture v1

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Anna Garcia <anna.g@posthog.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.

Support disableGeoip config

3 participants