Skip to content

feat(audience-quickstart): add drop-in QuickStart sample (SDK-229)#704

Closed
ImmutableJeffrey wants to merge 2 commits into
feat/sdk-146-unityfrom
feat/audience-quick-start
Closed

feat(audience-quickstart): add drop-in QuickStart sample (SDK-229)#704
ImmutableJeffrey wants to merge 2 commits into
feat/sdk-146-unityfrom
feat/audience-quick-start

Conversation

@ImmutableJeffrey
Copy link
Copy Markdown
Collaborator

@ImmutableJeffrey ImmutableJeffrey commented Apr 24, 2026

Summary

Adds a Samples/QuickStart folder containing AudienceDemo.cs — a drop-in MonoBehaviour that exercises every public ImmutableAudience API from an IMGUI overlay. Studios can set a publishable key, press Play, and verify their audience pipeline end-to-end without wiring a Canvas or prefab.

IMGUI overlay

  • Boxed SDK-status panel reads the public diagnostic getters live (Initialized, Environment, Consent, Pub key, UserId, AnonymousId, SessionId, Queued). Full GUIDs render without truncation; a Copy button next to each ID writes the raw value to the system clipboard. The Pub key row highlights the REPLACE_ME placeholder in red so misconfiguration is obvious before the backend returns 401.
  • Sections: SDK lifecycle (Init / Shutdown / Flush), Typed events, Custom event, Identity, Privacy consent, Advanced (GDPR erasure). Each section has a plain-English description so a first-time reader understands what the buttons do without opening source.
  • Two-line buttons: action sentence on top ("Player started a level"), SDK API in parens below ("(Progression.Start)").
  • Buttons gate on live SDK state. Track-family disables below Consent.None; Identify / Alias require Consent.Full; each Consent button disables at its own level; Init enables only when the SDK is not initialised; Shutdown / Flush / Delete enable only when it is.
  • No auto-init. The user presses "Start the SDK" explicitly; every SDK-dependent button stays disabled until they do.
  • Panel width caps at 800px and centres horizontally so the overlay reads as a focused card on wide screens and fills narrow Game views without an off-to-one-side sidebar.

Bundled scene

  • AudienceDemo.unity is a minimal scene with a camera, a light, and one GameObject carrying AudienceDemo. The overlay renders entirely through IMGUI so the scene has no dependency on a specific uGUI or UI Toolkit version.

Sample payloads

  • Familiar fantasy terminology (overworld, stone_age, gold, diamond_sword, dragon_defeated) — cold-readable without gaming background. Studios replace these strings with their own world names, currencies, item ids, and milestones during integration.

Transport fixes (bundled)

  • HttpTransport reports backend response body on 4xx so the validation message reaches onError instead of being dropped.
  • Request envelope corrected from `{"batch":[…]}` to `{"messages":[…]}` to match the backend MessagesRequest schema.

Linear: SDK-229


Note

Medium Risk
Touches the event flush transport by changing the request envelope to {"messages":[...]} and surfacing 4xx response bodies, which could impact backend compatibility and error reporting behavior if assumptions differ. Sample additions are low risk but increase package surface area.

Overview
Adds a drop-in QuickStart Unity sample (Samples/QuickStart) including an AudienceDemo IMGUI overlay and a minimal .unity scene, letting studios initialize the SDK, send representative events, manage identity/consent, and trigger flush/GDPR deletion without building UI.

Updates HttpTransport to (1) wrap queued events under {"messages":[...]} instead of {"batch":[...]} and (2) include the backend’s 4xx response body (truncated) in ValidationRejected errors for more actionable diagnostics; associated unit tests and gzip test payloads are updated accordingly.

Reviewed by Cursor Bugbot for commit 99bf8c2. Bugbot is set up for automated code reviews on this repo. Configure here.

ImmutableJeffrey and others added 2 commits April 24, 2026 10:27
…...]} envelope

Two bugs that together kept the QuickStart sample from ever shipping
events successfully:

1. The 4xx branch of SendBatchAsync reported only the status code.
   Now reads response.Content (truncated to 500 chars) so the
   backend's validation message lands in the onError callback —
   no more silently dropped batches with "something is wrong" as
   the only signal.
2. BuildPayload wrapped events in {"batch":[...]}. The backend's
   MessagesRequest schema expects the top-level key "messages";
   every send 400'd. Envelope switched, tests updated, and the
   GzipTests fixture aligned to the real wire shape.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…DK API (SDK-49)

Adds a Samples/QuickStart folder (no tilde — Unity auto-includes it
when the package is installed). Drop AudienceDemo on any GameObject
or open the bundled scene, set the publishable key, press Play.

IMGUI overlay (zero scene setup):
- Boxed SDK-status panel reads the public diagnostic getters live
  (Init, Environment, Consent, Pub key, User ID, Anon ID, Session
  ID, Queued). Full GUIDs; Copy buttons write raw values to the
  system clipboard. Pub key row flags the REPLACE_ME placeholder
  in red so misconfiguration is obvious before the backend 401s.
- Sections: SDK lifecycle (Init / Shutdown / Flush), Typed events,
  Custom event, Identity, Privacy consent, Advanced (GDPR erasure).
  Each has a plain-English description so a zero-context reader
  understands what the buttons do without opening source.
- Two-line buttons: action sentence on top ("Player started a
  level"), SDK API in parens below ("(Progression.Start)").
- Buttons gate on live SDK state — Track-family disables below
  Consent.None, Identify/Alias require Full consent, each Consent
  button disables at its own level, Init enables only when not
  initialised, Shutdown/Flush/Delete only when initialised.
- No auto-init: user presses Start the SDK explicitly; every
  SDK-dependent button stays disabled until they do.
- Panel caps at 800px and centres horizontally so it reads as a
  focused card on wide screens and fills narrow Game views.

Sample payloads use familiar fantasy terminology (overworld,
stone_age, gold, diamond_sword, dragon_defeated) — cold-readable
without gaming background, replaced during integration.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ImmutableJeffrey ImmutableJeffrey requested review from a team as code owners April 24, 2026 01:16
Copy link
Copy Markdown
Collaborator

@nattb8 nattb8 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it supposed to be Samples~/

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.

2 participants