Skip to content

Commit 8a6d017

Browse files
Fix race condition in initialization - eagerly load properties
- 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>
1 parent 20a888a commit 8a6d017

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Mixpanel/Controller.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,19 @@ internal static void Initialize() {
4949
// Copy over any runtime changes that happened before initialization from settings instance to the config.
5050
MixpanelSettings.Instance.ApplyToConfig();
5151
GetInstance();
52+
53+
// Eagerly load all persisted properties to ensure they're available immediately for tracking
54+
// This prevents race conditions where Track() is called before properties are loaded from disk
55+
var _ = MixpanelStorage.SuperProperties;
56+
var __ = MixpanelStorage.OnceProperties;
57+
var ___ = MixpanelStorage.TimedEvents;
58+
59+
// Pre-cache auto properties so they're ready for the first Track() call
60+
GetEventsDefaultProperties();
61+
GetEngageDefaultProperties();
62+
63+
// Initialize session metadata
64+
Metadata.InitSession();
5265
}
5366

5467
internal static bool IsInitialized() {

0 commit comments

Comments
 (0)