Skip to content

ci: remove the temporary 4.0 branch filters from the compliance workflow - #943

Open
turnipdabeets wants to merge 78 commits into
mainfrom
chore/remove-v4-ci-branch-filters
Open

turnipdabeets wants to merge 78 commits into
mainfrom
chore/remove-v4-ci-branch-filters

Conversation

@turnipdabeets

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

Post-release cleanup for 4.0. The 4.0 integration PR (#871) added 'chore/v4-*' and 'feat/v4-*' to the pull_request branch filter in .github/workflows/sdk-compliance-tests.yml so stacked 4.0 PRs got compliance harness runs. Once 4.0 ships those patterns aren't needed, so this restores the filter to branches: [ main ], matching main.

Merge only after #871 merges. This PR targets chore/v4-remove-deprecated so the diff is just this one line; when #871 merges, GitHub retargets it to main (or retarget it by hand).

💚 How did you test it?

CI-only change. Checked that the resulting on: block matches origin/main's version of the workflow. The 4.0 harness version bump (test-harness-version) is intentionally kept.

📝 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 (not needed: CI-only change)

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

  • Authored by Claude Opus 5.5 (Claude Code) at the maintainer's request, as a draft to merge after the 4.0 release.
  • Removed only the temporary v4 branch patterns; no other workflow changes. The equivalent iOS workflow has no pull_request branch filter, so no iOS counterpart is needed.

🤖 Generated with Claude Code

turnipdabeets and others added 27 commits October 26, 2026 14:11
Remove the public APIs already marked deprecated: apiKey and the
apiKey factories, propertiesSanitizer and PostHogPropertiesSanitizer,
evaluationEnvironments, getFeatureFlagPayload, and the replay
debouncerDelayMs. remoteConfig moves to its own change because
setting it to false still changes setup behavior.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Matches posthog-ios 4.0 and the sdk-specs payload decoding contract.
* chore!: make SDK-internal helpers non-public for posthog-android 4.0

Make internal the public declarations that no other module in this repo
and no wrapper (Flutter, React Native, KMP) uses. LogLine and LogcatParser
are Java, so they become package-private.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

* fix: keep GzipRequestInterceptor public for the compliance adapter

sdk_compliance_adapter is a separate Gradle module, only included by its
Dockerfile, and constructs GzipRequestInterceptor directly.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Setup now always loads /config. With remoteConfig = false, setup used to skip
/config, which left remote settings unloaded since /flags stopped returning
config.

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
* chore!: pass the load result to the feature flags callback

PostHogConfig.onFeatureFlags and reloadFeatureFlags() now take a PostHogFeatureFlagsCallback, whose loaded() receives a PostHogFeatureFlagsLoaded with the enabled flags, their values, and errorsLoading, matching posthog-ios 4.0. Every path that invoked the callback passes an accurate result, including failures, a disabled SDK, and bootstrap.

PostHogOnFeatureFlags moves to posthog-server under the same name, so the server's API is unchanged and it can drop the type in its own major.

* chore: drop the unused server callback wrapper

posthog-server calls its own PostHogOnFeatureFlags directly, and the core stateless client never calls config.onFeatureFlags. Bump posthog-server to minor since it now depends on core 7.0, and document that a bootstrapped onFeatureFlags runs on the setup() thread.

* fix: report persisted flags when the first flags load fails

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

* fix: isolate the bootstrap internal flags callback from setup

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

* fix: keep loaded flags when a flags reload fails

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

* fix: retry flag cache hydration while storage is unreadable

A failed load now hydrates the flag cache before the callback. Under Direct
Boot that read returned empty values and latched, so persisted flags stayed
hidden after unlock. Only latch once the preferences are readable.

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

* fix: skip flag cache reads while storage is unreadable

Every flag getter retried hydration under Direct Boot and re-read each cached
key, each read failing against locked preferences. Check availability once and
skip the reads until storage is readable.

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

* fix: don't let cache hydration undo a concurrent reset

Hydration reads the cache off the flags lock, so a reset() landing between the
read and the commit had the previous identity's flags restored. clear() now
bumps a generation and hydration drops a commit from an older one.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat: add an onFeatureFlags listener you can unsubscribe

Registers a PostHogFeatureFlagsCallback that runs after every feature flags load, replays the current flags to late subscribers, and returns a PostHogFeatureFlagsSubscription, matching posthog-ios onFeatureFlags(_:).

* fix: drop flag loads superseded by reset() or close() for listeners

A load that started before reset() or close() could finish afterwards, reach listeners, and be replayed to late subscribers, including the previous user's flags after reset(). Each load now captures a generation that reset() and close() bump, and listener updates from an older generation are dropped.

* fix: hydrate persisted flags before notifying onFeatureFlags listeners

A failed first load built the listener snapshot before the flag cache was
hydrated, so listeners and late replays got {} while the completion and
getters returned the persisted flags. Hydrate before either callback runs.

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

* fix: drop setup's flag load for listeners when the bootstrap callback closes the SDK

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

* fix: deliver onFeatureFlags listeners on the main thread on Android

Listeners usually update UI. On the remote config thread, a view update hits
CalledFromWrongThreadException and LiveData.setValue throws, which the SDK
catches, so the update is lost. This matches the on-feature-flags spec and
posthog-ios. The config and reload callbacks keep running in the background.

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

* fix: drop setup's flag load for listeners when an integration closes the SDK

Capture the flags generation right after setup enables the SDK, before
any user callout (integration install, session hooks, bootstrap config
callback) that could close() it.

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

* docs: scope onFeatureFlags threading notes by platform

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

* fix: deliver bootstrapped flags to listeners before integrations install

An integration that calls reloadFeatureFlags() during install queued its
/flags request on the serial remote config executor ahead of setup's
bootstrap notification, so onFeatureFlags listeners waited on the network
even though bootstrapped flags were ready.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
The fix shipped from main in #885, so keeping the changeset here would
release the same entry a second time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cated-release-docs

# Conflicts:
#	posthog/api/posthog.api
The canonical client signature has no default and iOS, Flutter and RN have
none. A fallback was also reported as the flag value in $feature_flag_called.
A disabled SDK now returns null; isFeatureEnabled keeps its defaultValue.
…918)

* feat!: remove defaultValue from getFeatureFlag

The canonical client signature has no default and iOS, Flutter and RN have
none. A fallback was also reported as the flag value in $feature_flag_called.
A disabled SDK now returns null; isFeatureEnabled keeps its defaultValue.

* feat!: remove PostHogConfig.onFeatureFlags in favor of the listener

The onFeatureFlags() listener can be registered before setup(), gets bootstrapped
flags, and is removable, so the config field no longer adds anything. iOS and
posthog-js only have the listener form.
* chore!: remove wireframe session replay capture

