Skip to content

SDK-981: Guarantee anonymousId is always sent on Unity SDK audience events - #829

Open
nattb8 wants to merge 1 commit into
mainfrom
feat/audience-alias-guaranteed-anon-id
Open

SDK-981: Guarantee anonymousId is always sent on Unity SDK audience events#829
nattb8 wants to merge 1 commit into
mainfrom
feat/audience-alias-guaranteed-anon-id

Conversation

@nattb8

@nattb8 nattb8 commented Sep 9, 2026

Copy link
Copy Markdown
Collaborator

Summary

File Change
Identity.cs LoadOrGenerate now falls back to an in-memory-only id when disk read/write fails, instead of leaving the cached anonymousId/deviceId null
MessageBuilder.cs Alias gains an anonymousId parameter (previously had none at all)
ImmutableAudience.cs Alias() now resolves and passes anonymousId alongside deviceId
Log.cs Warning message updated to reflect the new fallback behavior instead of claiming events ship without identity fields

Brings the Unity SDK's guarantee in line with ts-immutable-sdk, which already guarantees anonymousId on every event via its shared baseMessage()/BaseMessage type. Also documented on the REST API side (SDK-982): anonymousId doesn't drive the alias merge (fromId/toId do), but is required so every message type has the same shape.

Test plan

  • dotnet test in src/Audience.Build/Audience.Tests: 399 passed, 1 skipped, 0 failed
  • New tests: Identity.PersistenceFails_FallsBackToInMemoryId, Identity.PersistenceFails_InMemoryIdStableForRestOfSession, MessageBuilder.Alias_AnonymousId_PresentWhenProvided/_AbsentWhenNull, ImmutableAudience.Alias_FullConsent_IncludesAnonymousId

🤖 Generated with Claude Code

@nattb8
nattb8 force-pushed the feat/audience-alias-guaranteed-anon-id branch from 0da3a8a to 3457068 Compare September 11, 2026 01:43
Identity.LoadOrGenerate previously swallowed disk I/O failures and left
the cached anonymousId/deviceId null, so an event could silently ship
without an anonymousId. Ids are now computed and cached in memory
before persistence is attempted, so a write failure only costs
persistence across a restart, never a value already known to be
correct, e.g. an anonId read successfully from a legacy-format file
whose migration write then fails.

Alias messages never carried anonymousId at all. It doesn't drive the
merge (fromId/toId do), but per the REST API docs it should still be
attached so alias messages have the same shape as the rest of an
integration's traffic, matching ts-immutable-sdk's behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@nattb8
nattb8 force-pushed the feat/audience-alias-guaranteed-anon-id branch from 3457068 to 3a18fec Compare September 11, 2026 02:06
@github-actions

Copy link
Copy Markdown

Audience SDK — Build Size

Platform SDK Size Change
Android 0.39 / 20.00 MB +0.03 MB
Windows 0.17 / 20.00 MB +0.01 MB
iOS 8.60 / 20.00 MB +0.09 MB
macOS 1.00 / 20.00 MB +0.10 MB

SDK Size = build minus empty app. Change = vs baseline. Fails if any platform exceeds its absolute size limit.

@nattb8
nattb8 marked this pull request as ready for review September 11, 2026 03:34
@nattb8
nattb8 requested review from a team as code owners September 11, 2026 03:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant