Skip to content

feat(audience-consent): add CanTrack and CanIdentify predicates on ConsentLevel (SDK-226)#698

Merged
ImmutableJeffrey merged 1 commit into
mainfrom
feat/sdk-143-consent
Apr 22, 2026
Merged

feat(audience-consent): add CanTrack and CanIdentify predicates on ConsentLevel (SDK-226)#698
ImmutableJeffrey merged 1 commit into
mainfrom
feat/sdk-143-consent

Conversation

@ImmutableJeffrey
Copy link
Copy Markdown
Collaborator

@ImmutableJeffrey ImmutableJeffrey commented Apr 22, 2026

Summary

  • Adds ConsentLevel.CanTrack() and ConsentLevel.CanIdentify() extension predicates as the single source of truth for the SDK's consent gates.
  • Adopts both predicates at six internal call sites that previously inlined the rule (five in ImmutableAudience.cs, one in Identity.cs).
  • ConsentLevelExtensions stays internal, matching the convention used by IdentityTypeExtensions.
  • Tests/Runtime/ConsentLevelTests.cs pins each enum value plus the out-of-range cast against both predicates.

Linear:

  • SDK-226 — primary
  • SDK-143 — contributes consent gates: Identify/Alias require Full, Track requires Anonymous+

@ImmutableJeffrey ImmutableJeffrey requested review from a team as code owners April 22, 2026 23:06
…nsentLevel (SDK-226)

Centralise the consent rules behind two extension predicates and adopt
them at every internal gate site that previously inlined the rule.
ConsentLevelExtensions stays internal: same convention as
IdentityTypeExtensions, no external caller today, and a future PR can
promote when one lands.

Predicates:

  CanTrack    returns level != None.
              Fail-open on out-of-range casts so an unrecognised value
              still tracks, matching the gate shape every other call
              site already uses.

  CanIdentify returns level == Full.
              Fail-closed on out-of-range casts. Identify and Alias
              must not leak PII under uncertain consent.

Adoption:

  ImmutableAudience.cs (5 sites): Identify gate, Alias gate, the
    private static CanTrack body, Enqueue's drain-time recheck closure,
    FireGameLaunch early return.
  Identity.cs (1 site): GetOrCreate's null-on-no-consent guard.

Test coverage in Tests/Runtime/ConsentLevelTests.cs pins each enum
value against both predicates plus the out-of-range cast for both
fail policies, so a future change that flips either default breaks
the build loudly.

SDK-143 originally scoped the full consent infrastructure (state
machine, persistence, side effects, server sync, gates). The state
machine, persistence, side effects, and server sync shipped under
SDK-119, SDK-142, and SDK-147. SDK-226 was carved out for the
remaining slice this commit delivers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ImmutableJeffrey ImmutableJeffrey merged commit ac0125a into main Apr 22, 2026
19 checks passed
@ImmutableJeffrey ImmutableJeffrey deleted the feat/sdk-143-consent branch April 22, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants