Skip to content

feat(audience-diagnostics): expose SDK state as public API#708

Merged
ImmutableJeffrey merged 2 commits intofeat/sdk-146-unityfrom
feat/audience-diagnostics
Apr 24, 2026
Merged

feat(audience-diagnostics): expose SDK state as public API#708
ImmutableJeffrey merged 2 commits intofeat/sdk-146-unityfrom
feat/audience-diagnostics

Conversation

@ImmutableJeffrey
Copy link
Copy Markdown
Collaborator

@ImmutableJeffrey ImmutableJeffrey commented Apr 24, 2026

Summary

  • Adds six public diagnostic getters on ImmutableAudience: Initialized, CurrentConsent, UserId, AnonymousId, SessionId, QueueSize.
  • Adds EventQueue.InMemoryCount (internal) so QueueSize can sum the in-memory queue and on-disk store without holding the drain lock.
  • Getters are safe from any thread, before Init and after Shutdown; return a zero-value default (false / null / 0 / ConsentLevel.None) when the SDK is not in a state that can answer; values are tick-level snapshots.

Linear: SDK-243.

Adds six public getters on ImmutableAudience so studios can build
debug HUDs, settings-screen displays, and integration tests without
reaching into internals:

- Initialized: true between Init and Shutdown
- CurrentConsent: live consent level, reflects any SetConsent
- UserId: last Identify value, null below Full consent or pre-Identify
- AnonymousId: persisted id when consent allows tracking, null otherwise
- SessionId: current session id, null when no session is active
- QueueSize: in-memory plus on-disk event count awaiting send

Every getter is safe to call any time — before Init, after Shutdown,
from any thread — and returns a safe default when the SDK cannot
answer. Values are snapshots that can drift a tick against the
background drain thread; fine for display, do not use for invariants.

EventQueue gains an internal InMemoryCount property so QueueSize can
sum memory and disk without locking the drain thread.

Tests cover every getter's lifecycle edges: pre-Init defaults,
Init/Shutdown flips, consent downgrade effects, Reset clearing UserId,
and QueueSize growing across Init's session_start/game_launch plus an
explicit Track.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Comment thread src/Packages/Audience/Runtime/ImmutableAudience.cs
Addresses PR #708 review: adds per-getter comments for `Initialized`,
`UserId`, `SessionId` so all six public getters document their own
non-obvious semantics, not just the three that did before.

The block header above the getters still carries the shared contract
(zero-value default outside Init..Shutdown, tick-level snapshot); the
new lines only add what a reader cannot derive from the member name.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ImmutableJeffrey ImmutableJeffrey marked this pull request as ready for review April 24, 2026 04:49
@ImmutableJeffrey ImmutableJeffrey requested review from a team as code owners April 24, 2026 04:49
@ImmutableJeffrey ImmutableJeffrey merged commit 0767fb0 into feat/sdk-146-unity Apr 24, 2026
18 checks passed
@ImmutableJeffrey ImmutableJeffrey deleted the feat/audience-diagnostics branch April 24, 2026 04:49
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