Fix race condition causing missing super properties on first tracked event#191
Fix race condition causing missing super properties on first tracked event#191
Conversation
- Eagerly load SuperProperties, OnceProperties, and TimedEvents during Initialize() - Pre-cache auto properties (events and engage) before first Track() call - Initialize session metadata during Initialize() to ensure it's ready - Prevents race condition where Track() called before properties loaded from disk This fixes the issue where App Start events were missing super properties when Track() was called immediately after Init(). Addresses customer report of 30-44% event volume drop and missing super properties on first event after migrating to Unity SDK v3.5.3. Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com>
- Add ISSUE_ANALYSIS.md with detailed root cause analysis - Update CHANGELOG.md with fix description - Document customer's issue, investigation, and solution - Include testing recommendations and timeline Co-authored-by: jaredmixpanel <10504508+jaredmixpanel@users.noreply.github.com>
|
@copilot I see how this might address the missing super properties but I don't see how this would address the events not being tracked / flushed. |
Good question. The fix addresses both issues through the same root cause: Missing Super Properties → Event Volume Drop The customer's App Start events were being tracked but missing super properties (confirmed in their data). This likely caused:
The Race Condition App Exit Events My fix ensures all properties and metadata are loaded synchronously during Commit: 8a6d017 |
After migrating to mixpanel-unity v3.5.3, production customers observed 30-44% event volume drop on Android and missing super properties on the first event of each session. Root cause: lazy loading of persisted properties from PlayerPreferences created a race condition when
Track()was called immediately afterInit().Changes
Controller.Initialize(): AccessSuperProperties,OnceProperties, andTimedEventsto trigger synchronous disk I/O before returningGetEventsDefaultProperties()andGetEngageDefaultProperties()during initialization instead of deferring toAfterSceneLoadMetadata.InitSession()to ensure session ID and counters are readyTechnical Details
Properties were previously lazy-loaded on first access:
Now loads synchronously during initialization:
After
Init()returns, all properties are guaranteed loaded and ready for tracking. No API changes, fully backward compatible.See
ISSUE_ANALYSIS.mdfor detailed customer report and timeline.Original prompt
Below is the text from a Slack thread with a Mixpanel customer and user of the mixpanel-unity SDK about an issue they are experiencing. Study the complete thread carefully. Ultrathink about the issues described and create a detailed and well-specified GitHub Issue on the repo to capture the customer's report.
Here's the Slack thread formatted as clean, proper markdown:
Mixpanel Unity SDK Migration Issue - Event Volume Drop
Channel: #mixpanel-sagomini
Date Range: November 5-19, 2025
Initial Report
Guilherme Quadros da Silva - Nov 5th at 11:46 AM
Hello Mixpanel team — following up on what @brennan Clark flagged. After migrating some games from our prior native embedded SDKs (Android 5.3.0 via Gradle and a custom iOS wrapper at commit 0b982aab58e832ad85a8d9dca4d9729aa3948b53) to the Unity package (UPM mixpanel-unity v3.5.3), we are seeing two issues in the migrated titles:
Event volume has dropped significantly for our App Start and App Exit events on Android (Google Play) only.
The first event we fire every session (the App Start event) is missing all of our super properties.
What we observe:
The migration kept our existing C# wrapper/util classes; we just swapped underlying calls to the Unity Mixpanel API.
Android (GP): lower event counts (e.g., App Start)
iOS: event counts look normal
Missing super properties on both iOS and Android
Games not yet migrated continue to report expected event volumes (including App Start) with super properties present.
What we already checked:
Initialization paths appear to run (Mixpanel.Init + subsequent calls).
Super property registration code still executes (same location as before).
No recent logic changes that would gate or suppress tracking.
No obvious token or environment mismatches.
Request:
Could you help us identify root cause or provide guidance on what to instrument next? We can supply code snippets (initialization order, super property registration, distinct ID logic), verbose logs, or a minimal repro if useful. Let us know what would be most helpful.
Thanks in advance — happy to dig in quickly.
Investigation
Zach Bates - Nov 5th at 12:26 PM
Zendesk Case ID: (https://mixpanelsupport.zendesk.com/agent/tickets/674175)
Ticket Title: Event volume drop and missing super properties post Unity migration.
Zach Bates - Nov 5th at 12:50 PM
This will likely require an assist from my support team so I've gone ahead and submitted a ticket here to get some help, but in the mean time I'll take a crack at it.
Couple of things to help me take a look:
Which project are you currently seeing the impact? Is this in dev/staging or your production environment?
Do you have reports you're referencing for event volume drops that you can link to?
Guilherme Quadros da Silva - Nov 5th at 12:52 PM
School. Production.
but I know that also released World with it
@brennan Clark, can you share the links please?
Edwin Jo Mathew - Nov 5th at 1:06 PM
@zach Does this link work for you?
Guilherme Quadros da Silva - Nov 5th at 1:06 PM
Sago Mini - Production
We are looking for [School] App Start event.
Zach Bates - Nov 5th at 1:22 PM
Ok thank you yes that link works, and when did you execute this change?
Edwin Jo Mathew - Nov 5th at 1:23 PM
For School, we rolled out the update on Oct 1st
Zach Bates - Nov 5th at 1:31 PM
So taking a look at the volume of [School] App Start and [School] App Exit here is the since Sep30th volumes compared to 30 days previous. https://mixpanel.com/project/210340/view/23451/app/insights#fTLhAYFBMnRZ
Zach Bates - Nov 5th at 1:35 PM
So the ~30% drop in android traffic for these two events is one of the issues
Edwin Jo Mathew - Nov 5th at 1:40 PM
That's correct
Zach Bates - Nov 5th at 1:49 PM
"We can supply code snippets (initialization order, super property registration, distinct ID logic), verbose logs, or a minimal repro if useful."
This would be helpful I believe so that when a support rep is able to pick up this ticket we have those assets ready
Support Analysis
Lin Yee Koh - Nov 5th at 6:20 PM
Lin Yee here from Mixpanel Support, I'd be happy to review this with you. Mixpanel Unity (v3.5.3) initializes asynchronously. It is possible that the first event can fire before the instance is ready or before the super-properties file is loaded from disk. If your current code fires App Start immediately...
Guilherme Quadros da Silva - Nov 6th at 4:13 AM
Hello, but the Mixpanel.Init() call seems sync. It is not a coroutine or Task method. It just applies the configs from the scriptable object and then initialize a singleton instance.
How can we wait for the initialization finish? I didn't find an event or something that would tell the call finished.
BTW, we call Init() early in the game's first scene (Bootstrap).
Edwin Jo Mathew - Nov 6th at 10:37 AM
@zach @lin We could look at introducing a delay between Init() and App Start event. But that still doesn't explain the missing App Exit events. I used the dashboard Zach shared earlier ...
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.