feat(audience-unity): Unity integration (SDK-146 / 227 / 228)#707
Merged
ImmutableJeffrey merged 3 commits intomainfrom Apr 27, 2026
Merged
feat(audience-unity): Unity integration (SDK-146 / 227 / 228)#707ImmutableJeffrey merged 3 commits intomainfrom
ImmutableJeffrey merged 3 commits intomainfrom
Conversation
nattb8
reviewed
Apr 24, 2026
nattb8
reviewed
Apr 24, 2026
nattb8
reviewed
Apr 24, 2026
0767fb0 to
ae6780f
Compare
nattb8
reviewed
Apr 24, 2026
…ecycle (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>
…Unity NUnit compat Unity's com.unity.test-framework ships NUnit 3.5, which predates Assert.DoesNotThrowAsync. Awaiting the task achieves the same assertion semantic — NUnit fails the test if the awaited task throws. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ae6780f to
e03d3c9
Compare
nattb8
previously approved these changes
Apr 26, 2026
Adds six public diagnostic getters on ImmutableAudience: - Initialized: true between Init and Shutdown. - CurrentConsent: live consent level. - UserId: last Identify value; null below Full consent. - AnonymousId: anonymous, persistent ID. - SessionId: current session id; rotates on Init / Reset / timeout. - QueueSize: number of unsent events (memory + disk). Each getter is safe from any thread and returns a safe default when the SDK cannot answer. EventQueue gains an internal InMemoryCount property so QueueSize can sum without locking. Adds optional AudienceConfig.BaseUrl override (matches Web/Pixel SDK pattern; addresses #709 review). Null preserves the key-prefix derivation; integrations needing a different backend pass the URL directly. Tests cover diagnostics lifecycle and BaseUrl resolution. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
nattb8
approved these changes
Apr 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Runtime/Unity/(com.immutable.audience.unityasmdef).DeviceCollector— one-shot capture on the main thread:platform,version,buildGuid,unityVersion,osFamily,deviceModel,gpu,gpuVendor,cpu,cpuCores,ramMb,screenDpiforgame_launch;userAgent,locale,timezone,screenfor per-eventcontext. String fields capped at 256 chars (mirrors Web SDK'sMAX_STRING_LENGTH).UnityLifecycleBridge— forwardsOnApplicationPause/OnApplicationFocus(desktop only — mobile focus is noisy) toImmutableAudience.OnPause/OnResume.AudienceUnityHooksatSubsystemRegistration— wiresDefaultPersistentDataPathProvider,LaunchContextProvider,ContextProvider; forwardsApplication.quittingtoShutdown.ImmutableAudience— adds internalOnPause/OnResume;MergeUnityContextmergesContextProvideroutput into every outgoingmsg.contexton the Track and Identify paths.Directory.Build.propsredirectsbin/objto repo-rootartifacts/so dotnet output doesn't leak into Unity's asset importer.link.xmlpreservesImmutable.Audience.RuntimeandImmutable.Audience.Unityagainst IL2CPP stripping.ConstantsTests.ReadPackageJsonwalks up from the test binary to locate the package root, so theDirectory.Build.propsredirect doesn't break it.Linear: SDK-146, SDK-227, SDK-228.