Session replay always records masked screenshots, the mode
`screenshot = true` already used. Remove `PostHogSessionReplayConfig.screenshot`,
and `drawableConverter` / `PostHogDrawableConverter`, which only the
wireframe builder read.

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

* chore!: trim RRWireframe to the screenshot fields and drop RRStyle

With wireframe capture gone, each window sends a single screenshot node,
so the tree fields, RRStyle and the child-flattening diff are unused.
Screenshot frames no longer carry an empty `style`, matching iOS 4.0.

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

* fix(replay): scan for surfaces only during a legacy capture

* fix(replay): discard legacy frames with an unplaceable masked view

* style: format after merging main

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

* fix(replay): keep Compose mask markers scoped to their subtree

Merged semantics promote a child's postHogUnmask to its clickable parent,
which skipped masking for every sibling. Read the unmerged tree instead.

* fix(replay): mask overflowing and semantics-cleared Compose text

Text with TextOverflow.Visible draws past its layout box, and
clearAndSetSemantics removes the Text metadata the walk relies on. Both
left text unmasked in screenshots.

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

* fix(replay): map Compose text mask bounds to window space and include shadows

Overflow bounds ignored graphicsLayer transforms, and text shadows could
paint readable copies outside the mask.

* perf(replay): reuse Compose text layouts across a capture's mask walks

Text(String) rebuilds its paragraph on every GetTextLayoutResult call,
which the verification and draw-sample walks repeated on the main thread.

* fix(replay): refresh cached Compose text bounds on draw, clear once per walk

A text style change is invisible until the layout is re-read, so any draw now drops the cached bounds. A walk over several ComposeViews also evicted earlier roots by clearing the shared cache for each one.

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

* fix(replay): include text stroke extents in Compose mask bounds

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

* fix(replay): measure Compose text hidden by clearAndSetSemantics

Cleared semantics wipe the text semantics on the same layout node, so its overflow was masked only to the layout box. Read them from the text's modifier and reuse the painted-bounds measurement. Discard the frame when they can't be read, including on legacy walks.

* docs(replay): list Compose masking changes and capture mode in the 4.0 guide

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

* fix: log transient-state replay discards again

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…cated

# Conflicts:
#	posthog-android/consumer-rules.pro
#	posthog-android/src/main/java/com/posthog/android/replay/PostHogReplayIntegration.kt
…cated

Brings in #922 (drop touches inside masked views) and #937 (no
$feature_flag_called for survey targeting flags).

Resolution:
- PostHogReplayIntegration imports: union of both sides.
- PostHogReplayIntegrationTest: keep main's MaskedTouchHarness tests and
  drop the three wireframe-mode tests, since 4.0 removes wireframe mode.
- PostHogSurveysFlagEventTest: use the 2-argument getFeatureFlag, since
  4.0 removes the defaultValue overload.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The touch drop from #922 read the merged semantics tree, but the 4.0
mask walk reads the unmerged one. Inside a clickable parent, merging
folds a postHogMask child into the parent node, so a tap on the masked
child was recorded when the parent also held an unmasked sibling.

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

Brings in #823 (compose activity and dialog windows into one scene).

Adapted to 4.0, which removes wireframe mode and RRStyle:
- The scene path always runs; the wireframe-only branch and the
  sessionReplayConfig.screenshot checks are gone.
- A dialog's dim is a small translucent screenshot image stretched over
  the scene, and a dialog masked whole is a masked screenshot, as for a
  FLAG_SECURE window, instead of styled rectangles.
- Tests assert those images instead of RRStyle colors.
- #823's changeset is folded into android-v4-major.md.

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

* fix(flags): decode payloads cached by 3.x from the cached flag details

* docs: note that 3.13 caches keep malformed payloads until /flags

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
* feat!: disable the SDK when the project token is a personal API key

A `phx_` token is a personal API key; capture rejects every request made
with it. Setup now logs once and stays disabled, as for an empty token.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* feat!: send analytics events through capture v1

Analytics events now go to `POST /i/v1/analytics/events` with the project
token in an `Authorization: Bearer` header, `PostHog-Sdk-Info`,
`PostHog-Attempt`, `PostHog-Request-Id` and `PostHog-Request-Timestamp`.
The body is `{created_at, batch}`; each event drops `$lib`/`$lib_version`,
lifts string `$session_id`/`$window_id` to the root, and hoists the legacy
`$process_person_profile`, `$cookieless_mode`, `$ignore_sent_at` and
`$product_tour_id` properties into the new `PostHogEvent.options`.

The queue reads the per-event results: `ok`, `warning` and `drop` leave the
queue, only `retry` is kept and resent under the same request id and
`created_at` with the next attempt number. A 2xx without readable results
counts as delivered. 408 and 500/502/503/504 are retried; 429, 404 and
other 4xx are terminal, as are redirects other than a same-origin 307/308
(followed at most 5 times with the same body and headers). Backoff doubles
from 1 to 30 seconds with 25% jitter, and `Retry-After` is a floor capped
at 30 seconds for every queue. Replay and logs keep their retry sets.

Legacy cached events (`PostHogSendCachedEventsIntegration`) are sent
through capture v1 too; the ones capture asks to retry are re-queued at
the tail of the legacy file for the next launch.

`PostHogConfig.maxRetries` is renamed `pushNotificationSubscriptionMaxRetries`
since it only limits push-subscription retries. `PostHogApi.batch()` stays
for posthog-server.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* chore(compliance): run the capture v1 suite against the adapter

The adapter advertises `capture_v1` and `encoding_gzip`, tracks
`/i/v1/analytics/events` requests with `retry_attempt` derived from
`PostHog-Attempt`, maps `max_retries` to the renamed config field and runs
with `personProfiles = ALWAYS`, since the harness never identifies. The
workflow pins harness 1.20.0 and also runs for PRs that target the
`chore/v4-*` and `feat/v4-*` branches.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* docs: changeset bullets and migration guide for capture v1

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

* fix: resend a failed capture request as is, without client retries or logged bodies

The queue now resends exactly the files of a request that failed or came back
with events to retry, so the API keeps its request ID and `created_at` and bumps
`PostHog-Attempt`. Before, the next request took the head of the queue, and any
event queued since gave it a new ID at attempt 1. A 413 still halves the batch
as a new request, and a file the queue drops in the meantime starts over.

The capture client turns off OkHttp's `retryOnConnectionFailure`, which resent
a request on a reused connection with a stale attempt number and timestamp.

Debug logs for capture requests name the event count and the response status
instead of printing the request and response bodies, which hold event content.

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

* fix: stop OkHttp resending a capture 503 with Retry-After 0

