PostHog’s Android SDK 3.72.10, released on 26 October, fixes a bug in the shared core library (6.47.6) where the beforeSend hook ran twice for each event. Because the second run started from the original event, changes made on the first run to distinctId, timestamp and uuid were thrown away.
Why it matters: beforeSend is where many teams scrub personal data, rename events, drop noisy ones and correct identities. If it quietly runs twice and loses some edits, your event tracking can look fine in code review while sending something different to your analytics project.
What Goes Wrong Without It
A team uses beforeSend to replace a raw account ID with a hashed one in distinctId and to stamp events with a corrected timestamp. After the double run, the hashed ID is lost and the original value is sent. Users appear under two identities, funnels break in the middle, and nobody notices because the hook itself looks correct.
A second risk is side effects. If your hook increments a counter, writes a log line or calls a service, doing it twice per event inflates your own internal numbers.
Data Points to Track
sdk_version: the PostHog Android version running on each device, so you can compare before and after 3.72.10before_send_invocations: a local counter per event, to confirm the hook runs oncebefore_send_modified_fields: which ofdistinctId,timestamp,uuidor properties your hook changesevent_name: to see which events your hook renames or dropsdistinct_id_changed: a boolean for events where the hook replaced the identityduplicate_uuid_count: repeateduuidvalues received in a dayapp_versionandplatform: to separate release effects from SDK effects
Setup Steps
- List every
beforeSendhook in your Android app and note exactly which fields each one edits. - Add a temporary debug counter inside the hook and confirm how many times it fires for a single captured event on your current SDK version.
- Update to PostHog Android 3.72.10 or later and repeat the test. The counter should read one.
- Capture a test event while the hook changes
distinctId,timestampanduuid, then check the event in your PostHog live view to confirm the edited values arrived. - Make any side effects in the hook safe to repeat, so a future bug cannot double count them.
- Add
sdk_versionas a super property so you can filter dashboards by SDK release. - Save a saved insight that counts unique
distinct_idvalues per day, and note the release date on it.
Actionable Insights
Look for an identity step change. If unique users or anonymous profiles shift on the day a version rolled out, compare the share of events with edited identities before and after the update.
Check timestamps. If your hook corrects clock skew or backfills offline events, confirm that late events now land on the right day. Daily active user counts for earlier days may differ from what you saw before.
Separate old and new versions. Users on older app builds still send events through the old SDK. Break results down by sdk_version rather than assuming the whole base changed at once.
Treat hooks as code that needs tests. A small unit test that runs the hook against a sample event, and checks the output fields, would have caught this class of problem early.