@disconetwork/core 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,240 @@
1
+ # @disconetwork/core
2
+
3
+ The JavaScript/TypeScript SDK for the Disco recommendations and events APIs.
4
+ Works in any runtime with `fetch` — Node, edge, and the browser.
5
+
6
+ `DiscoClient` talks to the Disco partners gateway directly:
7
+
8
+ - **Recommendations** — fetch personalized offers for a placement.
9
+ - **Events** — report displays, views, and clicks back to Disco via a
10
+ session-bound tracker.
11
+
12
+ It gives you a typed request/response surface, validates both sides against the
13
+ API schema, and normalizes failures into a small, catchable error hierarchy.
14
+
15
+ ## Installation
16
+
17
+ ```sh
18
+ npm install @disconetwork/core
19
+ # or: pnpm add @disconetwork/core / yarn add @disconetwork/core
20
+ ```
21
+
22
+ Requires Node 20+ (or any runtime with a global `fetch`). `zod` is the only
23
+ runtime dependency.
24
+
25
+ ## Authentication
26
+
27
+ Authenticate with a **scoped public API key**:
28
+
29
+ | Prefix | Environment |
30
+ | -------------------- | ----------------- |
31
+ | `disco_pk_live_…` | production |
32
+ | `disco_pk_sandbox_…` | staging / sandbox |
33
+
34
+ Anything else — including a **secret** (`disco_sk_…`) key — is rejected:
35
+ `DiscoClient` is public-key only.
36
+
37
+ ## Quick start
38
+
39
+ ```ts
40
+ import { DiscoClient } from "@disconetwork/core";
41
+
42
+ const disco = new DiscoClient({ apiKey: process.env.DISCO_API_KEY! });
43
+
44
+ const { data, tracker } = await disco.getRecommendationsWithTracker({
45
+ userDetails: { email: "shopper@example.com" },
46
+ placementDetails: { displayMode: "OVERLAY", view: "THANK_YOU" },
47
+ });
48
+
49
+ // Report that the widget loaded.
50
+ tracker.track({ type: "WIDGET_LOAD" });
51
+
52
+ // Render recommendations from the normalized response.
53
+ for (const [groupKey, entries] of Object.entries(data.recommendationGroups)) {
54
+ for (const entry of entries) {
55
+ const rec = data.recommendations[entry.offerId];
56
+ console.log(rec.advertiser.name, "—", rec.offer.heading);
57
+ }
58
+ }
59
+ ```
60
+
61
+ ## Creating a client
62
+
63
+ ```ts
64
+ const disco = new DiscoClient({
65
+ apiKey: "disco_pk_live_…", // required; selects the environment
66
+ apiVersion: "1.0.0", // optional; sent as the X-API-Version header (default "1.0.0")
67
+ fetch: customFetch, // optional; defaults to globalThis.fetch
68
+ });
69
+ ```
70
+
71
+ `DiscoClientConfig`:
72
+
73
+ | Field | Type | Required | Description |
74
+ | ------------ | -------------- | -------- | --------------------------------------------------------------------- |
75
+ | `apiKey` | `string` | yes | Scoped public key. Prefix selects production vs. staging. |
76
+ | `apiVersion` | `string` | no | Value for the required `X-API-Version` header. Defaults to `"1.0.0"`. |
77
+ | `fetch` | `typeof fetch` | no | Custom fetch implementation. Defaults to the global `fetch`. |
78
+
79
+ ## Fetching recommendations
80
+
81
+ ### `getRecommendations(request, options?)`
82
+
83
+ Returns a `Promise<RecommendationsResponse>`.
84
+
85
+ ```ts
86
+ import type { RecommendationsRequest } from "@disconetwork/core";
87
+
88
+ const request: RecommendationsRequest = {
89
+ // Must carry at least one identifier: email, emailHash, externalGuid, or phone.
90
+ userDetails: {
91
+ email: "shopper@example.com",
92
+ firstName: "Ada",
93
+ gender: "FEMALE",
94
+ },
95
+ placementDetails: {
96
+ displayMode: "OVERLAY",
97
+ view: "THANK_YOU",
98
+ },
99
+ orderDetails: {
100
+ orderId: "order-123",
101
+ costDetails: { amount: 4999, currencyCode: "USD" },
102
+ },
103
+ purchases: [{ name: "Wireless Mouse", quantity: 1, productId: "sku-9" }],
104
+ };
105
+
106
+ const data = await disco.getRecommendations(request);
107
+ ```
108
+
109
+ The response is returned as a set of normalized maps for you to join and
110
+ transform as you see fit:
111
+
112
+ - `data.recommendations` — `offerId → Recommendation` (`{ advertiser, offer }`).
113
+ - `data.recommendationGroups` — `groupKey → RecommendationGroupEntry[]`, the
114
+ ordered entries referencing offer ids.
115
+ - `data.recommendationGroupProperties` — `groupKey → RecommendationGroupProperty`
116
+ (heading / slot context).
117
+ - `data.footer` — attribution and privacy-policy copy you must surface.
118
+ - `data.sessionId` — pass this to `createTrackingManager` to report events.
119
+
120
+ Pass `options.signal` to cancel an in-flight request; an aborted request rejects
121
+ with the native `AbortError` (see [Error handling](#error-handling)).
122
+
123
+ ### `getRecommendationsWithTracker(request, options?)`
124
+
125
+ Convenience for the common case: fetch recommendations **and** create a tracker
126
+ already bound to the response's session, in one call. Returns
127
+ `{ data, tracker }`. The tracker inherits the client's API key and environment.
128
+
129
+ ```ts
130
+ const { data, tracker } = await disco.getRecommendationsWithTracker(request);
131
+ ```
132
+
133
+ ## Tracking events
134
+
135
+ A tracker is bound to one recommendations **session**. Create it from a response's
136
+ `sessionId` (or use `getRecommendationsWithTracker` to get one back automatically):
137
+
138
+ ```ts
139
+ const tracker = disco.createTrackingManager(data.sessionId);
140
+ ```
141
+
142
+ `tracker.track(event)` is **fire-and-forget** — it never throws and returns
143
+ `void`. Failures are logged via `console.error`. `WIDGET_DISPLAY`,
144
+ `WIDGET_VIEW`, `BRAND_DISPLAY`, and `BRAND_VIEW` are automatically deduped
145
+ per-session, so re-emitting them for the same brand is a no-op.
146
+
147
+ ```ts
148
+ // Widget lifecycle — no extra fields.
149
+ tracker.track({ type: "WIDGET_LOAD" });
150
+ tracker.track({ type: "WIDGET_DISPLAY" });
151
+ tracker.track({ type: "WIDGET_VIEW" });
152
+
153
+ // Brand visibility — requires the brand and where it rendered.
154
+ tracker.track({
155
+ type: "BRAND_VIEW",
156
+ brand: { offerId, advertiserId, insertionId },
157
+ target: "INLINE_SLOT",
158
+ });
159
+
160
+ // Brand click.
161
+ tracker.track({
162
+ type: "BRAND_CLICK",
163
+ brand: { offerId, advertiserId, insertionId },
164
+ target: "INLINE_ASSET_TILE",
165
+ assetId: "ast_1", // optional
166
+ });
167
+
168
+ // Product events.
169
+ tracker.track({
170
+ type: "PRODUCT_CLICK",
171
+ product: { productId: "sku-9" },
172
+ brand: { offerId, advertiserId, insertionId },
173
+ target: "INLINE_TILE",
174
+ });
175
+
176
+ // Non-brand UI interactions.
177
+ tracker.track({ type: "ELEMENT_CLICK", target: "CLOSE_BUTTON" });
178
+ ```
179
+
180
+ `brand` identifies a recommendation instance — `offerId`, `advertiserId`, and
181
+ `insertionId` come straight from a `RecommendationGroupEntry`. The `insertionId`
182
+ is the unique-per-render id used for dedup. Every event also accepts an optional
183
+ `placement` (`{ displayMode?, view?, layoutId? }`) for placement context.
184
+
185
+ `session_id` and the event timestamp are stamped automatically — you supply only
186
+ the event-specific fields above. The full set of event types and targets is
187
+ described by the exported `EventPayload` type.
188
+
189
+ ## Error handling
190
+
191
+ Every failure the client raises (except cancellation) extends `DiscoError`, so
192
+ you can catch the base class to handle any SDK error, or narrow to a subclass:
193
+
194
+ ```ts
195
+ import {
196
+ DiscoError,
197
+ DiscoApiError,
198
+ DiscoNetworkError,
199
+ DiscoValidationError,
200
+ } from "@disconetwork/core";
201
+
202
+ try {
203
+ const data = await disco.getRecommendations(request);
204
+ } catch (err) {
205
+ if (err instanceof DiscoApiError) {
206
+ // Non-2xx response. err.status, err.statusText, err.body
207
+ } else if (err instanceof DiscoValidationError) {
208
+ // Request/response failed schema validation. err.cause (ZodError), err.rawValue
209
+ } else if (err instanceof DiscoNetworkError) {
210
+ // Request never reached the server (DNS, timeout, connection reset). err.cause
211
+ } else if (err instanceof DiscoError) {
212
+ // Any other SDK error.
213
+ } else if (err instanceof Error && err.name === "AbortError") {
214
+ // Cancellation via AbortSignal — intentionally NOT a DiscoError.
215
+ }
216
+ }
217
+ ```
218
+
219
+ | Error | Thrown when | Notable fields |
220
+ | ---------------------- | -------------------------------------------------- | -------------------------------- |
221
+ | `DiscoApiError` | The API returns a non-2xx status. | `status`, `statusText`, `body` |
222
+ | `DiscoValidationError` | Request or response data fails schema validation. | `cause` (`ZodError`), `rawValue` |
223
+ | `DiscoNetworkError` | The request never completes (network/DNS/timeout). | `cause` |
224
+ | `DiscoError` | Abstract base of all of the above. | — |
225
+
226
+ A request aborted via `AbortSignal` rejects with the native `AbortError`, which
227
+ is deliberately **not** a `DiscoError` — detect it with `err.name === "AbortError"`.
228
+
229
+ ## TypeScript
230
+
231
+ The package ships full type definitions, so the entire request, response, and
232
+ event surface is discoverable through your editor's autocomplete — including the
233
+ allowed values for fields like `displayMode`, `view`, and the event `type`. Build
234
+ requests and events as object literals; they're type-checked against the schema
235
+ as you write them. Import `RecommendationsRequest` / `RecommendationsResponse`
236
+ (and their pieces) when you need to name a type explicitly.
237
+
238
+ ## License
239
+
240
+ MIT
@@ -262,6 +262,16 @@ type EventPlacementDetails = {
262
262
  * service) and the internal/proxy client — the proxy forwards events verbatim,
263
263
  * so the contract is identical.
264
264
  */
265
+ /**
266
+ * Renderer-agnostic handle for emitting Disco events. Both the SDK-backed
267
+ * external tracker (`DiscoClient.createTrackingManager`) and the proxy
268
+ * `TrackingManager` implement this same interface, so consumers (and the React
269
+ * layer) depend on the interface, not the implementation. `track` is a closure,
270
+ * so it's safe to destructure.
271
+ */
272
+ type EventTracker = {
273
+ track: (event: EventPayload) => void;
274
+ };
265
275
  type EventPayload = {
266
276
  type: WidgetEventType;
267
277
  placement?: EventPlacementDetails;
@@ -289,67 +299,6 @@ type EventPayload = {
289
299
  placement?: EventPlacementDetails;
290
300
  };
291
301
  //#endregion
292
- //#region src/TrackingManager.d.ts
293
- type TrackingManagerConfig = {
294
- /**
295
- * Session identifier returned by the recommendations API. Stamped onto
296
- * every emitted event as `session_id`. A tracker is meaningless without
297
- * a session, so this is required — instantiate the manager only after
298
- * the recommendations response is in hand.
299
- */
300
- sessionId: string;
301
- /**
302
- * Absolute URL events are POSTed to. The external client points this at the
303
- * events service (`/events`); the internal client at the proxy
304
- * (`/track/partners_event/`). Prefer a client's `createTrackingManager` over
305
- * constructing this directly, so the endpoint and auth stay consistent with
306
- * the recommendations call.
307
- */
308
- endpoint: string;
309
- /**
310
- * Extra request headers — e.g. `{ "x-api-key": key }` for the external
311
- * events service. `Content-Type: application/json` is always sent.
312
- */
313
- headers?: Record<string, string>;
314
- /**
315
- * Override the global `fetch`. Primarily useful in tests and in runtimes
316
- * that provide a non-standard fetch implementation. Defaults to
317
- * `globalThis.fetch`.
318
- */
319
- fetch?: typeof fetch;
320
- };
321
- type EventTracker = {
322
- track: (event: EventPayload) => void;
323
- };
324
- /**
325
- * Renderer-agnostic event tracker for Disco recommendation surfaces.
326
- *
327
- * Owns:
328
- * - the dedup set (so repeated display/view events for the same brand
329
- * don't get re-sent within a session)
330
- * - the network call to the partner-events endpoint
331
- * - payload formatting (snake_case keys, BE-friendly datetime)
332
- *
333
- * Does not know about React. Wrap it in a Provider (`@disconetwork/react`'s
334
- * `DiscoProvider`) when consuming from a React tree, or instantiate it
335
- * directly from any other JS environment.
336
- *
337
- * `track` is implemented as an instance-bound arrow function so consumers
338
- * can safely destructure it without losing `this`.
339
- */
340
- declare class TrackingManager {
341
- #private;
342
- constructor(config: TrackingManagerConfig);
343
- /**
344
- * Send a tracking event. Fire-and-forget — never throws.
345
- * Failures are logged via `console.error`.
346
- *
347
- * Idempotency: `WIDGET_DISPLAY`, `WIDGET_VIEW`, `BRAND_DISPLAY`, and
348
- * `BRAND_VIEW` are deduped per-instance by (event type, insertionId).
349
- */
350
- track: (event: EventPayload) => void;
351
- }
352
- //#endregion
353
302
  //#region src/errors.d.ts
354
303
  /**
355
304
  * Base class for every error thrown by the Disco clients. Catch this to handle
@@ -404,5 +353,5 @@ declare class DiscoNetworkError extends DiscoError {
404
353
  constructor(message: string, cause: unknown);
405
354
  }
406
355
  //#endregion
407
- export { RecommendationsResponse as A, OfferCtaDetails as C, RecommendationGroupEntry as D, Recommendation as E, SubView as F, Title as I, View as L, DisplayMode as M, Gender as N, RecommendationGroupProperty as O, PlatformType as P, OfferAsset as S, OfferMetadata as T, ProductProperties as _, EventTracker as a, Footer as b, BrandClickInitiatingTarget as c, BrandVisibilityEventType as d, ElementClickInitiatingTarget as f, ProductEventType as g, ProductDisplayInitiatingTarget as h, DiscoValidationError as i, RunningExperiment as j, RecommendationsRequest as k, BrandDisplayInitiatingTarget as l, EventPlacementDetails as m, DiscoError as n, TrackingManager as o, EventPayload as p, DiscoNetworkError as r, TrackingManagerConfig as s, DiscoApiError as t, BrandProperties as u, WidgetEventType as v, OfferDisclosureDetails as w, Offer as x, Advertiser as y };
408
- //# sourceMappingURL=errors-C-xomnpl.d.ts.map
356
+ export { DisplayMode as A, OfferMetadata as C, RecommendationsRequest as D, RecommendationGroupProperty as E, View as F, PlatformType as M, SubView as N, RecommendationsResponse as O, Title as P, OfferDisclosureDetails as S, RecommendationGroupEntry as T, Advertiser as _, BrandClickInitiatingTarget as a, OfferAsset as b, BrandVisibilityEventType as c, EventPlacementDetails as d, EventTracker as f, WidgetEventType as g, ProductProperties as h, DiscoValidationError as i, Gender as j, RunningExperiment as k, ElementClickInitiatingTarget as l, ProductEventType as m, DiscoError as n, BrandDisplayInitiatingTarget as o, ProductDisplayInitiatingTarget as p, DiscoNetworkError as r, BrandProperties as s, DiscoApiError as t, EventPayload as u, Footer as v, Recommendation as w, OfferCtaDetails as x, Offer as y };
357
+ //# sourceMappingURL=errors-Dns2-5UC.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors-Dns2-5UC.d.ts","names":[],"sources":["../src/api/generated/recommendations/types.gen.ts","../src/external/recommendations.ts","../src/types.ts","../src/errors.ts"],"mappings":";;;;KA8dY,WAAA;;;;KAyKA,MAAA;;;;KAgMA,YAAA;;;;;;KAiTA,OAAA;;;;KAUA,KAAA;;;;;;KAyBA,IAAA;;;;;AApVY;AAiTxB;;KC1lCY,iBAAA;EACV,IAAA,UDylCiB;ECvlCjB,OAAO;AAAA;;ADimCQ;AAyBjB;;KCzmCK,UAAA;EACH,SAAA;EACA,eAAA;EACA,sBAAA;EACA,SAAA;EACA,aAAA;EACA,YAAA,GAAe,YAAY,EA1BA;EA4B3B,QAAA;EACA,UAAA;AAAA;AAAA,KAGG,WAAA;EACH,KAAA,GAAQ,K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, C as OfferCtaDetails, D as RecommendationGroupEntry, E as Recommendation, F as SubView, I as Title, L as View, M as DisplayMode, N as Gender, O as RecommendationGroupProperty, P as PlatformType, S as OfferAsset, T as OfferMetadata, a as EventTracker, b as Footer, i as DiscoValidationError, j as RunningExperiment, k as RecommendationsRequest, n as DiscoError, p as EventPayload, r as DiscoNetworkError, t as DiscoApiError, w as OfferDisclosureDetails, x as Offer, y as Advertiser } from "./errors-C-xomnpl.js";
1
+ import { A as DisplayMode, C as OfferMetadata, D as RecommendationsRequest, E as RecommendationGroupProperty, F as View, M as PlatformType, N as SubView, O as RecommendationsResponse, P as Title, S as OfferDisclosureDetails, T as RecommendationGroupEntry, _ as Advertiser, a as BrandClickInitiatingTarget, b as OfferAsset, d as EventPlacementDetails, f as EventTracker, i as DiscoValidationError, j as Gender, k as RunningExperiment, l as ElementClickInitiatingTarget, n as DiscoError, o as BrandDisplayInitiatingTarget, r as DiscoNetworkError, s as BrandProperties, t as DiscoApiError, u as EventPayload, v as Footer, w as Recommendation, x as OfferCtaDetails, y as Offer } from "./errors-Dns2-5UC.js";
2
2
 
3
3
  //#region src/external/DiscoClient.d.ts
4
4
  /**
@@ -64,10 +64,27 @@ declare class DiscoClient {
64
64
  /**
65
65
  * Create an events tracker bound to a recommendations session (the
66
66
  * `sessionId` from a `getRecommendations` response). Posts to the external
67
- * `/events` endpoint with this client's `x-api-key`.
67
+ * `/events` endpoint with this client's `x-api-key`, via the generated events
68
+ * SDK (`eventsPost`).
69
+ *
70
+ * This is the **raw** tracker — it sends every call, fire-and-forget (never
71
+ * throws; failures are logged). Impression dedup is a render-lifecycle policy
72
+ * applied a layer up (the React layer wraps this with `withImpressionDedupe`),
73
+ * not baked into the core client.
68
74
  */
69
75
  createTrackingManager: (sessionId: string, options?: CreateTrackingManagerOptions) => EventTracker;
70
76
  }
71
77
  //#endregion
72
- export { type Advertiser, DiscoApiError, DiscoClient, type DiscoClientConfig, DiscoError, DiscoNetworkError, DiscoValidationError, type DisplayMode, type EventPayload, type EventTracker, type Footer, type Gender, type Offer, type OfferAsset, type OfferCtaDetails, type OfferDisclosureDetails, type OfferMetadata, type PlatformType, type Recommendation, type RecommendationGroupEntry, type RecommendationGroupProperty, type RecommendationsRequest, type RecommendationsResponse, type RunningExperiment, type SubView, type Title, type View };
78
+ //#region src/events/dedupe.d.ts
79
+ /**
80
+ * Wrap an {@link EventTracker} so repeat impressions are suppressed within the
81
+ * session: a given (event type, insertionId) is forwarded once, then dropped.
82
+ *
83
+ * Dedup is a delivery *policy*, not transport — kept as an explicit, opt-in
84
+ * decorator so suppression is never a surprise. State (the seen-set) lives in
85
+ * the wrapper; create one per session-bound tracker to scope dedup per session.
86
+ */
87
+ declare function withImpressionDedupe(inner: EventTracker): EventTracker;
88
+ //#endregion
89
+ export { type Advertiser, type BrandClickInitiatingTarget, type BrandDisplayInitiatingTarget, type BrandProperties, DiscoApiError, DiscoClient, type DiscoClientConfig, DiscoError, DiscoNetworkError, DiscoValidationError, type DisplayMode, type ElementClickInitiatingTarget, type EventPayload, type EventPlacementDetails, type EventTracker, type Footer, type Gender, type Offer, type OfferAsset, type OfferCtaDetails, type OfferDisclosureDetails, type OfferMetadata, type PlatformType, type Recommendation, type RecommendationGroupEntry, type RecommendationGroupProperty, type RecommendationsRequest, type RecommendationsResponse, type RunningExperiment, type SubView, type Title, type View, withImpressionDedupe };
73
90
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../src/external/DiscoClient.ts"],"mappings":";;;;AA2BA;;;;KAAY,iBAAA;EACV,MAAA;EAMA;;;AAAoB;EADpB,UAAA;EACA,KAAA,UAAe,KAAK;AAAA;AAAA,KAGV,yBAAA;EAEU,uEAApB,MAAA,GAAS,WAAW;AAAA;AAAA,KAGV,4BAAA;EAEV,8EAAA,KAAA,UAAe,KAAK;AAAA;;;;;KAOV,0BAAA;EACV,IAAA,EAAM,uBAAA;EACN,OAAA,EAAS,YAAY;AAAA;A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