You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(audience-unity): add Unity integration layer for context and lifecycle (SDK-146)
AudienceUnityHooks installs on SubsystemRegistration and wires:
- DefaultPersistentDataPathProvider from Application.persistentDataPath
- LaunchContextProvider with DeviceCollector's one-shot game_launch
fields (platform, version, buildGuid, unityVersion, osFamily,
deviceModel, gpu*, cpu*, ramMb, screenDpi)
- ContextProvider with userAgent / locale / timezone / screen, merged
into every outgoing message.context
- Application.quitting -> ImmutableAudience.Shutdown
- UnityLifecycleBridge forwards OnApplicationPause / OnApplicationFocus
to ImmutableAudience.OnPause / OnResume
New Unity-layer files (Runtime/Unity/):
- DeviceCollector.cs — IL2CPP-safe SystemInfo / Screen / Application
readers. Strings capped at 256 chars to mirror the Web SDK identifier
cap (core/src/validation.ts MAX_STRING_LENGTH)
- UnityLifecycleBridge.cs — lifecycle forwarder
Core changes in ImmutableAudience:
- LaunchContextProvider / ContextProvider typed as
Func<IReadOnlyDictionary<string, object>>? so the cached snapshot
cannot be mutated by any downstream reader
- MergeUnityContext merges ContextProvider output into every outgoing
message.context before EnqueueChecked; throws and null returns are
swallowed so a misbehaving layer cannot drop events
Build and test infrastructure:
- Directory.Build.props redirects bin/obj to repo-root artifacts/ so
dotnet output doesn't leak into Unity's asset importer scan path
- ConstantsTests walks up from the test binary to find the package
root so the Directory.Build.props redirect doesn't break it
- com.immutable.audience / .unity asmdefs updated
- link.xml preserves Unity hooks from IL2CPP stripping
- .gitignore adds artifacts/
Tests:
- ContextProvider_Set / _Throwing / _ReturnsNull pin the merge +
swallow behaviour
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments