@disconetwork/core 0.0.4 → 0.0.5
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/dist/TrackingManager-LjaX_R2V.js +851 -0
- package/dist/TrackingManager-LjaX_R2V.js.map +1 -0
- package/dist/errors-C-xomnpl.d.ts +408 -0
- package/dist/errors-C-xomnpl.d.ts.map +1 -0
- package/dist/index.d.ts +40 -376
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +728 -319
- package/dist/index.js.map +1 -1
- package/dist/internal.d.ts +208 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +369 -0
- package/dist/internal.js.map +1 -0
- package/package.json +11 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,409 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
import { A as RecommendationsResponse, 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";
|
|
2
|
+
|
|
3
|
+
//#region src/external/DiscoClient.d.ts
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* tracker at unintended hosts while still supporting staging.
|
|
5
|
+
* Authenticate with a scoped public API key (`disco_pk_live_…` /
|
|
6
|
+
* `disco_pk_sandbox_…`). The prefix selects the environment, so there is no
|
|
7
|
+
* separate `env` to set.
|
|
7
8
|
*/
|
|
8
|
-
type
|
|
9
|
-
|
|
10
|
-
* Derive the environment from a Disco public API key.
|
|
11
|
-
*
|
|
12
|
-
* Public keys are prefixed `disco_pk_<env>_…`, where `<env>` is `live`
|
|
13
|
-
* (→ production) or `sandbox` (→ staging). The key is the single source
|
|
14
|
-
* of truth for which backend the SDK talks to — there is no separate
|
|
15
|
-
* `env` to pass or keep in sync, and a `live` key can't be pointed at
|
|
16
|
-
* staging (or vice versa).
|
|
17
|
-
*
|
|
18
|
-
* Throws on anything that isn't a recognized public key — including a
|
|
19
|
-
* secret (`disco_sk_…`) key, which must never be used in browser code.
|
|
20
|
-
*/
|
|
21
|
-
declare function envFromApiKey(apiKey: string): DiscoEnv;
|
|
22
|
-
//#endregion
|
|
23
|
-
//#region src/types.d.ts
|
|
24
|
-
/**
|
|
25
|
-
* Targets for `BRAND_CLICK` events — where in the widget the click originated.
|
|
26
|
-
*/
|
|
27
|
-
type BrandClickInitiatingTarget = "INLINE_ACTION_BUTTON" | "INLINE_ASSET_TILE" | "SCROLLABLE_SLOT_TILE";
|
|
28
|
-
/**
|
|
29
|
-
* Targets for `ELEMENT_CLICK` events — non-brand UI interactions.
|
|
30
|
-
*/
|
|
31
|
-
type ElementClickInitiatingTarget = "INLINE_NAV_FORWARD" | "INLINE_NAV_BACKWARD" | "INLINE_FOOTER_DISCO" | "INLINE_FOOTER_PRIVACY" | "CLOSE_BUTTON" | "CLOSE_BACKDROP" | "OPEN_OVERLAY";
|
|
32
|
-
/**
|
|
33
|
-
* Targets for `BRAND_DISPLAY` / `BRAND_VIEW` events.
|
|
34
|
-
*/
|
|
35
|
-
type BrandDisplayInitiatingTarget = "INLINE_SLOT" | "SCROLLABLE_SLOT";
|
|
36
|
-
/**
|
|
37
|
-
* Targets for `PRODUCT_DISPLAY` / `PRODUCT_VIEW` / `PRODUCT_CLICK` events.
|
|
38
|
-
*/
|
|
39
|
-
type ProductDisplayInitiatingTarget = "INLINE_TILE";
|
|
40
|
-
/**
|
|
41
|
-
* Identifies a brand instance in the recommendations response.
|
|
42
|
-
*
|
|
43
|
-
* `insertionId` is the unique-per-render identifier and is what dedup keys
|
|
44
|
-
* are built from.
|
|
45
|
-
*/
|
|
46
|
-
type BrandProperties = {
|
|
47
|
-
offerId: string;
|
|
48
|
-
advertiserId: string;
|
|
49
|
-
insertionId: string;
|
|
50
|
-
};
|
|
51
|
-
type ProductProperties = {
|
|
52
|
-
productId: string;
|
|
53
|
-
};
|
|
54
|
-
type WidgetEventType = "WIDGET_LOAD" | "WIDGET_DISPLAY" | "WIDGET_VIEW";
|
|
55
|
-
type BrandVisibilityEventType = "BRAND_DISPLAY" | "BRAND_VIEW";
|
|
56
|
-
type ProductEventType = "PRODUCT_DISPLAY" | "PRODUCT_VIEW" | "PRODUCT_CLICK";
|
|
57
|
-
/**
|
|
58
|
-
* Discriminated union of every event the SDK can emit.
|
|
59
|
-
*
|
|
60
|
-
* The shape of each variant matches what the partner-events backend
|
|
61
|
-
* expects after the `toBody` transformation applied inside the event tracker.
|
|
62
|
-
*/
|
|
63
|
-
type EventPayload = {
|
|
64
|
-
type: WidgetEventType;
|
|
65
|
-
} | {
|
|
66
|
-
type: BrandVisibilityEventType;
|
|
67
|
-
brand: BrandProperties;
|
|
68
|
-
target: BrandDisplayInitiatingTarget;
|
|
69
|
-
} | {
|
|
70
|
-
type: "BRAND_CLICK";
|
|
71
|
-
brand: BrandProperties;
|
|
72
|
-
target: BrandClickInitiatingTarget;
|
|
73
|
-
assetId?: string;
|
|
74
|
-
} | {
|
|
75
|
-
type: "ELEMENT_CLICK";
|
|
76
|
-
target: ElementClickInitiatingTarget;
|
|
77
|
-
brand?: BrandProperties;
|
|
78
|
-
} | {
|
|
79
|
-
type: ProductEventType;
|
|
80
|
-
product: ProductProperties;
|
|
81
|
-
brand: BrandProperties;
|
|
82
|
-
target: ProductDisplayInitiatingTarget;
|
|
83
|
-
};
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/TrackingManager.d.ts
|
|
86
|
-
type EventTracker = {
|
|
87
|
-
track: (event: EventPayload) => void;
|
|
88
|
-
};
|
|
89
|
-
//#endregion
|
|
90
|
-
//#region src/recommendations.d.ts
|
|
91
|
-
/**
|
|
92
|
-
* Public, camelCase types for the recommendations API request and response.
|
|
93
|
-
*
|
|
94
|
-
* The wire format uses snake_case; `DiscoClient` handles the translation
|
|
95
|
-
* in both directions so consumers never see snake_case keys — with one
|
|
96
|
-
* deliberate exception: keys inside `PublisherCustomization` are opaque
|
|
97
|
-
* server-defined identifiers (`widget_heading`, `widget_subheading`, …)
|
|
98
|
-
* and are passed through as-is.
|
|
99
|
-
*/
|
|
100
|
-
type RecommendationsRequest = {
|
|
101
|
-
user?: UserDetails;
|
|
102
|
-
placement?: PlacementDetails;
|
|
103
|
-
order?: OrderDetails;
|
|
104
|
-
purchases?: Purchase[];
|
|
105
|
-
experiments?: RunningExperiment[];
|
|
106
|
-
attributes?: Record<string, unknown>;
|
|
9
|
+
type DiscoClientConfig = {
|
|
10
|
+
apiKey: string;
|
|
107
11
|
/**
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* Keys here are not transformed — provide them in whatever case the
|
|
111
|
-
* backend expects.
|
|
12
|
+
* Value for the required `X-API-Version` header. Defaults to
|
|
13
|
+
* `DEFAULT_API_VERSION` (see `config.ts`).
|
|
112
14
|
*/
|
|
113
|
-
|
|
114
|
-
};
|
|
115
|
-
type UserDetails = {
|
|
116
|
-
email?: string;
|
|
117
|
-
firstName?: string;
|
|
118
|
-
lastName?: string;
|
|
119
|
-
phone?: string;
|
|
120
|
-
};
|
|
121
|
-
type PlacementDetails = {
|
|
122
|
-
/** e.g. `"INLINE"`. Open-ended — see backend for supported values. */displayMode?: string; /** e.g. `"THANK_YOU"`, `"ORDER_STATUS"`. Open-ended. */
|
|
123
|
-
view?: string;
|
|
124
|
-
};
|
|
125
|
-
type OrderDetails = {
|
|
126
|
-
id?: string;
|
|
127
|
-
amount?: number | string;
|
|
128
|
-
currencyCode?: string;
|
|
129
|
-
};
|
|
130
|
-
type Purchase = {
|
|
131
|
-
name?: string;
|
|
132
|
-
type?: string;
|
|
133
|
-
variant?: string;
|
|
134
|
-
quantity?: number;
|
|
135
|
-
productId?: string;
|
|
136
|
-
amount?: number;
|
|
137
|
-
currencyCode?: string;
|
|
138
|
-
};
|
|
139
|
-
type RunningExperiment = {
|
|
140
|
-
id: string;
|
|
141
|
-
variant: string;
|
|
142
|
-
};
|
|
143
|
-
type LayoutId = "SHOPIFY_NATIVE_LEAD_GEN" | "SHOPIFY_NATIVE_ESSENTIAL" | "SHOPIFY_NATIVE_COVER" | (string & {});
|
|
144
|
-
type RecommendationsResponse = {
|
|
145
|
-
sessionId: string;
|
|
146
|
-
layoutId: LayoutId;
|
|
147
|
-
recommendationGroups: RecommendationGroup[];
|
|
148
|
-
footer: Footer;
|
|
149
|
-
publisherCustomization: PublisherCustomization | null;
|
|
150
|
-
};
|
|
151
|
-
type RecommendationGroup = {
|
|
152
|
-
heading: string | null;
|
|
153
|
-
slotContext: "HERO" | "SCROLLABLE" | (string & {});
|
|
154
|
-
recommendations: Recommendation[];
|
|
155
|
-
};
|
|
156
|
-
type Recommendation = {
|
|
157
|
-
id: string;
|
|
158
|
-
insertionId: string;
|
|
159
|
-
advertiser: Advertiser;
|
|
160
|
-
offer: Offer;
|
|
161
|
-
};
|
|
162
|
-
type Advertiser = {
|
|
163
|
-
id: string;
|
|
164
|
-
name: string;
|
|
165
|
-
logoUrl: string;
|
|
166
|
-
description: string | null;
|
|
167
|
-
};
|
|
168
|
-
type Offer = {
|
|
169
|
-
id: string;
|
|
170
|
-
heading: string | null;
|
|
171
|
-
subheading: string | null;
|
|
172
|
-
jsonContent: Record<string, unknown> | null;
|
|
173
|
-
targetUrl: string;
|
|
174
|
-
ctaDetails: OfferCtaDetails;
|
|
175
|
-
assets: OfferAsset[];
|
|
176
|
-
metadata: Record<string, unknown> | null;
|
|
177
|
-
disclosureDetails: OfferDisclosureDetails | null;
|
|
178
|
-
};
|
|
179
|
-
type OfferCtaDetails = {
|
|
180
|
-
acceptCopy: string;
|
|
181
|
-
declineCopy: string;
|
|
182
|
-
transitionCopy: string | null;
|
|
183
|
-
};
|
|
184
|
-
type OfferAsset = {
|
|
185
|
-
id: string;
|
|
186
|
-
imageUrl: string;
|
|
187
|
-
targetUrl: string | null;
|
|
188
|
-
};
|
|
189
|
-
/**
|
|
190
|
-
* Server-defined disclosure copy / links for an offer. Shape is open;
|
|
191
|
-
* the SDK passes it through without inspection.
|
|
192
|
-
*/
|
|
193
|
-
type OfferDisclosureDetails = Record<string, unknown>;
|
|
194
|
-
type Footer = {
|
|
195
|
-
attributionDetails: {
|
|
196
|
-
copy: string;
|
|
197
|
-
discoLogoUrl: string;
|
|
198
|
-
targetUrl: string;
|
|
199
|
-
};
|
|
200
|
-
privacyPolicy: {
|
|
201
|
-
copy: string;
|
|
202
|
-
targetUrl: string;
|
|
203
|
-
};
|
|
204
|
-
};
|
|
205
|
-
/**
|
|
206
|
-
* Publisher-configured copy / overrides. Keyed first by surface type
|
|
207
|
-
* (`checkout`, `upfront`, …) and then by opaque server-defined keys —
|
|
208
|
-
* see `applyCustomizationOrFallback` consumer-side helpers.
|
|
209
|
-
*
|
|
210
|
-
* Inner keys remain snake_case because they're identifiers, not
|
|
211
|
-
* JavaScript field names.
|
|
212
|
-
*/
|
|
213
|
-
type PublisherCustomization = {
|
|
214
|
-
checkout?: Record<string, string>;
|
|
215
|
-
upfront?: Record<string, string>;
|
|
216
|
-
} & Record<string, Record<string, string> | undefined>;
|
|
217
|
-
//#endregion
|
|
218
|
-
//#region src/recommendationsMapper.d.ts
|
|
219
|
-
type RawRecommendationsResponse = {
|
|
220
|
-
session_id: string;
|
|
221
|
-
layout_id: string; /** Map of offer id → recommendation. */
|
|
222
|
-
recommendations?: Record<string, RawRecommendation> | null; /** Map of group key → ordered entry list referencing offer ids. */
|
|
223
|
-
recommendation_groups?: Record<string, RawGroupEntry[]> | null; /** Map of group key → group display properties. */
|
|
224
|
-
recommendation_group_properties?: Record<string, RawGroupProperties> | null;
|
|
225
|
-
footer: RawFooter;
|
|
226
|
-
publisher_customization?: RawPublisherCustomization | null;
|
|
227
|
-
is_using_cmos_recommendations?: boolean;
|
|
228
|
-
widget_type?: string;
|
|
229
|
-
widget_mode?: string;
|
|
230
|
-
widget_version?: string;
|
|
231
|
-
running_experiments?: unknown[];
|
|
232
|
-
};
|
|
233
|
-
type RawRecommendation = {
|
|
234
|
-
advertiser: RawAdvertiser;
|
|
235
|
-
offer: RawOffer;
|
|
236
|
-
};
|
|
237
|
-
type RawGroupEntry = {
|
|
238
|
-
insertion_order: number;
|
|
239
|
-
insertion_id: string;
|
|
240
|
-
offer_id: string;
|
|
241
|
-
advertiser_id: string;
|
|
242
|
-
};
|
|
243
|
-
type RawGroupProperties = {
|
|
244
|
-
heading?: string | null;
|
|
245
|
-
slot_context: string;
|
|
246
|
-
};
|
|
247
|
-
type RawAdvertiser = {
|
|
248
|
-
id: string;
|
|
249
|
-
name: string;
|
|
250
|
-
logo_url: string;
|
|
251
|
-
description?: string | null;
|
|
252
|
-
};
|
|
253
|
-
type RawOffer = {
|
|
254
|
-
id: string;
|
|
255
|
-
heading?: string | null;
|
|
256
|
-
subheading?: string | null;
|
|
257
|
-
json_content?: Record<string, unknown> | null;
|
|
258
|
-
target_url: string;
|
|
259
|
-
cta_details: RawOfferCtaDetails;
|
|
260
|
-
assets?: RawOfferAsset[] | null;
|
|
261
|
-
metadata?: Record<string, unknown> | null;
|
|
262
|
-
disclosure_details?: Record<string, unknown> | null;
|
|
263
|
-
};
|
|
264
|
-
type RawOfferCtaDetails = {
|
|
265
|
-
accept_copy: string;
|
|
266
|
-
decline_copy: string;
|
|
267
|
-
transition_copy?: string | null;
|
|
268
|
-
};
|
|
269
|
-
type RawOfferAsset = {
|
|
270
|
-
id: string;
|
|
271
|
-
image_url: string;
|
|
272
|
-
target_url?: string | null;
|
|
273
|
-
};
|
|
274
|
-
type RawFooter = {
|
|
275
|
-
attribution_details: {
|
|
276
|
-
copy: string;
|
|
277
|
-
disco_logo_url: string;
|
|
278
|
-
target_url: string;
|
|
279
|
-
};
|
|
280
|
-
privacy_policy: {
|
|
281
|
-
copy: string;
|
|
282
|
-
target_url: string;
|
|
283
|
-
};
|
|
284
|
-
};
|
|
285
|
-
type RawPublisherCustomization = Record<string, Record<string, string>>;
|
|
286
|
-
/**
|
|
287
|
-
* Denormalize a raw recommendations response into the public
|
|
288
|
-
* `RecommendationsResponse`: join group entries → recommendations by offer id,
|
|
289
|
-
* order groups by the numeric suffix of their key (group_0, group_1, …), and
|
|
290
|
-
* convert snake_case to camelCase.
|
|
291
|
-
*
|
|
292
|
-
* Pure and side-effect-free — call it on the result of
|
|
293
|
-
* `DiscoClient.getRecommendations` when you want the friendly shape.
|
|
294
|
-
*/
|
|
295
|
-
declare function mapRecommendationsResponse(raw: RawRecommendationsResponse): RecommendationsResponse;
|
|
296
|
-
//#endregion
|
|
297
|
-
//#region src/DiscoClient.d.ts
|
|
298
|
-
/**
|
|
299
|
-
* Authenticate with a scoped public API key. Sent as the `x-api-key`
|
|
300
|
-
* header against the unified `/core/recommendations/` endpoint. The key
|
|
301
|
-
* prefix (`disco_pk_live_` / `disco_pk_sandbox_`) determines the
|
|
302
|
-
* environment, so there is no separate `env` to set.
|
|
303
|
-
*
|
|
304
|
-
* Use this from partner apps and server-side code that hold a key.
|
|
305
|
-
*/
|
|
306
|
-
type ApiKeyConfig = {
|
|
307
|
-
apiKey: string;
|
|
308
|
-
fetch?: typeof fetch;
|
|
309
|
-
};
|
|
310
|
-
/**
|
|
311
|
-
* Authenticate by Shopify shop — for surfaces that must not embed a key,
|
|
312
|
-
* notably the App-Store-deployed checkout extension. The request hits the
|
|
313
|
-
* `/core/recommendations/shop_gid/<id>/` proxy with **no** API key; the
|
|
314
|
-
* backend resolves the publisher from the shop and injects the key
|
|
315
|
-
* server-side.
|
|
316
|
-
*
|
|
317
|
-
* `env` is required here because, unlike `ApiKeyConfig`, there is no key
|
|
318
|
-
* to derive it from. `shopGid` may be a full `gid://shopify/Shop/<id>` or
|
|
319
|
-
* the bare id.
|
|
320
|
-
*/
|
|
321
|
-
type ShopGidConfig = {
|
|
322
|
-
shopGid: string;
|
|
323
|
-
env: DiscoEnv;
|
|
15
|
+
apiVersion?: string;
|
|
324
16
|
fetch?: typeof fetch;
|
|
325
17
|
};
|
|
326
|
-
type DiscoClientConfig = ApiKeyConfig | ShopGidConfig;
|
|
327
18
|
type GetRecommendationsOptions = {
|
|
328
19
|
/** Forwarded to `fetch` so consumers can cancel in-flight requests. */signal?: AbortSignal;
|
|
329
20
|
};
|
|
330
21
|
type CreateTrackingManagerOptions = {
|
|
331
|
-
/**
|
|
332
|
-
* Override the fetch implementation used by the tracker. Defaults to the
|
|
333
|
-
* same fetch implementation configured on the client.
|
|
334
|
-
*/
|
|
335
|
-
fetch?: typeof fetch;
|
|
22
|
+
/** Override the fetch used by the tracker. Defaults to the client's fetch. */fetch?: typeof fetch;
|
|
336
23
|
};
|
|
337
24
|
/**
|
|
338
|
-
* Result of `getRecommendationsWithTracker`: the
|
|
339
|
-
*
|
|
25
|
+
* Result of `getRecommendationsWithTracker`: the mapped response plus a tracker
|
|
26
|
+
* already bound to its session.
|
|
340
27
|
*/
|
|
341
28
|
type RecommendationsWithTracker = {
|
|
342
|
-
|
|
343
|
-
* The verbatim API response (snake_case), exactly as `getRecommendations`
|
|
344
|
-
* returns it. Pass it through `mapRecommendationsResponse` for the friendly
|
|
345
|
-
* denormalized shape.
|
|
346
|
-
*/
|
|
347
|
-
data: RawRecommendationsResponse; /** Event tracker bound to this response's session. */
|
|
29
|
+
data: RecommendationsResponse;
|
|
348
30
|
tracker: EventTracker;
|
|
349
31
|
};
|
|
350
32
|
/**
|
|
351
|
-
*
|
|
352
|
-
*
|
|
353
|
-
*
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
status: number;
|
|
361
|
-
statusText: string;
|
|
362
|
-
body?: unknown;
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
/**
|
|
366
|
-
* Typed client for the Disco recommendations API.
|
|
33
|
+
* Typed client for the Disco recommendations API — calls
|
|
34
|
+
* `disco-recommendations-api` **directly** (no proxy) at
|
|
35
|
+
* `partners.disconetwork(-staging).com/recommendations`.
|
|
36
|
+
*
|
|
37
|
+
* This is the recommended, partner-facing client. It maps the friendly
|
|
38
|
+
* camelCase request into the rec-api wire body (sending `x-api-key` +
|
|
39
|
+
* `X-API-Version`) and recases the response into camelCase.
|
|
40
|
+
* Validation is performed by the generated SDK. The wire
|
|
41
|
+
* format is fully encapsulated.
|
|
367
42
|
*
|
|
368
|
-
* Renderer-agnostic:
|
|
369
|
-
* React dependency. Wrap it in a Provider (`@disconetwork/react`'s
|
|
370
|
-
* `DiscoProvider`) for use from a React tree, or instantiate it
|
|
371
|
-
* directly from server code, scripts, or tests.
|
|
43
|
+
* Renderer-agnostic: plain HTTP, no React dependency.
|
|
372
44
|
*/
|
|
373
45
|
declare class DiscoClient {
|
|
374
46
|
#private;
|
|
375
47
|
constructor(config: DiscoClientConfig);
|
|
376
48
|
/**
|
|
377
|
-
*
|
|
378
|
-
* **verbatim** — this reflects `ExternalAPIRecommendationView` with no
|
|
379
|
-
* transformation. Pass the result through `mapRecommendationsResponse`
|
|
380
|
-
* if you want the friendly denormalized `RecommendationsResponse`.
|
|
49
|
+
* Fetch recommendations for the given request.
|
|
381
50
|
*
|
|
382
|
-
*
|
|
383
|
-
* (
|
|
51
|
+
* Maps the request to the wire body, POSTs it, then recases the response to
|
|
52
|
+
* camelCase (keeping the API's normalized shape). The generated SDK validates
|
|
53
|
+
* both sides. Throws `DiscoValidationError` on a request/response schema
|
|
54
|
+
* failure, `DiscoApiError` on a non-2xx response, and `DiscoNetworkError` if
|
|
55
|
+
* the request can't reach the server. An aborted request rejects with the
|
|
56
|
+
* native `AbortError`.
|
|
384
57
|
*/
|
|
385
|
-
getRecommendations: (request: RecommendationsRequest, options?: GetRecommendationsOptions) => Promise<
|
|
58
|
+
getRecommendations: (request: RecommendationsRequest, options?: GetRecommendationsOptions) => Promise<RecommendationsResponse>;
|
|
386
59
|
/**
|
|
387
|
-
* Fetch recommendations and create a session-bound tracker in one
|
|
388
|
-
*
|
|
389
|
-
* Composition convenience over `getRecommendations` + `createTrackingManager`:
|
|
390
|
-
* it derives the tracker's session from the response so callers don't have to
|
|
391
|
-
* thread `session_id` through themselves (and can't bind a tracker to the
|
|
392
|
-
* wrong session). The returned `data` is the **raw** response — call
|
|
393
|
-
* `mapRecommendationsResponse` on it if you want the friendly shape.
|
|
394
|
-
*
|
|
395
|
-
* Throws `DiscoApiError` on non-2xx responses, same as `getRecommendations`.
|
|
60
|
+
* Fetch recommendations and create a session-bound events tracker in one
|
|
61
|
+
* call. The tracker inherits this client's API key and environment.
|
|
396
62
|
*/
|
|
397
63
|
getRecommendationsWithTracker: (request: RecommendationsRequest, options?: GetRecommendationsOptions & CreateTrackingManagerOptions) => Promise<RecommendationsWithTracker>;
|
|
398
64
|
/**
|
|
399
|
-
* Create an
|
|
400
|
-
*
|
|
401
|
-
*
|
|
402
|
-
* recommendations call, so sandbox recommendations cannot accidentally emit
|
|
403
|
-
* production tracking events.
|
|
65
|
+
* Create an events tracker bound to a recommendations session (the
|
|
66
|
+
* `sessionId` from a `getRecommendations` response). Posts to the external
|
|
67
|
+
* `/events` endpoint with this client's `x-api-key`.
|
|
404
68
|
*/
|
|
405
|
-
createTrackingManager: (
|
|
69
|
+
createTrackingManager: (sessionId: string, options?: CreateTrackingManagerOptions) => EventTracker;
|
|
406
70
|
}
|
|
407
71
|
//#endregion
|
|
408
|
-
export { type Advertiser,
|
|
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 };
|
|
409
73
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../src/
|
|
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;AAAA;AAgBvB;;;;;;;;;;;;AAhBuB,cAgBV,WAAA;EAAA;cAMC,MAAA,EAAQ,iBAAA;EA+FL;;;;;;;;;;EAzEf,kBAAA,GACE,OAAA,EAAS,sBAAA,EACT,OAAA,GAAU,yBAAA,KACT,OAAA,CAAQ,uBAAA;EAAR;;;;EAiDH,6BAAA,GACE,OAAA,EAAS,sBAAA,EACT,OAAA,GAAU,yBAAA,GAA4B,4BAAA,KACrC,OAAA,CAAQ,0BAAA;EADC;;;;;EAgBZ,qBAAA,GACE,SAAA,UACA,OAAA,GAAU,4BAAA,KACT,YAAA;AAAA"}
|