@contentful/optimization-api-client 0.1.0-alpha10 → 0.1.0-alpha12
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 +32 -88
- package/dist/index.cjs +24 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +476 -1260
- package/dist/index.d.mts +476 -1260
- package/dist/index.d.ts +476 -1260
- package/dist/index.mjs +9 -186
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<p align="center">
|
|
2
2
|
<a href="https://www.contentful.com/developers/docs/personalization/">
|
|
3
|
-
<img alt="Contentful Logo" title="Contentful" src="
|
|
3
|
+
<img alt="Contentful Logo" title="Contentful" src="https://raw.githubusercontent.com/contentful/optimization/v0.1.0-alpha12/contentful-icon.png" width="150">
|
|
4
4
|
</a>
|
|
5
5
|
</p>
|
|
6
6
|
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
<div align="center">
|
|
12
12
|
|
|
13
|
-
[
|
|
14
|
-
[Contributing](
|
|
13
|
+
[Guides](https://contentful.github.io/optimization/documents/Guides.html) ·
|
|
14
|
+
[Reference](https://contentful.github.io/optimization) · [Contributing](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/CONTRIBUTING.md)
|
|
15
15
|
|
|
16
16
|
</div>
|
|
17
17
|
|
|
@@ -20,11 +20,12 @@
|
|
|
20
20
|
> The Optimization SDK Suite is pre-release (alpha). Breaking changes may be published at any time.
|
|
21
21
|
|
|
22
22
|
The Contentful Optimization API Client Library provides methods for interfacing with Contentful's
|
|
23
|
-
Experience and Insights
|
|
23
|
+
Experience API and Insights API, which serve its Personalization and Analytics products.
|
|
24
24
|
|
|
25
25
|
> [!NOTE]
|
|
26
26
|
>
|
|
27
|
-
>
|
|
27
|
+
> The Experience API and Insights API are separate today, and this client provides a unified SDK
|
|
28
|
+
> surface for both APIs.
|
|
28
29
|
|
|
29
30
|
<details>
|
|
30
31
|
<summary>Table of Contents</summary>
|
|
@@ -34,8 +35,8 @@ Experience and Insights APIs, which serve its Personalization and Analytics prod
|
|
|
34
35
|
- [Configuration](#configuration)
|
|
35
36
|
- [Top-level Configuration Options](#top-level-configuration-options)
|
|
36
37
|
- [Fetch Options](#fetch-options)
|
|
37
|
-
- [
|
|
38
|
-
- [
|
|
38
|
+
- [Insights API Options](#insights-api-options)
|
|
39
|
+
- [Experience API Options](#experience-api-options)
|
|
39
40
|
- [Working With the APIs](#working-with-the-apis)
|
|
40
41
|
- [Experience API](#experience-api)
|
|
41
42
|
- [Get Profile data](#get-profile-data)
|
|
@@ -45,9 +46,7 @@ Experience and Insights APIs, which serve its Personalization and Analytics prod
|
|
|
45
46
|
- [Upsert Many Profiles](#upsert-many-profiles)
|
|
46
47
|
- [Insights API](#insights-api)
|
|
47
48
|
- [Send Batch Events](#send-batch-events)
|
|
48
|
-
- [Event
|
|
49
|
-
- [Event Builder Configuration](#event-builder-configuration)
|
|
50
|
-
- [Event Builder Configured Methods](#event-builder-configured-methods)
|
|
49
|
+
- [Event Construction](#event-construction)
|
|
51
50
|
|
|
52
51
|
<!-- mtoc-end -->
|
|
53
52
|
</details>
|
|
@@ -76,20 +75,20 @@ const client = new ApiClient({ clientId: 'abc123' })
|
|
|
76
75
|
|
|
77
76
|
### Top-level Configuration Options
|
|
78
77
|
|
|
79
|
-
| Option
|
|
80
|
-
|
|
|
81
|
-
| `
|
|
82
|
-
| `clientId`
|
|
83
|
-
| `environment`
|
|
84
|
-
| `fetchOptions`
|
|
85
|
-
| `
|
|
78
|
+
| Option | Required? | Default | Description |
|
|
79
|
+
| -------------- | --------- | ---------------------------- | ----------------------------------------------------------- |
|
|
80
|
+
| `experience` | No | See "Experience API Options" | Configuration specific to the Experience API |
|
|
81
|
+
| `clientId` | Yes | N/A | Shared API key for Experience API and Insights API requests |
|
|
82
|
+
| `environment` | No | `'main'` | The environment identifier |
|
|
83
|
+
| `fetchOptions` | No | See "Fetch Options" | Configuration for Fetch timeout and retry functionality |
|
|
84
|
+
| `insights` | No | See "Insights API Options" | Configuration specific to the Insights API |
|
|
86
85
|
|
|
87
86
|
### Fetch Options
|
|
88
87
|
|
|
89
88
|
Fetch options allow for configuration of both a Fetch API-compatible fetch method and the
|
|
90
|
-
retry/timeout logic integrated into
|
|
91
|
-
|
|
92
|
-
|
|
89
|
+
retry/timeout logic integrated into this API client. Specify the `fetchMethod` when the host
|
|
90
|
+
application environment does not offer a `fetch` method that is compatible with the standard Fetch
|
|
91
|
+
API in its global scope.
|
|
93
92
|
|
|
94
93
|
| Option | Required? | Default | Description |
|
|
95
94
|
| ------------------ | --------- | ----------- | --------------------------------------------------------------------- |
|
|
@@ -108,13 +107,13 @@ Configuration method signatures:
|
|
|
108
107
|
> [!NOTE]
|
|
109
108
|
>
|
|
110
109
|
> Retry behavior is intentionally fixed to HTTP `503` responses (`Service Unavailable`) for the
|
|
111
|
-
> default SDK transport policy. This matches current Experience and Insights API expectations:
|
|
112
|
-
> is treated as the transient availability signal, while other response classes are handled by
|
|
110
|
+
> default SDK transport policy. This matches current Experience API and Insights API expectations:
|
|
111
|
+
> `503` is treated as the transient availability signal, while other response classes are handled by
|
|
113
112
|
> caller logic and are intentionally not retried by default. Treat this as deliberate contract
|
|
114
113
|
> behavior, not a transport gap; broaden retry status handling only with an explicit API contract
|
|
115
114
|
> change.
|
|
116
115
|
|
|
117
|
-
###
|
|
116
|
+
### Insights API Options
|
|
118
117
|
|
|
119
118
|
| Option | Required? | Default | Description |
|
|
120
119
|
| --------------- | --------- | ------------------------------------------ | ------------------------------------------------------------------------ |
|
|
@@ -125,7 +124,7 @@ Configuration method signatures:
|
|
|
125
124
|
|
|
126
125
|
- `beaconHandler`: `(url: string | URL, data: BatchInsightsEventArray) => boolean`
|
|
127
126
|
|
|
128
|
-
###
|
|
127
|
+
### Experience API Options
|
|
129
128
|
|
|
130
129
|
| Option | Required? | Default | Description |
|
|
131
130
|
| ----------------- | --------- | ------------------------------------- | ------------------------------------------------------------------- |
|
|
@@ -144,7 +143,7 @@ Configuration method signatures:
|
|
|
144
143
|
|
|
145
144
|
### Experience API
|
|
146
145
|
|
|
147
|
-
Experience API methods are scoped to the client's `experience` member. All singular
|
|
146
|
+
Experience API methods are scoped to the client's `experience` member. All singular Experience API
|
|
148
147
|
methods return a `Promise` that resolves with the following data:
|
|
149
148
|
|
|
150
149
|
```json
|
|
@@ -152,14 +151,14 @@ methods return a `Promise` that resolves with the following data:
|
|
|
152
151
|
"profile": {
|
|
153
152
|
/* User profile data */
|
|
154
153
|
},
|
|
155
|
-
"
|
|
154
|
+
"selectedOptimizations": [
|
|
156
155
|
{
|
|
157
|
-
/*
|
|
156
|
+
/* Optimization/Experience API configuration for the associated profile */
|
|
158
157
|
}
|
|
159
158
|
],
|
|
160
159
|
"changes": [
|
|
161
160
|
{
|
|
162
|
-
/*
|
|
161
|
+
/* Custom Flag changes associated with the evaluated profile */
|
|
163
162
|
}
|
|
164
163
|
]
|
|
165
164
|
}
|
|
@@ -218,7 +217,7 @@ const profiles = await client.experience.upsertManyProfiles(
|
|
|
218
217
|
events: [
|
|
219
218
|
{
|
|
220
219
|
anonymousId: 'anon-123',
|
|
221
|
-
// valid Experience event payload fields
|
|
220
|
+
// valid Experience API event payload fields
|
|
222
221
|
},
|
|
223
222
|
],
|
|
224
223
|
},
|
|
@@ -251,63 +250,8 @@ await client.insights.sendBatchEvents([
|
|
|
251
250
|
])
|
|
252
251
|
```
|
|
253
252
|
|
|
254
|
-
## Event
|
|
253
|
+
## Event Construction
|
|
255
254
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
### Event Builder Configuration
|
|
260
|
-
|
|
261
|
-
Event Builder configuration options assist in adding contextual data to each event created by a
|
|
262
|
-
builder instance.
|
|
263
|
-
|
|
264
|
-
| Option | Required? | Default | Description |
|
|
265
|
-
| ------------------- | --------- | ------------------------------- | ---------------------------------------------------------------------------------- |
|
|
266
|
-
| `app` | No | `undefined` | The application definition used to attribute events to a specific consumer app |
|
|
267
|
-
| `channel` | Yes | N/A | The channel that identifies where events originate from (e.g. `'web'`, `'mobile'`) |
|
|
268
|
-
| `library` | Yes | N/A | The client library metadata that is attached to all events |
|
|
269
|
-
| `getLocale` | No | `() => 'en-US'` | Function used to resolve the locale for outgoing events |
|
|
270
|
-
| `getPageProperties` | No | `() => DEFAULT_PAGE_PROPERTIES` | Function that returns the current page properties |
|
|
271
|
-
| `getUserAgent` | No | `() => undefined` | Function used to obtain the current user agent string when applicable |
|
|
272
|
-
|
|
273
|
-
The `get*` functions are most useful in stateful environments. Stateless environments should set the
|
|
274
|
-
related data directly via Event Builder method arguments.
|
|
275
|
-
|
|
276
|
-
The `channel` option may contain one of the following values:
|
|
277
|
-
|
|
278
|
-
- `web`
|
|
279
|
-
- `mobile`
|
|
280
|
-
- `server`
|
|
281
|
-
|
|
282
|
-
Configuration method signatures:
|
|
283
|
-
|
|
284
|
-
- `getLocale`: `() => string | undefined`
|
|
285
|
-
- `getPageProperties`:
|
|
286
|
-
|
|
287
|
-
```ts
|
|
288
|
-
() => {
|
|
289
|
-
path: string,
|
|
290
|
-
query: Record<string, string>,
|
|
291
|
-
referrer: string,
|
|
292
|
-
search: string,
|
|
293
|
-
title?: string,
|
|
294
|
-
url: string
|
|
295
|
-
}
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
- `getUserAgent`: `() => string | undefined`
|
|
299
|
-
|
|
300
|
-
#### Event Builder Configured Methods
|
|
301
|
-
|
|
302
|
-
- `buildComponentClick`: Builds a component click event payload for a Contentful entry-based
|
|
303
|
-
component
|
|
304
|
-
- `buildComponentView`: Builds a component view event payload for a Contentful entry-based component
|
|
305
|
-
- `buildFlagView`: Builds a component view payload event for a Custom Flag component
|
|
306
|
-
- `buildIdentify`: Builds an identify event payload to associate a user ID with traits
|
|
307
|
-
- `buildPageView`: Builds a page view event payload
|
|
308
|
-
- `buildScreenView`: Builds a screen view event payload
|
|
309
|
-
- `buildTrack`: Builds a track event payload for arbitrary user actions
|
|
310
|
-
|
|
311
|
-
See the
|
|
312
|
-
[Event Builder documentation](https://contentful.github.io/optimization/classes/_contentful_optimization-api-client.EventBuilder.html)
|
|
313
|
-
for more information regarding arguments and return values.
|
|
255
|
+
Event-construction helpers (`EventBuilder`) are part of
|
|
256
|
+
[`@contentful/optimization-core`](https://github.com/contentful/optimization/blob/v0.1.0-alpha12/packages/universal/core-sdk/README.md) and environment SDKs that build on top of
|
|
257
|
+
it. This package focuses on API transport and request/response validation.
|
package/dist/index.cjs
CHANGED
|
@@ -148,11 +148,14 @@ var __webpack_exports__ = {};
|
|
|
148
148
|
(()=>{
|
|
149
149
|
__webpack_require__.r(__webpack_exports__);
|
|
150
150
|
__webpack_require__.d(__webpack_exports__, {
|
|
151
|
+
createTimeoutFetchMethod: ()=>createTimeoutFetchMethod,
|
|
152
|
+
ExperienceApiClient: ()=>ExperienceApiClient,
|
|
153
|
+
createProtectedFetchMethod: ()=>createProtectedFetchMethod,
|
|
151
154
|
EXPERIENCE_BASE_URL: ()=>EXPERIENCE_BASE_URL,
|
|
152
155
|
ApiClient: ()=>ApiClient,
|
|
153
156
|
INSIGHTS_BASE_URL: ()=>INSIGHTS_BASE_URL,
|
|
154
|
-
|
|
155
|
-
|
|
157
|
+
createRetryFetchMethod: ()=>createRetryFetchMethod,
|
|
158
|
+
InsightsApiClient: ()=>InsightsApiClient
|
|
156
159
|
});
|
|
157
160
|
const optimization_api_schemas_namespaceObject = require("@contentful/optimization-api-schemas");
|
|
158
161
|
var logger = __webpack_require__("./src/logger.ts");
|
|
@@ -319,7 +322,7 @@ var __webpack_exports__ = {};
|
|
|
319
322
|
const { data: { changes, experiences, profile } } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(optimization_api_schemas_namespaceObject.ExperienceResponse, await response.json());
|
|
320
323
|
const data = {
|
|
321
324
|
changes,
|
|
322
|
-
|
|
325
|
+
selectedOptimizations: experiences,
|
|
323
326
|
profile
|
|
324
327
|
};
|
|
325
328
|
ExperienceApiClient_logger.debug(`"${requestName}" request successfully completed`);
|
|
@@ -353,7 +356,7 @@ var __webpack_exports__ = {};
|
|
|
353
356
|
const { data: { changes, experiences, profile } } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(optimization_api_schemas_namespaceObject.ExperienceResponse, await response.json());
|
|
354
357
|
const data = {
|
|
355
358
|
changes,
|
|
356
|
-
|
|
359
|
+
selectedOptimizations: experiences,
|
|
357
360
|
profile
|
|
358
361
|
};
|
|
359
362
|
ExperienceApiClient_logger.debug(`"${requestName}" request successfully completed`);
|
|
@@ -380,7 +383,7 @@ var __webpack_exports__ = {};
|
|
|
380
383
|
const { data: { changes, experiences, profile } } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(optimization_api_schemas_namespaceObject.ExperienceResponse, await response.json());
|
|
381
384
|
const data = {
|
|
382
385
|
changes,
|
|
383
|
-
|
|
386
|
+
selectedOptimizations: experiences,
|
|
384
387
|
profile
|
|
385
388
|
};
|
|
386
389
|
ExperienceApiClient_logger.debug(`"${requestName}" request successfully completed`);
|
|
@@ -459,7 +462,6 @@ var __webpack_exports__ = {};
|
|
|
459
462
|
});
|
|
460
463
|
}
|
|
461
464
|
}
|
|
462
|
-
const experience = ExperienceApiClient;
|
|
463
465
|
const InsightsApiClient_logger = (0, logger.createScopedLogger)('ApiClient:Insights');
|
|
464
466
|
const INSIGHTS_BASE_URL = 'https://ingest.insights.ninetailed.co/';
|
|
465
467
|
class InsightsApiClient extends src_ApiClientBase {
|
|
@@ -503,216 +505,46 @@ var __webpack_exports__ = {};
|
|
|
503
505
|
}
|
|
504
506
|
}
|
|
505
507
|
}
|
|
506
|
-
const insights = InsightsApiClient;
|
|
507
508
|
class ApiClient {
|
|
508
509
|
config;
|
|
509
510
|
experience;
|
|
510
511
|
insights;
|
|
511
512
|
constructor(config){
|
|
512
|
-
const {
|
|
513
|
+
const { experience, insights, clientId, environment, fetchOptions } = config;
|
|
513
514
|
const apiConfig = {
|
|
514
515
|
clientId,
|
|
515
516
|
environment,
|
|
516
517
|
fetchOptions
|
|
517
518
|
};
|
|
518
519
|
this.config = apiConfig;
|
|
519
|
-
this.experience = new
|
|
520
|
+
this.experience = new ExperienceApiClient({
|
|
520
521
|
...apiConfig,
|
|
521
|
-
...
|
|
522
|
+
...experience
|
|
522
523
|
});
|
|
523
|
-
this.insights = new
|
|
524
|
+
this.insights = new InsightsApiClient({
|
|
524
525
|
...apiConfig,
|
|
525
|
-
...
|
|
526
|
+
...insights
|
|
526
527
|
});
|
|
527
528
|
}
|
|
528
529
|
}
|
|
529
|
-
const object_namespaceObject = require("es-toolkit/object");
|
|
530
|
-
const mini_namespaceObject = require("zod/mini");
|
|
531
|
-
const UniversalEventBuilderArgs = mini_namespaceObject.object({
|
|
532
|
-
campaign: mini_namespaceObject.optional(optimization_api_schemas_namespaceObject.Campaign),
|
|
533
|
-
locale: mini_namespaceObject.optional(mini_namespaceObject.string()),
|
|
534
|
-
location: mini_namespaceObject.optional(optimization_api_schemas_namespaceObject.GeoLocation),
|
|
535
|
-
page: mini_namespaceObject.optional(optimization_api_schemas_namespaceObject.Page),
|
|
536
|
-
screen: mini_namespaceObject.optional(optimization_api_schemas_namespaceObject.Screen),
|
|
537
|
-
userAgent: mini_namespaceObject.optional(mini_namespaceObject.string())
|
|
538
|
-
});
|
|
539
|
-
const ComponentInteractionBuilderArgsBase = mini_namespaceObject.extend(UniversalEventBuilderArgs, {
|
|
540
|
-
componentId: mini_namespaceObject.string(),
|
|
541
|
-
experienceId: mini_namespaceObject.optional(mini_namespaceObject.string()),
|
|
542
|
-
variantIndex: mini_namespaceObject.optional(mini_namespaceObject.number())
|
|
543
|
-
});
|
|
544
|
-
const ComponentViewBuilderArgs = mini_namespaceObject.extend(ComponentInteractionBuilderArgsBase, {
|
|
545
|
-
sticky: mini_namespaceObject.optional(mini_namespaceObject.boolean()),
|
|
546
|
-
componentViewId: mini_namespaceObject.string(),
|
|
547
|
-
viewDurationMs: mini_namespaceObject.number()
|
|
548
|
-
});
|
|
549
|
-
const ComponentClickBuilderArgs = ComponentInteractionBuilderArgsBase;
|
|
550
|
-
const ComponentHoverBuilderArgs = mini_namespaceObject.extend(ComponentInteractionBuilderArgsBase, {
|
|
551
|
-
componentHoverId: mini_namespaceObject.string(),
|
|
552
|
-
hoverDurationMs: mini_namespaceObject.number()
|
|
553
|
-
});
|
|
554
|
-
const IdentifyBuilderArgs = mini_namespaceObject.extend(UniversalEventBuilderArgs, {
|
|
555
|
-
traits: mini_namespaceObject.optional(optimization_api_schemas_namespaceObject.Traits),
|
|
556
|
-
userId: mini_namespaceObject.string()
|
|
557
|
-
});
|
|
558
|
-
const PageViewBuilderArgs = mini_namespaceObject.extend(UniversalEventBuilderArgs, {
|
|
559
|
-
properties: mini_namespaceObject.optional(mini_namespaceObject.partial(optimization_api_schemas_namespaceObject.Page))
|
|
560
|
-
});
|
|
561
|
-
const ScreenViewBuilderArgs = mini_namespaceObject.extend(UniversalEventBuilderArgs, {
|
|
562
|
-
name: mini_namespaceObject.string(),
|
|
563
|
-
properties: optimization_api_schemas_namespaceObject.Properties
|
|
564
|
-
});
|
|
565
|
-
const TrackBuilderArgs = mini_namespaceObject.extend(UniversalEventBuilderArgs, {
|
|
566
|
-
event: mini_namespaceObject.string(),
|
|
567
|
-
properties: mini_namespaceObject.optional(mini_namespaceObject.prefault(optimization_api_schemas_namespaceObject.Properties, {}))
|
|
568
|
-
});
|
|
569
|
-
const DEFAULT_PAGE_PROPERTIES = {
|
|
570
|
-
path: '',
|
|
571
|
-
query: {},
|
|
572
|
-
referrer: '',
|
|
573
|
-
search: '',
|
|
574
|
-
title: '',
|
|
575
|
-
url: ''
|
|
576
|
-
};
|
|
577
|
-
class EventBuilder {
|
|
578
|
-
app;
|
|
579
|
-
channel;
|
|
580
|
-
library;
|
|
581
|
-
getLocale;
|
|
582
|
-
getPageProperties;
|
|
583
|
-
getUserAgent;
|
|
584
|
-
constructor(config){
|
|
585
|
-
const { app, channel, library, getLocale, getPageProperties, getUserAgent } = config;
|
|
586
|
-
this.app = app;
|
|
587
|
-
this.channel = channel;
|
|
588
|
-
this.library = library;
|
|
589
|
-
this.getLocale = getLocale ?? (()=>'en-US');
|
|
590
|
-
this.getPageProperties = getPageProperties ?? (()=>DEFAULT_PAGE_PROPERTIES);
|
|
591
|
-
this.getUserAgent = getUserAgent ?? (()=>void 0);
|
|
592
|
-
}
|
|
593
|
-
buildUniversalEventProperties({ campaign = {}, locale, location, page, screen, userAgent }) {
|
|
594
|
-
const timestamp = new Date().toISOString();
|
|
595
|
-
return {
|
|
596
|
-
channel: this.channel,
|
|
597
|
-
context: {
|
|
598
|
-
app: this.app,
|
|
599
|
-
campaign,
|
|
600
|
-
gdpr: {
|
|
601
|
-
isConsentGiven: true
|
|
602
|
-
},
|
|
603
|
-
library: this.library,
|
|
604
|
-
locale: locale ?? this.getLocale() ?? 'en-US',
|
|
605
|
-
location,
|
|
606
|
-
page: page ?? this.getPageProperties(),
|
|
607
|
-
screen,
|
|
608
|
-
userAgent: userAgent ?? this.getUserAgent()
|
|
609
|
-
},
|
|
610
|
-
messageId: crypto.randomUUID(),
|
|
611
|
-
originalTimestamp: timestamp,
|
|
612
|
-
sentAt: timestamp,
|
|
613
|
-
timestamp
|
|
614
|
-
};
|
|
615
|
-
}
|
|
616
|
-
buildEntryComponentBase(universal, componentId, experienceId, variantIndex) {
|
|
617
|
-
return {
|
|
618
|
-
...this.buildUniversalEventProperties(universal),
|
|
619
|
-
componentType: 'Entry',
|
|
620
|
-
componentId,
|
|
621
|
-
experienceId,
|
|
622
|
-
variantIndex: variantIndex ?? 0
|
|
623
|
-
};
|
|
624
|
-
}
|
|
625
|
-
buildComponentView(args) {
|
|
626
|
-
const { componentId, componentViewId, experienceId, variantIndex, viewDurationMs, ...universal } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(ComponentViewBuilderArgs, args);
|
|
627
|
-
return {
|
|
628
|
-
...this.buildEntryComponentBase(universal, componentId, experienceId, variantIndex),
|
|
629
|
-
type: 'component',
|
|
630
|
-
componentViewId,
|
|
631
|
-
viewDurationMs
|
|
632
|
-
};
|
|
633
|
-
}
|
|
634
|
-
buildComponentClick(args) {
|
|
635
|
-
const { componentId, experienceId, variantIndex, ...universal } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(ComponentClickBuilderArgs, args);
|
|
636
|
-
return {
|
|
637
|
-
...this.buildEntryComponentBase(universal, componentId, experienceId, variantIndex),
|
|
638
|
-
type: 'component_click'
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
buildComponentHover(args) {
|
|
642
|
-
const { componentHoverId, componentId, experienceId, hoverDurationMs, variantIndex, ...universal } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(ComponentHoverBuilderArgs, args);
|
|
643
|
-
return {
|
|
644
|
-
...this.buildEntryComponentBase(universal, componentId, experienceId, variantIndex),
|
|
645
|
-
type: 'component_hover',
|
|
646
|
-
componentHoverId,
|
|
647
|
-
hoverDurationMs
|
|
648
|
-
};
|
|
649
|
-
}
|
|
650
|
-
buildFlagView(args) {
|
|
651
|
-
return {
|
|
652
|
-
...this.buildComponentView(args),
|
|
653
|
-
componentType: 'Variable'
|
|
654
|
-
};
|
|
655
|
-
}
|
|
656
|
-
buildIdentify(args) {
|
|
657
|
-
const { traits = {}, userId, ...universal } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(IdentifyBuilderArgs, args);
|
|
658
|
-
return {
|
|
659
|
-
...this.buildUniversalEventProperties(universal),
|
|
660
|
-
type: 'identify',
|
|
661
|
-
traits,
|
|
662
|
-
userId
|
|
663
|
-
};
|
|
664
|
-
}
|
|
665
|
-
buildPageView(args = {}) {
|
|
666
|
-
const { properties = {}, ...universal } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(PageViewBuilderArgs, args);
|
|
667
|
-
const pageProperties = this.getPageProperties();
|
|
668
|
-
const merged = (0, object_namespaceObject.merge)({
|
|
669
|
-
...pageProperties,
|
|
670
|
-
title: pageProperties.title ?? DEFAULT_PAGE_PROPERTIES.title
|
|
671
|
-
}, properties);
|
|
672
|
-
const { context: { screen: _, ...universalContext }, ...universalProperties } = this.buildUniversalEventProperties(universal);
|
|
673
|
-
const context = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(optimization_api_schemas_namespaceObject.PageEventContext, universalContext);
|
|
674
|
-
return {
|
|
675
|
-
...universalProperties,
|
|
676
|
-
context,
|
|
677
|
-
type: 'page',
|
|
678
|
-
properties: merged
|
|
679
|
-
};
|
|
680
|
-
}
|
|
681
|
-
buildScreenView(args) {
|
|
682
|
-
const { name, properties, ...universal } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(ScreenViewBuilderArgs, args);
|
|
683
|
-
const { context: { page: _, ...universalContext }, ...universalProperties } = this.buildUniversalEventProperties(universal);
|
|
684
|
-
const context = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(optimization_api_schemas_namespaceObject.ScreenEventContext, universalContext);
|
|
685
|
-
return {
|
|
686
|
-
...universalProperties,
|
|
687
|
-
context,
|
|
688
|
-
type: 'screen',
|
|
689
|
-
name,
|
|
690
|
-
properties
|
|
691
|
-
};
|
|
692
|
-
}
|
|
693
|
-
buildTrack(args) {
|
|
694
|
-
const { event, properties = {}, ...universal } = (0, optimization_api_schemas_namespaceObject.parseWithFriendlyError)(TrackBuilderArgs, args);
|
|
695
|
-
return {
|
|
696
|
-
...this.buildUniversalEventProperties(universal),
|
|
697
|
-
type: 'track',
|
|
698
|
-
event,
|
|
699
|
-
properties
|
|
700
|
-
};
|
|
701
|
-
}
|
|
702
|
-
}
|
|
703
|
-
const builders_EventBuilder = EventBuilder;
|
|
704
530
|
})();
|
|
705
531
|
exports.ApiClient = __webpack_exports__.ApiClient;
|
|
706
|
-
exports.DEFAULT_PAGE_PROPERTIES = __webpack_exports__.DEFAULT_PAGE_PROPERTIES;
|
|
707
532
|
exports.EXPERIENCE_BASE_URL = __webpack_exports__.EXPERIENCE_BASE_URL;
|
|
708
|
-
exports.
|
|
533
|
+
exports.ExperienceApiClient = __webpack_exports__.ExperienceApiClient;
|
|
709
534
|
exports.INSIGHTS_BASE_URL = __webpack_exports__.INSIGHTS_BASE_URL;
|
|
535
|
+
exports.InsightsApiClient = __webpack_exports__.InsightsApiClient;
|
|
536
|
+
exports.createProtectedFetchMethod = __webpack_exports__.createProtectedFetchMethod;
|
|
537
|
+
exports.createRetryFetchMethod = __webpack_exports__.createRetryFetchMethod;
|
|
538
|
+
exports.createTimeoutFetchMethod = __webpack_exports__.createTimeoutFetchMethod;
|
|
710
539
|
for(var __rspack_i in __webpack_exports__)if (-1 === [
|
|
711
540
|
"ApiClient",
|
|
712
|
-
"DEFAULT_PAGE_PROPERTIES",
|
|
713
541
|
"EXPERIENCE_BASE_URL",
|
|
714
|
-
"
|
|
715
|
-
"INSIGHTS_BASE_URL"
|
|
542
|
+
"ExperienceApiClient",
|
|
543
|
+
"INSIGHTS_BASE_URL",
|
|
544
|
+
"InsightsApiClient",
|
|
545
|
+
"createProtectedFetchMethod",
|
|
546
|
+
"createRetryFetchMethod",
|
|
547
|
+
"createTimeoutFetchMethod"
|
|
716
548
|
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
|
|
717
549
|
Object.defineProperty(exports, '__esModule', {
|
|
718
550
|
value: true
|