@contentful/optimization-core 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 +234 -169
- package/dist/160.mjs +3 -0
- package/dist/260.mjs +3 -3
- package/dist/260.mjs.map +1 -1
- package/dist/api-schemas.cjs +4 -1
- package/dist/api-schemas.mjs +1 -1
- package/dist/constants.cjs +7 -7
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +5 -5
- package/dist/constants.d.mts +5 -5
- package/dist/constants.d.ts +5 -5
- package/dist/constants.mjs +1 -1
- package/dist/index.cjs +1087 -1497
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1657 -1594
- package/dist/index.d.mts +1657 -1594
- package/dist/index.d.ts +1657 -1594
- package/dist/index.mjs +1052 -1510
- package/dist/index.mjs.map +1 -1
- package/package.json +15 -2
- package/dist/808.mjs +0 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,378 +1,62 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Optimization Core SDK — platform-agnostic
|
|
2
|
+
* Optimization Core SDK — platform-agnostic optimization and analytics.
|
|
3
3
|
*
|
|
4
4
|
* @packageDocumentation
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import { ApiClient } from '@contentful/optimization-api-client';
|
|
8
8
|
import { ApiClientConfig } from '@contentful/optimization-api-client';
|
|
9
|
+
import { App } from '@contentful/optimization-api-client/api-schemas';
|
|
9
10
|
import { batch } from '@preact/signals-core';
|
|
11
|
+
import { BatchInsightsEventArray } from '@contentful/optimization-api-client/api-schemas';
|
|
10
12
|
import type { ChainModifiers } from 'contentful';
|
|
11
|
-
import { ChangeArray } from '@contentful/optimization-api-client/api-schemas';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import { ComponentViewBuilderArgs } from '@contentful/optimization-api-client';
|
|
13
|
+
import type { ChangeArray } from '@contentful/optimization-api-client/api-schemas';
|
|
14
|
+
import { Channel } from '@contentful/optimization-api-client/api-schemas';
|
|
15
|
+
import { ClickEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
15
16
|
import { computed } from '@preact/signals-core';
|
|
16
17
|
import { effect } from '@preact/signals-core';
|
|
17
18
|
import type { Entry } from 'contentful';
|
|
18
19
|
import { EntryReplacementVariant } from '@contentful/optimization-api-schemas';
|
|
19
20
|
import { EntryReplacementVariant as EntryReplacementVariant_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
20
21
|
import type { EntrySkeletonType } from 'contentful';
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
23
|
-
import { ExperienceApiClientConfig } from '@contentful/optimization-api-client';
|
|
22
|
+
import type { ExperienceApiClientConfig } from '@contentful/optimization-api-client';
|
|
23
|
+
import type { ExperienceApiClientRequestOptions } from '@contentful/optimization-api-client';
|
|
24
24
|
import { ExperienceEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
25
25
|
import { ExperienceEventArray } from '@contentful/optimization-api-client/api-schemas';
|
|
26
26
|
import type { ExperienceEventType } from '@contentful/optimization-api-client/api-schemas';
|
|
27
|
-
import { Flags } from '@contentful/optimization-api-
|
|
27
|
+
import { Flags } from '@contentful/optimization-api-schemas';
|
|
28
|
+
import type { Flags as Flags_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
28
29
|
import { GlobalApiConfigProperties } from '@contentful/optimization-api-client';
|
|
29
|
-
import {
|
|
30
|
-
import {
|
|
30
|
+
import { HoverEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
31
|
+
import { IdentifyEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
32
|
+
import type { InsightsApiClientConfig } from '@contentful/optimization-api-client';
|
|
31
33
|
import { InsightsEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
32
34
|
import type { InsightsEventType } from '@contentful/optimization-api-client/api-schemas';
|
|
33
|
-
import { Json } from '@contentful/optimization-api-client/api-schemas';
|
|
35
|
+
import type { Json } from '@contentful/optimization-api-client/api-schemas';
|
|
36
|
+
import { Library } from '@contentful/optimization-api-client/api-schemas';
|
|
34
37
|
import type { LocaleCode } from 'contentful';
|
|
35
38
|
import type { LogLevels } from '@contentful/optimization-api-client/logger';
|
|
36
|
-
import { MergeTagEntry } from '@contentful/optimization-api-client/api-schemas';
|
|
39
|
+
import type { MergeTagEntry } from '@contentful/optimization-api-client/api-schemas';
|
|
37
40
|
import { OptimizationData } from '@contentful/optimization-api-client/api-schemas';
|
|
38
|
-
import {
|
|
41
|
+
import { OptimizationEntry } from '@contentful/optimization-api-schemas';
|
|
42
|
+
import { OptimizationEntry as OptimizationEntry_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
43
|
+
import { OptimizedEntry } from '@contentful/optimization-api-schemas';
|
|
44
|
+
import { OptimizedEntry as OptimizedEntry_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
45
|
+
import { Page } from '@contentful/optimization-api-client/api-schemas';
|
|
46
|
+
import { PageViewEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
39
47
|
import { PartialProfile } from '@contentful/optimization-api-client/api-schemas';
|
|
40
|
-
import { PersonalizationEntry } from '@contentful/optimization-api-schemas';
|
|
41
|
-
import { PersonalizationEntry as PersonalizationEntry_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
42
|
-
import { PersonalizedEntry } from '@contentful/optimization-api-schemas';
|
|
43
|
-
import { PersonalizedEntry as PersonalizedEntry_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
44
48
|
import { Profile } from '@contentful/optimization-api-client/api-schemas';
|
|
45
49
|
import { ReadonlySignal } from '@preact/signals-core';
|
|
46
|
-
import {
|
|
47
|
-
import {
|
|
48
|
-
import {
|
|
49
|
-
import {
|
|
50
|
+
import { ScreenViewEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
51
|
+
import { SelectedOptimization } from '@contentful/optimization-api-schemas';
|
|
52
|
+
import { SelectedOptimization as SelectedOptimization_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
53
|
+
import { SelectedOptimizationArray } from '@contentful/optimization-api-client/api-schemas';
|
|
50
54
|
import { Signal } from '@preact/signals-core';
|
|
51
|
-
import {
|
|
55
|
+
import { TrackEvent as TrackEvent_2 } from '@contentful/optimization-api-client/api-schemas';
|
|
56
|
+
import { UniversalEventProperties } from '@contentful/optimization-api-client/api-schemas';
|
|
52
57
|
import { untracked } from '@preact/signals-core';
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
* Base class for analytics implementations (internal).
|
|
56
|
-
*
|
|
57
|
-
* @internal
|
|
58
|
-
* @remarks
|
|
59
|
-
* Concrete analytics classes should implement the component/flag view tracking
|
|
60
|
-
* methods below. This base is not part of the public API.
|
|
61
|
-
*/
|
|
62
|
-
declare abstract class AnalyticsBase extends ProductBase {
|
|
63
|
-
/**
|
|
64
|
-
* Track a UI component view event.
|
|
65
|
-
*
|
|
66
|
-
* @param payload - Component view builder arguments.
|
|
67
|
-
* @returns A promise that resolves when processing is complete (or `void`).
|
|
68
|
-
*/
|
|
69
|
-
abstract trackComponentView(payload: ComponentViewBuilderArgs): Promise<void> | void;
|
|
70
|
-
/**
|
|
71
|
-
* Track a UI component click event.
|
|
72
|
-
*
|
|
73
|
-
* @param payload - Component click builder arguments.
|
|
74
|
-
* @returns A promise that resolves when processing is complete (or `void`).
|
|
75
|
-
*/
|
|
76
|
-
abstract trackComponentClick(payload: ComponentClickBuilderArgs): Promise<void> | void;
|
|
77
|
-
/**
|
|
78
|
-
* Track a UI component hover event.
|
|
79
|
-
*
|
|
80
|
-
* @param payload - Component hover builder arguments.
|
|
81
|
-
* @returns A promise that resolves when processing is complete (or `void`).
|
|
82
|
-
*/
|
|
83
|
-
abstract trackComponentHover(payload: ComponentHoverBuilderArgs): Promise<void> | void;
|
|
84
|
-
/**
|
|
85
|
-
* Track a flag (feature) view event.
|
|
86
|
-
*
|
|
87
|
-
* @param payload - Flag view builder arguments.
|
|
88
|
-
* @returns A promise that resolves when processing is complete (or `void`).
|
|
89
|
-
*/
|
|
90
|
-
abstract trackFlagView(payload: ComponentViewBuilderArgs): Promise<void> | void;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* Configuration for the stateful analytics implementation.
|
|
95
|
-
*
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
98
|
-
export declare interface AnalyticsProductConfig extends ProductConfig {
|
|
99
|
-
/**
|
|
100
|
-
* Default signal values applied on initialization.
|
|
101
|
-
*/
|
|
102
|
-
defaults?: AnalyticsProductConfigDefaults;
|
|
103
|
-
/**
|
|
104
|
-
* Policy that controls stateful queue flush retries, backoff, and circuit
|
|
105
|
-
* behavior after repeated failures.
|
|
106
|
-
*/
|
|
107
|
-
queuePolicy?: QueueFlushPolicy;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Default analytics state values applied at construction time.
|
|
112
|
-
*
|
|
113
|
-
* @public
|
|
114
|
-
*/
|
|
115
|
-
export declare interface AnalyticsProductConfigDefaults {
|
|
116
|
-
/** Whether analytics collection is allowed by default. */
|
|
117
|
-
consent?: boolean;
|
|
118
|
-
/** Default profile to associate with events. */
|
|
119
|
-
profile?: Profile;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Analytics implementation that maintains local state (consent, profile) and
|
|
124
|
-
* queues events until flushed or the queue reaches a maximum size.
|
|
125
|
-
*
|
|
126
|
-
* @remarks
|
|
127
|
-
* Repeated flush failures are managed by the configured {@link QueueFlushPolicy}
|
|
128
|
-
* using bounded backoff and a temporary circuit-open window.
|
|
129
|
-
*
|
|
130
|
-
* @public
|
|
131
|
-
*/
|
|
132
|
-
export declare class AnalyticsStateful extends AnalyticsBase implements ConsentGuard {
|
|
133
|
-
/** In-memory queue keyed by stable profile identifier. */
|
|
134
|
-
private readonly queue;
|
|
135
|
-
/** Shared queue flush retry runtime state machine. */
|
|
136
|
-
private readonly flushRuntime;
|
|
137
|
-
/** Exposed observable state references. */
|
|
138
|
-
readonly states: AnalyticsStates;
|
|
139
|
-
/**
|
|
140
|
-
* Create a new stateful analytics instance.
|
|
141
|
-
*
|
|
142
|
-
* @param options - Options to configure the analytics product for stateful environments.
|
|
143
|
-
* @example
|
|
144
|
-
* ```ts
|
|
145
|
-
* const analytics = new AnalyticsStateful({ api, builder, config: { defaults: { consent: true } }, interceptors })
|
|
146
|
-
* ```
|
|
147
|
-
*/
|
|
148
|
-
constructor(options: AnalyticsStatefulOptions);
|
|
149
|
-
/**
|
|
150
|
-
* Reset analytics‑related signals and the last emitted event.
|
|
151
|
-
*
|
|
152
|
-
* @example
|
|
153
|
-
* ```ts
|
|
154
|
-
* analytics.reset()
|
|
155
|
-
* ```
|
|
156
|
-
*/
|
|
157
|
-
reset(): void;
|
|
158
|
-
/**
|
|
159
|
-
* Determine whether the named operation is permitted based on consent and
|
|
160
|
-
* allowed event type configuration.
|
|
161
|
-
*
|
|
162
|
-
* @param name - The method name; component view/flag methods are normalized
|
|
163
|
-
* to `'component'`, component click methods are normalized to `'component_click'`,
|
|
164
|
-
* and component hover methods are normalized to `'component_hover'` for
|
|
165
|
-
* allow‑list checks.
|
|
166
|
-
* @returns `true` if the operation is permitted; otherwise `false`.
|
|
167
|
-
* @example
|
|
168
|
-
* ```ts
|
|
169
|
-
* if (analytics.hasConsent('track')) { ... }
|
|
170
|
-
* ```
|
|
171
|
-
*/
|
|
172
|
-
hasConsent(name: string): boolean;
|
|
173
|
-
/**
|
|
174
|
-
* Hook invoked when an operation is blocked due to missing consent.
|
|
175
|
-
*
|
|
176
|
-
* @param name - The blocked operation name.
|
|
177
|
-
* @param payload - The original arguments supplied to the operation.
|
|
178
|
-
* @example
|
|
179
|
-
* ```ts
|
|
180
|
-
* analytics.onBlockedByConsent('track', [payload])
|
|
181
|
-
* ```
|
|
182
|
-
*/
|
|
183
|
-
onBlockedByConsent(name: string, payload: readonly unknown[]): void;
|
|
184
|
-
/**
|
|
185
|
-
* Queue a component view event for the active profile.
|
|
186
|
-
*
|
|
187
|
-
* @param payload - Component view builder arguments.
|
|
188
|
-
* @returns A promise that resolves when the event has been queued.
|
|
189
|
-
* @example
|
|
190
|
-
* ```ts
|
|
191
|
-
* await analytics.trackComponentView({ componentId: 'hero-banner' })
|
|
192
|
-
* ```
|
|
193
|
-
*/
|
|
194
|
-
trackComponentView(payload: ComponentViewBuilderArgs): Promise<void>;
|
|
195
|
-
/**
|
|
196
|
-
* Queue a component click event for the active profile.
|
|
197
|
-
*
|
|
198
|
-
* @param payload - Component click builder arguments.
|
|
199
|
-
* @returns A promise that resolves when the event has been queued.
|
|
200
|
-
* @example
|
|
201
|
-
* ```ts
|
|
202
|
-
* await analytics.trackComponentClick({ componentId: 'hero-banner' })
|
|
203
|
-
* ```
|
|
204
|
-
*/
|
|
205
|
-
trackComponentClick(payload: ComponentClickBuilderArgs): Promise<void>;
|
|
206
|
-
/**
|
|
207
|
-
* Queue a component hover event for the active profile.
|
|
208
|
-
*
|
|
209
|
-
* @param payload - Component hover builder arguments.
|
|
210
|
-
* @returns A promise that resolves when the event has been queued.
|
|
211
|
-
* @example
|
|
212
|
-
* ```ts
|
|
213
|
-
* await analytics.trackComponentHover({ componentId: 'hero-banner' })
|
|
214
|
-
* ```
|
|
215
|
-
*/
|
|
216
|
-
trackComponentHover(payload: ComponentHoverBuilderArgs): Promise<void>;
|
|
217
|
-
/**
|
|
218
|
-
* Queue a flag view event for the active profile.
|
|
219
|
-
*
|
|
220
|
-
* @param payload - Flag view builder arguments.
|
|
221
|
-
* @returns A promise that resolves when the event has been queued.
|
|
222
|
-
* @example
|
|
223
|
-
* ```ts
|
|
224
|
-
* await analytics.trackFlagView({ componentId: 'feature-flag-123' })
|
|
225
|
-
* ```
|
|
226
|
-
*/
|
|
227
|
-
trackFlagView(payload: ComponentViewBuilderArgs): Promise<void>;
|
|
228
|
-
/**
|
|
229
|
-
* Intercept, validate, and place an event into the profile‑scoped queue; then
|
|
230
|
-
* trigger a size‑based flush if necessary.
|
|
231
|
-
*
|
|
232
|
-
* @param event - The event to enqueue.
|
|
233
|
-
*/
|
|
234
|
-
private enqueueEvent;
|
|
235
|
-
/**
|
|
236
|
-
* Flush the queue automatically when the total number of queued events
|
|
237
|
-
* reaches {@link MAX_QUEUED_EVENTS}.
|
|
238
|
-
*/
|
|
239
|
-
private flushMaxEvents;
|
|
240
|
-
/**
|
|
241
|
-
* Send all queued events grouped by profile and clear the queue.
|
|
242
|
-
*
|
|
243
|
-
* @param options - Optional flush controls.
|
|
244
|
-
* @param options.force - When `true`, bypass offline/backoff/circuit gates and attempt immediately.
|
|
245
|
-
* @remarks Only under rare circumstances should there be more than one
|
|
246
|
-
* profile in a stateful application.
|
|
247
|
-
* @example
|
|
248
|
-
* ```ts
|
|
249
|
-
* await analytics.flush()
|
|
250
|
-
* ```
|
|
251
|
-
*/
|
|
252
|
-
flush(options?: {
|
|
253
|
-
force?: boolean;
|
|
254
|
-
}): Promise<void>;
|
|
255
|
-
/**
|
|
256
|
-
* Apply default stateful analytics values when provided.
|
|
257
|
-
*
|
|
258
|
-
* @param defaults - Optional defaults for analytics state.
|
|
259
|
-
*/
|
|
260
|
-
private applyDefaults;
|
|
261
|
-
/**
|
|
262
|
-
* Initialize reactive effects for consent/profile logging and online flushes.
|
|
263
|
-
*/
|
|
264
|
-
private initializeEffects;
|
|
265
|
-
/**
|
|
266
|
-
* Build batch payloads grouped by profile from the in-memory queue.
|
|
267
|
-
*
|
|
268
|
-
* @returns Grouped batch payloads.
|
|
269
|
-
*/
|
|
270
|
-
private createBatches;
|
|
271
|
-
/**
|
|
272
|
-
* Attempt to send queued batches to the Insights API.
|
|
273
|
-
*
|
|
274
|
-
* @param batches - Batches to send.
|
|
275
|
-
* @returns `true` when send succeeds; otherwise `false`.
|
|
276
|
-
*/
|
|
277
|
-
private trySendBatches;
|
|
278
|
-
/**
|
|
279
|
-
* Compute the total number of queued events across all profiles.
|
|
280
|
-
*
|
|
281
|
-
* @returns Total queued event count.
|
|
282
|
-
*/
|
|
283
|
-
private getQueuedEventCount;
|
|
284
|
-
}
|
|
285
|
-
|
|
286
|
-
/**
|
|
287
|
-
* Options for configuring {@link AnalyticsStateful} functionality.
|
|
288
|
-
*
|
|
289
|
-
* @public
|
|
290
|
-
* @see {@link ProductBaseOptions}
|
|
291
|
-
*/
|
|
292
|
-
export declare type AnalyticsStatefulOptions = ProductBaseOptions & {
|
|
293
|
-
/** Configuration specific to the Analytics product */
|
|
294
|
-
config?: AnalyticsProductConfig;
|
|
295
|
-
};
|
|
296
|
-
|
|
297
|
-
/**
|
|
298
|
-
* Stateless analytics implementation that sends each event immediately in a
|
|
299
|
-
* single‑event batch.
|
|
300
|
-
*
|
|
301
|
-
* @public
|
|
302
|
-
*/
|
|
303
|
-
export declare class AnalyticsStateless extends AnalyticsBase {
|
|
304
|
-
/**
|
|
305
|
-
* Build, intercept, validate, and send a component view event.
|
|
306
|
-
*
|
|
307
|
-
* @param args - {@link TrackComponentViewArgs} used to build the event. Includes an
|
|
308
|
-
* optional partial profile.
|
|
309
|
-
* @returns A promise that resolves once the batch has been sent.
|
|
310
|
-
* @example
|
|
311
|
-
* ```ts
|
|
312
|
-
* await analytics.trackComponentView({ componentId: 'hero-banner', profile: { id: 'user-1' } })
|
|
313
|
-
* ```
|
|
314
|
-
*/
|
|
315
|
-
trackComponentView(args: TrackComponentViewArgs): Promise<void>;
|
|
316
|
-
/**
|
|
317
|
-
* Build, intercept, validate, and send a component click event.
|
|
318
|
-
*
|
|
319
|
-
* @param args - {@link TrackComponentClickArgs} used to build the event. Includes an
|
|
320
|
-
* optional partial profile.
|
|
321
|
-
* @returns A promise that resolves once the batch has been sent.
|
|
322
|
-
* @example
|
|
323
|
-
* ```ts
|
|
324
|
-
* await analytics.trackComponentClick({ componentId: 'hero-banner', profile: { id: 'user-1' } })
|
|
325
|
-
* ```
|
|
326
|
-
*/
|
|
327
|
-
trackComponentClick(args: TrackComponentClickArgs): Promise<void>;
|
|
328
|
-
/**
|
|
329
|
-
* Build, intercept, validate, and send a component hover event.
|
|
330
|
-
*
|
|
331
|
-
* @param args - {@link TrackComponentHoverArgs} used to build the event. Includes an
|
|
332
|
-
* optional partial profile.
|
|
333
|
-
* @returns A promise that resolves once the batch has been sent.
|
|
334
|
-
* @example
|
|
335
|
-
* ```ts
|
|
336
|
-
* await analytics.trackComponentHover({ componentId: 'hero-banner', profile: { id: 'user-1' } })
|
|
337
|
-
* ```
|
|
338
|
-
*/
|
|
339
|
-
trackComponentHover(args: TrackComponentHoverArgs): Promise<void>;
|
|
340
|
-
/**
|
|
341
|
-
* Build, intercept, validate, and send a flag view event.
|
|
342
|
-
*
|
|
343
|
-
* @param args - {@link TrackComponentViewArgs} used to build the event. Includes an
|
|
344
|
-
* optional partial profile.
|
|
345
|
-
* @returns A promise that resolves once the batch has been sent.
|
|
346
|
-
* @example
|
|
347
|
-
* ```ts
|
|
348
|
-
* await analytics.trackFlagView({ componentId: 'feature-flag-123' })
|
|
349
|
-
* ```
|
|
350
|
-
*/
|
|
351
|
-
trackFlagView(args: TrackComponentViewArgs): Promise<void>;
|
|
352
|
-
/**
|
|
353
|
-
* Send a single {@link AnalyticsEvent} wrapped in a one‑item batch.
|
|
354
|
-
*
|
|
355
|
-
* @param event - The event to send.
|
|
356
|
-
* @param profile - Optional partial profile to attach to the batch.
|
|
357
|
-
* @returns A promise that resolves when the API call completes.
|
|
358
|
-
* @internal
|
|
359
|
-
*/
|
|
360
|
-
private sendBatchEvent;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
/**
|
|
364
|
-
* Observables exposed by the stateful analytics product.
|
|
365
|
-
*
|
|
366
|
-
* @public
|
|
367
|
-
*/
|
|
368
|
-
export declare interface AnalyticsStates {
|
|
369
|
-
/** Observable stream of the latest blocked event payload (or `undefined`). */
|
|
370
|
-
blockedEventStream: Observable<BlockedEvent | undefined>;
|
|
371
|
-
/** Observable stream of the latest {@link AnalyticsEvent} or {@link PersonalizationEvent} (or `undefined`). */
|
|
372
|
-
eventStream: Observable<InsightsEvent | ExperienceEvent | undefined>;
|
|
373
|
-
/** Observable stream of the active {@link Profile} (or `undefined`). */
|
|
374
|
-
profile: Observable<Profile | undefined>;
|
|
375
|
-
}
|
|
58
|
+
import { ViewEvent } from '@contentful/optimization-api-client/api-schemas';
|
|
59
|
+
import * as z from 'zod/mini';
|
|
376
60
|
|
|
377
61
|
/**
|
|
378
62
|
* Anonymous-ID cookie name used by the Optimization Core.
|
|
@@ -380,7 +64,7 @@ export declare interface AnalyticsStates {
|
|
|
380
64
|
* @public
|
|
381
65
|
* @remarks
|
|
382
66
|
* This constant represents the cookie key used by the Optimization Framework
|
|
383
|
-
* to persist an anonymous identifier for tracking
|
|
67
|
+
* to persist an anonymous identifier for tracking optimization and insights
|
|
384
68
|
* events when no explicit profile is known.
|
|
385
69
|
*
|
|
386
70
|
* @example
|
|
@@ -422,22 +106,18 @@ export { batch }
|
|
|
422
106
|
export declare interface BlockedEvent {
|
|
423
107
|
/** Why the event was blocked. */
|
|
424
108
|
reason: BlockedEventReason;
|
|
425
|
-
/** Product that blocked the event. */
|
|
426
|
-
product: BlockedEventProduct;
|
|
427
109
|
/** Method name that was blocked. */
|
|
428
110
|
method: string;
|
|
429
111
|
/** Original arguments passed to the blocked method call. */
|
|
430
112
|
args: readonly unknown[];
|
|
431
113
|
}
|
|
432
114
|
|
|
433
|
-
declare const blockedEvent: Signal<BlockedEvent | undefined>;
|
|
434
|
-
|
|
435
115
|
/**
|
|
436
|
-
*
|
|
116
|
+
* Most recent blocked-event metadata produced by consent/runtime guards.
|
|
437
117
|
*
|
|
438
118
|
* @public
|
|
439
119
|
*/
|
|
440
|
-
|
|
120
|
+
declare const blockedEvent: Signal<BlockedEvent | undefined>;
|
|
441
121
|
|
|
442
122
|
/**
|
|
443
123
|
* Reasons why an event was blocked before being sent.
|
|
@@ -455,8 +135,20 @@ export declare type BlockedEventReason = 'consent';
|
|
|
455
135
|
*
|
|
456
136
|
* @public
|
|
457
137
|
*/
|
|
458
|
-
declare type BlockHandler = (methodName: string, args: readonly unknown[]) => void;
|
|
138
|
+
export declare type BlockHandler = (methodName: string, args: readonly unknown[]) => void;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Whether optimization selection data is available for entry resolution.
|
|
142
|
+
*
|
|
143
|
+
* @public
|
|
144
|
+
*/
|
|
145
|
+
declare const canOptimize: ReadonlySignal<boolean>;
|
|
459
146
|
|
|
147
|
+
/**
|
|
148
|
+
* Latest optimization changes returned by the Experience API.
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
460
152
|
declare const changes: Signal<ChangeArray | undefined>;
|
|
461
153
|
|
|
462
154
|
/**
|
|
@@ -466,6 +158,58 @@ declare const changes: Signal<ChangeArray | undefined>;
|
|
|
466
158
|
*/
|
|
467
159
|
export declare const CHANGES_CACHE_KEY = "__ctfl_opt_changes__";
|
|
468
160
|
|
|
161
|
+
export declare const ClickBuilderArgs: z.ZodMiniObject<{
|
|
162
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
163
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
164
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
165
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
166
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
167
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
168
|
+
}, z.core.$strip>>;
|
|
169
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
170
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
171
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
172
|
+
latitude: z.ZodMiniNumber<number>;
|
|
173
|
+
longitude: z.ZodMiniNumber<number>;
|
|
174
|
+
}, z.core.$strip>>;
|
|
175
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
176
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
177
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
178
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
179
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
180
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
181
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
182
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
183
|
+
}, z.core.$strip>>;
|
|
184
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
185
|
+
path: z.ZodMiniString<string>;
|
|
186
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
187
|
+
referrer: z.ZodMiniString<string>;
|
|
188
|
+
search: z.ZodMiniString<string>;
|
|
189
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
190
|
+
url: z.ZodMiniString<string>;
|
|
191
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
192
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
193
|
+
name: z.ZodMiniString<string>;
|
|
194
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
195
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
196
|
+
componentId: z.ZodMiniString<string>;
|
|
197
|
+
experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
198
|
+
variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
199
|
+
}, z.core.$strip>;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Arguments for constructing entry click events.
|
|
203
|
+
*
|
|
204
|
+
* @public
|
|
205
|
+
*/
|
|
206
|
+
export declare type ClickBuilderArgs = z.infer<typeof ClickBuilderArgs>;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Current optimization/analytics consent state.
|
|
210
|
+
*
|
|
211
|
+
* @public
|
|
212
|
+
*/
|
|
469
213
|
declare const consent: Signal<boolean | undefined>;
|
|
470
214
|
|
|
471
215
|
/**
|
|
@@ -482,7 +226,7 @@ export declare const CONSENT_KEY = "__ctfl_opt_consent__";
|
|
|
482
226
|
* @remarks
|
|
483
227
|
* Intended for internal wiring between Core classes and the consent signal/store.
|
|
484
228
|
*/
|
|
485
|
-
declare interface ConsentController {
|
|
229
|
+
export declare interface ConsentController {
|
|
486
230
|
/**
|
|
487
231
|
* Update the runtime consent state.
|
|
488
232
|
*
|
|
@@ -499,7 +243,7 @@ declare interface ConsentController {
|
|
|
499
243
|
* These methods are consumed by the `@guardedBy` decorator to decide whether to
|
|
500
244
|
* proceed with an operation and how to report blocked calls.
|
|
501
245
|
*/
|
|
502
|
-
declare interface ConsentGuard {
|
|
246
|
+
export declare interface ConsentGuard {
|
|
503
247
|
/**
|
|
504
248
|
* Determine whether the named operation is permitted given current consent and
|
|
505
249
|
* any allow‑list configuration.
|
|
@@ -520,22 +264,59 @@ declare interface ConsentGuard {
|
|
|
520
264
|
onBlockedByConsent: (name: string, args: unknown[]) => void;
|
|
521
265
|
}
|
|
522
266
|
|
|
267
|
+
/**
|
|
268
|
+
* API configuration union for Core runtimes.
|
|
269
|
+
*
|
|
270
|
+
* @public
|
|
271
|
+
*/
|
|
272
|
+
export declare type CoreApiConfig = CoreStatefulApiConfig | CoreStatelessApiConfig;
|
|
273
|
+
|
|
523
274
|
/**
|
|
524
275
|
* Internal base that wires the API client, event builder, and logging.
|
|
525
276
|
*
|
|
526
277
|
* @internal
|
|
527
278
|
*/
|
|
528
|
-
declare abstract class CoreBase
|
|
529
|
-
/** Product implementation for analytics. */
|
|
530
|
-
protected abstract _analytics: AnalyticsBase;
|
|
531
|
-
/** Product implementation for personalization. */
|
|
532
|
-
protected abstract _personalization: PersonalizationBase;
|
|
279
|
+
declare abstract class CoreBase<TConfig extends CoreConfig = CoreConfig> {
|
|
533
280
|
/** Shared Optimization API client instance. */
|
|
534
281
|
readonly api: ApiClient;
|
|
535
282
|
/** Shared event builder instance. */
|
|
536
283
|
readonly eventBuilder: EventBuilder;
|
|
537
|
-
/** Resolved core configuration
|
|
538
|
-
readonly config:
|
|
284
|
+
/** Resolved core configuration. */
|
|
285
|
+
readonly config: TConfig;
|
|
286
|
+
/** Static resolver for evaluating optimized custom flags. */
|
|
287
|
+
readonly flagsResolver: {
|
|
288
|
+
resolve(changes?: ChangeArray): Flags;
|
|
289
|
+
};
|
|
290
|
+
/** Static resolver for merge-tag lookups against profile data. */
|
|
291
|
+
readonly mergeTagValueResolver: {
|
|
292
|
+
normalizeSelectors(id: string): string[];
|
|
293
|
+
getValueFromProfile(id: string, profile?: Profile): string | undefined;
|
|
294
|
+
resolve(mergeTagEntry: MergeTagEntry | undefined, profile?: Profile): string | undefined;
|
|
295
|
+
};
|
|
296
|
+
/** Static resolver for optimized Contentful entries. */
|
|
297
|
+
readonly optimizedEntryResolver: {
|
|
298
|
+
getOptimizationEntry({ optimizedEntry, selectedOptimizations, }: {
|
|
299
|
+
optimizedEntry: OptimizedEntry;
|
|
300
|
+
selectedOptimizations: SelectedOptimizationArray;
|
|
301
|
+
}, skipValidation?: boolean): OptimizationEntry | undefined;
|
|
302
|
+
getSelectedOptimization({ optimizationEntry, selectedOptimizations, }: {
|
|
303
|
+
optimizationEntry: OptimizationEntry;
|
|
304
|
+
selectedOptimizations: SelectedOptimizationArray;
|
|
305
|
+
}, skipValidation?: boolean): SelectedOptimization | undefined;
|
|
306
|
+
getSelectedVariant({ optimizedEntry, optimizationEntry, selectedVariantIndex, }: {
|
|
307
|
+
optimizedEntry: OptimizedEntry;
|
|
308
|
+
optimizationEntry: OptimizationEntry;
|
|
309
|
+
selectedVariantIndex: number;
|
|
310
|
+
}, skipValidation?: boolean): EntryReplacementVariant | undefined;
|
|
311
|
+
getSelectedVariantEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>({ optimizationEntry, selectedVariant, }: {
|
|
312
|
+
optimizationEntry: OptimizationEntry;
|
|
313
|
+
selectedVariant: EntryReplacementVariant;
|
|
314
|
+
}, skipValidation?: boolean): Entry<S, M, L> | undefined;
|
|
315
|
+
resolve: {
|
|
316
|
+
<S extends EntrySkeletonType = EntrySkeletonType, L extends LocaleCode = string>(entry: Entry<S, undefined, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, undefined, L>;
|
|
317
|
+
<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>(entry: Entry<S, M, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, M, L>;
|
|
318
|
+
};
|
|
319
|
+
};
|
|
539
320
|
/** Lifecycle interceptors for events and state updates. */
|
|
540
321
|
readonly interceptors: LifecycleInterceptors;
|
|
541
322
|
/**
|
|
@@ -547,26 +328,7 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
547
328
|
* const sdk = new CoreStateless({ clientId: 'abc123', environment: 'prod' })
|
|
548
329
|
* ```
|
|
549
330
|
*/
|
|
550
|
-
constructor(config:
|
|
551
|
-
/**
|
|
552
|
-
* Static {@link FlagsResolver | resolver} for evaluating personalized
|
|
553
|
-
* custom flags.
|
|
554
|
-
*/
|
|
555
|
-
get flagsResolver(): typeof FlagsResolver;
|
|
556
|
-
/**
|
|
557
|
-
* Static {@link MergeTagValueResolver | resolver} that returns values
|
|
558
|
-
* sourced from a user profile based on a Contentful Merge Tag entry.
|
|
559
|
-
*/
|
|
560
|
-
get mergeTagValueResolver(): typeof MergeTagValueResolver;
|
|
561
|
-
/**
|
|
562
|
-
* Static {@link PersonalizedEntryResolver | resolver } for personalized
|
|
563
|
-
* Contentful entries (e.g., entry variants targeted to a profile audience).
|
|
564
|
-
*
|
|
565
|
-
* @remarks
|
|
566
|
-
* Used by higher-level personalization flows to materialize entry content
|
|
567
|
-
* prior to event emission.
|
|
568
|
-
*/
|
|
569
|
-
get personalizedEntryResolver(): typeof PersonalizedEntryResolver;
|
|
331
|
+
constructor(config: TConfig, api?: CoreBaseApiClientConfig);
|
|
570
332
|
/**
|
|
571
333
|
* Get the value of a custom flag derived from a set of optimization changes.
|
|
572
334
|
*
|
|
@@ -574,174 +336,66 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
574
336
|
* @param changes - Optional change list to resolve from.
|
|
575
337
|
* @returns The resolved JSON value for the flag if available.
|
|
576
338
|
* @remarks
|
|
577
|
-
* This is a convenience wrapper around
|
|
578
|
-
* @example
|
|
579
|
-
* ```ts
|
|
580
|
-
* const darkMode = core.getCustomFlag('dark-mode', data.changes)
|
|
581
|
-
* ```
|
|
582
|
-
*/
|
|
583
|
-
getCustomFlag(name: string, changes?: ChangeArray): Json;
|
|
584
|
-
/**
|
|
585
|
-
* Get all resolved custom flags derived from a set of optimization changes.
|
|
586
|
-
*
|
|
587
|
-
* @param changes - Optional change list to resolve from.
|
|
588
|
-
* @returns The resolved custom flag map.
|
|
589
|
-
* @remarks
|
|
590
|
-
* This is a convenience wrapper around personalization’s flag resolution.
|
|
339
|
+
* This is a convenience wrapper around Core's shared flag resolution.
|
|
591
340
|
* @example
|
|
592
341
|
* ```ts
|
|
593
|
-
* const
|
|
342
|
+
* const darkMode = core.getFlag('dark-mode', data.changes)
|
|
594
343
|
* ```
|
|
595
344
|
*/
|
|
596
|
-
|
|
345
|
+
getFlag(name: string, changes?: ChangeArray): Json;
|
|
597
346
|
/**
|
|
598
|
-
* Resolve a Contentful entry to the appropriate
|
|
347
|
+
* Resolve a Contentful entry to the appropriate optimized variant (or
|
|
599
348
|
* return the baseline entry if no matching variant is selected).
|
|
600
349
|
*
|
|
601
350
|
* @typeParam S - Entry skeleton type.
|
|
602
351
|
* @typeParam M - Chain modifiers.
|
|
603
352
|
* @typeParam L - Locale code.
|
|
604
353
|
* @param entry - The baseline entry to resolve.
|
|
605
|
-
* @param
|
|
354
|
+
* @param selectedOptimizations - Optional selected optimization array for the current profile.
|
|
606
355
|
* @returns {@link ResolvedData} containing the resolved entry and
|
|
607
|
-
*
|
|
356
|
+
* selected optimization metadata (if any).
|
|
357
|
+
* @remarks
|
|
358
|
+
* This helper is intended for request-local resolution. When the supplied
|
|
359
|
+
* entry comes from a shared application cache, avoid mutating the returned
|
|
360
|
+
* entry in place unless you first clone it.
|
|
608
361
|
* @example
|
|
609
362
|
* ```ts
|
|
610
|
-
* const { entry,
|
|
363
|
+
* const { entry, selectedOptimization } = core.resolveOptimizedEntry(
|
|
364
|
+
* baselineEntry,
|
|
365
|
+
* data.selectedOptimizations,
|
|
366
|
+
* )
|
|
611
367
|
* ```
|
|
612
368
|
*/
|
|
613
|
-
|
|
369
|
+
resolveOptimizedEntry<S extends EntrySkeletonType = EntrySkeletonType, L extends LocaleCode = LocaleCode>(entry: Entry<S, undefined, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, undefined, L>;
|
|
370
|
+
resolveOptimizedEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, M, L>;
|
|
614
371
|
/**
|
|
615
372
|
* Resolve a merge-tag value from the given entry node and profile.
|
|
616
373
|
*
|
|
617
374
|
* @param embeddedEntryNodeTarget - The merge-tag entry node to resolve.
|
|
618
375
|
* @param profile - Optional profile used for value lookup.
|
|
619
376
|
* @returns The resolved value (typically a string) or `undefined` if not found.
|
|
377
|
+
* @remarks
|
|
378
|
+
* Use this during request rendering with the current profile. The resolved
|
|
379
|
+
* value is profile-dependent and is not safe for shared-output caching.
|
|
620
380
|
* @example
|
|
621
381
|
* ```ts
|
|
622
382
|
* const name = core.getMergeTagValue(mergeTagNode, profile)
|
|
623
383
|
* ```
|
|
624
384
|
*/
|
|
625
385
|
getMergeTagValue(embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile): string | undefined;
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
* @example
|
|
632
|
-
* ```ts
|
|
633
|
-
* const data = await core.identify({ userId: 'user-123', traits: { plan: 'pro' } })
|
|
634
|
-
* ```
|
|
635
|
-
*/
|
|
636
|
-
identify(payload: IdentifyBuilderArgs & {
|
|
637
|
-
profile?: PartialProfile;
|
|
638
|
-
}): Promise<OptimizationData | undefined>;
|
|
639
|
-
/**
|
|
640
|
-
* Convenience wrapper for sending a `page` event via personalization.
|
|
641
|
-
*
|
|
642
|
-
* @param payload - Page view builder arguments.
|
|
643
|
-
* @returns The evaluated {@link OptimizationData} for this page view.
|
|
644
|
-
* @example
|
|
645
|
-
* ```ts
|
|
646
|
-
* const data = await core.page({ properties: { title: 'Home' } })
|
|
647
|
-
* ```
|
|
648
|
-
*/
|
|
649
|
-
page(payload: PageViewBuilderArgs & {
|
|
650
|
-
profile?: PartialProfile;
|
|
651
|
-
}): Promise<OptimizationData | undefined>;
|
|
652
|
-
/**
|
|
653
|
-
* Convenience wrapper for sending a `screen` event via personalization.
|
|
654
|
-
*
|
|
655
|
-
* @param payload - Screen view builder arguments.
|
|
656
|
-
* @returns The evaluated {@link OptimizationData} for this screen view.
|
|
657
|
-
* @example
|
|
658
|
-
* ```ts
|
|
659
|
-
* const data = await core.screen({ name: 'HomeScreen' })
|
|
660
|
-
* ```
|
|
661
|
-
*/
|
|
662
|
-
screen(payload: ScreenViewBuilderArgs & {
|
|
663
|
-
profile?: PartialProfile;
|
|
664
|
-
}): Promise<OptimizationData | undefined>;
|
|
665
|
-
/**
|
|
666
|
-
* Convenience wrapper for sending a custom `track` event via personalization.
|
|
667
|
-
*
|
|
668
|
-
* @param payload - Track builder arguments.
|
|
669
|
-
* @returns The evaluated {@link OptimizationData} for this event.
|
|
670
|
-
* @example
|
|
671
|
-
* ```ts
|
|
672
|
-
* const data = await core.track({ event: 'button_click', properties: { label: 'Buy' } })
|
|
673
|
-
* ```
|
|
674
|
-
*/
|
|
675
|
-
track(payload: TrackBuilderArgs & {
|
|
676
|
-
profile?: PartialProfile;
|
|
677
|
-
}): Promise<OptimizationData | undefined>;
|
|
678
|
-
/**
|
|
679
|
-
* Track a component view in both personalization and analytics.
|
|
680
|
-
*
|
|
681
|
-
* @param payload - Component view builder arguments. When `payload.sticky` is
|
|
682
|
-
* `true`, the event will also be sent via personalization as a sticky
|
|
683
|
-
* component view.
|
|
684
|
-
* @returns A promise that resolves when all delegated calls complete.
|
|
685
|
-
* @remarks
|
|
686
|
-
* The sticky behavior is delegated to personalization; analytics is always
|
|
687
|
-
* invoked regardless of `sticky`.
|
|
688
|
-
* @example
|
|
689
|
-
* ```ts
|
|
690
|
-
* await core.trackComponentView({ componentId: 'hero-banner', sticky: true })
|
|
691
|
-
* ```
|
|
692
|
-
*/
|
|
693
|
-
trackComponentView(payload: ComponentViewBuilderArgs & {
|
|
694
|
-
profile?: PartialProfile;
|
|
695
|
-
}): Promise<OptimizationData | undefined>;
|
|
696
|
-
/**
|
|
697
|
-
* Track a component click via analytics.
|
|
698
|
-
*
|
|
699
|
-
* @param payload - Component click builder arguments.
|
|
700
|
-
* @returns A promise that resolves when processing completes.
|
|
701
|
-
* @example
|
|
702
|
-
* ```ts
|
|
703
|
-
* await core.trackComponentClick({ componentId: 'hero-banner' })
|
|
704
|
-
* ```
|
|
705
|
-
*/
|
|
706
|
-
trackComponentClick(payload: ComponentClickBuilderArgs): Promise<void>;
|
|
707
|
-
/**
|
|
708
|
-
* Track a component hover via analytics.
|
|
709
|
-
*
|
|
710
|
-
* @param payload - Component hover builder arguments.
|
|
711
|
-
* @returns A promise that resolves when processing completes.
|
|
712
|
-
* @example
|
|
713
|
-
* ```ts
|
|
714
|
-
* await core.trackComponentHover({ componentId: 'hero-banner' })
|
|
715
|
-
* ```
|
|
716
|
-
*/
|
|
717
|
-
trackComponentHover(payload: ComponentHoverBuilderArgs): Promise<void>;
|
|
718
|
-
/**
|
|
719
|
-
* Track a feature flag view via analytics.
|
|
720
|
-
*
|
|
721
|
-
* @param payload - Component view builder arguments used to build the flag view event.
|
|
722
|
-
* @returns A promise that resolves when processing completes.
|
|
723
|
-
* @example
|
|
724
|
-
* ```ts
|
|
725
|
-
* await core.trackFlagView({ componentId: 'feature-flag-123' })
|
|
726
|
-
* ```
|
|
727
|
-
*/
|
|
728
|
-
trackFlagView(payload: ComponentViewBuilderArgs): Promise<void>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
declare interface CoreBaseApiClientConfig {
|
|
389
|
+
experience?: ApiClientConfig['experience'];
|
|
390
|
+
insights?: ApiClientConfig['insights'];
|
|
729
391
|
}
|
|
730
392
|
|
|
731
393
|
/**
|
|
732
|
-
* Options for configuring the
|
|
394
|
+
* Options for configuring the `CoreBase` runtime and underlying clients.
|
|
733
395
|
*
|
|
734
396
|
* @public
|
|
735
397
|
*/
|
|
736
398
|
export declare interface CoreConfig extends Pick<ApiClientConfig, GlobalApiConfigProperties> {
|
|
737
|
-
/**
|
|
738
|
-
* Configuration for the personalization (Experience) API client.
|
|
739
|
-
*/
|
|
740
|
-
personalization?: Omit<ExperienceApiClientConfig, GlobalApiConfigProperties>;
|
|
741
|
-
/**
|
|
742
|
-
* Configuration for the analytics (Insights) API client.
|
|
743
|
-
*/
|
|
744
|
-
analytics?: Omit<InsightsApiClientConfig, GlobalApiConfigProperties>;
|
|
745
399
|
/**
|
|
746
400
|
* Event builder configuration (channel/library metadata, etc.).
|
|
747
401
|
*/
|
|
@@ -751,225 +405,271 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
751
405
|
}
|
|
752
406
|
|
|
753
407
|
/**
|
|
754
|
-
* Default values used to preconfigure the stateful core
|
|
408
|
+
* Default values used to preconfigure the stateful core.
|
|
755
409
|
*
|
|
756
410
|
* @public
|
|
757
411
|
*/
|
|
758
412
|
export declare interface CoreConfigDefaults {
|
|
759
413
|
/** Global consent default applied at construction time. */
|
|
760
414
|
consent?: boolean;
|
|
761
|
-
/** Default active profile used for
|
|
415
|
+
/** Default active profile used for optimization and insights. */
|
|
762
416
|
profile?: Profile;
|
|
763
417
|
/** Initial diff of changes produced by the service. */
|
|
764
418
|
changes?: ChangeArray;
|
|
765
|
-
/** Preselected
|
|
766
|
-
|
|
419
|
+
/** Preselected optimization variants (e.g., winning treatments). */
|
|
420
|
+
selectedOptimizations?: SelectedOptimizationArray;
|
|
767
421
|
}
|
|
768
422
|
|
|
769
423
|
/**
|
|
770
|
-
*
|
|
771
|
-
*
|
|
424
|
+
* Shared API configuration for all Core runtimes.
|
|
425
|
+
*
|
|
426
|
+
* @public
|
|
427
|
+
*/
|
|
428
|
+
export declare interface CoreSharedApiConfig {
|
|
429
|
+
/** Base URL override for Experience API requests. */
|
|
430
|
+
experienceBaseUrl?: ExperienceApiClientConfig['baseUrl'];
|
|
431
|
+
/** Base URL override for Insights API requests. */
|
|
432
|
+
insightsBaseUrl?: InsightsApiClientConfig['baseUrl'];
|
|
433
|
+
/** Experience API features enabled for outgoing requests. */
|
|
434
|
+
enabledFeatures?: ExperienceApiClientConfig['enabledFeatures'];
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/**
|
|
438
|
+
* Core runtime that owns stateful event delivery, consent, and shared signals.
|
|
772
439
|
*
|
|
773
|
-
* @remarks
|
|
774
|
-
* Extends {@link CoreBase} with stateful capabilities, including
|
|
775
|
-
* consent management via {@link ConsentController}.
|
|
776
|
-
* @see {@link CoreBase}
|
|
777
|
-
* @see {@link ConsentController}
|
|
778
440
|
* @public
|
|
779
441
|
*/
|
|
780
|
-
export declare class CoreStateful extends
|
|
442
|
+
export declare class CoreStateful extends CoreStatefulEventEmitter implements ConsentController, ConsentGuard {
|
|
781
443
|
private readonly singletonOwner;
|
|
782
444
|
private destroyed;
|
|
783
|
-
|
|
784
|
-
protected
|
|
785
|
-
|
|
786
|
-
protected
|
|
445
|
+
protected readonly allowedEventTypes: EventType[];
|
|
446
|
+
protected readonly experienceQueue: ExperienceQueue;
|
|
447
|
+
protected readonly insightsQueue: InsightsQueue;
|
|
448
|
+
protected readonly onEventBlocked?: CoreStatefulConfig['onEventBlocked'];
|
|
787
449
|
/**
|
|
788
|
-
*
|
|
789
|
-
*
|
|
790
|
-
* @param config - Core and defaults configuration.
|
|
791
|
-
* @example
|
|
792
|
-
* ```ts
|
|
793
|
-
* const core = new CoreStateful({
|
|
794
|
-
* clientId: 'app',
|
|
795
|
-
* environment: 'prod',
|
|
796
|
-
* defaults: { consent: true }
|
|
797
|
-
* })
|
|
798
|
-
* core.consent(true)
|
|
799
|
-
* ```
|
|
450
|
+
* Expose merged observable state for consumers.
|
|
800
451
|
*/
|
|
452
|
+
readonly states: CoreStates;
|
|
801
453
|
constructor(config: CoreStatefulConfig);
|
|
454
|
+
private initializeEffects;
|
|
455
|
+
private flushQueues;
|
|
456
|
+
destroy(): void;
|
|
457
|
+
reset(): void;
|
|
458
|
+
flush(): Promise<void>;
|
|
459
|
+
consent(accept: boolean): void;
|
|
460
|
+
protected get online(): boolean;
|
|
461
|
+
protected set online(isOnline: boolean);
|
|
462
|
+
registerPreviewPanel(previewPanel: PreviewPanelSignalObject): void;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
/**
|
|
466
|
+
* API configuration for stateful Core runtimes.
|
|
467
|
+
*
|
|
468
|
+
* @public
|
|
469
|
+
*/
|
|
470
|
+
export declare interface CoreStatefulApiConfig extends CoreSharedApiConfig {
|
|
471
|
+
/** Beacon-like handler used by Insights event delivery when available. */
|
|
472
|
+
beaconHandler?: InsightsApiClientConfig['beaconHandler'];
|
|
473
|
+
/** Experience API IP override. */
|
|
474
|
+
ip?: ExperienceApiClientConfig['ip'];
|
|
475
|
+
/** Experience API locale override. */
|
|
476
|
+
locale?: ExperienceApiClientConfig['locale'];
|
|
477
|
+
/** Experience API plain-text request toggle. */
|
|
478
|
+
plainText?: ExperienceApiClientConfig['plainText'];
|
|
479
|
+
/** Experience API preflight request toggle. */
|
|
480
|
+
preflight?: ExperienceApiClientConfig['preflight'];
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
/**
|
|
484
|
+
* Configuration for {@link CoreStateful}.
|
|
485
|
+
*
|
|
486
|
+
* @public
|
|
487
|
+
*/
|
|
488
|
+
export declare interface CoreStatefulConfig extends CoreConfig {
|
|
802
489
|
/**
|
|
803
|
-
*
|
|
804
|
-
*
|
|
805
|
-
* @remarks
|
|
806
|
-
* This method is idempotent and should be called when a stateful SDK instance
|
|
807
|
-
* is no longer needed (e.g. tests, hot reload, explicit teardown).
|
|
490
|
+
* Unified API configuration for stateful environments.
|
|
808
491
|
*/
|
|
809
|
-
|
|
492
|
+
api?: CoreStatefulApiConfig;
|
|
810
493
|
/**
|
|
811
|
-
*
|
|
812
|
-
|
|
813
|
-
|
|
494
|
+
* Allow-listed event type strings permitted when consent is not set.
|
|
495
|
+
*/
|
|
496
|
+
allowedEventTypes?: EventType[];
|
|
497
|
+
/** Optional set of default values applied on initialization. */
|
|
498
|
+
defaults?: CoreConfigDefaults;
|
|
499
|
+
/** Function used to obtain an anonymous user identifier. */
|
|
500
|
+
getAnonymousId?: () => string | undefined;
|
|
501
|
+
/**
|
|
502
|
+
* Callback invoked whenever an event call is blocked by checks.
|
|
814
503
|
*/
|
|
815
|
-
|
|
504
|
+
onEventBlocked?: (event: BlockedEvent) => void;
|
|
505
|
+
/** Unified queue policy for queued stateful work. */
|
|
506
|
+
queuePolicy?: QueuePolicy;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Shared stateful event-emission surface extracted to keep `CoreStateful.ts`
|
|
511
|
+
* below the local max-lines limit while preserving the public API.
|
|
512
|
+
*
|
|
513
|
+
* @internal
|
|
514
|
+
*/
|
|
515
|
+
declare abstract class CoreStatefulEventEmitter extends CoreBase<CoreStatefulConfig> implements ConsentGuard {
|
|
516
|
+
protected readonly flagObservables: Map<string, Observable<unknown>>;
|
|
517
|
+
protected abstract readonly allowedEventTypes: EventType[];
|
|
518
|
+
protected abstract readonly experienceQueue: ExperienceQueue;
|
|
519
|
+
protected abstract readonly insightsQueue: InsightsQueue;
|
|
520
|
+
protected abstract readonly onEventBlocked?: CoreStatefulConfig['onEventBlocked'];
|
|
521
|
+
getFlag(name: string, changes?: ChangeArray | undefined): Json;
|
|
522
|
+
resolveOptimizedEntry<S extends EntrySkeletonType = EntrySkeletonType, L extends LocaleCode = LocaleCode>(entry: Entry<S, undefined, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, undefined, L>;
|
|
523
|
+
resolveOptimizedEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, M, L>;
|
|
524
|
+
getMergeTagValue(embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile | undefined): string | undefined;
|
|
816
525
|
/**
|
|
817
|
-
*
|
|
526
|
+
* Convenience wrapper for sending an `identify` event through the Experience path.
|
|
818
527
|
*
|
|
819
|
-
* @
|
|
820
|
-
*
|
|
821
|
-
* consequence of the current shared-state design.
|
|
528
|
+
* @param payload - Identify builder arguments.
|
|
529
|
+
* @returns The resulting {@link OptimizationData} for the identified user.
|
|
822
530
|
* @example
|
|
823
531
|
* ```ts
|
|
824
|
-
* core.
|
|
532
|
+
* const data = await core.identify({ userId: 'user-123', traits: { plan: 'pro' } })
|
|
825
533
|
* ```
|
|
826
534
|
*/
|
|
827
|
-
|
|
535
|
+
identify(payload: IdentifyBuilderArgs & {
|
|
536
|
+
profile?: PartialProfile;
|
|
537
|
+
}): Promise<OptimizationData | undefined>;
|
|
828
538
|
/**
|
|
829
|
-
*
|
|
830
|
-
*
|
|
831
|
-
*
|
|
832
|
-
*
|
|
539
|
+
* Convenience wrapper for sending a `page` event through the Experience path.
|
|
540
|
+
*
|
|
541
|
+
* @param payload - Page view builder arguments.
|
|
542
|
+
* @returns The evaluated {@link OptimizationData} for this page view.
|
|
833
543
|
* @example
|
|
834
544
|
* ```ts
|
|
835
|
-
* await core.
|
|
545
|
+
* const data = await core.page({ properties: { title: 'Home' } })
|
|
836
546
|
* ```
|
|
837
547
|
*/
|
|
838
|
-
|
|
548
|
+
page(payload?: PageViewBuilderArgs & {
|
|
549
|
+
profile?: PartialProfile;
|
|
550
|
+
}): Promise<OptimizationData | undefined>;
|
|
839
551
|
/**
|
|
840
|
-
*
|
|
552
|
+
* Convenience wrapper for sending a `screen` event through the Experience path.
|
|
841
553
|
*
|
|
842
|
-
* @param
|
|
554
|
+
* @param payload - Screen view builder arguments.
|
|
555
|
+
* @returns The evaluated {@link OptimizationData} for this screen view.
|
|
843
556
|
* @example
|
|
844
557
|
* ```ts
|
|
845
|
-
* core.
|
|
558
|
+
* const data = await core.screen({ name: 'HomeScreen' })
|
|
846
559
|
* ```
|
|
847
560
|
*/
|
|
848
|
-
|
|
561
|
+
screen(payload: ScreenViewBuilderArgs & {
|
|
562
|
+
profile?: PartialProfile;
|
|
563
|
+
}): Promise<OptimizationData | undefined>;
|
|
849
564
|
/**
|
|
850
|
-
*
|
|
565
|
+
* Convenience wrapper for sending a custom `track` event through the Experience path.
|
|
851
566
|
*
|
|
567
|
+
* @param payload - Track builder arguments.
|
|
568
|
+
* @returns The evaluated {@link OptimizationData} for this event.
|
|
852
569
|
* @example
|
|
853
570
|
* ```ts
|
|
854
|
-
*
|
|
855
|
-
* await this.flush()
|
|
856
|
-
* }
|
|
571
|
+
* const data = await core.track({ event: 'button_click', properties: { label: 'Buy' } })
|
|
857
572
|
* ```
|
|
858
573
|
*/
|
|
859
|
-
|
|
574
|
+
track(payload: TrackBuilderArgs & {
|
|
575
|
+
profile?: PartialProfile;
|
|
576
|
+
}): Promise<OptimizationData | undefined>;
|
|
860
577
|
/**
|
|
861
|
-
*
|
|
578
|
+
* Track an entry view through Insights and, when sticky, Experience.
|
|
862
579
|
*
|
|
863
|
-
* @param
|
|
580
|
+
* @param payload - Entry view builder arguments. When `payload.sticky` is
|
|
581
|
+
* `true`, the event will also be sent through Experience as a sticky
|
|
582
|
+
* entry view.
|
|
583
|
+
* @returns A promise that resolves when all delegated calls complete.
|
|
584
|
+
* @remarks
|
|
585
|
+
* Experience receives sticky entry views only; Insights is always invoked
|
|
586
|
+
* regardless of `sticky`.
|
|
864
587
|
* @example
|
|
865
588
|
* ```ts
|
|
866
|
-
*
|
|
589
|
+
* await core.trackView({ componentId: 'entry-123', sticky: true })
|
|
867
590
|
* ```
|
|
868
591
|
*/
|
|
869
|
-
|
|
592
|
+
trackView(payload: ViewBuilderArgs & {
|
|
593
|
+
profile?: PartialProfile;
|
|
594
|
+
}): Promise<OptimizationData | undefined>;
|
|
870
595
|
/**
|
|
871
|
-
*
|
|
872
|
-
* This enables the preview panel to modify SDK state for testing and simulation.
|
|
596
|
+
* Track an entry click through Insights.
|
|
873
597
|
*
|
|
874
|
-
* @param
|
|
875
|
-
* @
|
|
876
|
-
* This method is intended for use by the Preview Panel component.
|
|
877
|
-
* Direct signal access allows immediate state updates without API calls.
|
|
598
|
+
* @param payload - Entry click builder arguments.
|
|
599
|
+
* @returns A promise that resolves when processing completes.
|
|
878
600
|
* @example
|
|
879
601
|
* ```ts
|
|
880
|
-
*
|
|
881
|
-
* core.registerPreviewPanel(previewBridge)
|
|
602
|
+
* await core.trackClick({ componentId: 'entry-123' })
|
|
882
603
|
* ```
|
|
883
604
|
*/
|
|
884
|
-
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
/**
|
|
888
|
-
* Stateful analytics configuration.
|
|
889
|
-
*
|
|
890
|
-
* @public
|
|
891
|
-
*/
|
|
892
|
-
export declare type CoreStatefulAnalyticsConfig = NonNullable<CoreConfig['analytics']> & {
|
|
605
|
+
trackClick(payload: ClickBuilderArgs): Promise<void>;
|
|
893
606
|
/**
|
|
894
|
-
*
|
|
607
|
+
* Track an entry hover through Insights.
|
|
895
608
|
*
|
|
896
|
-
* @
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
* Configuration for {@link CoreStateful}.
|
|
903
|
-
*
|
|
904
|
-
* @public
|
|
905
|
-
* @see {@link CoreConfig}
|
|
906
|
-
*/
|
|
907
|
-
export declare interface CoreStatefulConfig extends CoreConfig {
|
|
908
|
-
/**
|
|
909
|
-
* Configuration for the analytics (Insights) API client plus stateful queue behavior.
|
|
910
|
-
*/
|
|
911
|
-
analytics?: CoreStatefulAnalyticsConfig;
|
|
912
|
-
/**
|
|
913
|
-
* Configuration for the personalization (Experience) API client plus stateful queue behavior.
|
|
609
|
+
* @param payload - Entry hover builder arguments.
|
|
610
|
+
* @returns A promise that resolves when processing completes.
|
|
611
|
+
* @example
|
|
612
|
+
* ```ts
|
|
613
|
+
* await core.trackHover({ componentId: 'entry-123' })
|
|
614
|
+
* ```
|
|
914
615
|
*/
|
|
915
|
-
|
|
616
|
+
trackHover(payload: HoverBuilderArgs): Promise<void>;
|
|
916
617
|
/**
|
|
917
|
-
*
|
|
618
|
+
* Track a feature flag view through Insights.
|
|
918
619
|
*
|
|
919
|
-
* @
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
getAnonymousId?: PersonalizationProductConfig['getAnonymousId'];
|
|
926
|
-
/**
|
|
927
|
-
* Callback invoked whenever an event call is blocked by checks.
|
|
620
|
+
* @param payload - Flag view builder arguments used to build the flag view event.
|
|
621
|
+
* @returns A promise that resolves when processing completes.
|
|
622
|
+
* @example
|
|
623
|
+
* ```ts
|
|
624
|
+
* await core.trackFlagView({ componentId: 'feature-flag-123' })
|
|
625
|
+
* ```
|
|
928
626
|
*/
|
|
929
|
-
|
|
627
|
+
trackFlagView(payload: FlagViewBuilderArgs): Promise<void>;
|
|
628
|
+
hasConsent(name: string): boolean;
|
|
629
|
+
onBlockedByConsent(name: string, args: readonly unknown[]): void;
|
|
630
|
+
protected sendExperienceEvent(method: string, args: readonly unknown[], event: ExperienceEvent, _profile?: PartialProfile): Promise<OptimizationData | undefined>;
|
|
631
|
+
protected sendInsightsEvent(method: string, args: readonly unknown[], event: InsightsEvent, _profile?: PartialProfile): Promise<void>;
|
|
632
|
+
private buildFlagViewBuilderArgs;
|
|
633
|
+
protected getFlagObservable(name: string): Observable<Json>;
|
|
634
|
+
private reportBlockedEvent;
|
|
930
635
|
}
|
|
931
636
|
|
|
932
637
|
/**
|
|
933
|
-
*
|
|
638
|
+
* Core runtime for stateless environments.
|
|
934
639
|
*
|
|
935
640
|
* @public
|
|
641
|
+
* Built on top of `CoreBase`. Event-emitting methods are exposed directly on
|
|
642
|
+
* the stateless instance and accept request-scoped Experience options as a
|
|
643
|
+
* separate final argument.
|
|
644
|
+
* @remarks
|
|
645
|
+
* The runtime itself is stateless, but event methods still perform outbound
|
|
646
|
+
* Experience and Insights API calls. Cache Contentful delivery data in the
|
|
647
|
+
* host application, not the results of those calls.
|
|
936
648
|
*/
|
|
937
|
-
export declare
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
649
|
+
export declare class CoreStateless extends CoreBase<CoreStatelessConfig> {
|
|
650
|
+
constructor(config: CoreStatelessConfig);
|
|
651
|
+
identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
652
|
+
page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
653
|
+
screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
654
|
+
track(payload: StatelessExperiencePayload<TrackBuilderArgs>, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData>;
|
|
655
|
+
trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload, requestOptions?: CoreStatelessRequestOptions): Promise<OptimizationData | undefined>;
|
|
656
|
+
trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
657
|
+
trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
658
|
+
trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>, _requestOptions?: CoreStatelessRequestOptions): Promise<void>;
|
|
659
|
+
private sendExperienceEvent;
|
|
660
|
+
private sendInsightsEvent;
|
|
661
|
+
}
|
|
945
662
|
|
|
946
663
|
/**
|
|
947
|
-
*
|
|
664
|
+
* API configuration for stateless Core runtimes.
|
|
948
665
|
*
|
|
949
666
|
* @public
|
|
950
|
-
* @see {@link CoreBase}
|
|
951
667
|
*/
|
|
952
|
-
export declare
|
|
953
|
-
/** Stateless analytics product. */
|
|
954
|
-
protected _analytics: AnalyticsStateless;
|
|
955
|
-
/** Stateless personalization product. */
|
|
956
|
-
protected _personalization: PersonalizationStateless;
|
|
957
|
-
/**
|
|
958
|
-
* Create a stateless core. Product instances share the same API client and
|
|
959
|
-
* event builder configured in {@link CoreBase}.
|
|
960
|
-
*
|
|
961
|
-
* @param config - Stateless Core configuration.
|
|
962
|
-
* @example
|
|
963
|
-
* ```ts
|
|
964
|
-
* const sdk = new CoreStateless({ clientId: 'app', environment: 'prod' })
|
|
965
|
-
* core.trackFlagView({ componentId: 'hero' })
|
|
966
|
-
* ```
|
|
967
|
-
*/
|
|
968
|
-
constructor(config: CoreStatelessConfig);
|
|
668
|
+
export declare interface CoreStatelessApiConfig extends CoreSharedApiConfig {
|
|
969
669
|
}
|
|
970
670
|
|
|
971
671
|
/**
|
|
972
|
-
* Configuration for
|
|
672
|
+
* Configuration for stateless Optimization Core runtimes.
|
|
973
673
|
*
|
|
974
674
|
* @public
|
|
975
675
|
* @remarks
|
|
@@ -979,10 +679,9 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
979
679
|
*/
|
|
980
680
|
export declare interface CoreStatelessConfig extends CoreConfig {
|
|
981
681
|
/**
|
|
982
|
-
*
|
|
983
|
-
* `beaconHandler`.
|
|
682
|
+
* Unified API configuration for stateless environments.
|
|
984
683
|
*/
|
|
985
|
-
|
|
684
|
+
api?: CoreStatelessApiConfig;
|
|
986
685
|
/**
|
|
987
686
|
* Overrides for the event builder configuration. Omits methods that are only
|
|
988
687
|
* useful in stateful environments.
|
|
@@ -990,14 +689,20 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
990
689
|
eventBuilder?: Omit<EventBuilderConfig, 'getLocale' | 'getPageProperties' | 'getUserAgent'>;
|
|
991
690
|
}
|
|
992
691
|
|
|
692
|
+
/**
|
|
693
|
+
* Request-bound Experience API options for stateless runtimes.
|
|
694
|
+
*
|
|
695
|
+
* @public
|
|
696
|
+
*/
|
|
697
|
+
export declare interface CoreStatelessRequestOptions extends Pick<ExperienceApiClientRequestOptions, 'ip' | 'locale' | 'plainText' | 'preflight'> {
|
|
698
|
+
}
|
|
699
|
+
|
|
993
700
|
/**
|
|
994
701
|
* Combined observable state exposed by the stateful core.
|
|
995
702
|
*
|
|
996
703
|
* @public
|
|
997
|
-
* @see {@link AnalyticsStates}
|
|
998
|
-
* @see {@link PersonalizationStates}
|
|
999
704
|
*/
|
|
1000
|
-
export declare interface CoreStates
|
|
705
|
+
export declare interface CoreStates {
|
|
1001
706
|
/** Current consent value (if any). */
|
|
1002
707
|
consent: Observable<boolean | undefined>;
|
|
1003
708
|
/** Whether the preview panel has been attached to the host runtime. */
|
|
@@ -1006,8 +711,16 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
1006
711
|
previewPanelOpen: Observable<boolean>;
|
|
1007
712
|
/** Stream of the most recent blocked event payload. */
|
|
1008
713
|
blockedEventStream: Observable<BlockedEvent | undefined>;
|
|
1009
|
-
/** Stream of the most recent event emitted
|
|
714
|
+
/** Stream of the most recent event emitted. */
|
|
1010
715
|
eventStream: Observable<InsightsEvent | ExperienceEvent | undefined>;
|
|
716
|
+
/** Key-scoped observable for a single Custom Flag value. */
|
|
717
|
+
flag: (name: string) => Observable<Json>;
|
|
718
|
+
/** Live view of the current profile. */
|
|
719
|
+
profile: Observable<Profile | undefined>;
|
|
720
|
+
/** Live view of selected optimizations (variants). */
|
|
721
|
+
selectedOptimizations: Observable<SelectedOptimizationArray | undefined>;
|
|
722
|
+
/** Whether optimization data is currently available. */
|
|
723
|
+
canOptimize: Observable<boolean>;
|
|
1011
724
|
}
|
|
1012
725
|
|
|
1013
726
|
/**
|
|
@@ -1017,522 +730,456 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
1017
730
|
*/
|
|
1018
731
|
export declare const DEBUG_FLAG_KEY = "__ctfl_opt_debug__";
|
|
1019
732
|
|
|
1020
|
-
export { effect }
|
|
1021
|
-
|
|
1022
|
-
declare const event_2: Signal<InsightsEvent | ExperienceEvent | undefined>;
|
|
1023
|
-
|
|
1024
733
|
/**
|
|
1025
|
-
*
|
|
734
|
+
* Default page properties used when no explicit page information is available.
|
|
735
|
+
*
|
|
736
|
+
* @defaultValue
|
|
737
|
+
* ```ts
|
|
738
|
+
* {
|
|
739
|
+
* path: '',
|
|
740
|
+
* query: {},
|
|
741
|
+
* referrer: '',
|
|
742
|
+
* search: '',
|
|
743
|
+
* title: '',
|
|
744
|
+
* url: '',
|
|
745
|
+
* }
|
|
746
|
+
* ```
|
|
747
|
+
*
|
|
748
|
+
* @remarks
|
|
749
|
+
* Values are required by the API; values may not be `undefined`. Empty values are valid.
|
|
1026
750
|
*
|
|
1027
751
|
* @public
|
|
1028
752
|
*/
|
|
1029
|
-
declare
|
|
753
|
+
export declare const DEFAULT_PAGE_PROPERTIES: {
|
|
754
|
+
path: string;
|
|
755
|
+
query: {};
|
|
756
|
+
referrer: string;
|
|
757
|
+
search: string;
|
|
758
|
+
title: string;
|
|
759
|
+
url: string;
|
|
760
|
+
};
|
|
1030
761
|
|
|
1031
|
-
|
|
762
|
+
export { effect }
|
|
1032
763
|
|
|
1033
|
-
|
|
1034
|
-
|
|
764
|
+
export declare const EntryInteractionBuilderArgsBase: z.ZodMiniObject<{
|
|
765
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
766
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
767
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
768
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
769
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
770
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
771
|
+
}, z.core.$strip>>;
|
|
772
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
773
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
774
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
775
|
+
latitude: z.ZodMiniNumber<number>;
|
|
776
|
+
longitude: z.ZodMiniNumber<number>;
|
|
777
|
+
}, z.core.$strip>>;
|
|
778
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
779
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
780
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
781
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
782
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
783
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
784
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
785
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
786
|
+
}, z.core.$strip>>;
|
|
787
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
788
|
+
path: z.ZodMiniString<string>;
|
|
789
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
790
|
+
referrer: z.ZodMiniString<string>;
|
|
791
|
+
search: z.ZodMiniString<string>;
|
|
792
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
793
|
+
url: z.ZodMiniString<string>;
|
|
794
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
795
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
796
|
+
name: z.ZodMiniString<string>;
|
|
797
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
798
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
799
|
+
componentId: z.ZodMiniString<string>;
|
|
800
|
+
experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
801
|
+
variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
802
|
+
}, z.core.$strip>;
|
|
803
|
+
|
|
804
|
+
/**
|
|
805
|
+
* Arguments shared by entry view, click, and hover events.
|
|
1035
806
|
*
|
|
1036
807
|
* @public
|
|
1037
|
-
* @remarks
|
|
1038
|
-
* Given an Optimization {@link ChangeArray}, this utility flattens the list into a
|
|
1039
|
-
* simple key–value object suitable for quick lookups in client code. When `changes`
|
|
1040
|
-
* is `undefined`, an empty object is returned. If a change value is wrapped in an
|
|
1041
|
-
* object like `{ value: { ... } }`, this resolver unwraps it to the underlying object.
|
|
1042
808
|
*/
|
|
1043
|
-
export declare
|
|
1044
|
-
/**
|
|
1045
|
-
* Build a flattened map of flag keys to values from a change list.
|
|
1046
|
-
*
|
|
1047
|
-
* @param changes - The change list returned by the optimization service.
|
|
1048
|
-
* @returns A map of flag keys to their resolved values.
|
|
1049
|
-
* @example
|
|
1050
|
-
* ```ts
|
|
1051
|
-
* const flags = FlagsResolver.resolve(data.changes)
|
|
1052
|
-
* if (flags['theme'] === 'dark') enableDarkMode()
|
|
1053
|
-
* ```
|
|
1054
|
-
* @example
|
|
1055
|
-
* // Handles wrapped values produced by the API
|
|
1056
|
-
* ```ts
|
|
1057
|
-
* const flags = FlagsResolver.resolve([
|
|
1058
|
-
* { type: 'Variable', key: 'price', value: { value: { amount: 10, currency: 'USD' } } }
|
|
1059
|
-
* ])
|
|
1060
|
-
* console.log(flags.price.amount) // 10
|
|
1061
|
-
* ```
|
|
1062
|
-
*/
|
|
1063
|
-
resolve(changes?: ChangeArray): Flags;
|
|
1064
|
-
};
|
|
809
|
+
export declare type EntryInteractionBuilderArgsBase = z.infer<typeof EntryInteractionBuilderArgsBase>;
|
|
1065
810
|
|
|
1066
811
|
/**
|
|
1067
|
-
*
|
|
1068
|
-
*
|
|
1069
|
-
* When a decorated method is invoked:
|
|
1070
|
-
* - If the predicate returns a value that evaluates to **allowed** (see `invert`), the original
|
|
1071
|
-
* method is executed and its result is returned.
|
|
1072
|
-
* - If the call is **blocked**, the optional `onBlocked` hook is invoked (if configured) and:
|
|
1073
|
-
* - `undefined` is returned for sync methods; or
|
|
1074
|
-
* - `Promise<undefined>` is returned for async methods (to preserve `await` compatibility).
|
|
1075
|
-
*
|
|
1076
|
-
* @typeParam T - The instance type that owns both the predicate and the decorated method.
|
|
1077
|
-
*
|
|
1078
|
-
* @param predicateName - The name (string or symbol) of a **synchronous** instance method on `this`
|
|
1079
|
-
* that acts as the predicate. It is called as `this[predicateName](methodName, argsArray)`.
|
|
1080
|
-
* @param opts - Optional {@link GuardedByOptions | options} to configure inversion and `onBlocked`.
|
|
1081
|
-
*
|
|
1082
|
-
* @returns A methods-only class decorator compatible with Stage-3 decorators that wraps the method.
|
|
1083
|
-
*
|
|
1084
|
-
* @throws TypeError
|
|
1085
|
-
* Thrown at initialization time (first instance construction) if `predicateName` does not resolve
|
|
1086
|
-
* to a **synchronous function** on the instance.
|
|
1087
|
-
*
|
|
1088
|
-
* @remarks
|
|
1089
|
-
* - This is a **methods-only** decorator; applying it to accessors/fields is a no-op.
|
|
1090
|
-
* - The decorator preserves the original method's sync/async shape.
|
|
1091
|
-
* - The predicate is invoked with `(decoratedMethodName, argsArray)` to support context-aware checks.
|
|
1092
|
-
*
|
|
1093
|
-
* @example
|
|
1094
|
-
* Here, `canRun` allows the call when it returns truthy:
|
|
1095
|
-
* ```ts
|
|
1096
|
-
* class Runner {
|
|
1097
|
-
* canRun(method: string, _args: readonly unknown[]) { return method !== 'stop'; }
|
|
1098
|
-
*
|
|
1099
|
-
* @guardedBy<Runner>('canRun')
|
|
1100
|
-
* go() { console.log('running'); }
|
|
1101
|
-
* }
|
|
1102
|
-
* ```
|
|
1103
|
-
*
|
|
1104
|
-
* @example
|
|
1105
|
-
* Invert the predicate and call a handler on block:
|
|
1106
|
-
* ```ts
|
|
1107
|
-
* class Door {
|
|
1108
|
-
* isLocked() { return true } // truthy means "locked"
|
|
1109
|
-
* onBlocked(method: string) { console.warn(`${method} blocked`) }
|
|
1110
|
-
*
|
|
1111
|
-
* @guardedBy<Door>('isLocked', { invert: true, onBlocked: 'onBlocked' })
|
|
1112
|
-
* open() { /* ... *\/ }
|
|
1113
|
-
* }
|
|
1114
|
-
* ```
|
|
812
|
+
* Most recent emitted optimization event.
|
|
1115
813
|
*
|
|
1116
814
|
* @public
|
|
1117
815
|
*/
|
|
1118
|
-
|
|
816
|
+
declare const event_2: Signal<InsightsEvent | ExperienceEvent | undefined>;
|
|
1119
817
|
|
|
1120
818
|
/**
|
|
1121
|
-
*
|
|
1122
|
-
*
|
|
1123
|
-
* @typeParam A - The parameter tuple of the original method.
|
|
1124
|
-
* @typeParam R - The return type of the original method.
|
|
1125
|
-
* @param value - The method being decorated.
|
|
1126
|
-
* @param context - The Stage-3 decorator context for a class method.
|
|
1127
|
-
* @returns Nothing.
|
|
819
|
+
* Helper class for building optimization events.
|
|
1128
820
|
*
|
|
1129
821
|
* @remarks
|
|
1130
|
-
*
|
|
1131
|
-
*
|
|
1132
|
-
*
|
|
1133
|
-
*/
|
|
1134
|
-
declare type GuardedByFunction<T extends object> = <A extends readonly unknown[], R>(value: (...args: A) => R, context: ClassMethodDecoratorContext<T, (...args: A) => R>) => void;
|
|
1135
|
-
|
|
1136
|
-
/**
|
|
1137
|
-
* Options that tweak the behavior of {@link guardedBy}.
|
|
822
|
+
* This class coordinates configuration and argument validation to produce
|
|
823
|
+
* strongly-typed event payloads compatible with
|
|
824
|
+
* `@contentful/optimization-api-schemas`.
|
|
1138
825
|
*
|
|
1139
|
-
* @
|
|
826
|
+
* @see {@link EventBuilderConfig}
|
|
1140
827
|
*
|
|
1141
828
|
* @public
|
|
1142
829
|
*/
|
|
1143
|
-
declare
|
|
830
|
+
export declare class EventBuilder {
|
|
1144
831
|
/**
|
|
1145
|
-
*
|
|
832
|
+
* Application metadata attached to each event.
|
|
1146
833
|
*
|
|
1147
|
-
*
|
|
1148
|
-
|
|
834
|
+
* @internal
|
|
835
|
+
*/
|
|
836
|
+
app?: App;
|
|
837
|
+
/**
|
|
838
|
+
* Channel value attached to each event.
|
|
1149
839
|
*
|
|
1150
|
-
* @
|
|
1151
|
-
* @remarks
|
|
1152
|
-
* This option is useful when the predicate expresses a *forbid* condition
|
|
1153
|
-
* (e.g. "isLocked" or "isDestroyed") rather than an *allow* condition.
|
|
840
|
+
* @internal
|
|
1154
841
|
*/
|
|
1155
|
-
|
|
842
|
+
channel: Channel;
|
|
1156
843
|
/**
|
|
1157
|
-
*
|
|
1158
|
-
* an instance method on `this` to call when blocked.
|
|
844
|
+
* Library metadata attached to each event.
|
|
1159
845
|
*
|
|
1160
|
-
*
|
|
1161
|
-
|
|
1162
|
-
|
|
846
|
+
* @internal
|
|
847
|
+
*/
|
|
848
|
+
library: Library;
|
|
849
|
+
/**
|
|
850
|
+
* Function that provides the locale when available.
|
|
1163
851
|
*
|
|
1164
|
-
* @
|
|
1165
|
-
* - If a property key is supplied and the instance does not have a callable at that key,
|
|
1166
|
-
* the hook is ignored.
|
|
1167
|
-
* - The hook **must not** be `async`; any async work should be scheduled manually.
|
|
852
|
+
* @internal
|
|
1168
853
|
*/
|
|
1169
|
-
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
/**
|
|
1173
|
-
* A function that receives a value of type `T` and returns a (possibly async)
|
|
1174
|
-
* value of the same type `T`. The input is marked as `readonly` to discourage
|
|
1175
|
-
* mutation of the original object.
|
|
1176
|
-
*
|
|
1177
|
-
* @typeParam T - The value type intercepted and returned.
|
|
1178
|
-
* @param value - The current (readonly) value in the interception chain.
|
|
1179
|
-
* @returns The next value for the chain, either directly or via a promise.
|
|
1180
|
-
* @remarks Implementations SHOULD avoid mutating `value` and instead return a
|
|
1181
|
-
* new or safely-updated instance.
|
|
1182
|
-
* @see {@link InterceptorManager}
|
|
1183
|
-
* @public
|
|
1184
|
-
*/
|
|
1185
|
-
export declare type Interceptor<T> = (value: Readonly<T>) => MaybePromise<T>;
|
|
1186
|
-
|
|
1187
|
-
/**
|
|
1188
|
-
* Manages a list of interceptors and provides a way to run them in sequence.
|
|
1189
|
-
*
|
|
1190
|
-
* Interceptors are executed in insertion order. Each interceptor receives the
|
|
1191
|
-
* result of the previous interceptor (or the initial input for the first one)
|
|
1192
|
-
* and may return a new value synchronously or asynchronously.
|
|
1193
|
-
*
|
|
1194
|
-
* @typeParam T - The value type processed by the interceptors.
|
|
1195
|
-
* @remarks This class snapshots the current interceptor list at invocation time
|
|
1196
|
-
* so additions/removals during `run` do not affect the in-flight execution.
|
|
1197
|
-
* @example
|
|
1198
|
-
* ```ts
|
|
1199
|
-
* const mgr = new InterceptorManager<number>();
|
|
1200
|
-
* const id = mgr.add((n) => n + 1);
|
|
1201
|
-
* const final = await mgr.run(1); // 2
|
|
1202
|
-
* mgr.remove(id);
|
|
1203
|
-
* ```
|
|
1204
|
-
* @public
|
|
1205
|
-
*/
|
|
1206
|
-
export declare class InterceptorManager<T> {
|
|
854
|
+
getLocale: () => string | undefined;
|
|
1207
855
|
/**
|
|
1208
|
-
*
|
|
856
|
+
* Function that provides baseline page properties.
|
|
1209
857
|
*
|
|
1210
|
-
* @
|
|
1211
|
-
* {@link clear} to manage contents.
|
|
1212
|
-
* @readonly
|
|
1213
|
-
* @defaultValue `new Map()`
|
|
858
|
+
* @internal
|
|
1214
859
|
*/
|
|
1215
|
-
|
|
860
|
+
getPageProperties: () => Page;
|
|
1216
861
|
/**
|
|
1217
|
-
*
|
|
862
|
+
* Function that provides the user agent string when available.
|
|
1218
863
|
*
|
|
1219
|
-
* @
|
|
1220
|
-
* @defaultValue `0`
|
|
864
|
+
* @internal
|
|
1221
865
|
*/
|
|
1222
|
-
|
|
866
|
+
getUserAgent: () => string | undefined;
|
|
1223
867
|
/**
|
|
1224
|
-
*
|
|
868
|
+
* Creates a new {@link EventBuilder} instance.
|
|
869
|
+
*
|
|
870
|
+
* @param config - Configuration used to customize event payloads.
|
|
871
|
+
*
|
|
872
|
+
* @remarks
|
|
873
|
+
* Callers are expected to reuse a single instance when possible to avoid
|
|
874
|
+
* repeatedly reconfiguring the builder.
|
|
1225
875
|
*
|
|
1226
|
-
* @param interceptor - The interceptor function to register.
|
|
1227
|
-
* @returns The numeric id that can later be used with {@link remove}.
|
|
1228
|
-
* @remarks Interceptors are executed in the order they are added.
|
|
1229
876
|
* @example
|
|
1230
877
|
* ```ts
|
|
1231
|
-
* const
|
|
878
|
+
* const builder = new EventBuilder({
|
|
879
|
+
* channel: 'web',
|
|
880
|
+
* library: { name: '@contentful/optimization-sdk', version: '1.0.0' },
|
|
881
|
+
* })
|
|
1232
882
|
* ```
|
|
1233
|
-
* @public
|
|
1234
883
|
*/
|
|
1235
|
-
|
|
884
|
+
constructor(config: EventBuilderConfig);
|
|
1236
885
|
/**
|
|
1237
|
-
*
|
|
886
|
+
* Builds the universal event properties shared across all event types.
|
|
887
|
+
*
|
|
888
|
+
* @param args - Arguments overriding the default context values.
|
|
889
|
+
* @returns A fully populated {@link UniversalEventProperties} object.
|
|
890
|
+
*
|
|
891
|
+
* @remarks
|
|
892
|
+
* This method is used internally by the specific event-builder methods
|
|
893
|
+
* (e.g. {@link EventBuilder.buildPageView}).
|
|
894
|
+
*/
|
|
895
|
+
protected buildUniversalEventProperties({ campaign, locale, location, page, screen, userAgent, }: UniversalEventBuilderArgs): UniversalEventProperties;
|
|
896
|
+
private buildEntryInteractionBase;
|
|
897
|
+
/**
|
|
898
|
+
* Builds a `component` view event payload for entry exposure tracking.
|
|
899
|
+
*
|
|
900
|
+
* @param args - {@link ViewBuilderArgs} arguments describing the entry view.
|
|
901
|
+
* @returns A {@link ViewEvent} describing the view.
|
|
1238
902
|
*
|
|
1239
|
-
* @param id - The id previously returned by {@link add}.
|
|
1240
|
-
* @returns `true` if an interceptor was removed; otherwise `false`.
|
|
1241
903
|
* @example
|
|
1242
904
|
* ```ts
|
|
1243
|
-
* const
|
|
905
|
+
* const event = builder.buildView({
|
|
906
|
+
* componentId: 'entry-123',
|
|
907
|
+
* viewId: crypto.randomUUID(),
|
|
908
|
+
* experienceId: 'experience-123',
|
|
909
|
+
* variantIndex: 1,
|
|
910
|
+
* viewDurationMs: 1_000,
|
|
911
|
+
* })
|
|
1244
912
|
* ```
|
|
913
|
+
*
|
|
1245
914
|
* @public
|
|
1246
915
|
*/
|
|
1247
|
-
|
|
916
|
+
buildView(args: ViewBuilderArgs): ViewEvent;
|
|
1248
917
|
/**
|
|
1249
|
-
*
|
|
918
|
+
* Builds a `component_click` payload for entry click tracking.
|
|
919
|
+
*
|
|
920
|
+
* @param args - {@link ClickBuilderArgs} arguments describing the entry click.
|
|
921
|
+
* @returns A {@link ClickEvent} describing the click.
|
|
1250
922
|
*
|
|
1251
|
-
* @returns Nothing.
|
|
1252
|
-
* @remarks After calling this, {@link count} will return `0`.
|
|
1253
923
|
* @example
|
|
1254
924
|
* ```ts
|
|
1255
|
-
*
|
|
925
|
+
* const event = builder.buildClick({
|
|
926
|
+
* componentId: 'entry-123',
|
|
927
|
+
* experienceId: 'experience-123',
|
|
928
|
+
* variantIndex: 1,
|
|
929
|
+
* })
|
|
1256
930
|
* ```
|
|
931
|
+
*
|
|
1257
932
|
* @public
|
|
1258
933
|
*/
|
|
1259
|
-
|
|
934
|
+
buildClick(args: ClickBuilderArgs): ClickEvent;
|
|
1260
935
|
/**
|
|
1261
|
-
*
|
|
936
|
+
* Builds a `component_hover` payload for entry hover tracking.
|
|
937
|
+
*
|
|
938
|
+
* @param args - {@link HoverBuilderArgs} arguments describing the entry hover.
|
|
939
|
+
* @returns A {@link HoverEvent} describing the hover.
|
|
1262
940
|
*
|
|
1263
|
-
* @returns The count of interceptors.
|
|
1264
941
|
* @example
|
|
1265
942
|
* ```ts
|
|
1266
|
-
*
|
|
943
|
+
* const event = builder.buildHover({
|
|
944
|
+
* componentId: 'entry-123',
|
|
945
|
+
* hoverId: crypto.randomUUID(),
|
|
946
|
+
* experienceId: 'experience-123',
|
|
947
|
+
* hoverDurationMs: 1_000,
|
|
948
|
+
* variantIndex: 1,
|
|
949
|
+
* })
|
|
1267
950
|
* ```
|
|
951
|
+
*
|
|
1268
952
|
* @public
|
|
1269
953
|
*/
|
|
1270
|
-
|
|
954
|
+
buildHover(args: HoverBuilderArgs): HoverEvent;
|
|
1271
955
|
/**
|
|
1272
|
-
*
|
|
956
|
+
* Builds a `component` view event payload for Custom Flag exposure tracking.
|
|
1273
957
|
*
|
|
1274
|
-
*
|
|
1275
|
-
*
|
|
958
|
+
* @param args - {@link FlagViewBuilderArgs} arguments describing the Custom Flag view.
|
|
959
|
+
* @returns A {@link ViewEvent} describing the view.
|
|
960
|
+
*
|
|
961
|
+
* @remarks
|
|
962
|
+
* This is a specialized variant of {@link EventBuilder.buildView}
|
|
963
|
+
* that sets `componentType` to `'Variable'`.
|
|
1276
964
|
*
|
|
1277
|
-
* @param input - The initial value to pass to the first interceptor.
|
|
1278
|
-
* @returns A promise resolving to the final value after all interceptors have run.
|
|
1279
|
-
* @throws May rethrow any error thrown by an interceptor. <!-- Intentionally vague: error type depends on interceptor implementation -->
|
|
1280
|
-
* @remarks The interceptor list is snapshotted at invocation time; changes to
|
|
1281
|
-
* the registry during execution do not affect the running sequence.
|
|
1282
965
|
* @example
|
|
1283
966
|
* ```ts
|
|
1284
|
-
* const
|
|
967
|
+
* const event = builder.buildFlagView({
|
|
968
|
+
* componentId: 'feature-flag-key',
|
|
969
|
+
* viewId: crypto.randomUUID(),
|
|
970
|
+
* experienceId: 'experience-123',
|
|
971
|
+
* viewDurationMs: 1_000,
|
|
972
|
+
* })
|
|
1285
973
|
* ```
|
|
974
|
+
*
|
|
1286
975
|
* @public
|
|
1287
976
|
*/
|
|
1288
|
-
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
/**
|
|
1292
|
-
* Lifecycle container for event and state interceptors.
|
|
1293
|
-
*
|
|
1294
|
-
* @public
|
|
1295
|
-
*/
|
|
1296
|
-
export declare interface LifecycleInterceptors {
|
|
1297
|
-
/** Interceptors invoked for individual events prior to validation/sending. */
|
|
1298
|
-
event: InterceptorManager<InsightsEvent | ExperienceEvent>;
|
|
1299
|
-
/** Interceptors invoked before optimization state updates. */
|
|
1300
|
-
state: InterceptorManager<OptimizationData>;
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
/**
|
|
1304
|
-
* A utility type representing a value that may be synchronously available or
|
|
1305
|
-
* produced asynchronously.
|
|
1306
|
-
*
|
|
1307
|
-
* @typeParam T - The resolved value type.
|
|
1308
|
-
* @public
|
|
1309
|
-
*/
|
|
1310
|
-
declare type MaybePromise<T> = T | Promise<T>;
|
|
1311
|
-
|
|
1312
|
-
/**
|
|
1313
|
-
* Resolves merge tag values from a {@link Profile}.
|
|
1314
|
-
*
|
|
1315
|
-
* @public
|
|
1316
|
-
* @remarks
|
|
1317
|
-
* *Merge tags* are references to user profile data that may be embedded in content
|
|
1318
|
-
* and expanded at runtime. This resolver normalizes the merge-tag identifier into
|
|
1319
|
-
* a set of candidate selectors and searches the profile for a matching value.
|
|
1320
|
-
* Result values are returned as strings; numeric/boolean primitives are stringified.
|
|
1321
|
-
*/
|
|
1322
|
-
export declare const MergeTagValueResolver: {
|
|
977
|
+
buildFlagView(args: FlagViewBuilderArgs): ViewEvent;
|
|
1323
978
|
/**
|
|
1324
|
-
*
|
|
979
|
+
* Builds an identify event payload to associate a user ID with traits.
|
|
980
|
+
*
|
|
981
|
+
* @param args - {@link IdentifyBuilderArgs} arguments describing the identified user.
|
|
982
|
+
* @returns An {@link IdentifyEvent} payload.
|
|
983
|
+
*
|
|
984
|
+
* @remarks
|
|
985
|
+
* - Traits are merged by the API; only specified properties may be overwritten.
|
|
986
|
+
* - The User ID is consumer-specified and should not contain the value of any
|
|
987
|
+
* ID generated by the Experience API.
|
|
1325
988
|
*
|
|
1326
|
-
* @param id - Merge-tag identifier (segments separated by `_`).
|
|
1327
|
-
* @returns Array of dot-path selectors to try against a profile.
|
|
1328
989
|
* @example
|
|
1329
990
|
* ```ts
|
|
1330
|
-
*
|
|
1331
|
-
*
|
|
1332
|
-
*
|
|
1333
|
-
*
|
|
1334
|
-
* // ]
|
|
1335
|
-
* const selectors = MergeTagValueResolver.normalizeSelectors('profile_name_first')
|
|
991
|
+
* const event = builder.buildIdentify({
|
|
992
|
+
* userId: 'user-123',
|
|
993
|
+
* traits: { plan: 'pro' },
|
|
994
|
+
* })
|
|
1336
995
|
* ```
|
|
996
|
+
*
|
|
997
|
+
* @public
|
|
1337
998
|
*/
|
|
1338
|
-
|
|
999
|
+
buildIdentify(args: IdentifyBuilderArgs): IdentifyEvent;
|
|
1339
1000
|
/**
|
|
1340
|
-
*
|
|
1001
|
+
* Builds a page view event payload.
|
|
1002
|
+
*
|
|
1003
|
+
* @param args - Optional {@link PageViewBuilderArgs} overrides for the page view event.
|
|
1004
|
+
* @returns A {@link PageViewEvent} payload.
|
|
1341
1005
|
*
|
|
1342
|
-
* @param id - Merge-tag identifier.
|
|
1343
|
-
* @param profile - Profile from which to resolve the value.
|
|
1344
|
-
* @returns A stringified primitive if found; otherwise `undefined`.
|
|
1345
1006
|
* @remarks
|
|
1346
|
-
*
|
|
1007
|
+
* Page properties are created by merging:
|
|
1008
|
+
* 1. The base page properties from {@link EventBuilderConfig.getPageProperties}, and
|
|
1009
|
+
* 2. The partial `properties` argument passed in.
|
|
1010
|
+
*
|
|
1011
|
+
* The title always falls back to {@link DEFAULT_PAGE_PROPERTIES}.title when undefined.
|
|
1012
|
+
*
|
|
1347
1013
|
* @example
|
|
1348
1014
|
* ```ts
|
|
1349
|
-
* const
|
|
1350
|
-
*
|
|
1015
|
+
* const event = builder.buildPageView({
|
|
1016
|
+
* properties: {
|
|
1017
|
+
* title: 'Homepage',
|
|
1018
|
+
* },
|
|
1019
|
+
* })
|
|
1351
1020
|
* ```
|
|
1021
|
+
*
|
|
1022
|
+
* @public
|
|
1352
1023
|
*/
|
|
1353
|
-
|
|
1024
|
+
buildPageView(args?: PageViewBuilderArgs): PageViewEvent;
|
|
1354
1025
|
/**
|
|
1355
|
-
*
|
|
1356
|
-
*
|
|
1026
|
+
* Builds a screen view event payload.
|
|
1027
|
+
*
|
|
1028
|
+
* @param args - {@link ScreenViewBuilderArgs} arguments for the screen view event.
|
|
1029
|
+
* @returns A {@link ScreenViewEvent} payload.
|
|
1357
1030
|
*
|
|
1358
|
-
* @param mergeTagEntry - The merge-tag entry to resolve.
|
|
1359
|
-
* @param profile - Optional profile used for lookup.
|
|
1360
|
-
* @returns The resolved string, or `undefined` if the entry is invalid and no
|
|
1361
|
-
* fallback is available.
|
|
1362
1031
|
* @example
|
|
1363
1032
|
* ```ts
|
|
1364
|
-
* const
|
|
1365
|
-
*
|
|
1033
|
+
* const event = builder.buildScreenView({
|
|
1034
|
+
* name: 'home',
|
|
1035
|
+
* properties: {
|
|
1036
|
+
* title: 'Home Screen',
|
|
1037
|
+
* },
|
|
1038
|
+
* })
|
|
1366
1039
|
* ```
|
|
1040
|
+
*
|
|
1041
|
+
* @public
|
|
1367
1042
|
*/
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1043
|
+
buildScreenView(args: ScreenViewBuilderArgs): ScreenViewEvent;
|
|
1044
|
+
/**
|
|
1045
|
+
* Builds a track event payload for arbitrary user actions.
|
|
1046
|
+
*
|
|
1047
|
+
* @param args - {@link TrackBuilderArgs} arguments describing the tracked event.
|
|
1048
|
+
* @returns A {@link TrackEvent} payload.
|
|
1049
|
+
*
|
|
1050
|
+
* @example
|
|
1051
|
+
* ```ts
|
|
1052
|
+
* const event = builder.buildTrack({
|
|
1053
|
+
* event: 'button_clicked',
|
|
1054
|
+
* properties: { id: 'primary-cta', location: 'hero' },
|
|
1055
|
+
* })
|
|
1056
|
+
* ```
|
|
1057
|
+
*
|
|
1058
|
+
* @public
|
|
1059
|
+
*/
|
|
1060
|
+
buildTrack(args: TrackBuilderArgs): TrackEvent_2;
|
|
1373
1061
|
}
|
|
1374
1062
|
|
|
1375
|
-
declare const online: Signal<boolean | undefined>;
|
|
1376
|
-
|
|
1377
1063
|
/**
|
|
1378
|
-
*
|
|
1064
|
+
* Configuration options for creating an {@link EventBuilder} instance.
|
|
1379
1065
|
*
|
|
1380
|
-
* @
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
/**
|
|
1385
|
-
* The current version of the Optimization Core SDK, injected at build time.
|
|
1066
|
+
* @remarks
|
|
1067
|
+
* The configuration is typically provided by the host application to adapt
|
|
1068
|
+
* event payloads to the runtime environment (browser, framework, etc.).
|
|
1386
1069
|
*
|
|
1387
|
-
* @
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
*
|
|
1070
|
+
* @example
|
|
1071
|
+
* ```ts
|
|
1072
|
+
* const builder = new EventBuilder({
|
|
1073
|
+
* app: { name: 'my-app', version: '1.0.0' },
|
|
1074
|
+
* channel: 'web',
|
|
1075
|
+
* library: { name: '@contentful/optimization-sdk', version: '1.2.3' },
|
|
1076
|
+
* getLocale: () => navigator.language,
|
|
1077
|
+
* getPageProperties: () => ({
|
|
1078
|
+
* path: window.location.pathname,
|
|
1079
|
+
* url: window.location.href,
|
|
1080
|
+
* title: document.title,
|
|
1081
|
+
* query: {},
|
|
1082
|
+
* referrer: document.referrer,
|
|
1083
|
+
* search: window.location.search,
|
|
1084
|
+
* }),
|
|
1085
|
+
* })
|
|
1086
|
+
* ```
|
|
1393
1087
|
*
|
|
1394
|
-
* @
|
|
1395
|
-
* @remarks
|
|
1396
|
-
* Concrete implementations should extend this class to expose public methods for
|
|
1397
|
-
* identify, page, and track events. This base wires in shared singleton
|
|
1398
|
-
* resolvers used to fetch/resolve personalized data.
|
|
1088
|
+
* @public
|
|
1399
1089
|
*/
|
|
1400
|
-
export declare
|
|
1401
|
-
/**
|
|
1402
|
-
* Static {@link FlagsResolver | resolver} for evaluating personalized
|
|
1403
|
-
* custom flags.
|
|
1404
|
-
*/
|
|
1405
|
-
readonly flagsResolver: {
|
|
1406
|
-
resolve(changes?: ChangeArray): Flags;
|
|
1407
|
-
};
|
|
1408
|
-
/**
|
|
1409
|
-
* Static {@link MergeTagValueResolver | resolver} that returns values
|
|
1410
|
-
* sourced from a user profile based on a Contentful Merge Tag entry.
|
|
1411
|
-
*/
|
|
1412
|
-
readonly mergeTagValueResolver: {
|
|
1413
|
-
normalizeSelectors(id: string): string[];
|
|
1414
|
-
getValueFromProfile(id: string, profile?: Profile): string | undefined;
|
|
1415
|
-
resolve(mergeTagEntry: MergeTagEntry | undefined, profile?: Profile): string | undefined;
|
|
1416
|
-
};
|
|
1090
|
+
export declare interface EventBuilderConfig {
|
|
1417
1091
|
/**
|
|
1418
|
-
*
|
|
1419
|
-
* Contentful entries (e.g., entry variants targeted to a profile audience).
|
|
1092
|
+
* The application definition used to attribute events to a specific consumer app.
|
|
1420
1093
|
*
|
|
1421
1094
|
* @remarks
|
|
1422
|
-
*
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
readonly personalizedEntryResolver: {
|
|
1426
|
-
getPersonalizationEntry({ personalizedEntry, selectedPersonalizations, }: {
|
|
1427
|
-
personalizedEntry: PersonalizedEntry;
|
|
1428
|
-
selectedPersonalizations: SelectedPersonalizationArray;
|
|
1429
|
-
}, skipValidation?: boolean): PersonalizationEntry | undefined;
|
|
1430
|
-
getSelectedPersonalization({ personalizationEntry, selectedPersonalizations, }: {
|
|
1431
|
-
personalizationEntry: PersonalizationEntry;
|
|
1432
|
-
selectedPersonalizations: SelectedPersonalizationArray;
|
|
1433
|
-
}, skipValidation?: boolean): SelectedPersonalization_2 | undefined;
|
|
1434
|
-
getSelectedVariant({ personalizedEntry, personalizationEntry, selectedVariantIndex, }: {
|
|
1435
|
-
personalizedEntry: PersonalizedEntry;
|
|
1436
|
-
personalizationEntry: PersonalizationEntry;
|
|
1437
|
-
selectedVariantIndex: number;
|
|
1438
|
-
}, skipValidation?: boolean): EntryReplacementVariant | undefined;
|
|
1439
|
-
getSelectedVariantEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>({ personalizationEntry, selectedVariant, }: {
|
|
1440
|
-
personalizationEntry: PersonalizationEntry;
|
|
1441
|
-
selectedVariant: EntryReplacementVariant;
|
|
1442
|
-
}, skipValidation?: boolean): Entry<S, M, L> | undefined;
|
|
1443
|
-
resolve<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>(entry: Entry<S, M, L>, selectedPersonalizations?: SelectedPersonalizationArray): ResolvedData<S, M, L>;
|
|
1444
|
-
};
|
|
1445
|
-
/**
|
|
1446
|
-
* Get the specified Custom Flag's value from the supplied changes.
|
|
1447
|
-
* @param name - The name/key of the Custom Flag.
|
|
1448
|
-
* @param changes - Optional changes array.
|
|
1449
|
-
* @returns The current value of the Custom Flag if found.
|
|
1450
|
-
* @remarks
|
|
1451
|
-
* The changes array can be sourced from the data returned when emitting any
|
|
1452
|
-
* personalization event.
|
|
1453
|
-
* */
|
|
1454
|
-
getCustomFlag(name: string, changes?: ChangeArray): Json;
|
|
1455
|
-
/**
|
|
1456
|
-
* Get all resolved Custom Flags from the supplied changes.
|
|
1457
|
-
* @param changes - Optional changes array.
|
|
1458
|
-
* @returns The resolved Custom Flag map.
|
|
1459
|
-
* @remarks
|
|
1460
|
-
* The changes array can be sourced from the data returned when emitting any
|
|
1461
|
-
* personalization event.
|
|
1462
|
-
* */
|
|
1463
|
-
getCustomFlags(changes?: ChangeArray): Flags;
|
|
1095
|
+
* When not provided, events will not contain app metadata in their context.
|
|
1096
|
+
*/
|
|
1097
|
+
app?: App;
|
|
1464
1098
|
/**
|
|
1465
|
-
*
|
|
1466
|
-
* or provided selected personalizations.
|
|
1099
|
+
* The channel that identifies where events originate from (e.g. web, mobile).
|
|
1467
1100
|
*
|
|
1468
|
-
* @
|
|
1469
|
-
* @typeParam M - Chain modifiers.
|
|
1470
|
-
* @typeParam L - Locale code.
|
|
1471
|
-
* @param entry - The entry to personalize.
|
|
1472
|
-
* @param personalizations - Optional selected personalizations.
|
|
1473
|
-
* @returns The resolved entry data.
|
|
1474
|
-
* @remarks
|
|
1475
|
-
* Selected personalizations can be sourced from the data returned when emitting any
|
|
1476
|
-
* personalization event.
|
|
1101
|
+
* @see {@link Channel}
|
|
1477
1102
|
*/
|
|
1478
|
-
|
|
1103
|
+
channel: Channel;
|
|
1479
1104
|
/**
|
|
1480
|
-
*
|
|
1105
|
+
* The client library metadata that is attached to all events.
|
|
1481
1106
|
*
|
|
1482
|
-
* @param embeddedEntryNodeTarget - The merge tag entry node to resolve.
|
|
1483
|
-
* @param profile - Optional profile.
|
|
1484
|
-
* @returns The resolved value (type depends on the tag).
|
|
1485
1107
|
* @remarks
|
|
1486
|
-
*
|
|
1487
|
-
* profile can be sourced from the data returned when emitting any personalization event.
|
|
1108
|
+
* This is typically used to record the library name and version.
|
|
1488
1109
|
*/
|
|
1489
|
-
|
|
1110
|
+
library: Library;
|
|
1490
1111
|
/**
|
|
1491
|
-
*
|
|
1112
|
+
* Function used to resolve the locale for outgoing events.
|
|
1492
1113
|
*
|
|
1493
|
-
* @
|
|
1494
|
-
*
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
/**
|
|
1498
|
-
* Record a page view.
|
|
1114
|
+
* @remarks
|
|
1115
|
+
* If not provided, the builder falls back to the default `'en-US'`. Locale
|
|
1116
|
+
* values supplied directly as arguments to event builder methods take
|
|
1117
|
+
* precedence.
|
|
1499
1118
|
*
|
|
1500
|
-
* @
|
|
1501
|
-
* @returns The evaluated {@link OptimizationData} for this page view if the device is online.
|
|
1119
|
+
* @returns The locale string (e.g. `'en-US'`), or `undefined` if unavailable.
|
|
1502
1120
|
*/
|
|
1503
|
-
|
|
1121
|
+
getLocale?: () => string | undefined;
|
|
1504
1122
|
/**
|
|
1505
|
-
*
|
|
1123
|
+
* Function that returns the current page properties.
|
|
1124
|
+
*
|
|
1125
|
+
* @remarks
|
|
1126
|
+
* Page properties are currently added to the context of all events, as well
|
|
1127
|
+
* as the `properties` of the page event. When specified, all properties of
|
|
1128
|
+
* the `Page` type are required, but may contain empty values.
|
|
1506
1129
|
*
|
|
1507
|
-
* @
|
|
1508
|
-
* @
|
|
1130
|
+
* @returns A {@link Page} object containing information about the current page.
|
|
1131
|
+
* @see {@link Page}
|
|
1509
1132
|
*/
|
|
1510
|
-
|
|
1133
|
+
getPageProperties?: () => Page;
|
|
1511
1134
|
/**
|
|
1512
|
-
*
|
|
1135
|
+
* Function used to obtain the current user agent string when applicable.
|
|
1513
1136
|
*
|
|
1514
|
-
* @
|
|
1515
|
-
* @returns The evaluated {@link OptimizationData} for this event if the device is online.
|
|
1137
|
+
* @returns A user agent string, or `undefined` if unavailable.
|
|
1516
1138
|
*/
|
|
1517
|
-
|
|
1518
|
-
/**
|
|
1519
|
-
* Record a "sticky" component view.
|
|
1520
|
-
*
|
|
1521
|
-
* @param payload - "Sticky" component view builder payload.
|
|
1522
|
-
* @returns The evaluated {@link OptimizationData} for this component view if the device is online.
|
|
1523
|
-
* @remarks
|
|
1524
|
-
* This method is intended to be called only when a component is considered
|
|
1525
|
-
* "sticky".
|
|
1526
|
-
*/
|
|
1527
|
-
abstract trackComponentView(payload: ComponentViewBuilderArgs): Promise<OptimizationData | undefined>;
|
|
1139
|
+
getUserAgent?: () => string | undefined;
|
|
1528
1140
|
}
|
|
1529
1141
|
|
|
1530
1142
|
/**
|
|
1531
|
-
*
|
|
1143
|
+
* Union of all event type keys that stateful Core may emit.
|
|
1532
1144
|
*
|
|
1533
1145
|
* @public
|
|
1534
1146
|
*/
|
|
1535
|
-
export declare
|
|
1147
|
+
export declare type EventType = InsightsEventType | ExperienceEventType;
|
|
1148
|
+
|
|
1149
|
+
/**
|
|
1150
|
+
* Internal Experience send/offline runtime used by {@link CoreStateful}.
|
|
1151
|
+
*
|
|
1152
|
+
* @internal
|
|
1153
|
+
*/
|
|
1154
|
+
declare class ExperienceQueue {
|
|
1155
|
+
private readonly experienceApi;
|
|
1156
|
+
private readonly eventInterceptors;
|
|
1157
|
+
private readonly flushRuntime;
|
|
1158
|
+
private readonly getAnonymousId;
|
|
1159
|
+
private readonly offlineMaxEvents;
|
|
1160
|
+
private readonly onOfflineDrop?;
|
|
1161
|
+
private readonly queuedExperienceEvents;
|
|
1162
|
+
private readonly stateInterceptors;
|
|
1163
|
+
constructor(options: ExperienceQueueOptions);
|
|
1164
|
+
clearScheduledRetry(): void;
|
|
1165
|
+
send(event: ExperienceEvent): Promise<OptimizationData | undefined>;
|
|
1166
|
+
flush(options?: {
|
|
1167
|
+
force?: boolean;
|
|
1168
|
+
}): Promise<void>;
|
|
1169
|
+
private enqueueEvent;
|
|
1170
|
+
private dropOldestEvents;
|
|
1171
|
+
private invokeOfflineDropCallback;
|
|
1172
|
+
private tryUpsertQueuedEvents;
|
|
1173
|
+
private upsertProfile;
|
|
1174
|
+
private updateOutputSignals;
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Context payload emitted when offline Experience events are dropped.
|
|
1179
|
+
*
|
|
1180
|
+
* @public
|
|
1181
|
+
*/
|
|
1182
|
+
export declare interface ExperienceQueueDropContext {
|
|
1536
1183
|
/** Number of dropped events. */
|
|
1537
1184
|
droppedCount: number;
|
|
1538
1185
|
/** Dropped events in oldest-first order. */
|
|
@@ -1543,533 +1190,682 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
1543
1190
|
queuedEvents: number;
|
|
1544
1191
|
}
|
|
1545
1192
|
|
|
1193
|
+
declare interface ExperienceQueueOptions {
|
|
1194
|
+
experienceApi: {
|
|
1195
|
+
upsertProfile: (payload: {
|
|
1196
|
+
profileId?: string;
|
|
1197
|
+
events: ExperienceEventArray;
|
|
1198
|
+
}) => Promise<OptimizationData>;
|
|
1199
|
+
};
|
|
1200
|
+
eventInterceptors: LifecycleInterceptors['event'];
|
|
1201
|
+
flushPolicy: ResolvedQueueFlushPolicy;
|
|
1202
|
+
getAnonymousId: () => string | undefined;
|
|
1203
|
+
offlineMaxEvents: number;
|
|
1204
|
+
onOfflineDrop?: (context: ExperienceQueueDropContext) => void;
|
|
1205
|
+
stateInterceptors: LifecycleInterceptors['state'];
|
|
1206
|
+
}
|
|
1207
|
+
|
|
1546
1208
|
/**
|
|
1547
|
-
*
|
|
1209
|
+
* Resolves a {@link Flags} map from a list of optimization changes.
|
|
1548
1210
|
*
|
|
1549
1211
|
* @public
|
|
1212
|
+
* @remarks
|
|
1213
|
+
* Given an Optimization {@link ChangeArray}, this utility flattens the list into a
|
|
1214
|
+
* simple key–value object suitable for quick lookups in client code. When `changes`
|
|
1215
|
+
* is `undefined`, an empty object is returned. If a change value is wrapped in an
|
|
1216
|
+
* object like `{ value: { ... } }`, this resolver unwraps it to the underlying object.
|
|
1550
1217
|
*/
|
|
1551
|
-
export declare
|
|
1552
|
-
/** Default signal values applied during initialization. */
|
|
1553
|
-
defaults?: PersonalizationProductConfigDefaults;
|
|
1554
|
-
/**
|
|
1555
|
-
* Policy that controls the offline personalization queue size and drop telemetry.
|
|
1556
|
-
*/
|
|
1557
|
-
queuePolicy?: PersonalizationQueuePolicy;
|
|
1218
|
+
export declare const FlagsResolver: {
|
|
1558
1219
|
/**
|
|
1559
|
-
*
|
|
1560
|
-
*
|
|
1561
|
-
* @remarks
|
|
1562
|
-
* If a `getAnonymousId` function has been provided, the returned value will
|
|
1563
|
-
* take precedence over the `id` property of the current {@link Profile}
|
|
1564
|
-
* signal value
|
|
1220
|
+
* Build a flattened map of flag keys to values from a change list.
|
|
1565
1221
|
*
|
|
1566
|
-
* @
|
|
1222
|
+
* @param changes - The change list returned by the optimization service.
|
|
1223
|
+
* @returns A map of flag keys to their resolved values.
|
|
1224
|
+
* @example
|
|
1225
|
+
* ```ts
|
|
1226
|
+
* const flags = FlagsResolver.resolve(data.changes)
|
|
1227
|
+
* if (flags['theme'] === 'dark') enableDarkMode()
|
|
1228
|
+
* ```
|
|
1229
|
+
* @example
|
|
1230
|
+
* // Handles wrapped values produced by the API
|
|
1231
|
+
* ```ts
|
|
1232
|
+
* const flags = FlagsResolver.resolve([
|
|
1233
|
+
* { type: 'Variable', key: 'price', value: { value: { amount: 10, currency: 'USD' } } }
|
|
1234
|
+
* ])
|
|
1235
|
+
* console.log(flags.price.amount) // 10
|
|
1236
|
+
* ```
|
|
1567
1237
|
*/
|
|
1568
|
-
|
|
1569
|
-
}
|
|
1238
|
+
resolve(changes?: ChangeArray): Flags_2;
|
|
1239
|
+
};
|
|
1570
1240
|
|
|
1571
|
-
|
|
1572
|
-
|
|
1241
|
+
export declare const FlagViewBuilderArgs: z.ZodMiniObject<{
|
|
1242
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1243
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1244
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1245
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1246
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1247
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1248
|
+
}, z.core.$strip>>;
|
|
1249
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1250
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1251
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1252
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1253
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1254
|
+
}, z.core.$strip>>;
|
|
1255
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1256
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1257
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1258
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1259
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1260
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1261
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1262
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1263
|
+
}, z.core.$strip>>;
|
|
1264
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1265
|
+
path: z.ZodMiniString<string>;
|
|
1266
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1267
|
+
referrer: z.ZodMiniString<string>;
|
|
1268
|
+
search: z.ZodMiniString<string>;
|
|
1269
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1270
|
+
url: z.ZodMiniString<string>;
|
|
1271
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1272
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1273
|
+
name: z.ZodMiniString<string>;
|
|
1274
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1275
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1276
|
+
componentId: z.ZodMiniString<string>;
|
|
1277
|
+
experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1278
|
+
variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
1279
|
+
viewId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1280
|
+
viewDurationMs: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
1281
|
+
}, z.core.$strip>;
|
|
1282
|
+
|
|
1283
|
+
/**
|
|
1284
|
+
* Arguments for constructing Custom Flag view events.
|
|
1573
1285
|
*
|
|
1574
1286
|
* @public
|
|
1575
1287
|
*/
|
|
1576
|
-
export declare
|
|
1577
|
-
/** Whether personalization is allowed by default. */
|
|
1578
|
-
consent?: boolean;
|
|
1579
|
-
/** Initial diff of changes produced by the service. */
|
|
1580
|
-
changes?: ChangeArray;
|
|
1581
|
-
/** Default active profile used for personalization. */
|
|
1582
|
-
profile?: Profile;
|
|
1583
|
-
/** Preselected personalization variants (e.g., winning treatments). */
|
|
1584
|
-
personalizations?: SelectedPersonalizationArray;
|
|
1585
|
-
}
|
|
1288
|
+
export declare type FlagViewBuilderArgs = z.infer<typeof FlagViewBuilderArgs>;
|
|
1586
1289
|
|
|
1587
1290
|
/**
|
|
1588
|
-
*
|
|
1291
|
+
* Decorator factory that **guards** class methods behind a synchronous predicate.
|
|
1292
|
+
*
|
|
1293
|
+
* When a decorated method is invoked:
|
|
1294
|
+
* - If the predicate returns a value that evaluates to **allowed** (see `invert`), the original
|
|
1295
|
+
* method is executed and its result is returned.
|
|
1296
|
+
* - If the call is **blocked**, the optional `onBlocked` hook is invoked (if configured) and:
|
|
1297
|
+
* - `undefined` is returned for sync methods; or
|
|
1298
|
+
* - `Promise<undefined>` is returned for async methods (to preserve `await` compatibility).
|
|
1299
|
+
*
|
|
1300
|
+
* @typeParam T - The instance type that owns both the predicate and the decorated method.
|
|
1301
|
+
*
|
|
1302
|
+
* @param predicateName - The name (string or symbol) of a **synchronous** instance method on `this`
|
|
1303
|
+
* that acts as the predicate. It is called as `this[predicateName](methodName, argsArray)`.
|
|
1304
|
+
* @param opts - Optional `GuardedByOptions` to configure inversion and `onBlocked`.
|
|
1305
|
+
*
|
|
1306
|
+
* @returns A methods-only class decorator compatible with Stage-3 decorators that wraps the method.
|
|
1307
|
+
*
|
|
1308
|
+
* @throws TypeError
|
|
1309
|
+
* Thrown at initialization time (first instance construction) if `predicateName` does not resolve
|
|
1310
|
+
* to a **synchronous function** on the instance.
|
|
1311
|
+
*
|
|
1312
|
+
* @remarks
|
|
1313
|
+
* - This is a **methods-only** decorator; applying it to accessors/fields is a no-op.
|
|
1314
|
+
* - The decorator preserves the original method's sync/async shape.
|
|
1315
|
+
* - The predicate is invoked with `(decoratedMethodName, argsArray)` to support context-aware checks.
|
|
1316
|
+
*
|
|
1317
|
+
* @example
|
|
1318
|
+
* Here, `canRun` allows the call when it returns truthy:
|
|
1319
|
+
* ```ts
|
|
1320
|
+
* class Runner {
|
|
1321
|
+
* canRun(method: string, _args: readonly unknown[]) { return method !== 'stop'; }
|
|
1322
|
+
*
|
|
1323
|
+
* @guardedBy<Runner>('canRun')
|
|
1324
|
+
* go() { console.log('running'); }
|
|
1325
|
+
* }
|
|
1326
|
+
* ```
|
|
1327
|
+
*
|
|
1328
|
+
* @example
|
|
1329
|
+
* Invert the predicate and call a handler on block:
|
|
1330
|
+
* ```ts
|
|
1331
|
+
* class Door {
|
|
1332
|
+
* isLocked() { return true } // truthy means "locked"
|
|
1333
|
+
* onBlocked(method: string) { console.warn(`${method} blocked`) }
|
|
1334
|
+
*
|
|
1335
|
+
* @guardedBy<Door>('isLocked', { invert: true, onBlocked: 'onBlocked' })
|
|
1336
|
+
* open() { /* ... *\/ }
|
|
1337
|
+
* }
|
|
1338
|
+
* ```
|
|
1589
1339
|
*
|
|
1590
1340
|
* @public
|
|
1591
1341
|
*/
|
|
1592
|
-
export declare
|
|
1593
|
-
/**
|
|
1594
|
-
* Maximum number of personalization events retained while offline.
|
|
1595
|
-
*/
|
|
1596
|
-
maxEvents?: number;
|
|
1597
|
-
/**
|
|
1598
|
-
* Callback invoked whenever oldest events are dropped due to queue bounds.
|
|
1599
|
-
*/
|
|
1600
|
-
onDrop?: (context: PersonalizationOfflineQueueDropContext) => void;
|
|
1601
|
-
/**
|
|
1602
|
-
* Policy that controls offline queue flush retries, backoff, and circuit
|
|
1603
|
-
* behavior after repeated failures.
|
|
1604
|
-
*/
|
|
1605
|
-
flushPolicy?: QueueFlushPolicy;
|
|
1606
|
-
}
|
|
1607
|
-
|
|
1608
|
-
declare const personalizations: Signal<{
|
|
1609
|
-
experienceId: string;
|
|
1610
|
-
variantIndex: number;
|
|
1611
|
-
variants: Record<string, string>;
|
|
1612
|
-
sticky?: boolean | undefined;
|
|
1613
|
-
}[] | undefined>;
|
|
1342
|
+
export declare function guardedBy<T extends object>(predicateName: keyof T & (string | symbol), opts?: GuardedByOptions<T>): GuardedByFunction<T>;
|
|
1614
1343
|
|
|
1615
1344
|
/**
|
|
1616
|
-
*
|
|
1345
|
+
* The original method implementation.
|
|
1346
|
+
*
|
|
1347
|
+
* @typeParam A - The parameter tuple of the original method.
|
|
1348
|
+
* @typeParam R - The return type of the original method.
|
|
1349
|
+
* @param value - The method being decorated.
|
|
1350
|
+
* @param context - The Stage-3 decorator context for a class method.
|
|
1351
|
+
* @returns Nothing.
|
|
1352
|
+
*
|
|
1353
|
+
* @remarks
|
|
1354
|
+
* Users do not call this directly; it's returned by {@link guardedBy}.
|
|
1617
1355
|
*
|
|
1618
1356
|
* @internal
|
|
1619
1357
|
*/
|
|
1620
|
-
export declare
|
|
1358
|
+
export declare type GuardedByFunction<T extends object> = <A extends readonly unknown[], R>(value: (...args: A) => R, context: ClassMethodDecoratorContext<T, (...args: A) => R>) => void;
|
|
1621
1359
|
|
|
1622
1360
|
/**
|
|
1623
|
-
*
|
|
1624
|
-
*
|
|
1361
|
+
* Options that tweak the behavior of {@link guardedBy}.
|
|
1362
|
+
*
|
|
1363
|
+
* @typeParam T - The instance type on which the decorator is applied.
|
|
1625
1364
|
*
|
|
1626
1365
|
* @public
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
* {@link PersonalizationStateful.states}. Events are validated via schema parsers and
|
|
1630
|
-
* run through interceptors before being submitted. Resulting state is merged
|
|
1631
|
-
* back into signals.
|
|
1632
|
-
*/
|
|
1633
|
-
export declare class PersonalizationStateful extends PersonalizationBase implements ConsentGuard {
|
|
1634
|
-
/** In-memory ordered queue for offline personalization events. */
|
|
1635
|
-
private readonly offlineQueue;
|
|
1636
|
-
/** Resolved offline queue policy values. */
|
|
1637
|
-
private readonly queuePolicy;
|
|
1638
|
-
/** Shared queue flush retry runtime state machine. */
|
|
1639
|
-
private readonly flushRuntime;
|
|
1640
|
-
/** Exposed observable state references. */
|
|
1641
|
-
readonly states: PersonalizationStates;
|
|
1642
|
-
/**
|
|
1643
|
-
* Function that provides an anonymous ID when available.
|
|
1644
|
-
*
|
|
1645
|
-
* @internal
|
|
1646
|
-
*/
|
|
1647
|
-
getAnonymousId: () => string | undefined;
|
|
1366
|
+
*/
|
|
1367
|
+
export declare interface GuardedByOptions<T extends object> {
|
|
1648
1368
|
/**
|
|
1649
|
-
*
|
|
1369
|
+
* Inverts the predicate result.
|
|
1650
1370
|
*
|
|
1651
|
-
*
|
|
1652
|
-
*
|
|
1653
|
-
* ```ts
|
|
1654
|
-
* const personalization = new PersonalizationStateful({ api, builder, config: { getAnonymousId }, interceptors })
|
|
1655
|
-
* ```
|
|
1656
|
-
*/
|
|
1657
|
-
constructor(options: PersonalizationStatefulOptions);
|
|
1658
|
-
/**
|
|
1659
|
-
* Reset stateful signals managed by this product.
|
|
1371
|
+
* When `true`, a truthy predicate result **blocks** the method.
|
|
1372
|
+
* When `false` (default) or omitted, a truthy predicate result **allows** the method.
|
|
1660
1373
|
*
|
|
1374
|
+
* @defaultValue `false`
|
|
1661
1375
|
* @remarks
|
|
1662
|
-
*
|
|
1663
|
-
*
|
|
1664
|
-
* ```ts
|
|
1665
|
-
* personalization.reset()
|
|
1666
|
-
* ```
|
|
1667
|
-
*/
|
|
1668
|
-
reset(): void;
|
|
1669
|
-
/**
|
|
1670
|
-
* Get the specified Custom Flag's value (derived from the signal).
|
|
1671
|
-
* @param name - The name or key of the Custom Flag.
|
|
1672
|
-
* @returns The current value of the Custom Flag if found.
|
|
1673
|
-
* @example
|
|
1674
|
-
* ```ts
|
|
1675
|
-
* const flagValue = personalization.getCustomFlag('dark-mode')
|
|
1676
|
-
* ```
|
|
1677
|
-
* */
|
|
1678
|
-
getCustomFlag(name: string, changes?: ChangeArray | undefined): Json;
|
|
1679
|
-
/**
|
|
1680
|
-
* Get all resolved Custom Flags (derived from the signal).
|
|
1681
|
-
* @param changes - Optional changes array; defaults to the current signal value.
|
|
1682
|
-
* @returns The resolved Custom Flag map.
|
|
1683
|
-
* @example
|
|
1684
|
-
* ```ts
|
|
1685
|
-
* const flags = personalization.getCustomFlags()
|
|
1686
|
-
* ```
|
|
1376
|
+
* This option is useful when the predicate expresses a *forbid* condition
|
|
1377
|
+
* (e.g. "isLocked" or "isDestroyed") rather than an *allow* condition.
|
|
1687
1378
|
*/
|
|
1688
|
-
|
|
1379
|
+
readonly invert?: boolean;
|
|
1689
1380
|
/**
|
|
1690
|
-
*
|
|
1691
|
-
*
|
|
1381
|
+
* Either a function to call when a method is blocked, or the name/symbol of
|
|
1382
|
+
* an instance method on `this` to call when blocked.
|
|
1692
1383
|
*
|
|
1693
|
-
*
|
|
1694
|
-
*
|
|
1695
|
-
*
|
|
1696
|
-
* @param entry - The entry to personalize.
|
|
1697
|
-
* @param personalizations - Optional selections; defaults to the current signal value.
|
|
1698
|
-
* @returns The resolved entry data.
|
|
1699
|
-
* @example
|
|
1700
|
-
* ```ts
|
|
1701
|
-
* const { entry } = personalization.personalizeEntry(baselineEntry)
|
|
1702
|
-
* ```
|
|
1703
|
-
*/
|
|
1704
|
-
personalizeEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, personalizations?: SelectedPersonalizationArray | undefined): ResolvedData<S, M, L>;
|
|
1705
|
-
/**
|
|
1706
|
-
* Resolve a merge tag to a value based on the current (or provided) profile.
|
|
1384
|
+
* Both forms are **synchronous** and receive `(methodName, argsArray)`.
|
|
1385
|
+
* If omitted, blocked calls fail silently (i.e., return `undefined` or
|
|
1386
|
+
* `Promise<undefined>` for async methods).
|
|
1707
1387
|
*
|
|
1708
|
-
* @param embeddedEntryNodeTarget - The merge‑tag entry node to resolve.
|
|
1709
|
-
* @param profile - Optional profile; defaults to the current signal value.
|
|
1710
|
-
* @returns The resolved value (type depends on the tag).
|
|
1711
1388
|
* @remarks
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
*
|
|
1715
|
-
* const name = personalization.getMergeTagValue(mergeTagNode)
|
|
1716
|
-
* ```
|
|
1717
|
-
*/
|
|
1718
|
-
getMergeTagValue(embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile | undefined): string | undefined;
|
|
1719
|
-
/**
|
|
1720
|
-
* Determine whether the named operation is permitted based on consent and
|
|
1721
|
-
* allowed event type configuration.
|
|
1722
|
-
*
|
|
1723
|
-
* @param name - Method name; `trackComponentView` is normalized to
|
|
1724
|
-
* `'component'` for allow‑list checks.
|
|
1725
|
-
* @returns `true` if the operation is permitted; otherwise `false`.
|
|
1726
|
-
* @example
|
|
1727
|
-
* ```ts
|
|
1728
|
-
* if (personalization.hasConsent('track')) { ... }
|
|
1729
|
-
* ```
|
|
1389
|
+
* - If a property key is supplied and the instance does not have a callable at that key,
|
|
1390
|
+
* the hook is ignored.
|
|
1391
|
+
* - The hook **must not** be `async`; any async work should be scheduled manually.
|
|
1730
1392
|
*/
|
|
1731
|
-
|
|
1393
|
+
readonly onBlocked?: BlockHandler | (keyof T & (string | symbol));
|
|
1394
|
+
}
|
|
1395
|
+
|
|
1396
|
+
export declare const HoverBuilderArgs: z.ZodMiniObject<{
|
|
1397
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1398
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1399
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1400
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1401
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1402
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1403
|
+
}, z.core.$strip>>;
|
|
1404
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1405
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1406
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1407
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1408
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1409
|
+
}, z.core.$strip>>;
|
|
1410
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1411
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1412
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1413
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1414
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1415
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1416
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1417
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1418
|
+
}, z.core.$strip>>;
|
|
1419
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1420
|
+
path: z.ZodMiniString<string>;
|
|
1421
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1422
|
+
referrer: z.ZodMiniString<string>;
|
|
1423
|
+
search: z.ZodMiniString<string>;
|
|
1424
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1425
|
+
url: z.ZodMiniString<string>;
|
|
1426
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1427
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1428
|
+
name: z.ZodMiniString<string>;
|
|
1429
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1430
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1431
|
+
componentId: z.ZodMiniString<string>;
|
|
1432
|
+
experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1433
|
+
variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
1434
|
+
hoverId: z.ZodMiniString<string>;
|
|
1435
|
+
hoverDurationMs: z.ZodMiniNumber<number>;
|
|
1436
|
+
}, z.core.$strip>;
|
|
1437
|
+
|
|
1438
|
+
/**
|
|
1439
|
+
* Arguments for constructing entry hover events.
|
|
1440
|
+
*
|
|
1441
|
+
* @public
|
|
1442
|
+
*/
|
|
1443
|
+
export declare type HoverBuilderArgs = z.infer<typeof HoverBuilderArgs>;
|
|
1444
|
+
|
|
1445
|
+
export declare const IdentifyBuilderArgs: z.ZodMiniObject<{
|
|
1446
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1447
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1448
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1449
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1450
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1451
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1452
|
+
}, z.core.$strip>>;
|
|
1453
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1454
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1455
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1456
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1457
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1458
|
+
}, z.core.$strip>>;
|
|
1459
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1460
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1461
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1462
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1463
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1464
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1465
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1466
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1467
|
+
}, z.core.$strip>>;
|
|
1468
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1469
|
+
path: z.ZodMiniString<string>;
|
|
1470
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1471
|
+
referrer: z.ZodMiniString<string>;
|
|
1472
|
+
search: z.ZodMiniString<string>;
|
|
1473
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1474
|
+
url: z.ZodMiniString<string>;
|
|
1475
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1476
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1477
|
+
name: z.ZodMiniString<string>;
|
|
1478
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1479
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1480
|
+
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>>;
|
|
1481
|
+
userId: z.ZodMiniString<string>;
|
|
1482
|
+
}, z.core.$strip>;
|
|
1483
|
+
|
|
1484
|
+
/**
|
|
1485
|
+
* Arguments for constructing identify events.
|
|
1486
|
+
*
|
|
1487
|
+
* @remarks
|
|
1488
|
+
* Traits are merged by the API; only specified properties may be overwritten.
|
|
1489
|
+
*
|
|
1490
|
+
* @public
|
|
1491
|
+
*/
|
|
1492
|
+
export declare type IdentifyBuilderArgs = z.infer<typeof IdentifyBuilderArgs>;
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* Internal Insights queueing and flush runtime used by {@link CoreStateful}.
|
|
1496
|
+
*
|
|
1497
|
+
* @internal
|
|
1498
|
+
*/
|
|
1499
|
+
declare class InsightsQueue {
|
|
1500
|
+
private readonly eventInterceptors;
|
|
1501
|
+
private readonly flushIntervalMs;
|
|
1502
|
+
private readonly flushRuntime;
|
|
1503
|
+
private readonly insightsApi;
|
|
1504
|
+
private readonly queuedInsightsByProfile;
|
|
1505
|
+
private insightsPeriodicFlushTimer;
|
|
1506
|
+
constructor(options: InsightsQueueOptions);
|
|
1507
|
+
clearScheduledRetry(): void;
|
|
1508
|
+
clearPeriodicFlushTimer(): void;
|
|
1509
|
+
send(event: InsightsEvent): Promise<void>;
|
|
1510
|
+
flush(options?: {
|
|
1511
|
+
force?: boolean;
|
|
1512
|
+
}): Promise<void>;
|
|
1513
|
+
private createBatches;
|
|
1514
|
+
private trySendBatches;
|
|
1515
|
+
private getQueuedEventCount;
|
|
1516
|
+
private ensurePeriodicFlushTimer;
|
|
1517
|
+
private reconcilePeriodicFlushTimer;
|
|
1518
|
+
}
|
|
1519
|
+
|
|
1520
|
+
declare interface InsightsQueueOptions {
|
|
1521
|
+
eventInterceptors: LifecycleInterceptors['event'];
|
|
1522
|
+
flushPolicy: ResolvedQueueFlushPolicy;
|
|
1523
|
+
insightsApi: {
|
|
1524
|
+
sendBatchEvents: (batches: BatchInsightsEventArray) => Promise<boolean>;
|
|
1525
|
+
};
|
|
1526
|
+
}
|
|
1527
|
+
|
|
1528
|
+
/**
|
|
1529
|
+
* A function that receives a value of type `T` and returns a (possibly async)
|
|
1530
|
+
* value of the same type `T`. The input is marked as `readonly` to discourage
|
|
1531
|
+
* mutation of the original object.
|
|
1532
|
+
*
|
|
1533
|
+
* @typeParam T - The value type intercepted and returned.
|
|
1534
|
+
* @param value - The current (readonly) value in the interception chain.
|
|
1535
|
+
* @returns The next value for the chain, either directly or via a promise.
|
|
1536
|
+
* @remarks Implementations SHOULD avoid mutating `value` and instead return a
|
|
1537
|
+
* new or safely-updated instance.
|
|
1538
|
+
* @see {@link InterceptorManager}
|
|
1539
|
+
* @public
|
|
1540
|
+
*/
|
|
1541
|
+
export declare type Interceptor<T> = (value: Readonly<T>) => MaybePromise<T>;
|
|
1542
|
+
|
|
1543
|
+
/**
|
|
1544
|
+
* Manages a list of interceptors and provides a way to run them in sequence.
|
|
1545
|
+
*
|
|
1546
|
+
* Interceptors are executed in insertion order. Each interceptor receives the
|
|
1547
|
+
* result of the previous interceptor (or the initial input for the first one)
|
|
1548
|
+
* and may return a new value synchronously or asynchronously.
|
|
1549
|
+
*
|
|
1550
|
+
* @typeParam T - The value type processed by the interceptors.
|
|
1551
|
+
* @remarks This class snapshots the current interceptor list at invocation time
|
|
1552
|
+
* so additions/removals during `run` do not affect the in-flight execution.
|
|
1553
|
+
* @example
|
|
1554
|
+
* ```ts
|
|
1555
|
+
* const mgr = new InterceptorManager<number>();
|
|
1556
|
+
* const id = mgr.add((n) => n + 1);
|
|
1557
|
+
* const final = await mgr.run(1); // 2
|
|
1558
|
+
* mgr.remove(id);
|
|
1559
|
+
* ```
|
|
1560
|
+
* @public
|
|
1561
|
+
*/
|
|
1562
|
+
export declare class InterceptorManager<T> {
|
|
1732
1563
|
/**
|
|
1733
|
-
*
|
|
1564
|
+
* The registry of interceptors keyed by their insertion id.
|
|
1734
1565
|
*
|
|
1735
|
-
* @
|
|
1736
|
-
* @
|
|
1737
|
-
* @
|
|
1738
|
-
*
|
|
1739
|
-
* personalization.onBlockedByConsent('track', [payload])
|
|
1740
|
-
* ```
|
|
1566
|
+
* @privateRemarks Internal storage; use {@link add}, {@link remove}, and
|
|
1567
|
+
* {@link clear} to manage contents.
|
|
1568
|
+
* @readonly
|
|
1569
|
+
* @defaultValue `new Map()`
|
|
1741
1570
|
*/
|
|
1742
|
-
|
|
1571
|
+
private readonly interceptors;
|
|
1743
1572
|
/**
|
|
1744
|
-
*
|
|
1745
|
-
* and update optimization state.
|
|
1573
|
+
* The next numeric id to assign to an added interceptor.
|
|
1746
1574
|
*
|
|
1747
|
-
* @
|
|
1748
|
-
* @
|
|
1749
|
-
* @example
|
|
1750
|
-
* ```ts
|
|
1751
|
-
* const data = await personalization.identify({ userId: 'user-123' })
|
|
1752
|
-
* ```
|
|
1575
|
+
* @privateRemarks Used only to generate unique, monotonically increasing ids.
|
|
1576
|
+
* @defaultValue `0`
|
|
1753
1577
|
*/
|
|
1754
|
-
|
|
1578
|
+
private nextId;
|
|
1755
1579
|
/**
|
|
1756
|
-
*
|
|
1580
|
+
* Add an interceptor and return its identifier.
|
|
1757
1581
|
*
|
|
1758
|
-
* @param
|
|
1759
|
-
* @returns The
|
|
1582
|
+
* @param interceptor - The interceptor function to register.
|
|
1583
|
+
* @returns The numeric id that can later be used with {@link remove}.
|
|
1584
|
+
* @remarks Interceptors are executed in the order they are added.
|
|
1760
1585
|
* @example
|
|
1761
1586
|
* ```ts
|
|
1762
|
-
* const
|
|
1587
|
+
* const id = manager.add(async (value) => transform(value));
|
|
1763
1588
|
* ```
|
|
1589
|
+
* @public
|
|
1764
1590
|
*/
|
|
1765
|
-
|
|
1591
|
+
add(interceptor: Interceptor<T>): number;
|
|
1766
1592
|
/**
|
|
1767
|
-
*
|
|
1593
|
+
* Remove an interceptor by its identifier.
|
|
1768
1594
|
*
|
|
1769
|
-
* @param
|
|
1770
|
-
* @returns
|
|
1595
|
+
* @param id - The id previously returned by {@link add}.
|
|
1596
|
+
* @returns `true` if an interceptor was removed; otherwise `false`.
|
|
1771
1597
|
* @example
|
|
1772
1598
|
* ```ts
|
|
1773
|
-
* const
|
|
1599
|
+
* const removed = manager.remove(id);
|
|
1774
1600
|
* ```
|
|
1601
|
+
* @public
|
|
1775
1602
|
*/
|
|
1776
|
-
|
|
1603
|
+
remove(id: number): boolean;
|
|
1777
1604
|
/**
|
|
1778
|
-
*
|
|
1605
|
+
* Remove all registered interceptors.
|
|
1779
1606
|
*
|
|
1780
|
-
* @
|
|
1781
|
-
* @
|
|
1607
|
+
* @returns Nothing.
|
|
1608
|
+
* @remarks After calling this, {@link count} will return `0`.
|
|
1782
1609
|
* @example
|
|
1783
1610
|
* ```ts
|
|
1784
|
-
*
|
|
1611
|
+
* manager.clear();
|
|
1785
1612
|
* ```
|
|
1613
|
+
* @public
|
|
1786
1614
|
*/
|
|
1787
|
-
|
|
1615
|
+
clear(): void;
|
|
1788
1616
|
/**
|
|
1789
|
-
*
|
|
1617
|
+
* Get the number of currently registered interceptors.
|
|
1790
1618
|
*
|
|
1791
|
-
* @
|
|
1792
|
-
* @returns The evaluated {@link OptimizationData} for this component view.
|
|
1619
|
+
* @returns The count of interceptors.
|
|
1793
1620
|
* @example
|
|
1794
1621
|
* ```ts
|
|
1795
|
-
*
|
|
1622
|
+
* if (manager.count() === 0) { /* ... *\/ }
|
|
1796
1623
|
* ```
|
|
1624
|
+
* @public
|
|
1797
1625
|
*/
|
|
1798
|
-
|
|
1799
|
-
/**
|
|
1800
|
-
* Intercept, validate, and place an event into the offline event queue; then
|
|
1801
|
-
* trigger a size‑based flush if necessary.
|
|
1802
|
-
*
|
|
1803
|
-
* @param event - The event to enqueue.
|
|
1804
|
-
*/
|
|
1805
|
-
private sendOrEnqueueEvent;
|
|
1806
|
-
/**
|
|
1807
|
-
* Enqueue an offline event, dropping oldest events first when queue bounds are reached.
|
|
1808
|
-
*
|
|
1809
|
-
* @param event - Event to enqueue.
|
|
1810
|
-
*/
|
|
1811
|
-
private enqueueOfflineEvent;
|
|
1812
|
-
/**
|
|
1813
|
-
* Drop oldest offline events from the queue.
|
|
1814
|
-
*
|
|
1815
|
-
* @param count - Number of oldest events to drop.
|
|
1816
|
-
* @returns Dropped events in oldest-first order.
|
|
1817
|
-
*/
|
|
1818
|
-
private dropOldestOfflineEvents;
|
|
1819
|
-
/**
|
|
1820
|
-
* Invoke offline queue drop callback in a fault-tolerant manner.
|
|
1821
|
-
*
|
|
1822
|
-
* @param context - Drop callback payload.
|
|
1823
|
-
*/
|
|
1824
|
-
private invokeQueueDropCallback;
|
|
1626
|
+
count(): number;
|
|
1825
1627
|
/**
|
|
1826
|
-
*
|
|
1628
|
+
* Run all interceptors in sequence on an input value and return the final result.
|
|
1827
1629
|
*
|
|
1828
|
-
*
|
|
1829
|
-
*
|
|
1630
|
+
* Supports both sync and async interceptors; the return type is always `Promise<T>`
|
|
1631
|
+
* for consistency.
|
|
1830
1632
|
*
|
|
1633
|
+
* @param input - The initial value to pass to the first interceptor.
|
|
1634
|
+
* @returns A promise resolving to the final value after all interceptors have run.
|
|
1635
|
+
* @throws May rethrow any error thrown by an interceptor. <!-- Intentionally vague: error type depends on interceptor implementation -->
|
|
1636
|
+
* @remarks The interceptor list is snapshotted at invocation time; changes to
|
|
1637
|
+
* the registry during execution do not affect the running sequence.
|
|
1831
1638
|
* @example
|
|
1832
1639
|
* ```ts
|
|
1833
|
-
* await
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
force?: boolean;
|
|
1837
|
-
}): Promise<void>;
|
|
1838
|
-
/**
|
|
1839
|
-
* Flush queued offline events using retry/circuit guards.
|
|
1840
|
-
*
|
|
1841
|
-
* @param options - Flush controls.
|
|
1842
|
-
* @param options.force - When true, bypass online/backoff/circuit gates.
|
|
1843
|
-
*/
|
|
1844
|
-
private flushOfflineQueue;
|
|
1845
|
-
/**
|
|
1846
|
-
* Attempt to send queued events to the Experience API.
|
|
1847
|
-
*
|
|
1848
|
-
* @param events - Snapshot of queued events to send.
|
|
1849
|
-
* @returns `true` when send succeeds; otherwise `false`.
|
|
1850
|
-
*/
|
|
1851
|
-
private tryUpsertQueuedEvents;
|
|
1852
|
-
/**
|
|
1853
|
-
* Submit events to the Experience API, updating output signals with the
|
|
1854
|
-
* returned state.
|
|
1855
|
-
*
|
|
1856
|
-
* @param events - The events to submit.
|
|
1857
|
-
* @returns The {@link OptimizationData} returned by the service.
|
|
1858
|
-
* @internal
|
|
1859
|
-
* @privateRemarks
|
|
1860
|
-
* If a `getAnonymousId` function has been provided, the returned value will
|
|
1861
|
-
* take precedence over the `id` property of the current {@link Profile}
|
|
1862
|
-
* signal value
|
|
1863
|
-
*/
|
|
1864
|
-
private upsertProfile;
|
|
1865
|
-
/**
|
|
1866
|
-
* Apply returned optimization state to local signals after interceptor processing.
|
|
1867
|
-
*
|
|
1868
|
-
* @param data - Optimization state returned by the service.
|
|
1869
|
-
* @internal
|
|
1640
|
+
* const result = await manager.run(initial);
|
|
1641
|
+
* ```
|
|
1642
|
+
* @public
|
|
1870
1643
|
*/
|
|
1871
|
-
|
|
1644
|
+
run(input: T): Promise<T>;
|
|
1645
|
+
}
|
|
1646
|
+
|
|
1647
|
+
/**
|
|
1648
|
+
* Lifecycle container for event and state interceptors.
|
|
1649
|
+
*
|
|
1650
|
+
* @public
|
|
1651
|
+
*/
|
|
1652
|
+
export declare interface LifecycleInterceptors {
|
|
1653
|
+
/** Interceptors invoked for individual events prior to validation/sending. */
|
|
1654
|
+
event: InterceptorManager<InsightsEvent | ExperienceEvent>;
|
|
1655
|
+
/** Interceptors invoked before optimization state updates. */
|
|
1656
|
+
state: InterceptorManager<OptimizationData>;
|
|
1872
1657
|
}
|
|
1873
1658
|
|
|
1874
1659
|
/**
|
|
1875
|
-
*
|
|
1660
|
+
* A utility type representing a value that may be synchronously available or
|
|
1661
|
+
* produced asynchronously.
|
|
1876
1662
|
*
|
|
1663
|
+
* @typeParam T - The resolved value type.
|
|
1877
1664
|
* @public
|
|
1878
|
-
* @see {@link ProductBaseOptions}
|
|
1879
1665
|
*/
|
|
1880
|
-
export declare type
|
|
1881
|
-
/** Configuration specific to the Personalization product */
|
|
1882
|
-
config?: PersonalizationProductConfig;
|
|
1883
|
-
};
|
|
1666
|
+
export declare type MaybePromise<T> = T | Promise<T>;
|
|
1884
1667
|
|
|
1885
1668
|
/**
|
|
1886
|
-
*
|
|
1887
|
-
* a single event to the Experience API, upserting the profile as needed.
|
|
1669
|
+
* Resolves merge tag values from a {@link Profile}.
|
|
1888
1670
|
*
|
|
1889
1671
|
* @public
|
|
1890
1672
|
* @remarks
|
|
1891
|
-
*
|
|
1892
|
-
*
|
|
1893
|
-
*
|
|
1894
|
-
*
|
|
1673
|
+
* *Merge tags* are references to user profile data that may be embedded in content
|
|
1674
|
+
* and expanded at runtime. This resolver normalizes the merge-tag identifier into
|
|
1675
|
+
* a set of candidate selectors and searches the profile for a matching value.
|
|
1676
|
+
* Result values are returned as strings; numeric/boolean primitives are stringified.
|
|
1895
1677
|
*/
|
|
1896
|
-
export declare
|
|
1678
|
+
export declare const MergeTagValueResolver: {
|
|
1897
1679
|
/**
|
|
1898
|
-
*
|
|
1680
|
+
* Generate a list of candidate selectors for a merge-tag ID.
|
|
1899
1681
|
*
|
|
1900
|
-
* @param
|
|
1901
|
-
*
|
|
1902
|
-
* @returns The resulting {@link OptimizationData} for the identified user.
|
|
1682
|
+
* @param id - Merge-tag identifier (segments separated by `_`).
|
|
1683
|
+
* @returns Array of dot-path selectors to try against a profile.
|
|
1903
1684
|
* @example
|
|
1904
1685
|
* ```ts
|
|
1905
|
-
*
|
|
1686
|
+
* // "profile_name_first" -> [
|
|
1687
|
+
* // 'profile',
|
|
1688
|
+
* // 'profile.name',
|
|
1689
|
+
* // 'profile.name.first'
|
|
1690
|
+
* // ]
|
|
1691
|
+
* const selectors = MergeTagValueResolver.normalizeSelectors('profile_name_first')
|
|
1906
1692
|
* ```
|
|
1907
1693
|
*/
|
|
1908
|
-
|
|
1909
|
-
profile?: PartialProfile;
|
|
1910
|
-
}): Promise<OptimizationData>;
|
|
1694
|
+
normalizeSelectors(id: string): string[];
|
|
1911
1695
|
/**
|
|
1912
|
-
*
|
|
1696
|
+
* Look up a merge-tag value from a profile using normalized selectors.
|
|
1913
1697
|
*
|
|
1914
|
-
* @param
|
|
1915
|
-
* @
|
|
1698
|
+
* @param id - Merge-tag identifier.
|
|
1699
|
+
* @param profile - Profile from which to resolve the value.
|
|
1700
|
+
* @returns A stringified primitive if found; otherwise `undefined`.
|
|
1701
|
+
* @remarks
|
|
1702
|
+
* Only string/number/boolean primitives are returned; objects/arrays are ignored.
|
|
1916
1703
|
* @example
|
|
1917
1704
|
* ```ts
|
|
1918
|
-
* const
|
|
1705
|
+
* const value = MergeTagValueResolver.getValueFromProfile('user_email', profile)
|
|
1706
|
+
* if (value) sendEmailTo(value)
|
|
1919
1707
|
* ```
|
|
1920
1708
|
*/
|
|
1921
|
-
|
|
1922
|
-
profile?: PartialProfile;
|
|
1923
|
-
}): Promise<OptimizationData>;
|
|
1709
|
+
getValueFromProfile(id: string, profile?: Profile): string | undefined;
|
|
1924
1710
|
/**
|
|
1925
|
-
*
|
|
1711
|
+
* Resolve the display value for a merge-tag entry using the provided profile,
|
|
1712
|
+
* falling back to the entry's configured `nt_fallback` when necessary.
|
|
1926
1713
|
*
|
|
1927
|
-
* @param
|
|
1928
|
-
* @
|
|
1714
|
+
* @param mergeTagEntry - The merge-tag entry to resolve.
|
|
1715
|
+
* @param profile - Optional profile used for lookup.
|
|
1716
|
+
* @returns The resolved string, or `undefined` if the entry is invalid and no
|
|
1717
|
+
* fallback is available.
|
|
1718
|
+
* @remarks
|
|
1719
|
+
* The resolved value depends on the current request profile, so callers
|
|
1720
|
+
* should not reuse rendered output across users or requests unless the
|
|
1721
|
+
* cache varies on the same profile inputs.
|
|
1929
1722
|
* @example
|
|
1930
1723
|
* ```ts
|
|
1931
|
-
* const
|
|
1724
|
+
* const text = MergeTagValueResolver.resolve(entry, profile)
|
|
1725
|
+
* render(text ?? 'Guest')
|
|
1932
1726
|
* ```
|
|
1933
1727
|
*/
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1728
|
+
resolve(mergeTagEntry: MergeTagEntry | undefined, profile?: Profile): string | undefined;
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
/**
|
|
1732
|
+
* Minimal observable contract used by stateful Core signal streams.
|
|
1733
|
+
*
|
|
1734
|
+
* @typeParam T - Value type emitted by the observable.
|
|
1735
|
+
* @public
|
|
1736
|
+
*/
|
|
1737
|
+
export declare interface Observable<T> {
|
|
1937
1738
|
/**
|
|
1938
|
-
*
|
|
1739
|
+
* Deep-cloned snapshot of the current signal value.
|
|
1939
1740
|
*
|
|
1940
|
-
* @
|
|
1941
|
-
*
|
|
1942
|
-
*
|
|
1943
|
-
* ```ts
|
|
1944
|
-
* const data = await personalization.track({ event: 'purchase', profile: { id: 'anon-1' } })
|
|
1945
|
-
* ```
|
|
1741
|
+
* @remarks
|
|
1742
|
+
* A clone is returned to prevent accidental in-place mutations from leaking
|
|
1743
|
+
* back into internal signal state.
|
|
1946
1744
|
*/
|
|
1947
|
-
|
|
1948
|
-
profile?: PartialProfile;
|
|
1949
|
-
}): Promise<OptimizationData>;
|
|
1745
|
+
readonly current: T;
|
|
1950
1746
|
/**
|
|
1951
|
-
*
|
|
1747
|
+
* Subscribe to all value updates (including the current value immediately).
|
|
1952
1748
|
*
|
|
1953
|
-
* @param
|
|
1954
|
-
* @returns
|
|
1955
|
-
*
|
|
1956
|
-
*
|
|
1957
|
-
*
|
|
1958
|
-
* ```
|
|
1749
|
+
* @param next - Callback invoked for each emitted value snapshot.
|
|
1750
|
+
* @returns A {@link Subscription} used to stop observing updates.
|
|
1751
|
+
*
|
|
1752
|
+
* @remarks
|
|
1753
|
+
* Values are deep-cloned before being passed to `next`.
|
|
1959
1754
|
*/
|
|
1960
|
-
|
|
1961
|
-
profile?: PartialProfile;
|
|
1962
|
-
}): Promise<OptimizationData>;
|
|
1755
|
+
subscribe: (next: (v: T) => void) => Subscription;
|
|
1963
1756
|
/**
|
|
1964
|
-
*
|
|
1965
|
-
* event.
|
|
1757
|
+
* Subscribe to the first non-nullish value, then auto-unsubscribe.
|
|
1966
1758
|
*
|
|
1967
|
-
* @param
|
|
1968
|
-
* @
|
|
1969
|
-
*
|
|
1970
|
-
* @
|
|
1971
|
-
*
|
|
1759
|
+
* @param next - Callback invoked exactly once with the first non-nullish value.
|
|
1760
|
+
* @returns A {@link Subscription} that can cancel before the first emission.
|
|
1761
|
+
*
|
|
1762
|
+
* @remarks
|
|
1763
|
+
* Values are deep-cloned before being passed to `next`.
|
|
1972
1764
|
*/
|
|
1973
|
-
|
|
1765
|
+
subscribeOnce: (next: (v: NonNullable<T>) => void) => Subscription;
|
|
1974
1766
|
}
|
|
1975
1767
|
|
|
1976
1768
|
/**
|
|
1977
|
-
*
|
|
1769
|
+
* Runtime online/offline signal used by queue flush logic.
|
|
1978
1770
|
*
|
|
1771
|
+
* @defaultValue `true`
|
|
1979
1772
|
* @public
|
|
1980
1773
|
*/
|
|
1981
|
-
|
|
1982
|
-
/** Observable stream of the latest blocked event payload (or `undefined`). */
|
|
1983
|
-
blockedEventStream: Observable<BlockedEvent | undefined>;
|
|
1984
|
-
/** Observable stream of the latest {@link AnalyticsEvent} or {@link PersonalizationEvent} (or `undefined`). */
|
|
1985
|
-
eventStream: Observable<InsightsEvent | ExperienceEvent | undefined>;
|
|
1986
|
-
/** Live view of effective flags for the current profile (if available). */
|
|
1987
|
-
flags: Observable<Flags | undefined>;
|
|
1988
|
-
/** Live view of the current profile. */
|
|
1989
|
-
profile: Observable<Profile | undefined>;
|
|
1990
|
-
/** Live view of selected personalizations (variants). */
|
|
1991
|
-
personalizations: Observable<SelectedPersonalizationArray | undefined>;
|
|
1992
|
-
}
|
|
1774
|
+
declare const online: Signal<boolean | undefined>;
|
|
1993
1775
|
|
|
1994
1776
|
/**
|
|
1995
|
-
*
|
|
1777
|
+
* The package name of the Optimization Core SDK, injected at build time.
|
|
1778
|
+
*
|
|
1779
|
+
* @public
|
|
1780
|
+
*/
|
|
1781
|
+
export declare const OPTIMIZATION_CORE_SDK_NAME: string;
|
|
1782
|
+
|
|
1783
|
+
/**
|
|
1784
|
+
* The current version of the Optimization Core SDK, injected at build time.
|
|
1785
|
+
*
|
|
1786
|
+
* @public
|
|
1787
|
+
*/
|
|
1788
|
+
export declare const OPTIMIZATION_CORE_SDK_VERSION: string;
|
|
1789
|
+
|
|
1790
|
+
/**
|
|
1791
|
+
* Resolve an optimized Contentful entry to the correct variant for the current
|
|
1996
1792
|
* selections.
|
|
1997
1793
|
*
|
|
1998
1794
|
* @public
|
|
1999
1795
|
* @remarks
|
|
2000
|
-
* Given a baseline {@link
|
|
1796
|
+
* Given a baseline {@link OptimizedEntry} and a set of selected optimizations
|
|
2001
1797
|
* (variants per experience), this resolver finds the matching replacement variant
|
|
2002
1798
|
* for the component configured against the baseline entry.
|
|
2003
1799
|
*
|
|
2004
|
-
* **Variant indexing**: `variantIndex` in {@link
|
|
1800
|
+
* **Variant indexing**: `variantIndex` in {@link SelectedOptimization} is treated as
|
|
2005
1801
|
* 1‑based (index 1 = first variant). A value of `0` indicates baseline.
|
|
2006
1802
|
*/
|
|
2007
|
-
export declare const
|
|
1803
|
+
export declare const OptimizedEntryResolver: {
|
|
2008
1804
|
/**
|
|
2009
|
-
* Find the
|
|
1805
|
+
* Find the optimization entry corresponding to one of the selected experiences.
|
|
2010
1806
|
*
|
|
2011
|
-
* @param params - Object containing the baseline
|
|
1807
|
+
* @param params - Object containing the baseline optimized entry and the selections.
|
|
2012
1808
|
* @param skipValidation - When `true`, skip type/shape validation for perf.
|
|
2013
|
-
* @returns The matching {@link
|
|
1809
|
+
* @returns The matching {@link OptimizationEntry}, or `undefined` if not found/invalid.
|
|
2014
1810
|
* @remarks
|
|
2015
|
-
*
|
|
2016
|
-
* `
|
|
2017
|
-
* multiple
|
|
1811
|
+
* An optimization entry is an optimization configuration object supplied in an
|
|
1812
|
+
* `OptimizedEntry.nt_experiences` array. An optimized entry may relate to
|
|
1813
|
+
* multiple optimizations.
|
|
2018
1814
|
* @example
|
|
2019
1815
|
* ```ts
|
|
2020
|
-
* const
|
|
2021
|
-
*
|
|
2022
|
-
*
|
|
1816
|
+
* const optimizationEntry = OptimizedEntryResolver.getOptimizationEntry({
|
|
1817
|
+
* optimizedEntry: entry,
|
|
1818
|
+
* selectedOptimizations
|
|
2023
1819
|
* })
|
|
2024
1820
|
* ```
|
|
2025
1821
|
*/
|
|
2026
|
-
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
}, skipValidation?: boolean):
|
|
1822
|
+
getOptimizationEntry({ optimizedEntry, selectedOptimizations, }: {
|
|
1823
|
+
optimizedEntry: OptimizedEntry_2;
|
|
1824
|
+
selectedOptimizations: SelectedOptimizationArray;
|
|
1825
|
+
}, skipValidation?: boolean): OptimizationEntry_2 | undefined;
|
|
2030
1826
|
/**
|
|
2031
|
-
* Look up the selection metadata for a specific
|
|
1827
|
+
* Look up the selection metadata for a specific optimization entry.
|
|
2032
1828
|
*
|
|
2033
|
-
* @param params - Object with the target
|
|
1829
|
+
* @param params - Object with the target optimization entry and selections.
|
|
2034
1830
|
* @param skipValidation - When `true`, skip type checks.
|
|
2035
|
-
* @returns The matching {@link
|
|
1831
|
+
* @returns The matching {@link SelectedOptimization}, if present.
|
|
2036
1832
|
* @remarks
|
|
2037
|
-
* Selected
|
|
1833
|
+
* Selected optimizations are supplied by the Experience API in the
|
|
2038
1834
|
* `experiences` response data property.
|
|
2039
1835
|
* @example
|
|
2040
1836
|
* ```ts
|
|
2041
|
-
* const
|
|
2042
|
-
*
|
|
2043
|
-
*
|
|
1837
|
+
* const selectedOptimization = OptimizedEntryResolver.getSelectedOptimization({
|
|
1838
|
+
* optimizationEntry,
|
|
1839
|
+
* selectedOptimizations
|
|
2044
1840
|
* })
|
|
2045
1841
|
* ```
|
|
2046
1842
|
*/
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
}, skipValidation?: boolean):
|
|
1843
|
+
getSelectedOptimization({ optimizationEntry, selectedOptimizations, }: {
|
|
1844
|
+
optimizationEntry: OptimizationEntry_2;
|
|
1845
|
+
selectedOptimizations: SelectedOptimizationArray;
|
|
1846
|
+
}, skipValidation?: boolean): SelectedOptimization_2 | undefined;
|
|
2051
1847
|
/**
|
|
2052
1848
|
* Get the replacement variant config for the given selection index.
|
|
2053
1849
|
*
|
|
2054
|
-
* @param params - Baseline entry,
|
|
1850
|
+
* @param params - Baseline entry, optimization entry, and 1‑based variant index.
|
|
2055
1851
|
* @param skipValidation - When `true`, skip type checks.
|
|
2056
1852
|
* @returns The {@link EntryReplacementVariant} for the component, if any.
|
|
2057
1853
|
* @remarks
|
|
2058
1854
|
* Entry replacement variants are variant configurations specified in a
|
|
2059
|
-
*
|
|
2060
|
-
*
|
|
1855
|
+
* optimization configuration component's `variants` array supplied by the
|
|
1856
|
+
* optimized entry via its `nt_config` field.
|
|
2061
1857
|
* @example
|
|
2062
1858
|
* ```ts
|
|
2063
|
-
* const selectedVariant =
|
|
2064
|
-
*
|
|
2065
|
-
*
|
|
1859
|
+
* const selectedVariant = OptimizedEntryResolver.getSelectedVariant({
|
|
1860
|
+
* optimizedEntry: entry,
|
|
1861
|
+
* optimizationEntry,
|
|
2066
1862
|
* selectedVariantIndex: 2 // second variant (1‑based)
|
|
2067
1863
|
* })
|
|
2068
1864
|
* ```
|
|
2069
1865
|
*/
|
|
2070
|
-
getSelectedVariant({
|
|
2071
|
-
|
|
2072
|
-
|
|
1866
|
+
getSelectedVariant({ optimizedEntry, optimizationEntry, selectedVariantIndex, }: {
|
|
1867
|
+
optimizedEntry: OptimizedEntry_2;
|
|
1868
|
+
optimizationEntry: OptimizationEntry_2;
|
|
2073
1869
|
selectedVariantIndex: number;
|
|
2074
1870
|
}, skipValidation?: boolean): EntryReplacementVariant_2 | undefined;
|
|
2075
1871
|
/**
|
|
@@ -2078,44 +1874,83 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
2078
1874
|
* @typeParam S - Entry skeleton type.
|
|
2079
1875
|
* @typeParam M - Chain modifiers.
|
|
2080
1876
|
* @typeParam L - Locale code.
|
|
2081
|
-
* @param params -
|
|
1877
|
+
* @param params - Optimization entry and selected variant.
|
|
2082
1878
|
* @param skipValidation - When `true`, skip type checks.
|
|
2083
1879
|
* @returns The resolved entry typed as {@link Entry} or `undefined`.
|
|
2084
1880
|
* @remarks
|
|
2085
|
-
*
|
|
2086
|
-
* supplied as `
|
|
1881
|
+
* An optimized entry will resolve either to the baseline (the entry
|
|
1882
|
+
* supplied as `optimizedEntry`) or the selected variant.
|
|
2087
1883
|
* @example
|
|
2088
1884
|
* ```ts
|
|
2089
|
-
* const selectedVariantEntry =
|
|
2090
|
-
*
|
|
1885
|
+
* const selectedVariantEntry = OptimizedEntryResolver.getSelectedVariantEntry<{ fields: unknown }>({
|
|
1886
|
+
* optimizationEntry,
|
|
2091
1887
|
* selectedVariant
|
|
2092
1888
|
* })
|
|
2093
1889
|
* ```
|
|
2094
1890
|
*/
|
|
2095
|
-
getSelectedVariantEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>({
|
|
2096
|
-
|
|
1891
|
+
getSelectedVariantEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>({ optimizationEntry, selectedVariant, }: {
|
|
1892
|
+
optimizationEntry: OptimizationEntry_2;
|
|
2097
1893
|
selectedVariant: EntryReplacementVariant_2;
|
|
2098
1894
|
}, skipValidation?: boolean): Entry<S, M, L> | undefined;
|
|
2099
|
-
|
|
2100
|
-
* Resolve the selected entry (baseline or variant) for a personalized entry
|
|
2101
|
-
* and optional selected personalizations, returning both the entry and the
|
|
2102
|
-
* personalization metadata.
|
|
2103
|
-
*
|
|
2104
|
-
* @typeParam S - Entry skeleton type.
|
|
2105
|
-
* @typeParam M - Chain modifiers.
|
|
2106
|
-
* @typeParam L - Locale code.
|
|
2107
|
-
* @param entry - The baseline personalized entry.
|
|
2108
|
-
* @param selectedPersonalizations - Optional selections for the current profile.
|
|
2109
|
-
* @returns An object containing the resolved entry and (if chosen) the selection.
|
|
2110
|
-
* @example
|
|
2111
|
-
* ```ts
|
|
2112
|
-
* const { entry: personalizedEntry, personalization } = PersonalizedEntryResolver.resolve(entry, selections)
|
|
2113
|
-
* if (personalization) console.log('Variant index', personalization.variantIndex)
|
|
2114
|
-
* ```
|
|
2115
|
-
*/
|
|
2116
|
-
resolve<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>(entry: Entry<S, M, L>, selectedPersonalizations?: SelectedPersonalizationArray): ResolvedData<S, M, L>;
|
|
1895
|
+
resolve: typeof resolve;
|
|
2117
1896
|
};
|
|
2118
1897
|
|
|
1898
|
+
export declare const PageViewBuilderArgs: z.ZodMiniObject<{
|
|
1899
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1900
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1901
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1902
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1903
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1904
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1905
|
+
}, z.core.$strip>>;
|
|
1906
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1907
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1908
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1909
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1910
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1911
|
+
}, z.core.$strip>>;
|
|
1912
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1913
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1914
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1915
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1916
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1917
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1918
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1919
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1920
|
+
}, z.core.$strip>>;
|
|
1921
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1922
|
+
path: z.ZodMiniString<string>;
|
|
1923
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1924
|
+
referrer: z.ZodMiniString<string>;
|
|
1925
|
+
search: z.ZodMiniString<string>;
|
|
1926
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1927
|
+
url: z.ZodMiniString<string>;
|
|
1928
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1929
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1930
|
+
name: z.ZodMiniString<string>;
|
|
1931
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1932
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1933
|
+
properties: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1934
|
+
path: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1935
|
+
query: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
|
|
1936
|
+
referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1937
|
+
search: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1938
|
+
title: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
1939
|
+
url: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1940
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1941
|
+
}, z.core.$strip>;
|
|
1942
|
+
|
|
1943
|
+
/**
|
|
1944
|
+
* Arguments for constructing page view events.
|
|
1945
|
+
*
|
|
1946
|
+
* @remarks
|
|
1947
|
+
* Any properties passed here are merged with the base page properties from
|
|
1948
|
+
* {@link EventBuilderConfig.getPageProperties}.
|
|
1949
|
+
*
|
|
1950
|
+
* @public
|
|
1951
|
+
*/
|
|
1952
|
+
export declare type PageViewBuilderArgs = z.infer<typeof PageViewBuilderArgs>;
|
|
1953
|
+
|
|
2119
1954
|
export declare const PREVIEW_PANEL_SIGNAL_FNS_SYMBOL: unique symbol;
|
|
2120
1955
|
|
|
2121
1956
|
/**
|
|
@@ -2125,8 +1960,20 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
2125
1960
|
*/
|
|
2126
1961
|
export declare const PREVIEW_PANEL_SIGNALS_SYMBOL: unique symbol;
|
|
2127
1962
|
|
|
1963
|
+
/**
|
|
1964
|
+
* Indicates whether the preview panel bridge has been attached.
|
|
1965
|
+
*
|
|
1966
|
+
* @defaultValue `false`
|
|
1967
|
+
* @public
|
|
1968
|
+
*/
|
|
2128
1969
|
declare const previewPanelAttached: Signal<boolean>;
|
|
2129
1970
|
|
|
1971
|
+
/**
|
|
1972
|
+
* Indicates whether the preview panel is currently open.
|
|
1973
|
+
*
|
|
1974
|
+
* @defaultValue `false`
|
|
1975
|
+
* @public
|
|
1976
|
+
*/
|
|
2130
1977
|
declare const previewPanelOpen: Signal<boolean>;
|
|
2131
1978
|
|
|
2132
1979
|
/**
|
|
@@ -2142,84 +1989,10 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
2142
1989
|
}
|
|
2143
1990
|
|
|
2144
1991
|
/**
|
|
2145
|
-
*
|
|
2146
|
-
*
|
|
2147
|
-
* @internal
|
|
2148
|
-
* @remarks
|
|
2149
|
-
* This abstract class is not exported as part of the public API surface.
|
|
2150
|
-
* Concrete implementations (e.g., analytics) should extend this class and
|
|
2151
|
-
* expose their own public methods.
|
|
2152
|
-
*/
|
|
2153
|
-
declare abstract class ProductBase {
|
|
2154
|
-
/**
|
|
2155
|
-
* Allow‑list of event {@link AnalyticsEventType | type keys} permitted when consent is not present.
|
|
2156
|
-
*/
|
|
2157
|
-
protected readonly allowedEventTypes?: string[];
|
|
2158
|
-
/** Event builder used to construct strongly‑typed events. */
|
|
2159
|
-
protected readonly builder: EventBuilder;
|
|
2160
|
-
/** Optimization API client used to send events to the Experience and Insights APIs. */
|
|
2161
|
-
protected readonly api: ApiClient;
|
|
2162
|
-
/** Interceptors that can mutate/augment outgoing events or optimization state. */
|
|
2163
|
-
readonly interceptors: LifecycleInterceptors;
|
|
2164
|
-
/** Optional callback invoked when an event call is blocked. */
|
|
2165
|
-
protected readonly onEventBlocked?: ProductConfig['onEventBlocked'];
|
|
2166
|
-
/**
|
|
2167
|
-
* Creates a new product base instance.
|
|
2168
|
-
*
|
|
2169
|
-
* @param options - Options for configuring the functionality common among products.
|
|
2170
|
-
*/
|
|
2171
|
-
constructor(options: ProductBaseOptions);
|
|
2172
|
-
/**
|
|
2173
|
-
* Publish blocked event metadata to both callback and blocked event signal.
|
|
2174
|
-
*
|
|
2175
|
-
* @param reason - Reason the method call was blocked.
|
|
2176
|
-
* @param product - Product that blocked the method call.
|
|
2177
|
-
* @param method - Name of the blocked method.
|
|
2178
|
-
* @param args - Original blocked call arguments.
|
|
2179
|
-
*/
|
|
2180
|
-
protected reportBlockedEvent(reason: BlockedEventReason, product: BlockedEventProduct, method: string, args: readonly unknown[]): void;
|
|
2181
|
-
}
|
|
2182
|
-
|
|
2183
|
-
/**
|
|
2184
|
-
* Options for configuring the common functionality of {@link ProductBase} descendents.
|
|
2185
|
-
*
|
|
2186
|
-
* @public
|
|
2187
|
-
*/
|
|
2188
|
-
declare interface ProductBaseOptions {
|
|
2189
|
-
/** Optimization API client. */
|
|
2190
|
-
api: ApiClient;
|
|
2191
|
-
/** Event builder for constructing events. */
|
|
2192
|
-
builder: EventBuilder;
|
|
2193
|
-
/** Optional configuration for allow‑lists and guard callbacks. */
|
|
2194
|
-
config?: ProductConfig;
|
|
2195
|
-
/** Lifecycle container for event and state interceptors. */
|
|
2196
|
-
interceptors: LifecycleInterceptors;
|
|
2197
|
-
}
|
|
2198
|
-
|
|
2199
|
-
/**
|
|
2200
|
-
* Common configuration for all product implementations.
|
|
1992
|
+
* Active profile associated with current runtime state.
|
|
2201
1993
|
*
|
|
2202
1994
|
* @public
|
|
2203
1995
|
*/
|
|
2204
|
-
declare interface ProductConfig {
|
|
2205
|
-
/**
|
|
2206
|
-
* The set of event type strings that are allowed to be sent even if consent is
|
|
2207
|
-
* not granted.
|
|
2208
|
-
*
|
|
2209
|
-
* @defaultValue `['identify', 'page', 'screen']`
|
|
2210
|
-
* @remarks These types are compared against the `type` property of events.
|
|
2211
|
-
*/
|
|
2212
|
-
allowedEventTypes?: EventType[];
|
|
2213
|
-
/**
|
|
2214
|
-
* Callback invoked whenever an event call is blocked by guards.
|
|
2215
|
-
*
|
|
2216
|
-
* @remarks
|
|
2217
|
-
* This callback is best-effort. Any exception thrown by the callback is
|
|
2218
|
-
* swallowed to keep event handling fault tolerant.
|
|
2219
|
-
*/
|
|
2220
|
-
onEventBlocked?: (event: BlockedEvent) => void;
|
|
2221
|
-
}
|
|
2222
|
-
|
|
2223
1996
|
declare const profile: Signal<Profile | undefined>;
|
|
2224
1997
|
|
|
2225
1998
|
/**
|
|
@@ -2234,7 +2007,7 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
2234
2007
|
*
|
|
2235
2008
|
* @public
|
|
2236
2009
|
*/
|
|
2237
|
-
declare interface QueueFlushFailureContext {
|
|
2010
|
+
export declare interface QueueFlushFailureContext {
|
|
2238
2011
|
/** Number of consecutive failed flush attempts. */
|
|
2239
2012
|
consecutiveFailures: number;
|
|
2240
2013
|
/** Number of queued batches at the time of the failed attempt. */
|
|
@@ -2250,7 +2023,13 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
2250
2023
|
*
|
|
2251
2024
|
* @public
|
|
2252
2025
|
*/
|
|
2253
|
-
declare interface QueueFlushPolicy {
|
|
2026
|
+
export declare interface QueueFlushPolicy {
|
|
2027
|
+
/**
|
|
2028
|
+
* Periodic flush interval in milliseconds while events remain queued.
|
|
2029
|
+
*
|
|
2030
|
+
* @defaultValue `30000`
|
|
2031
|
+
*/
|
|
2032
|
+
flushIntervalMs?: number;
|
|
2254
2033
|
/**
|
|
2255
2034
|
* Base retry backoff delay in milliseconds.
|
|
2256
2035
|
*
|
|
@@ -2303,13 +2082,53 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
2303
2082
|
*
|
|
2304
2083
|
* @public
|
|
2305
2084
|
*/
|
|
2306
|
-
declare interface QueueFlushRecoveredContext {
|
|
2085
|
+
export declare interface QueueFlushRecoveredContext {
|
|
2307
2086
|
/** Consecutive failure count that existed immediately before recovery. */
|
|
2308
2087
|
consecutiveFailures: number;
|
|
2309
2088
|
}
|
|
2310
2089
|
|
|
2311
2090
|
/**
|
|
2312
|
-
*
|
|
2091
|
+
* Unified queue policy for stateful Core.
|
|
2092
|
+
*
|
|
2093
|
+
* @public
|
|
2094
|
+
*/
|
|
2095
|
+
export declare interface QueuePolicy {
|
|
2096
|
+
/** Shared retry/backoff/circuit policy for queued flushes. */
|
|
2097
|
+
flush?: QueueFlushPolicy;
|
|
2098
|
+
/** Maximum number of offline Experience events retained. */
|
|
2099
|
+
offlineMaxEvents?: number;
|
|
2100
|
+
/** Callback invoked when oldest offline Experience events are dropped. */
|
|
2101
|
+
onOfflineDrop?: (context: ExperienceQueueDropContext) => void;
|
|
2102
|
+
}
|
|
2103
|
+
|
|
2104
|
+
/**
|
|
2105
|
+
* Resolve the selected entry (baseline or variant) for an optimized entry
|
|
2106
|
+
* and optional selected optimizations, returning both the entry and the
|
|
2107
|
+
* optimization metadata.
|
|
2108
|
+
*
|
|
2109
|
+
* @typeParam S - Entry skeleton type.
|
|
2110
|
+
* @typeParam L - Locale code.
|
|
2111
|
+
* @typeParam M - Chain modifiers for advanced/non-default Contentful clients.
|
|
2112
|
+
* @param entry - The baseline optimized entry.
|
|
2113
|
+
* @param selectedOptimizations - Optional selections for the current profile.
|
|
2114
|
+
* @returns An object containing the resolved entry and (if chosen) the selection.
|
|
2115
|
+
* @example
|
|
2116
|
+
* ```ts
|
|
2117
|
+
* const { entry: optimizedEntry, selectedOptimization } = OptimizedEntryResolver.resolve(
|
|
2118
|
+
* entry,
|
|
2119
|
+
* selections,
|
|
2120
|
+
* )
|
|
2121
|
+
* if (selectedOptimization) {
|
|
2122
|
+
* console.log('Variant index', selectedOptimization.variantIndex)
|
|
2123
|
+
* }
|
|
2124
|
+
* ```
|
|
2125
|
+
*/
|
|
2126
|
+
declare function resolve<S extends EntrySkeletonType = EntrySkeletonType, L extends LocaleCode = LocaleCode>(entry: Entry<S, undefined, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, undefined, L>;
|
|
2127
|
+
|
|
2128
|
+
declare function resolve<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, M, L>;
|
|
2129
|
+
|
|
2130
|
+
/**
|
|
2131
|
+
* Result returned by {@link OptimizedEntryResolver.resolve}.
|
|
2313
2132
|
*
|
|
2314
2133
|
* @typeParam S - Entry skeleton type.
|
|
2315
2134
|
* @typeParam M - Chain modifiers.
|
|
@@ -2319,114 +2138,358 @@ declare abstract class CoreBase implements ResolverMethods {
|
|
|
2319
2138
|
export declare interface ResolvedData<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode> {
|
|
2320
2139
|
/** The baseline or resolved variant entry. */
|
|
2321
2140
|
entry: Entry<S, M, L>;
|
|
2322
|
-
/** The selected
|
|
2323
|
-
|
|
2141
|
+
/** The selected optimization metadata, if a non-baseline variant was chosen. */
|
|
2142
|
+
selectedOptimization?: SelectedOptimization_2;
|
|
2324
2143
|
}
|
|
2325
2144
|
|
|
2326
2145
|
/**
|
|
2327
|
-
*
|
|
2146
|
+
* Internal normalized shape of queue flush policy values.
|
|
2328
2147
|
*
|
|
2329
2148
|
* @internal
|
|
2330
|
-
* @privateRemarks
|
|
2331
|
-
* This interface exists to document that the included methods should not be
|
|
2332
|
-
* considered static.
|
|
2333
2149
|
*/
|
|
2334
|
-
|
|
2335
|
-
|
|
2336
|
-
|
|
2337
|
-
|
|
2338
|
-
|
|
2339
|
-
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
getCustomFlag: (name: string, changes?: ChangeArray) => Json;
|
|
2345
|
-
/**
|
|
2346
|
-
* Get all resolved Custom Flags from the supplied changes.
|
|
2347
|
-
* @param changes - Optional changes array.
|
|
2348
|
-
* @returns The resolved Custom Flag map.
|
|
2349
|
-
* @remarks
|
|
2350
|
-
* The changes array can be sourced from the data returned when emitting any
|
|
2351
|
-
* personalization event.
|
|
2352
|
-
* */
|
|
2353
|
-
getCustomFlags: (changes?: ChangeArray) => Flags;
|
|
2354
|
-
/**
|
|
2355
|
-
* Resolve a Contentful entry to a personalized variant using the current
|
|
2356
|
-
* or provided selected personalizations.
|
|
2357
|
-
*
|
|
2358
|
-
* @typeParam S - Entry skeleton type.
|
|
2359
|
-
* @typeParam M - Chain modifiers.
|
|
2360
|
-
* @typeParam L - Locale code.
|
|
2361
|
-
* @param entry - The entry to personalize.
|
|
2362
|
-
* @param personalizations - Optional selections.
|
|
2363
|
-
* @returns The resolved entry data.
|
|
2364
|
-
* @remarks
|
|
2365
|
-
* Selected personalizations can be sourced from the data returned when emitting any
|
|
2366
|
-
* personalization event.
|
|
2367
|
-
*/
|
|
2368
|
-
personalizeEntry: <S extends EntrySkeletonType, M extends ChainModifiers, L extends LocaleCode>(entry: Entry<S, M, L>, personalizations?: SelectedPersonalizationArray) => ResolvedData<S, M, L>;
|
|
2369
|
-
/**
|
|
2370
|
-
* Resolve a merge tag to a value based on the current (or provided) profile.
|
|
2371
|
-
*
|
|
2372
|
-
* @param embeddedEntryNodeTarget - The merge‑tag entry node to resolve.
|
|
2373
|
-
* @param profile - Optional profile.
|
|
2374
|
-
* @returns The resolved value (type depends on the tag).
|
|
2375
|
-
* @remarks
|
|
2376
|
-
* Merge tags are references to profile data that can be substituted into content. The
|
|
2377
|
-
* profile can be sourced from the data returned when emitting any personalization event.
|
|
2378
|
-
*/
|
|
2379
|
-
getMergeTagValue: (embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile) => string | undefined;
|
|
2150
|
+
declare interface ResolvedQueueFlushPolicy {
|
|
2151
|
+
flushIntervalMs: number;
|
|
2152
|
+
baseBackoffMs: number;
|
|
2153
|
+
maxBackoffMs: number;
|
|
2154
|
+
jitterRatio: number;
|
|
2155
|
+
maxConsecutiveFailures: number;
|
|
2156
|
+
circuitOpenMs: number;
|
|
2157
|
+
onCircuitOpen?: QueueFlushPolicy['onCircuitOpen'];
|
|
2158
|
+
onFlushFailure?: QueueFlushPolicy['onFlushFailure'];
|
|
2159
|
+
onFlushRecovered?: QueueFlushPolicy['onFlushRecovered'];
|
|
2380
2160
|
}
|
|
2381
2161
|
|
|
2162
|
+
export declare const ScreenViewBuilderArgs: z.ZodMiniObject<{
|
|
2163
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2164
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2165
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2166
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2167
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2168
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2169
|
+
}, z.core.$strip>>;
|
|
2170
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2171
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2172
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2173
|
+
latitude: z.ZodMiniNumber<number>;
|
|
2174
|
+
longitude: z.ZodMiniNumber<number>;
|
|
2175
|
+
}, z.core.$strip>>;
|
|
2176
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2177
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2178
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2179
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2180
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2181
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2182
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2183
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2184
|
+
}, z.core.$strip>>;
|
|
2185
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2186
|
+
path: z.ZodMiniString<string>;
|
|
2187
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
2188
|
+
referrer: z.ZodMiniString<string>;
|
|
2189
|
+
search: z.ZodMiniString<string>;
|
|
2190
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2191
|
+
url: z.ZodMiniString<string>;
|
|
2192
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2193
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2194
|
+
name: z.ZodMiniString<string>;
|
|
2195
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2196
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2197
|
+
name: z.ZodMiniString<string>;
|
|
2198
|
+
properties: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>;
|
|
2199
|
+
}, z.core.$strip>;
|
|
2200
|
+
|
|
2201
|
+
/**
|
|
2202
|
+
* Arguments for constructing screen view events.
|
|
2203
|
+
*
|
|
2204
|
+
* @remarks
|
|
2205
|
+
* Any properties passed here are merged with the base screen properties supplied
|
|
2206
|
+
* by the runtime.
|
|
2207
|
+
*
|
|
2208
|
+
* @public
|
|
2209
|
+
*/
|
|
2210
|
+
export declare type ScreenViewBuilderArgs = z.infer<typeof ScreenViewBuilderArgs>;
|
|
2211
|
+
|
|
2212
|
+
/**
|
|
2213
|
+
* Storage key for cached selected optimizations.
|
|
2214
|
+
*
|
|
2215
|
+
* @internal
|
|
2216
|
+
*/
|
|
2217
|
+
export declare const SELECTED_OPTIMIZATIONS_CACHE_KEY = "__ctfl_opt_selected-optimizations__";
|
|
2218
|
+
|
|
2219
|
+
/**
|
|
2220
|
+
* Latest selected optimization variants.
|
|
2221
|
+
*
|
|
2222
|
+
* @public
|
|
2223
|
+
*/
|
|
2224
|
+
declare const selectedOptimizations: Signal<{
|
|
2225
|
+
experienceId: string;
|
|
2226
|
+
variantIndex: number;
|
|
2227
|
+
variants: Record<string, string>;
|
|
2228
|
+
sticky?: boolean | undefined;
|
|
2229
|
+
}[] | undefined>;
|
|
2230
|
+
|
|
2382
2231
|
export { Signal }
|
|
2383
2232
|
|
|
2233
|
+
/**
|
|
2234
|
+
* Signal utility functions shared with preview tooling and extensions.
|
|
2235
|
+
*
|
|
2236
|
+
* @public
|
|
2237
|
+
*/
|
|
2384
2238
|
export declare interface SignalFns {
|
|
2239
|
+
/** Execute multiple signal writes in one reactive batch. */
|
|
2385
2240
|
batch: typeof batch;
|
|
2241
|
+
/** Create a derived computed signal. */
|
|
2386
2242
|
computed: typeof computed;
|
|
2243
|
+
/** Register a reactive effect. */
|
|
2387
2244
|
effect: typeof effect;
|
|
2245
|
+
/** Read signal values without dependency tracking. */
|
|
2388
2246
|
untracked: typeof untracked;
|
|
2389
2247
|
}
|
|
2390
2248
|
|
|
2249
|
+
/**
|
|
2250
|
+
* Pre-bundled reference to shared signal helpers.
|
|
2251
|
+
*
|
|
2252
|
+
* @public
|
|
2253
|
+
*/
|
|
2391
2254
|
export declare const signalFns: SignalFns;
|
|
2392
2255
|
|
|
2256
|
+
/**
|
|
2257
|
+
* Collection of shared stateful Core signals.
|
|
2258
|
+
*
|
|
2259
|
+
* @public
|
|
2260
|
+
*/
|
|
2393
2261
|
export declare interface Signals {
|
|
2262
|
+
/** Most recent blocked-event metadata. */
|
|
2394
2263
|
blockedEvent: typeof blockedEvent;
|
|
2264
|
+
/** Latest optimization changes payload. */
|
|
2395
2265
|
changes: typeof changes;
|
|
2266
|
+
/** Current consent signal. */
|
|
2396
2267
|
consent: typeof consent;
|
|
2268
|
+
/** Most recent emitted event signal. */
|
|
2397
2269
|
event: typeof event_2;
|
|
2398
|
-
|
|
2270
|
+
/** Runtime connectivity signal. */
|
|
2399
2271
|
online: typeof online;
|
|
2272
|
+
/** Preview panel attachment signal. */
|
|
2400
2273
|
previewPanelAttached: typeof previewPanelAttached;
|
|
2274
|
+
/** Preview panel open-state signal. */
|
|
2401
2275
|
previewPanelOpen: typeof previewPanelOpen;
|
|
2402
|
-
|
|
2276
|
+
/** Selected optimization variants signal. */
|
|
2277
|
+
selectedOptimizations: typeof selectedOptimizations;
|
|
2278
|
+
/** Whether optimization selection data is currently available. */
|
|
2279
|
+
canOptimize: typeof canOptimize;
|
|
2280
|
+
/** Active profile signal. */
|
|
2403
2281
|
profile: typeof profile;
|
|
2404
2282
|
}
|
|
2405
2283
|
|
|
2284
|
+
/**
|
|
2285
|
+
* Pre-bundled reference to all shared signals.
|
|
2286
|
+
*
|
|
2287
|
+
* @public
|
|
2288
|
+
*/
|
|
2406
2289
|
export declare const signals: Signals;
|
|
2407
2290
|
|
|
2408
|
-
declare
|
|
2409
|
-
unsubscribe: () => void;
|
|
2410
|
-
}
|
|
2411
|
-
|
|
2412
|
-
export declare type TrackComponentClickArgs = ComponentClickBuilderArgs & {
|
|
2291
|
+
declare type StatelessExperiencePayload<TPayload> = TPayload & {
|
|
2413
2292
|
profile?: PartialProfile;
|
|
2414
2293
|
};
|
|
2415
2294
|
|
|
2416
|
-
|
|
2295
|
+
declare type StatelessInsightsPayload<TPayload> = TPayload & {
|
|
2296
|
+
profile: PartialProfile;
|
|
2297
|
+
};
|
|
2298
|
+
|
|
2299
|
+
declare type StatelessNonStickyTrackViewPayload = Omit<ViewBuilderArgs, 'sticky'> & {
|
|
2300
|
+
profile: PartialProfile;
|
|
2301
|
+
sticky?: false | undefined;
|
|
2302
|
+
};
|
|
2303
|
+
|
|
2304
|
+
declare type StatelessStickyTrackViewPayload = ViewBuilderArgs & {
|
|
2417
2305
|
profile?: PartialProfile;
|
|
2306
|
+
sticky: true;
|
|
2418
2307
|
};
|
|
2419
2308
|
|
|
2420
2309
|
/**
|
|
2421
|
-
*
|
|
2310
|
+
* Disposable handle returned by observable subscriptions.
|
|
2422
2311
|
*
|
|
2423
2312
|
* @public
|
|
2313
|
+
*/
|
|
2314
|
+
export declare interface Subscription {
|
|
2315
|
+
/** Stop receiving future emissions for the subscription. */
|
|
2316
|
+
unsubscribe: () => void;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
/**
|
|
2320
|
+
* Wrap a signal-like object with an {@link Observable} that suppresses
|
|
2321
|
+
* duplicate emissions according to a comparator.
|
|
2322
|
+
*
|
|
2323
|
+
* @typeParam T - Signal value type.
|
|
2324
|
+
* @param s - Signal-like source exposing a `value` property.
|
|
2325
|
+
* @param isEqual - Comparator that returns `true` when values are equivalent.
|
|
2326
|
+
* @returns Observable adapter that only emits distinct values.
|
|
2327
|
+
*
|
|
2424
2328
|
* @remarks
|
|
2425
|
-
* The
|
|
2426
|
-
*
|
|
2329
|
+
* The first emission is always delivered. Subsequent emissions are skipped
|
|
2330
|
+
* when `isEqual(previous, current)` returns `true`.
|
|
2331
|
+
*
|
|
2332
|
+
* @public
|
|
2427
2333
|
*/
|
|
2428
|
-
export declare
|
|
2429
|
-
|
|
2430
|
-
}
|
|
2334
|
+
export declare function toDistinctObservable<T>(s: {
|
|
2335
|
+
value: T;
|
|
2336
|
+
}, isEqual: (previous: T, current: T) => boolean): Observable<T>;
|
|
2337
|
+
|
|
2338
|
+
/**
|
|
2339
|
+
* Wrap a signal-like object with the local {@link Observable} contract.
|
|
2340
|
+
*
|
|
2341
|
+
* @typeParam T - Signal value type.
|
|
2342
|
+
* @param s - Signal-like source exposing a `value` property.
|
|
2343
|
+
* @returns Observable adapter for the given signal source.
|
|
2344
|
+
*
|
|
2345
|
+
* @remarks
|
|
2346
|
+
* All emitted values and `current` snapshots are deep-cloned to isolate
|
|
2347
|
+
* subscriber-side mutation from internal Core state.
|
|
2348
|
+
*
|
|
2349
|
+
* @public
|
|
2350
|
+
*/
|
|
2351
|
+
export declare function toObservable<T>(s: {
|
|
2352
|
+
value: T;
|
|
2353
|
+
}): Observable<T>;
|
|
2354
|
+
|
|
2355
|
+
export declare const TrackBuilderArgs: z.ZodMiniObject<{
|
|
2356
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2357
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2358
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2359
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2360
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2361
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2362
|
+
}, z.core.$strip>>;
|
|
2363
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2364
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2365
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2366
|
+
latitude: z.ZodMiniNumber<number>;
|
|
2367
|
+
longitude: z.ZodMiniNumber<number>;
|
|
2368
|
+
}, z.core.$strip>>;
|
|
2369
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2370
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2371
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2372
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2373
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2374
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2375
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2376
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2377
|
+
}, z.core.$strip>>;
|
|
2378
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2379
|
+
path: z.ZodMiniString<string>;
|
|
2380
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
2381
|
+
referrer: z.ZodMiniString<string>;
|
|
2382
|
+
search: z.ZodMiniString<string>;
|
|
2383
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2384
|
+
url: z.ZodMiniString<string>;
|
|
2385
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2386
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2387
|
+
name: z.ZodMiniString<string>;
|
|
2388
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2389
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2390
|
+
event: z.ZodMiniString<string>;
|
|
2391
|
+
properties: z.ZodMiniOptional<z.ZodMiniPrefault<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>>>;
|
|
2392
|
+
}, z.core.$strip>;
|
|
2393
|
+
|
|
2394
|
+
/**
|
|
2395
|
+
* Arguments for constructing track events.
|
|
2396
|
+
*
|
|
2397
|
+
* @public
|
|
2398
|
+
*/
|
|
2399
|
+
export declare type TrackBuilderArgs = z.infer<typeof TrackBuilderArgs>;
|
|
2400
|
+
|
|
2401
|
+
export declare const UniversalEventBuilderArgs: z.ZodMiniObject<{
|
|
2402
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2403
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2404
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2405
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2406
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2407
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2408
|
+
}, z.core.$strip>>;
|
|
2409
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2410
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2411
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2412
|
+
latitude: z.ZodMiniNumber<number>;
|
|
2413
|
+
longitude: z.ZodMiniNumber<number>;
|
|
2414
|
+
}, z.core.$strip>>;
|
|
2415
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2416
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2417
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2418
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2419
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2420
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2421
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2422
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2423
|
+
}, z.core.$strip>>;
|
|
2424
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2425
|
+
path: z.ZodMiniString<string>;
|
|
2426
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
2427
|
+
referrer: z.ZodMiniString<string>;
|
|
2428
|
+
search: z.ZodMiniString<string>;
|
|
2429
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2430
|
+
url: z.ZodMiniString<string>;
|
|
2431
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2432
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2433
|
+
name: z.ZodMiniString<string>;
|
|
2434
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2435
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2436
|
+
}, z.core.$strip>;
|
|
2437
|
+
|
|
2438
|
+
/**
|
|
2439
|
+
* Arguments used to construct the universal (shared) portion of all events.
|
|
2440
|
+
*
|
|
2441
|
+
* @public
|
|
2442
|
+
*/
|
|
2443
|
+
export declare type UniversalEventBuilderArgs = z.infer<typeof UniversalEventBuilderArgs>;
|
|
2444
|
+
|
|
2445
|
+
export declare const ViewBuilderArgs: z.ZodMiniObject<{
|
|
2446
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2447
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2448
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2449
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2450
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2451
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2452
|
+
}, z.core.$strip>>;
|
|
2453
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2454
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2455
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2456
|
+
latitude: z.ZodMiniNumber<number>;
|
|
2457
|
+
longitude: z.ZodMiniNumber<number>;
|
|
2458
|
+
}, z.core.$strip>>;
|
|
2459
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2460
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2461
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2462
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2463
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2464
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2465
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2466
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2467
|
+
}, z.core.$strip>>;
|
|
2468
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2469
|
+
path: z.ZodMiniString<string>;
|
|
2470
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
2471
|
+
referrer: z.ZodMiniString<string>;
|
|
2472
|
+
search: z.ZodMiniString<string>;
|
|
2473
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2474
|
+
url: z.ZodMiniString<string>;
|
|
2475
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2476
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
2477
|
+
name: z.ZodMiniString<string>;
|
|
2478
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
2479
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2480
|
+
componentId: z.ZodMiniString<string>;
|
|
2481
|
+
experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
2482
|
+
variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
2483
|
+
sticky: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
2484
|
+
viewId: z.ZodMiniString<string>;
|
|
2485
|
+
viewDurationMs: z.ZodMiniNumber<number>;
|
|
2486
|
+
}, z.core.$strip>;
|
|
2487
|
+
|
|
2488
|
+
/**
|
|
2489
|
+
* Arguments for constructing entry view events.
|
|
2490
|
+
*
|
|
2491
|
+
* @public
|
|
2492
|
+
*/
|
|
2493
|
+
export declare type ViewBuilderArgs = z.infer<typeof ViewBuilderArgs>;
|
|
2431
2494
|
|
|
2432
2495
|
export { }
|