Skip to content

Commit 385cac4

Browse files
docs(audience): add @imtbl/audience README (SDK-115) (#2856)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent c4f8424 commit 385cac4

File tree

2 files changed

+17
-65
lines changed

2 files changed

+17
-65
lines changed

packages/audience/pixel/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,3 +151,10 @@ Note: the nonce covers the inline snippet only. The CDN-loaded script (`imtbl.js
151151
| Firefox | 78+ |
152152
| Safari | 14+ |
153153
| Edge | 80+ |
154+
155+
## Documentation
156+
157+
- [Tracking Pixel](https://docs.immutable.com/docs/products/audience/tracking-pixel) — this package (setup, consent modes, auto-tracked events)
158+
- [Web SDK](https://docs.immutable.com/docs/products/audience/web-sdk) — sibling `@imtbl/audience` package for typed event tracking and identity management
159+
- [REST API](https://docs.immutable.com/docs/products/audience/rest-api) — backend reference for direct integration
160+
- [Data dictionary](https://docs.immutable.com/docs/products/audience/data-dictionary) — predefined event names and property schemas

packages/audience/sdk/README.md

Lines changed: 10 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,6 @@ IIFE for `<script>`-tag loading.
88
> stabilising but breaking changes may still land before the first
99
> published release.
1010
11-
## Which Immutable event-tracking product is this?
12-
13-
Immutable ships two complementary event-tracking products in this
14-
monorepo. Pick based on your integration shape:
15-
16-
- **`@imtbl/audience`** (this package) — the programmatic SDK. You call
17-
`Audience.init()` from your app code and explicitly track events
18-
(`track('purchase', {...})`, `identify()`, `setConsent()`, etc.).
19-
Pick this when you need fine-grained control, typed events, player
20-
identity, or explicit consent state machines.
21-
- **`@imtbl/pixel`** ([sibling package](../pixel/README.md)) — a drop-in
22-
`<script>` snippet that captures page views, device signals, and
23-
attribution data passively. Zero configuration beyond a publishable
24-
key. Pick this for marketing sites, landing pages, and web shops
25-
where you want to measure campaign performance without writing
26-
tracking code.
27-
28-
The two share the same backend pipeline, the same anonymous-id cookie
29-
(`imtbl_anon_id`), and the same publishable-key format — they're
30-
designed to coexist on a single site if you need both at once.
31-
3211
## Install
3312

3413
```sh
@@ -41,17 +20,15 @@ yarn add @imtbl/audience
4120

4221
For the CDN build, drop one `<script>` tag into your HTML and call
4322
`ImmutableAudience.init({...})` — no bundler, no `npm install`.
44-
Once `@imtbl/audience` is published, the bundle URL will be
45-
`https://cdn.jsdelivr.net/npm/@imtbl/audience@<version>/dist/cdn/imtbl-audience.global.js`
46-
(replace `<version>` with a specific release tag).
23+
The bundle URL is `https://cdn.immutable.com/audience/v1/imtbl.js`.
4724

4825
## Quickstart — ESM
4926

5027
```ts
5128
import { Audience } from '@imtbl/audience';
5229

5330
const audience = Audience.init({
54-
publishableKey: 'pk_imapik-test-...',
31+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
5532
consent: 'anonymous',
5633
onError: (err) => console.error(err.code, err.message),
5734
});
@@ -68,14 +45,14 @@ audience.shutdown();
6845
## Quickstart — CDN
6946

7047
```html
71-
<script src="https://cdn.jsdelivr.net/npm/@imtbl/audience@<version>/dist/cdn/imtbl-audience.global.js"></script>
48+
<script src="https://cdn.immutable.com/audience/v1/imtbl.js"></script>
7249
<script>
7350
const {
7451
init, AudienceError, AudienceEvents,
7552
IdentityType, canTrack, canIdentify,
7653
} = window.ImmutableAudience;
7754
const audience = init({
78-
publishableKey: 'pk_imapik-test-...',
55+
publishableKey: 'YOUR_PUBLISHABLE_KEY',
7956
consent: 'anonymous',
8057
onError: (err) => console.error(err.code, err.message),
8158
});
@@ -84,45 +61,13 @@ audience.shutdown();
8461
</script>
8562
```
8663

87-
The CDN bundle attaches `init` (the same static factory ESM consumers
88-
call as `Audience.init({...})`) alongside `AudienceError`,
89-
`AudienceEvents`, `IdentityType`, `canTrack`, `canIdentify`, and
90-
`version`, so every runtime helper an ESM consumer needs is reachable
91-
from the CDN global too.
92-
93-
## Error handling
94-
95-
`AudienceError.code` is a closed union — `'FLUSH_FAILED'`,
96-
`'CONSENT_SYNC_FAILED'`, `'NETWORK_ERROR'`, `'VALIDATION_REJECTED'`
97-
so you can branch on the failure mode:
98-
99-
```ts
100-
Audience.init({
101-
publishableKey: 'pk_imapik-test-...',
102-
onError: (err) => {
103-
switch (err.code) {
104-
case 'VALIDATION_REJECTED':
105-
// Terminal: messages were dropped. Inspect err.responseBody
106-
// for per-message detail when the backend provides it.
107-
break;
108-
default:
109-
// Transient: the queue will retry automatically.
110-
break;
111-
}
112-
telemetry.captureException(err);
113-
},
114-
});
115-
```
116-
117-
Exceptions thrown from `onError` are swallowed by the SDK so a
118-
bad handler can't wedge the queue.
119-
120-
## Interactive sample app
64+
## Documentation
12165

122-
For a live harness that exercises every public method, every typed
123-
`track()` event, and every reachable `AudienceErrorCode` against the
124-
real sandbox backend, see [`packages/audience/sdk-sample-app`](https://github.com/immutable/ts-immutable-sdk/tree/main/packages/audience/sdk-sample-app)
125-
in the `ts-immutable-sdk` monorepo.
66+
- [Web SDK](https://docs.immutable.com/docs/products/audience/web-sdk) — API reference, usage, integration walkthrough
67+
- [Tracking Pixel](https://docs.immutable.com/docs/products/audience/tracking-pixel) — sibling `@imtbl/pixel` package for drop-in page-view tracking
68+
- [REST API](https://docs.immutable.com/docs/products/audience/rest-api) — backend reference for direct integration
69+
- [Data dictionary](https://docs.immutable.com/docs/products/audience/data-dictionary) — predefined event names and property schemas
70+
- [Sample app](../sdk-sample-app) — runnable example showing init, tracking, identity, and consent
12671

12772
## License
12873

0 commit comments

Comments
 (0)