feat(audience): stamp consent level on Unity SDK messages#812
Open
JCSanPedro wants to merge 2 commits into
Open
feat(audience): stamp consent level on Unity SDK messages#812JCSanPedro wants to merge 2 commits into
JCSanPedro wants to merge 2 commits into
Conversation
Stamp the current consent level onto every message in MessageBuilder.BuildBase (threaded through Track/Identify/Alias), so the backend records the explicit level rather than inferring it from userId presence. Every build/enqueue path is consent-guarded, so only decided levels (anonymous/full) are ever stamped. On a Full -> Anonymous downgrade, queued track messages now have consentLevel rewritten to anonymous alongside the existing userId strip — in the in-memory EnqueueChecked transform and the on-disk DiskStore rewrite (which also normalises events persisted before consentLevel existed). Mirrors the web/pixel SDK change (SDK-565) and the audience-service ingest side (SDK-554). Co-authored-by: Cursor <cursoragent@cursor.com>
Audience SDK — Build Size
SDK Size = build minus empty app. Change = vs baseline. Fails if any platform exceeds its absolute size limit. |
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.
What
MessageBuilder.BuildBase()(threaded throughTrack/Identify/Alias), serialized asconsentLevel(none/anonymous/full) to match the API.Full → Anonymousdowngrade, queued track messages now haveconsentLevelrewritten toanonymousalongside the existinguserIdstrip — in both the in-memoryEnqueueCheckedtransform and the on-diskDiskStorerewrite. The disk rewrite also normalises events persisted beforeconsentLevelexisted.Why
Consent level is being plumbed end-to-end through the pipeline (SDK → audience ingest → attribution → postbacks) as part of SDK-449. Attribution currently infers consent from the presence of a
userId, which cannot distinguish full-but-unidentified traffic from genuinely anonymous traffic. Sending the decided level explicitly lets the backend record provenance rather than guess.This is the Unity half of SDK-565, mirroring the web/pixel SDK change (ts-immutable-sdk) and the audience-service ingest/derivation side (SDK-554, already landed and accepting the field as optional). Non-breaking, forward-compatible.
Notes:
CanTrack/CanIdentify), so the stamped level is always a decided, sendable value (anonymous/full) — nevernone. Unity'sConsentLevelenum has nonot_set(which the API rejects), so it can never be emitted.EnqueueCheckedtransform re-stamps under the drain lock soconsentLevelreflects consent at enqueue time, closing the build→enqueue race the same way the existinguserIdstrip does.End-to-end validation (dev)
Ran the audience sample app against the dev environment and drove the consent flow (init full, identify, downgrade to anonymous). Confirmed in BigQuery (
dev-im-cdp.cdp_raw.events) that every event emitted by this SDK carriesconsent_level, and can be identified as Unity traffic viasurface = 'unity'(context.library = com.immutable.audience):