Skip to content

feat(audience): mirror server-side event validation client-side [SDK-679]#821

Merged
nattb8 merged 1 commit into
mainfrom
feat/sdk-679-mirror-server-validation
Jul 21, 2026
Merged

feat(audience): mirror server-side event validation client-side [SDK-679]#821
nattb8 merged 1 commit into
mainfrom
feat/sdk-679-mirror-server-validation

Conversation

@nattb8

@nattb8 nattb8 commented Jul 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

Ticket: SDK-679

Brings client-side validation in the Audience package to parity with the ingest API. Invalid calls (empty/malformed id, identical alias ids, a null/empty typed event) now throw immediately instead of dropping silently with a Log.Warn that's easy to miss; valid calls are unaffected and still enqueue as before. The passport-ID format check already covered part of this scope (bac4b2fc); this closes the rest.

Gap Before After
Alias() equality check Not checked at all Throws on fromId == toId, matching the backend (ignores identityType)
Identify()/Alias()/Track() caller-bug input (empty id, malformed passport id, identical alias ids, empty event name, null IEvent) Logged via Log.Warn and silently dropped Throws (ArgumentException/ArgumentNullException)
Track() validation order Checked the argument after the consent gate, so Track(null)/Track("") at None consent silently no-opped instead of throwing, unlike Identify()/Alias() Argument validated before the consent gate, matching Identify()/Alias()
Clock-skew future bound Not checked (only the past bound existed, coincidentally) Files stamped more than 24h in the future are also excluded now
Sample app (AudienceSample.cs) mirror accuracy Only checked for empty ids Also checks equality, kept in sync with the fix above
Sample app flush outcome visibility Only an app-tier "flush() Ok" row confirming the async call didn't throw — no signal for whether the actual send succeeded SDK now logs a per-attempt "flush ok/failed (N messages)" outcome (mirrors the TS SDK's logFlush); sample app gives it its own Ok/Err row with the message itself as the label, matching the web sample app's console-mirror instead of the generic "sdk" tag used for other SDK-sourced messages

Consent-gated no-ops (e.g. Identify() below Full consent) and a buggy consumer IEvent.ToProperties()/EventName implementation still just log a warning: the first is routine flow-gating, not a caller bug; the second is third-party code we can't trust not to crash the game.

Sample app (AudienceSample.cs): OnAlias()/OnIdentify() already run through RunAndLog, which catches and displays thrown exceptions, so no new plumbing was needed. The OnAlias() mirror check now tracks only the one case it can still detect, consent below Full, since the id/equality checks it used to make now throw before reaching it. Added a live-fire UI test (Alias_SameId_Throws), matching the existing passport-ID test's pattern.

Test plan

  • dotnet build src/Audience.Build/Audience.Tests/Audience.Tests.csproj — no errors, only pre-existing unrelated warnings
  • dotnet test — 382 passed, 1 skipped (pre-existing), 0 failed; includes coverage converted from Log.Warn assertions to Assert.Throws, new tests for the flush-outcome log on both success and failure, and regression tests proving Track() throws even at None consent
  • dotnet format --verify-no-changes on all changed files — clean
  • Unity Editor Test Runner not run here (can't execute in this environment) — needs a pass before merge, especially Alias_SameId_Throws, Identify_PassportWithInvalidIdFormat_Throws, and the AudienceSample.cs sample app fix (including the new flush-outcome log row)

🤖 Generated with Claude Code

@nattb8
nattb8 force-pushed the feat/sdk-679-mirror-server-validation branch 4 times, most recently from 452b473 to 6426b86 Compare July 20, 2026 06:22
@github-actions

github-actions Bot commented Jul 20, 2026

Copy link
Copy Markdown

Audience SDK — Build Size

Platform SDK Size Change
Android 0.37 / 20.00 MB +0.01 MB
Windows 0.17 / 20.00 MB +0.01 MB
iOS 8.55 / 20.00 MB +0.03 MB
macOS 0.92 / 20.00 MB +0.02 MB

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

@nattb8
nattb8 force-pushed the feat/sdk-679-mirror-server-validation branch 5 times, most recently from 0d28d18 to fc9ab2c Compare July 20, 2026 23:56
@nattb8
nattb8 marked this pull request as ready for review July 21, 2026 01:24
@nattb8
nattb8 requested review from a team as code owners July 21, 2026 01:24
@nattb8
nattb8 force-pushed the feat/sdk-679-mirror-server-validation branch from fc9ab2c to 3eaae8a Compare July 21, 2026 01:32
Brings client-side validation to parity with the ingest API so bad
events are caught and dropped locally instead of round-tripping to
the server just to be rejected.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@nattb8
nattb8 force-pushed the feat/sdk-679-mirror-server-validation branch from 3eaae8a to 093f876 Compare July 21, 2026 02:35
@nattb8
nattb8 merged commit 9e84f54 into main Jul 21, 2026
53 of 56 checks passed
@nattb8
nattb8 deleted the feat/sdk-679-mirror-server-validation branch July 21, 2026 02:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

2 participants