Skip to content

SDK-32: Add shared audience SDK core package#2810

Closed
nattb8 wants to merge 2 commits into
mainfrom
feat/sdk-32-shared-foundation
Closed

SDK-32: Add shared audience SDK core package#2810
nattb8 wants to merge 2 commits into
mainfrom
feat/sdk-32-shared-foundation

Conversation

@nattb8
Copy link
Copy Markdown
Contributor

@nattb8 nattb8 commented Apr 1, 2026

Summary

New @imtbl/audience-core package that provides the shared foundation both the web SDK and pixel build on. This lets web SDK and pixel development happen in parallel.

What's in the core:

  • Cookie-based anonymous ID (imtbl_anon_id) -- shared between pixel and SDK for identity stitching across surfaces
  • HTTP transport -- POST to /v1/audience/messages with publishable key auth, keepalive: true for page unload reliability
  • Batched queue -- flushes at 20 messages or 5s interval, persists to localStorage so events survive navigation
  • Context collection -- device fingerprint signals (userAgent, locale, timezone, screen, page info) and UTM param extraction
  • Types -- message types matching the audience service API contract (track, page, screen, identify, alias)

Key design decisions:

  • Anonymous ID uses a cookie (not localStorage) so it works across the pixel script tag and npm SDK on the same domain
  • Context collection is parameterised by library name so the pixel and SDK identify themselves differently
  • collectPageProperties() and collectUtmParams() are exported separately so the pixel can use them for auto-capture and the SDK can use them in page()
  • No external dependencies

Test plan

  • 27 unit tests passing (cookie, queue, transport, context, storage)
  • TypeScript strict mode passes
  • CI lint/build

Linear: https://linear.app/imtbl/issue/SDK-32

🤖 Generated with Claude Code

nattb8 and others added 2 commits April 1, 2026 14:02
Shared foundation package for the web SDK and pixel. Provides:
- Cookie-based anonymous ID (imtbl_anon_id) for cross-surface stitching
- HTTP transport with publishable key auth
- Batched message queue with localStorage durability
- Device fingerprint and page context collection
- Types matching the audience service API contract

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@nattb8 nattb8 closed this Apr 1, 2026
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