feat(audience): add Audience class with consent, tracking, and identity#2826
Merged
JCSanPedro merged 5 commits intomainfrom Apr 8, 2026
Merged
feat(audience): add Audience class with consent, tracking, and identity#2826JCSanPedro merged 5 commits intomainfrom
JCSanPedro merged 5 commits intomainfrom
Conversation
2 tasks
68de603 to
d72536d
Compare
739a16a to
bfd4618
Compare
|
View your CI Pipeline Execution ↗ for commit e98f452
☁️ Nx Cloud last updated this comment at |
d72536d to
2ed1923
Compare
bfd4618 to
0960d7a
Compare
e4fe335 to
a404b5e
Compare
c7592b3 to
6cc1921
Compare
a404b5e to
dae297d
Compare
6cc1921 to
a830608
Compare
dae297d to
b90f61a
Compare
a830608 to
b5964c5
Compare
b90f61a to
45ebb0b
Compare
16ecf2d to
82b1a90
Compare
ed3509e to
45967cd
Compare
82b1a90 to
0375ff4
Compare
45967cd to
f8e493a
Compare
0375ff4 to
8fb34be
Compare
f8e493a to
d7cbd5d
Compare
8fb34be to
37bcb3d
Compare
d7cbd5d to
af5828c
Compare
37bcb3d to
7cccbb2
Compare
af5828c to
7ecb14c
Compare
0df2286 to
ac5ad0d
Compare
9791814 to
d7e6011
Compare
312c6c2 to
5d003f8
Compare
nattb8
reviewed
Apr 7, 2026
4ca8371 to
70cccb1
Compare
- Rename package to @imtbl/audience - DebugLogger: opt-in console logging for events, flushes, consent changes, and warnings - AudienceConfig: publishable key, environment, consent, debug, cookie domain, flush interval/size - Config constants: library name/version, log prefix, consent source, session event names Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Audience.init() provides consent-aware event tracking for web: - track(), page(), identify(), alias() with three-tier consent gating - Uses core's createConsentManager (shared with pixel), collectAttribution, and getOrCreateSession — no duplicated logic - session_start/session_end lifecycle with duration tracking - Attribution capture (UTM, click IDs, referrer) on first page view - setConsent() with queue cleanup on downgrade, session restart on upgrade - reset() for player logout, flush() for manual send, shutdown() for cleanup 46 tests covering all public methods, consent transitions, and edge cases. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
70cccb1 to
fcf6063
Compare
JCSanPedro
previously approved these changes
Apr 8, 2026
rodrigo-fournier-immutable
previously approved these changes
Apr 8, 2026
nattb8
reviewed
Apr 8, 2026
bkbooth
reviewed
Apr 8, 2026
bkbooth
reviewed
Apr 8, 2026
Both the SDK and pixel use these event names — they belong in @imtbl/audience-core so both surfaces import from one place. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add destroyed flag so calling shutdown() twice (e.g. React strict mode useEffect cleanup) doesn't queue duplicate session_end or decrement liveInstances below the real count. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ngrade Move the identify/alias queue purge from the SDK into core's createConsentManager so both the SDK and pixel correctly remove PII-linked messages on full→anonymous downgrade. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
e98f452
bkbooth
approved these changes
Apr 8, 2026
rodrigo-fournier-immutable
approved these changes
Apr 8, 2026
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.
Summary
Adds the
Audienceclass to@imtbl/audience(renamed from@imtbl/audience-sdk) — the web SDK for consent-aware event tracking and player identity.What's included
Audience.init()withtrack,page,identify,alias,setConsent,reset,flush,shutdownnone(inert),anonymous(no PII),full(all events)session_starton new session,session_endonshutdown()createConsentManager,collectAttribution, andgetOrCreateSession— no duplicated logic with pixelDe-duplication with #2830
attribution.ts,cookie.ts— now imports from@imtbl/audience-coreConsentControllerclass — now uses core'screateConsentManager(shared with pixel)consent-transport.ts— core'shttpSendhandles the PUTweb/package intosdk/per review feedbackTest plan
cd packages/audience/sdk && pnpm test— 46 tests passcd packages/audience/sdk && pnpm build— builds clean🤖 Generated with Claude Code