Guidance for OpenAI Codex coding agents working on the Mixpanel Unity SDK. Keep this current so agents can ramp quickly.
- Maintain and extend the Unity SDK under
Mixpanel/(plus assets). Package ships via Unity Package Manager; treat.metafiles as required artifacts. - Target Unity 2018.3+ with .NET 4.x Equivalent. Guard any newer API usage.
- No test suite lives here (tests are in
Tests.unitypackage). Expect manual validation or targeted scripts. - Unity threading model only—work through coroutines, not raw threads.
Mixpanelstatic partial class (MixpanelAPI.cs,Log.cs, etc.) is the public API. Every public method starts withIsInitialized()and then delegates to controller helpers.ControllerMonoBehaviour singleton (Controller.cs) governs initialization, coroutine-based flush cadence, default property capture, and migration hooks.MixpanelStorage(Storage.cs) usesIPreferences(defaultPlayerPreferences) for persistence. Watch key names and migration flags (HasMigratedFrom1To2).Value(Value.cs) is the JSON-like container for event/people properties (primitives, arrays, Unity structs like Vector/Quaternion/Color) with merge and serialization logic.MixpanelSettings+Configsurface tokens, debug flags, flush/batch settings, and manual initialization. Token selection follows:#if UNITY_EDITOR || DEBUG return DebugToken; #else return RuntimeToken; #endif
- Version bumps: use
python scripts/release.py --old X.Y.Z --new A.B.Cto automate version updates, commit, tag, and push. Manual alternative: updateMixpanelAPI.cs(MixpanelUnityVersion),package.json, andCHANGELOG.md; then tag (git tag -a vX.Y.Z -m "version X.Y.Z" && git push origin --tags). - Local testing: in a Unity project
Packages/manifest.json, add"com.mixpanel.unity": "file:/absolute/path/to/mixpanel-unity". ImportExamples.unitypackagefor sample scenes. - Debugging: enable
ShowDebugin Unity Project Settings → Mixpanel or callMixpanel.Log()(respectsConfig.ShowDebug). - PR hygiene: ensure every new asset/code file has a
.meta. Do not delete existing.metafiles; Unity regenerates them if needed.
- Auto-init:
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]; respectConfig.ManualInitializationand theMixpanel.Init()path. - Event flow:
Track()→DoTrack()→ merge default + user props →EnqueueTrackingData()→ periodic flush (default 60s, configurable). People ops useDoEngage(). - Tuning:
Config.BatchSizeandConfig.FlushInterval. When changing defaults, update docs and any editor UI. - Serialization changes in
Valuemust update the backing store and JSON conversion and stay backward compatible with existing PlayerPreferences data.
- Namespaces:
mixpanel(runtime) andmixpanel.editor(editor scripts). Keep assembly definition boundaries intact. - Public APIs need XML docs (
<summary>,<param>). Match existing tone. - Conditional compilation:
#if UNITY_EDITOR || DEBUGfor editor-only logic; platform guards like#if UNITY_IOSwhere applicable. - Keep dependencies minimal to stay UPM-friendly.
- Use
rgfor search (rg SymbolName Mixpanel) to navigate the codebase quickly. - When editing storage, migrations, or PlayerPreferences keys, add concise inline comments for future debugging.
- Prefer placing sample/debug scripts under
Mixpanel/Examplesand referencing them in docs rather than leaving ad-hoc files at repo root.
- Docs:
README.md,CLAUDE.md,.github/copilot-instructions.md - Release automation:
.github/workflows/ - Support links: README FAQ and Mixpanel support portal
Update this playbook whenever workflows or expectations change.