Skip to content

feat(audience): add web SDK with consent, page tracking, and attribution#2821

Closed
ImmutableJeffrey wants to merge 1 commit into
feat/audience-web-scaffold-pr1from
feat/audience-web-features-pr2
Closed

feat(audience): add web SDK with consent, page tracking, and attribution#2821
ImmutableJeffrey wants to merge 1 commit into
feat/audience-web-scaffold-pr1from
feat/audience-web-features-pr2

Conversation

@ImmutableJeffrey
Copy link
Copy Markdown
Contributor

Summary

  • ImmutableWebSDK class: static init() factory, track(), page(), identify(), alias(), setConsent(), reset(), flush(), shutdown()
  • ConsentManager: three-tier consent (none/anonymous/full), server-side sync via PUT, DNT/GPC auto-detection, consent cookie persistence
  • MessageQueue: localStorage persistence, batch flush on timer/size, page-unload flush with keepalive: true, stale message filtering, consent-aware purge()/transform()
  • PageTracker: SPA route detection via pushState/replaceState/popstate patching with dedup
  • Attribution: UTM params, click IDs (gclid, fbclid, ttclid, msclkid), referrer, landing page — cached in sessionStorage
  • Transport: fetch with optional keepalive for unload resilience
  • Cookie: domain-aware anonymous ID (2yr), session (30min rolling), consent (1yr)
  • CDN bundle: IIFE exposing window.ImmutableWebSDK, window.AudienceEvent, window.IdentityProvider

All types, config constants, and events imported from @imtbl/audience-core. Web-specific runtime only: WebSDKConfig is the only locally-defined type.

Test plan

  • pnpm build passes (npm + CDN bundles + type declarations)
  • pnpm typecheck passes
  • Bundle sizes: npm ~12KB, CDN ~13KB

🤖 Generated with Claude Code

Stacked PR 2/3 — depends on #2820

Implement @imtbl/audience-web-sdk importing types, config, and events
from @imtbl/audience-core (contract-only). All runtime code is
web-specific:

- ImmutableWebSDK class: init, track, page, identify, alias, consent
- ConsentManager: three-tier (none/anonymous/full), server sync, DNT/GPC
- MessageQueue: localStorage persistence, unload flush (keepalive),
  stale filtering, consent-aware purge/transform
- PageTracker: SPA route detection (pushState/replaceState/popstate)
- Attribution: UTM params, click IDs, referrer, landing page
- Transport: fetch with keepalive for page-unload resilience
- Cookie: domain-aware, session (30min rolling), consent (1yr)
- Validation: timestamp range, alias dedup, max-length truncation
- CDN bundle: IIFE exposing window.ImmutableWebSDK

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@nx-cloud
Copy link
Copy Markdown

nx-cloud Bot commented Apr 5, 2026

View your CI Pipeline Execution ↗ for commit 358f4ea

Command Status Duration Result
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 1m 54s View ↗
nx affected -t build,lint,test ✅ Succeeded 10s View ↗

☁️ Nx Cloud last updated this comment at 2026-04-05 02:32:35 UTC

@ImmutableJeffrey
Copy link
Copy Markdown
Contributor Author

Closing — part of stacked PR set, pending architecture alignment.

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.

1 participant