OkHttp's follow-up layer resends a 503 carrying `Retry-After: 0` even with
retryOnConnectionFailure off, repeating PostHog-Attempt and
PostHog-Request-Timestamp outside the queue's backoff. A network interceptor
on the capture client drops that header before the retry layer sees it; the
queue waits the same with or without it.

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

* fix: cap the capture v1 response read at 1 MiB

A successful capture response was read whole into memory. Read at most 1 MiB
and treat a larger or endless body as unreadable, which counts the batch as
delivered like any other 2xx without readable results.

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

* fix: keep the queue's retry jitter in milliseconds

Rounding the jittered backoff to whole seconds removed the jitter from the
1 s and 2 s waits, so devices refused together retried together. The delay
is now kept in milliseconds.

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

* test: send a 3.x event queued on disk through capture v1

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

* docs: list what a reverse proxy needs for capture v1

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

* fix: cap the time spent reading capture v1 results

A 2xx body that trickles bytes within the read timeout held the queue thread until it ended. Reading the results now has a 10 second deadline, after which the body counts as unreadable and the events as delivered, like an oversized body.

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

* feat!: add per-event capture options and one property precedence

`capture`, `screen`, `identify`, `setPersonProperties`, `alias`, `group` and
`captureException` take an `options` map that is copied onto the new
`PostHogEvent.options`, so PostHog can be told how to process one event apart
from its properties and `beforeSend` can edit it.

Properties are merged in one order: SDK-set values, registered super
properties, the caller's properties (with `$set`, `$set_once` and `$groups`
as per-call values), then `beforeSend`. `$is_identified`,
`$process_person_profile` and the replay debug properties are no longer
re-applied after the caller's values.

The SDK sets the `process_person_profile` option to `false` only when person
processing is off, and only when neither a caller option nor a caller or
registered `$process_person_profile` property already says so. It no longer
writes a `$process_person_profile` property.

Also: a blank `distinctId` argument on `capture` uses the current distinct id;
a `$set` sent with `process_person_profile: false` neither stores nor matches
the person-properties hash; an event returned by `beforeSend` keeps the uuid of
the client capture it came from; the minimal `$feature_flag_called` allowlist
keeps `$cookieless_mode`, `$ignore_sent_at` and `$product_tour_id`; the
compliance adapter forwards `options` and advertises `event_options`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRbQPidntd4hVufNpMT19L

* test: cover capture options, property precedence and the personless option

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRbQPidntd4hVufNpMT19L

* docs: describe capture options and property precedence for 4.0

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRbQPidntd4hVufNpMT19L

* fix: skip PostHog-reserved deep link query parameters

A link opened with ?$process_person_profile=true copied that parameter into the Deep Link Opened properties, where capture v1 turns it into the process_person_profile option and enables person processing despite PersonProfiles.NEVER. Query parameters whose name starts with $ are now skipped.

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

* docs: say the retry jitter keeps millisecond precision

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

* fix: keep the personless option when the legacy property is null

A Java caller can pass a null `$process_person_profile`. It no longer counts as an override, so the SDK still sends `process_person_profile: false` when person processing is off.

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

* docs: escape dollar-prefixed keys in the Kotlin migration examples

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

* feat: add captureAi on the capture v1 AI endpoint

`captureAi` takes the same arguments as `capture`, goes through the same
enrichment, precedence, personless default and `beforeSend`, and queues the
event on its own disk queue, executor and retry identity for
`POST /i/v1/ai/events`. It returns the event's uuid once it's handed to the
queue, or null when the SDK is disabled or opted out or `beforeSend` dropped
it. A name not starting with `$ai_` logs one debug line and is sent unchanged;
`capture` never reroutes `$ai_*` events. The AI request client uses
`captureAiTimeout` for its call, read and write timeouts and honors
`captureAiCompression` through its own gzip interceptor instance.

`PostHogQueue` becomes byte-aware through `EndpointSpec`: `maxBatchBytes`
bounds a request window (check before append, an oversize record goes alone)
and flushes as soon as that much is queued; `maxQueueBytes` is a FIFO disk cap
on top of `maxQueueSize`, enforced on add and on load; `maxRecordBytes` drops a
record over the limit when it's queued, logging only its name and size. The
analytics spec gets a 5 MiB request cap; the AI spec gets 5 MiB requests,
50 MiB on disk and `captureAiMaxEventBytes` (at most 8 MiB) plus a 64 KiB
envelope per event.

New `PostHogConfig` knobs: `captureAiCompression`, `captureAiMaxQueueSize`,
`captureAiTimeout` and `captureAiMaxEventBytes`; non-positive values use the
defaults. `PostHogAndroid` stores the AI queue under `posthog-disk-ai-queue`.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRbQPidntd4hVufNpMT19L

* test: cover captureAi, the AI lane and byte-aware batching

SDK-level: routing by method, beforeSend and options, null returns, a
terminal 404, the oversize drop (name and size only in the log), the non-`$ai_`
debug line, flush and close draining the AI queue, compression per lane and the
AI timeout. API-level: the AI endpoint's headers and body, separate retry
identities per lane, and an AI queue keeping only the events asked to retry.
Queue-level, on a synthetic record: byte-limited request windows, an oversize
record sent alone, the flush at a request's worth of bytes, the per-record
drop, the disk cap on add and on load, and the spec limits and config
fallbacks. The Android setup test covers the AI storage prefix.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRbQPidntd4hVufNpMT19L

* chore(compliance): run the capture v1 AI suite against the adapter

Adds `POST /capture_ai`, which routes through `captureAi` and returns the uuid
it sent, tracks `/i/v1/ai/events` requests next to the analytics ones and
advertises `capture_ai_v1`. Also restores the capture v1 adapter changes
(tracking by capture path, `PostHog-Attempt` as the retry count,
`personProfiles = ALWAYS`, the renamed push retries field) that the options
commit reverted.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRbQPidntd4hVufNpMT19L

* docs: changeset bullets and migration guide for captureAi

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DRbQPidntd4hVufNpMT19L

* docs: list the AI endpoint in the migration guide's endpoint table

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

* fix: check the AI event size before queuing and return null when over

The queue measured an AI event after `encryption`, so an encryption that
grows the data dropped events PostHog would accept, and captureAi had
already returned the uuid. captureAi now measures the serialized event
before encryption and returns null when it's over the limit. The queue's
per-record limit had no other user and is removed.

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

* docs: describe the AI size limit and timeout as they behave

The limit covers an AI event's properties up to 8 MiB, with 64 KiB for the
rest of the serialized event, measured before encryption. captureAiTimeout
is a timeout without network activity, not a call timeout.

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

* chore(compliance): report no uuid when captureAi doesn't queue the event

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

* fix: log each event capture v1 drops with the reason it gives

Debug logs named only the drop count, so a misrouted_event or
ai_event_too_big drop was invisible. Each dropped event is now logged with
its name, uuid and the server's details, never its properties. Adds a test
that an AI event with exactly 8 MiB of properties is sent.

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

* fix: stop measuring an AI event once it passes the size limit

captureAi checks the size on the caller's thread, so a huge prompt or
base64 payload no longer costs a full serialization just to be dropped.

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

* fix: log an unserializable property by key and type, not by value

Properties can hold prompts and other user content.

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

* docs: say the AI size check builds the full JSON tree before it stops counting

* test: double bytes instead of Base64 in the AI encryption test

java.util.Base64 isn't on API 23, so animalsnifferTest failed.

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

* test: make the unserializable Turn a plain class

The data class hashCode calls Double.hashCode(double), which isn't on API 23.

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

* test: write encrypted test streams in blocks

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

* fix: retry capture v1 requests that get 404 or 429 (#897)

* fix: retry capture v1 requests that get 404 or 429

A 404 usually means a misconfigured proxy and a 429 now only comes from an overloaded ingress, so keep the events queued and retry them with the usual backoff and Retry-After handling instead of dropping them. Matches PostHog/posthog-go#395.

* fix: warn once when capture v1 returns 404

A 404 now keeps events queued, so nothing tells the app that the route
is missing. Print one warning per client, even without debug, naming the
URL and the path a reverse proxy or self-hosted instance must serve.

* fix: leave host credentials and query out of the capture v1 404 warning

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* docs: escape dollar signs in captureAi examples

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

* test: give the serializer privacy fixture a prompt-bearing toString

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

* fix: make captureAiMaxEventBytes limit the whole serialized event

Match posthog-ios, posthog-python and the Flutter desktop lane: the value
is the serialized event size, defaulting to 8 MiB + 64 KiB, instead of a
properties size the SDK added 64 KiB to. A value over the ceiling now
logs a warning when it is clamped.

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

* fix: subtract a queued file's counted size when it's removed

A file deleted from the cache dir reads as 0 bytes, so the queue kept
counting it and evicted new AI events against bytes that were gone.

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

* fix: read lenient false person-processing values before caching person properties

Capture reads "false", 0 and similar strings as false, so a $set sent
with them is personless and must not store the person-properties hash.

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

* fix: send a fatal event even while a request waits to be retried

The fatal flush resent only the retry set, so the crash report stayed
on disk as the process exited.

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

* chore(compliance): count only delivered events when capture asks to retry some

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

* chore(compliance): run the 1.26.0 test harness against the adapter (#902)

* chore(compliance): run the 1.25.0 test harness against the adapter

Bump the harness from 1.20.0 (CI) and 0.10.0 (local docker-compose) to
1.25.0, and declare the 1.25 capabilities the SDK supports:
generated_payloads, log_capture, property_layers and fail_open.

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

* chore(compliance): count the marker's serialized bytes when padding AI properties

* chore(compliance): bump the test harness to 1.26.0

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* feat: let wrapper SDKs run their own beforeSend on the fully built event (#904)

* chore(api): keep @PostHogInternal declarations out of the API dumps

* feat: let wrapper SDKs build an event, run their own beforeSend, then send it

* fix: start the replay debug window when the wrapper's event is queued

* fix: defer wrapper build state changes and the replay debug claim to send

A built event the wrapper drops no longer caches the screen name, updates the
person properties used for flags, or claims the replay debug bundle. The send
does all three, as capture does, so the window starts with the event that
carries the bundle.

* fix: keep wrapper builds state-free and send each built event once

Build defers person processing to send and records the built name for replay
debug eligibility. Send adds only the throttled replay debug keys (API 23 safe,
keeps keys the wrapper's hook removed), skips flag person properties when the
user changed since the build, and ignores a second send of the same event.

* fix: tie a wrapper send to the build's setup, instance and identity

A send now drops an event this instance didn't build or built before setup()/close(), skips person processing and flag person properties after reset() (also when reuseAnonymousId keeps the distinct id), and adds the replay debug values snapshotted at build.

* fix: don't restore a wrapper screen name after a reset since the build

* fix: add the replay debug bundle to wrapper AI events, like captureAi

* fix: read replay debug state once per wrapper build

The build's required replay keys and the deferred bundle came from two
debugProperties() reads, so a replay transition between them could send
$recording_status=buffering without its hold reason.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix: record the wrapper build's identity before enriching the event

A reset() or identify() during the build left the event with the old
distinct ID while the build recorded the new identity, so the send applied
the old user's $set to the new user's flag properties.

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

* chore(compliance): read capture responses outside the adapter lock

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

* fix: drop the oldest AI events while too many wait to be written to disk (#901)

* fix: drop an AI event while too many wait to be written to disk

One executor both writes and sends AI events, so during a slow upload new
multi-MiB events waited in memory with no limit. captureAi now returns
null while captureAiMaxQueueSize events or 50 MiB are waiting, the same
limits the disk queue keeps.

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

* fix: drop the oldest waiting AI events instead of the new one

While a slow upload holds the AI executor, captureAi now keeps the new
event and drops the oldest events still waiting to be written once
captureAiMaxQueueSize events or 50 MiB wait, the same as the disk queue
already does. captureAi returns null again only for disabled, opted-out,
beforeSend-dropped or oversized events.

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

* fix: queue no more AI write tasks than events waiting to be written

Dropping a waiting AI event no longer leaves its executor task behind
for nothing: a dropped event's task writes a newer one instead, so the
executor never holds more tasks than events are waiting.

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

* fix: queue AI write tasks in the order their events were added

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* docs: tell proxies that strip credentials to keep the project token

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

* docs: say which capture drop logs need debug and what they print

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

* docs: add 402, 404 warning, debug logs and AI queue details to the 4.0 guide

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

* chore: keep PostHogInternal APIs in the api dumps

apiCheck is the only check that flags a changed internal signature that
posthog-server or a wrapper SDK relies on. The dumps list them again, as on main.

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

* docs: remove leftover conflict markers from the 4.0 guide

* fix: keep the capture result when an event handler throws

* fix: match capture v1 rules for empty names, drop logs, retry identity and typed values (#903)

* fix: match the capture v1 rules for empty names, drop logs, retry identity and typed values

* fix: merge a $groups map in properties into the groups set with group()

* fix: log an empty-name drop once, without the generic dropped-event line

* fix: clamp each duplicates_dropped count to the batch size

* fix: keep the pending retry map off Java 8 Map methods missing on API 23

* fix: keep the personless option over a legacy property and drop a 2xx without results (#905)

* fix: keep the personless option when a legacy person processing property is set

A passed or registered `$process_person_profile` property no longer stops
the SDK from setting `process_person_profile: false` when person
processing is off. The send hoists the property only into an unset
option, so an option set by any layer wins, as the capture spec requires.

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

* fix: treat a 2xx without readable per-event results as a terminal failure

A 2xx whose body can't be read as `{"results": {...}}` no longer counts
the batch as delivered. It throws a PostHogApiError with that status,
which the queue drops without retrying, and logs only the status and
event count, as the capture spec requires.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix: warn about empty and personal API keys without debug and log rejected batches (#909)

* fix: let a caller's $process_person_profile override the personless option

Reverts the person-processing half of #905. A passed or registered
`$process_person_profile` property again stops the SDK from adding
`process_person_profile: false` when person processing is off, so the
caller wins, as the client property precedence in sdk-specs `capture`
(#143) requires. The send still hoists the property into the option.

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

* fix: log drop reasons per batch and batch migrated legacy events by bytes

- The capture v1 per-batch debug line names the endpoint and counts the
  dropped events by their `details` tag (opaque strings, never uuids or
  content), e.g. `ai_event_too_big: 1, misrouted_event: 1`.
- Sending events cached by 2.x/3.x closes a batch before it would pass
  the 5 MiB capture v1 byte target, as the queue does, so a large
  migrated batch isn't lost to a 413. Order is kept and an event over
  the target ships alone.

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

* docs: say the token warnings print without debug

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

* fix: name the records in the flush drop log

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

* test: cover the capture rules on the captureStateless path

Also adds the posthog-server changeset for them.

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

* docs: fold the server capture changes into the server changeset

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* docs: keep PostHog keys when a proxy strips Authorization

* fix: only move the current screen for wrapper events built as $screen (#930)

* fix: keep a wrapper event sent for another distinct id out of the current user's person state (#928)

* docs: review beforeSend hooks for the 4.0 event shape (#924)

* docs: ask users to review beforeSend hooks for the 4.0 event shape

* docs: cover replacing event.options in beforeSend

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* feat!: report the device language as $locale and add $app_language (#927)

* feat!: report the device language as $locale and add $app_language

* fix: address the pre-PR review of $locale and $app_language

* docs: correct the $locale migration notes

* fix: read a registered $app_language without relying on merge order

* fix: read locales and the locale config only on the worker thread

Setup and capture no longer make Binder calls or parse the locale config, and
supported locales changed at runtime with setOverrideLocaleConfig are picked up.

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

* fix: leave out $app_language when several declared regions could match

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

* fix: stop reading a registered $app_language on every event

Registered properties are merged later and win anyway.

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

* fix: guard LocaleList calls for the API 23 lint check

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

* fix: read the override locale config only when the locales change

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

* docs: say when $app_language is left out with no match

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep events with non-string map keys and align capture v1 logs (#929)

* fix: align capture v1 logs, request IDs and beforeSend handling

* fix: copy arrays and cycles for beforeSend, and keep the hook failure log debug-only

* fix: keep array types in the copy beforeSend hooks get

* fix: keep sorted map lookups and copy primitive arrays for beforeSend

* fix: read an HTTP-date Retry-After

* fix: log the key type when a map key can't be serialized

* docs: link the capture v1 upgrade guide and align the 4.0 guide with the backend guides (#934)

* docs: link the capture v1 SDK upgrade guide

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

* docs: add timestamps, UUID v7 and the person-only drop to the 4.0 guide

* docs: align the 4.0 capture v1 guide with the backend SDK guides

Claude-Session: https://claude.ai/code/session_019xLynws83apuXa9LfRy9Aq

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

* fix!: keep the 3.x PostHogEvent constructor and copy

posthog-server is a minor release and its beforeSend gets PostHogEvent,
so a new trailing constructor parameter broke Java callers and copy
calls compiled against 3.x. options is now a property. When beforeSend
returns a different event with null options, such as a copy, it keeps
the options of the event the hook was given.

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

* docs: close the 4.0 guide gaps found in the release review

- Remove the two internal TODO comments.
- Say surveys-compose works with core 6.x and 7.0.
- List RRStyle and the trimmed RRWireframe under internal APIs.
- captureAi also returns null for an empty event name.
- Note per-event product quota drops, the per-batch drop reasons and
  the removed per-event "queued" log line.
- Self-hosting needs /i/v1/ai/events for captureAi.
- A whitespace-only token disables the SDK too.
- Describe the 3.x $set/$set_once/$groups replacement rule and the
  registered $set rule.
- KDoc: the AI size drop logs the limit, not the event's size.

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

---------

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
- Sort the Android changeset with breaking entries first, in imperative
  one-line entries, and drop the composed-scene bullet that 3.76.0
  already released; keep only the 4.0 change to dialog dims.
- Add changelog entries for the 2xx-without-results drop, HTTP-date
  Retry-After, migrated 3.x queues and non-string map keys.
- Add the core changes posthog-server also gets to its changeset:
  PostHogEvent.options, the non-string key fix, beforeSend copies and
  the quieter debug logs.
- Guide: pin surveys-compose users to posthog-android 4.0.0 or later
  instead of 4.+, say PostHog no longer saves non-JSON payloads, and
  note that the first event after a language change can carry the
  previous $locale or $app_language.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replay, logs, flags and remote config requests still print their bodies
with debug on; only the capture v1 lanes log counts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turnipdabeets turnipdabeets self-assigned this Nov 5, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@turnipdabeets turnipdabeets mentioned this pull request Nov 5, 2026
11 of 20 tasks
turnipdabeets and others added 19 commits November 12, 2026 10:14
# Conflicts:
#	posthog/src/main/java/com/posthog/PostHog.kt
…e migration guide

Capture v1 moved to /docs/api/capture-v1 (posthog.com#21385).
…974)

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>
* docs: publish MIGRATION.md as the SDK's migration guide page

The reference generator read docs/migration-*.md, which the 4.0 branch no
longer has since the guide moved to MIGRATION.md, so a release kept the old
generated page. That page now becomes the Android migration guide on
posthog.com, so read MIGRATION.md and regenerate it.

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

* docs: say Gradle upgrades posthog-android 3.x to 4.0 next to core 7.0

Since the core-to-android constraint, core 7.0 or posthog-server 2.25 next
to posthog-android 3.x resolves posthog-android 4.0 instead of failing at
runtime.

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

* test: queue events in the personless hash tests and fix a Retry-After flake

The two personless dedup tests dropped every event in beforeSend, so no hash
was ever stored and they passed with personless detection switched off. They
now queue events to a mock server, and fail under that mutation.

The HTTP-date Retry-After test compared against the real clock, so it read
19 instead of 20 when the request crossed a second boundary.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Keeps the 4.0 shapes where main conflicts: $feature_flag_response is still
omitted for a missing or failed flag and getFeatureFlag has no defaultValue;
main's $feature_flag_error and disableGeoIp ($geoip_disable stays a property
under capture v1) come through. Main's new tests are adapted to the capture v1
path and the 4.0 flag API.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Gson can build a failed FeatureFlag record without its metadata object, and
the 3.x payload migration read flag.metadata.payload unguarded, so the first
flag read after reopening a PostHogMemoryPreferences cache threw a
NullPointerException to the caller.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…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>
* fix: keep a registered personless setting off identity events

A registered `$process_person_profile: false`, or a `process_person_profile`
option a wrapper registers, no longer applies to `$identify`, `$create_alias`,
`$merge_dangerously`, `$groupidentify`, `$set` and `$set_once`. PostHog drops
those events with person processing off. A value passed on the call or set
in `beforeSend` still applies.

* docs: note the identity-event exception on register

* docs: keep the $set and $set_once distinction in the migration guide

* test: cover $set_once, $merge_dangerously, a call property and beforeSend
The generated page still told users that a registered
$process_person_profile reaches identify, alias, group and
setPersonProperties, which #979 changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* fix: close replay masking and legacy retry gaps from 4.0 review

- Mask Compose text that a negative TextIndent paints left of its layout
  box (or right of it, for right-to-left text).
- Read cleared text semantics from SemanticsModifier elements on Compose
  1.0-1.2, which have no getTail, instead of discarding every frame.
- Re-queue one copy per uuid when capture asks to retry legacy events,
  since it drops a uuid's later copies in a batch for good.

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

* fix: measure only rendered text and keep node runtimes fail-closed

- Skip clearAndSetSemantics { text = ... } replacements when looking for
  the text to measure: only semantics with GetTextLayoutResult count.
- A missing getTail is only expected on pre-1.3 layout wrappers. On a
  NodeCoordinator it throws again, so the frame is discarded.

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
* feat!: enable surveys by default

Match the iOS, Flutter, React Native, web and KMP SDKs. Surveys still
display only with posthog-android-surveys-compose or a custom
surveysDelegate.

* fix: skip survey matching without a survey UI

Without posthog-android-surveys-compose or a custom surveysDelegate, the default delegate only logs, so matching evaluated linked flags (capturing $feature_flag_called) and property-filter regexes for surveys nobody could see.

* chore: fold the surveys default changeset into the 4.0 changeset

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts:
#	posthog/api/posthog.api
#	posthog/src/main/java/com/posthog/internal/PostHogApi.kt
Base automatically changed from chore/v4-remove-deprecated to main November 20, 2026 17:56
@turnipdabeets
turnipdabeets marked this pull request as ready for review November 20, 2026 18:00
@turnipdabeets
turnipdabeets requested a review from a team as a code owner November 20, 2026 18:00
@veria-ai

veria-ai Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

4.0 landed on main (#871), so take main's tree everywhere and keep only
this PR's workflow change. Drop the 4.0 changesets main's release already
consumed.

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

@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

Found 1 must fix, 6 should fix.

This pull request is large, so the review ran in 4 parts with less depth than usual.

This is the last automatic review of this pull request. Comment @posthog review to review new changes.

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.

Findings on the changed lines

posthog/src/main/java/com/posthog/PostHog.kt:1693

P1 · Preserve wrapper event options when normalizing null properties

When a wrapper returns an event with null properties and explicit options, sendBuiltEventForWrapper calls event.copy(properties = properties). Because options is outside the data-class constructor, this resets it to null, silently discarding controls such as process_person_profile: false and enabling unwanted person processing. Preserve event.options on this copy.

posthog-android/src/main/java/com/posthog/android/replay/PostHogReplayIntegration.kt:321

P2 · Invalidate text bounds only when the corresponding layout changes

During capture on a text-heavy Compose screen, every redraw clears all cached bounds before drawSampleWalk. maskBounds() then calls GetTextLayoutResult for every masked Text(String), rebuilding its paragraph on the UI thread even for an unrelated spinner animation. This adds repeated text shaping and GC to the frame budget; invalidate only changed text layouts.

posthog/src/main/java/com/posthog/PostHog.kt:261

P2 · Isolate replay startup failures from flag listener notifications

When replay startup throws, internalOnFeatureFlagsLoaded exits before notifyFeatureFlagsListeners. The remote-config loader catches the exception around this entire callback, so successfully loaded flags never reach subscribers or populate the notification cached for late subscribers. Catch replay startup failures separately and always notify listeners.

sdk_compliance_adapter/src/main/kotlin/com/posthog/compliance/ComplianceAdapter.kt:268

P2 · Keep response tracking from shortening the SDK read deadline

When a successful response body takes between five and ten seconds to arrive, retriedCount times out the SDK's underlying response stream before its ten-second results deadline. The SDK then treats the unreadable 2xx as terminal and drops queued events, so instrumentation changes delivery behavior. Observe results without imposing a shorter stream deadline.

posthog-android/src/main/java/com/posthog/android/replay/PostHogReplayIntegration.kt:1872

P2 · Preserve unmask precedence within explicitly masked containers

When a clickable row uses postHogMask() and a child uses postHogUnmask(), the unmerged traversal adds the row's entire rectangle. Skipping the child's mask cannot remove that covering rectangle, so the child now appears masked, violating postHogUnmask()'s documented precedence. Exclude explicitly unmasked descendants from ancestor masks.

posthog/src/main/java/com/posthog/internal/PostHogApi.kt:933

P2 · Normalize missing UUIDs before building capture v1 batches

After upgrading, a 3.x disk-cached event whose beforeSend returned copy(uuid = null) reaches captureV1Json without a UUID. The serializer omits this required field, so capture v1 returns 400 and the queue deletes the entire batch, including healthy neighbors. Normalize missing UUIDs when loading cached records and persist them before sending.

posthog/src/main/java/com/posthog/internal/PostHogQueue.kt:489

P2 · Exclude terminal duplicate copies from partial retries

When queued records repeat a UUID and capture returns result: retry with duplicates_dropped, sendRecords retains every matching file. The capture contract makes the later copies terminal drops, but subsequent requests resend them and repeatedly consume queue capacity. Preserve occurrence-level dispositions and retain only the first retryable copy.

@turnipdabeets
turnipdabeets enabled auto-merge (squash) November 20, 2026 18:06

@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.

Not approved — this change needs a human reviewer.

Re-adding the stamphog label gives the same result unless the changed files change.

stamphog can't approve this pull request. The deny-list gate refused it because .github/workflows/sdk-compliance-tests.yml matches the infra_cicd category, and the tier gate then placed it in T2-never, so CI/CD workflow changes always need a human reviewer. The size gate was fine (one line changed), and that doesn't affect the outcome. Please ask a maintainer to review this change; since it is meant to merge only after #871, mention that ordering when you request the review.

Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✗ matches: infra_cicd in .github/workflows/sdk-compliance-tests.yml
every_file_attested ✓ not a bot PR
size ✓ 2L, 1F substantive — within ceiling
tier ✗ T2-never because the deny-list matched infra_cicd
stamphog 2.9.1 .stamphog/policy.yml @ unknown · reviewed head dc71458

@stamphog stamphog Bot removed the stamphog label Nov 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

posthog-android Compliance Report

Date: 2026-11-20T18:13:20.155402+00:00
Duration: 472350ms

✅ 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 ✅ 285ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 32ms
Required Headers.Has Authorization Bearer Header ✅ 30ms
Required Headers.Has Content Type Json ✅ 32ms
Required Headers.Has Posthog Sdk Info Format ✅ 23ms
Required Headers.Has Posthog Attempt Header ✅ 24ms
Required Headers.Has Posthog Request Id ✅ 20ms
Required Headers.Has Posthog Request Timestamp ✅ 23ms
Required Headers.Has User Agent ✅ 22ms
Body Format.Body Has Created At And Batch ✅ 16ms
Body Format.No Api Key In Body ✅ 19ms
Body Format.No Sent At In Body ✅ 16ms
Event Format.Event Has Required Root Fields ✅ 16ms
Event Format.Event Uuid Is Valid ✅ 16ms
Event Format.Event Timestamp Is Rfc3339 ✅ 16ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 17ms
Event Format.Distinct Id Is String ✅ 15ms
Event Format.Distinct Id At Root Not Properties ✅ 15ms
Event Format.Custom Properties Preserved ✅ 17ms
Event Format.Set Properties Preserved ✅ 16ms
Event Format.Set Once Properties Preserved ✅ 18ms
Event Format.Groups Properties Preserved ✅ 14ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 15ms
Event Format.Event Has Required Root Fields Batch ✅ 24ms
Event Format.Event Uuid Is Valid Batch ✅ 19ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 19ms
Event Format.Distinct Id Is String Batch ✅ 20ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 18ms
Event Format.Custom Properties Preserved Batch ✅ 20ms
Event Format.Set Properties Preserved Batch ✅ 21ms
Event Format.Set Once Properties Preserved Batch ✅ 20ms
Event Format.Groups Properties Preserved Batch ✅ 21ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 19ms
Batch Behavior.Multiple Events In Single Batch ✅ 27ms
Batch Behavior.Batch Envelope Smoke ✅ 26ms
Batch Behavior.Flush With No Events Sends Nothing ✅ 17ms
Batch Behavior.Flush At Triggers Batch ✅ 1035ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 17ms
Deduplication.Generates Unique Uuids ✅ 27ms
Deduplication.Different Events Same Content Different Uuids ✅ 16ms
Deduplication.Preserves Uuid On Retry ✅ 7014ms
Deduplication.Preserves Timestamp On Retry ✅ 7018ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7026ms
Deduplication.No Duplicate Events In Batch ✅ 27ms
Header Behavior On Retry.Attempt Header Starts At One ✅ 12ms
Header Behavior On Retry.Attempt Header Increments On Retry ✅ 12023ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 7017ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2029ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 7018ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 16ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 17ms
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 ✅ 12ms
Retry Behavior.Retries On 408 ✅ 7015ms
Retry Behavior.Retries On 500 ✅ 7018ms
Retry Behavior.Retries On 503 ✅ 7022ms
Retry Behavior.Retries On 504 ✅ 7017ms
Retry Behavior.Retries On 404 ✅ 6015ms
Retry Behavior.Retries On 429 ✅ 6017ms
Retry Behavior.Retries On 502 ✅ 6015ms
Retry Behavior.Retryable Errors Have Retry After ✅ 4013ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10023ms
Retry Behavior.Does Not Retry On 400 ✅ 4019ms
Retry Behavior.Does Not Retry On 401 ✅ 4018ms
Retry Behavior.Does Not Retry On 402 ✅ 4017ms
Retry Behavior.Does Not Retry On 413 ✅ 4016ms
Retry Behavior.Does Not Retry On 415 ✅ 4020ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4019ms
Retry Behavior.Implements Backoff ✅ 14028ms
Partial Batch Handling.Handles 200 Full Success ✅ 2015ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3028ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3024ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 3021ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7016ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7016ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7017ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7016ms
Partial Batch Handling.Partial Retry Attempt Header Increments ✅ 7017ms
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 ✅ 3022ms
Partial Batch Handling.Mixed Ok Drop Warning No Retry ✅ 3025ms
Compression.Sends Gzip Content Encoding ✅ 15ms
Compression.No Content Encoding When Disabled ✅ 12ms
Compression.Compressed Body Is Decompressible ✅ 11ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4013ms
Event Options.Cookieless Mode Override ✅ 14ms
Event Options.Disable Skew Correction Override ✅ 10ms
Event Options.Process Person Profile Override ✅ 10ms
Event Options.Product Tour Id Override ✅ 9ms
Event Options.Unset Options Omitted ✅ 10ms
Event Options.Options Override In Batch ✅ 17ms
Event Options.Unknown Option Passes Through ✅ 12ms
Event Options.Option Value Is Not Converted ✅ 13ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 14ms
Event Options.Option Wins Over Legacy Property ✅ 11ms
Event Options.Legacy Property Fills Unset Option ✅ 14ms
Event Options.Null Option Falls Back To Legacy Property ✅ 11ms
Property Layers.Caller Property Beats Registered Property ✅ 11ms
Property Layers.Before Send Runs Last ✅ 13ms
Fail Open.Empty Api Key Sends Nothing ✅ 3009ms
Fail Open.Personal Api Key Sends Nothing ✅ 3011ms
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 ✅ 13ms
Endpoint And Method.Does Not Use Legacy Endpoints ✅ 11ms
Endpoint And Method.Capture Does Not Reroute Ai Named Events ✅ 10ms
Endpoint And Method.Capture Ai Does Not Reroute Non Ai Events ✅ 12ms
Lane Isolation.Failing Ai Lane Does Not Delay Analytics ✅ 7023ms
Required Headers.Has Authorization Bearer Header ✅ 16ms
Required Headers.Has Content Type Json ✅ 13ms
Required Headers.Has Posthog Sdk Info Format ✅ 11ms
Required Headers.Has Posthog Attempt Header ✅ 11ms
Required Headers.Has Posthog Request Id ✅ 11ms
Required Headers.Has Posthog Request Timestamp ✅ 12ms
Required Headers.Has User Agent ✅ 11ms
Body Format.Body Has Created At And Batch ✅ 11ms
Body Format.No Api Key In Body ✅ 9ms
Body Format.No Sent At In Body ✅ 10ms
Event Format.Event Has Required Root Fields ✅ 13ms
Event Format.Event Uuid Is Valid ✅ 13ms
Event Format.Event Timestamp Is Rfc3339 ✅ 10ms
Event Format.Non Utc Event Timestamp Is Converted To Utc ✅ 12ms
Event Format.Distinct Id Is String ✅ 11ms
Event Format.Distinct Id At Root Not Properties ✅ 11ms
Event Format.Custom Properties Preserved ✅ 12ms
Event Format.Set Properties Preserved ✅ 11ms
Event Format.Set Once Properties Preserved ✅ 12ms
Event Format.Groups Properties Preserved ✅ 10ms
Event Format.Sdk Generates Uuid If Not Provided ✅ 13ms
Event Format.Event Has Required Root Fields Batch ✅ 13ms
Event Format.Event Uuid Is Valid Batch ✅ 14ms
Event Format.Event Timestamp Is Rfc3339 Batch ✅ 12ms
Event Format.Distinct Id Is String Batch ✅ 15ms
Event Format.Distinct Id At Root Not Properties Batch ✅ 14ms
Event Format.Custom Properties Preserved Batch ✅ 14ms
Event Format.Set Properties Preserved Batch ✅ 16ms
Event Format.Set Once Properties Preserved Batch ✅ 21ms
Event Format.Groups Properties Preserved Batch ✅ 20ms
Event Format.Sdk Generates Uuid If Not Provided Batch ✅ 13ms
Batch Behavior.Multiple Events In Single Batch ✅ 18ms
Batch Behavior.Batch Envelope Smoke ✅ 14ms
Batch Behavior.Flush At Triggers Batch ✅ 1012ms
Batch Behavior.Created At Reflects Batch Creation Time ✅ 15ms
Deduplication.Generates Unique Uuids ✅ 22ms
Deduplication.Different Events Same Content Different Uuids ✅ 12ms
Deduplication.Preserves Uuid On Retry ✅ 7012ms
Deduplication.Preserves Timestamp On Retry ✅ 7016ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 7017ms
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 ✅ 12015ms
Header Behavior On Retry.Request Id Preserved On Retry ✅ 7016ms
Header Behavior On Retry.Different Requests Have Different Request Ids ✅ 2032ms
Header Behavior On Retry.Request Timestamp Changes On Retry ✅ 7015ms
Response Format Validation.Success Response Has Uuid Keyed Results ✅ 14ms
Response Format Validation.Success Response Has Ok For Each Event ✅ 14ms
Response Format Validation.Success No Retry After When All Ok ✅ 13ms
Response Format Validation.Success Retry After Present When Retry Events ✅ 2007ms
Response Format Validation.Success No Retry After When Drop Only ✅ 16ms
Response Format Validation.Response Echoes Request Id ✅ 9ms
Retry Behavior.Retries On 408 ✅ 7014ms
Retry Behavior.Retries On 500 ✅ 7014ms
Retry Behavior.Retries On 503 ✅ 7022ms
Retry Behavior.Retries On 504 ✅ 7016ms
Retry Behavior.Retries On 404 ✅ 6016ms
Retry Behavior.Retries On 429 ✅ 7015ms
Retry Behavior.Retries On 502 ✅ 6016ms
Retry Behavior.Retryable Errors Have Retry After ✅ 4011ms
Retry Behavior.Respects Retry After On Retryable Error ✅ 10022ms
Retry Behavior.Does Not Retry On 400 ✅ 4016ms
Retry Behavior.Does Not Retry On 401 ✅ 4016ms
Retry Behavior.Does Not Retry On 402 ✅ 4015ms
Retry Behavior.Does Not Retry On 413 ✅ 4018ms
Retry Behavior.Does Not Retry On 415 ✅ 4015ms
Retry Behavior.Non Retryable Errors Have No Retry After ✅ 4015ms
Retry Behavior.Implements Backoff ✅ 14021ms
Partial Batch Handling.Handles 200 Full Success ✅ 2016ms
Partial Batch Handling.Handles 200 With All Ok ✅ 3027ms
Partial Batch Handling.Does Not Retry Dropped Events ✅ 3022ms
Partial Batch Handling.Does Not Retry Warning Events ✅ 3021ms
Partial Batch Handling.Prunes Ok Events On Partial Retry ✅ 7017ms
Partial Batch Handling.Prunes Dropped Events On Partial Retry ✅ 7014ms
Partial Batch Handling.Retries Only Retry Events From Partial ✅ 7016ms
Partial Batch Handling.Partial Retry Preserves Uuids ✅ 7016ms
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 ✅ 3022ms
Compression.Sends Gzip Content Encoding ✅ 15ms
Compression.No Content Encoding When Disabled ✅ 14ms
Compression.Compressed Body Is Decompressible ✅ 13ms
Error Handling.Does Not Retry On Unknown 4Xx ✅ 4014ms
Event Options.Cookieless Mode Override ✅ 13ms
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 ✅ 9ms
Event Options.Options Override In Batch ✅ 13ms
Event Options.Unknown Option Passes Through ✅ 8ms
Event Options.Option Value Is Not Converted ✅ 13ms
Event Options.Lenient Bool Option Values Are Not Converted ✅ 10ms
Event Options.Option Wins Over Legacy Property ✅ 9ms
Event Options.Legacy Property Fills Unset Option ✅ 8ms
Event Options.Null Option Falls Back To Legacy Property ✅ 10ms
Event Size.Event Over Ceiling Is Not Sent ✅ 3290ms
Event Size.Over Ceiling Drop Is Reported Or Logged Without Content ✅ 2045ms
Event Size.Batches Close Before Byte Target ✅ 6071ms
Geoip And Historical Migration.Historical Migration Absent By Default ✅ 14ms
Property Layers.Caller Property Beats Registered Property ✅ 11ms
Property Layers.Before Send Runs Last ✅ 10ms
Fail Open.Empty Api Key Sends Nothing ✅ 1007ms
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 ✅ 29ms
Request Payload.Flags Request Uses V2 Query Param ✅ 15ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 12ms
Request Payload.Flags Request Omits Authorization Header ✅ 11ms
Request Payload.Token In Flags Body Matches Init ✅ 11ms
Request Payload.Groups Round Trip ✅ 12ms
Request Payload.Groups Default To Empty Object ✅ 15ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 12ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 11ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 13ms
Request Lifecycle.No Flags Request On Init Alone ✅ 7ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 12ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 17ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 16ms
Retry Behavior.Retries Flags On 502 ✅ 318ms
Retry Behavior.Retries Flags On 504 ✅ 316ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 14ms

This branch has not been deployed

No deployments
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.

3 participants