@contentful/optimization-core 0.1.0-alpha10 → 0.1.0-alpha11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,378 +1,62 @@
1
1
  /**
2
- * Optimization Core SDK — platform-agnostic personalization and analytics.
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 { ComponentClickBuilderArgs } from '@contentful/optimization-api-client';
13
- import { ComponentHoverBuilderArgs } from '@contentful/optimization-api-client';
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 { EventBuilder } from '@contentful/optimization-api-client';
22
- import { EventBuilderConfig } from '@contentful/optimization-api-client';
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-client/api-schemas';
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 { IdentifyBuilderArgs } from '@contentful/optimization-api-client';
30
- import { InsightsApiClientConfig } from '@contentful/optimization-api-client';
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 { PageViewBuilderArgs } from '@contentful/optimization-api-client';
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 { ScreenViewBuilderArgs } from '@contentful/optimization-api-client';
47
- import { SelectedPersonalization } from '@contentful/optimization-api-client/api-schemas';
48
- import { SelectedPersonalization as SelectedPersonalization_2 } from '@contentful/optimization-api-schemas';
49
- import { SelectedPersonalizationArray } from '@contentful/optimization-api-client/api-schemas';
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 { TrackBuilderArgs } from '@contentful/optimization-api-client';
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 personalization and analytics
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
- * Product that blocked the event.
116
+ * Most recent blocked-event metadata produced by consent/runtime guards.
437
117
  *
438
118
  * @public
439
119
  */
440
- export declare type BlockedEventProduct = 'analytics' | 'personalization';
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 implements ResolverMethods {
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 (minus any name metadata). */
538
- readonly config: Omit<CoreConfig, 'name'>;
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: CoreConfig);
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,43 +336,34 @@ 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 personalization’s flag resolution.
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 flags = core.getCustomFlags(data.changes)
342
+ * const darkMode = core.getFlag('dark-mode', data.changes)
594
343
  * ```
595
344
  */
596
- getCustomFlags(changes?: ChangeArray): Flags;
345
+ getFlag(name: string, changes?: ChangeArray): Json;
597
346
  /**
598
- * Resolve a Contentful entry to the appropriate personalized variant (or
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 personalizations - Optional selection array for the current profile.
354
+ * @param selectedOptimizations - Optional selected optimization array for the current profile.
606
355
  * @returns {@link ResolvedData} containing the resolved entry and
607
- * personalization metadata (if any).
356
+ * selected optimization metadata (if any).
608
357
  * @example
609
358
  * ```ts
610
- * const { entry, personalization } = core.personalizeEntry(baselineEntry, data.personalizations)
359
+ * const { entry, selectedOptimization } = core.resolveOptimizedEntry(
360
+ * baselineEntry,
361
+ * data.selectedOptimizations,
362
+ * )
611
363
  * ```
612
364
  */
613
- personalizeEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, personalizations?: SelectedPersonalizationArray): ResolvedData<S, M, L>;
365
+ resolveOptimizedEntry<S extends EntrySkeletonType = EntrySkeletonType, L extends LocaleCode = LocaleCode>(entry: Entry<S, undefined, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, undefined, L>;
366
+ resolveOptimizedEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, M, L>;
614
367
  /**
615
368
  * Resolve a merge-tag value from the given entry node and profile.
616
369
  *
@@ -623,125 +376,19 @@ declare abstract class CoreBase implements ResolverMethods {
623
376
  * ```
624
377
  */
625
378
  getMergeTagValue(embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile): string | undefined;
626
- /**
627
- * Convenience wrapper for sending an `identify` event via personalization.
628
- *
629
- * @param payload - Identify builder arguments.
630
- * @returns The resulting {@link OptimizationData} for the identified user.
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>;
379
+ }
380
+
381
+ declare interface CoreBaseApiClientConfig {
382
+ experience?: ApiClientConfig['experience'];
383
+ insights?: ApiClientConfig['insights'];
729
384
  }
730
385
 
731
386
  /**
732
- * Options for configuring the {@link CoreBase} runtime and underlying clients.
387
+ * Options for configuring the `CoreBase` runtime and underlying clients.
733
388
  *
734
389
  * @public
735
390
  */
736
391
  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
392
  /**
746
393
  * Event builder configuration (channel/library metadata, etc.).
747
394
  */
@@ -751,253 +398,343 @@ declare abstract class CoreBase implements ResolverMethods {
751
398
  }
752
399
 
753
400
  /**
754
- * Default values used to preconfigure the stateful core and products.
401
+ * Default values used to preconfigure the stateful core.
755
402
  *
756
403
  * @public
757
404
  */
758
405
  export declare interface CoreConfigDefaults {
759
406
  /** Global consent default applied at construction time. */
760
407
  consent?: boolean;
761
- /** Default active profile used for personalization and analytics. */
408
+ /** Default active profile used for optimization and insights. */
762
409
  profile?: Profile;
763
410
  /** Initial diff of changes produced by the service. */
764
411
  changes?: ChangeArray;
765
- /** Preselected personalization variants (e.g., winning treatments). */
766
- personalizations?: SelectedPersonalizationArray;
412
+ /** Preselected optimization variants (e.g., winning treatments). */
413
+ selectedOptimizations?: SelectedOptimizationArray;
767
414
  }
768
415
 
769
416
  /**
770
- * Core runtime that constructs stateful product instances and exposes shared
771
- * states, including consent, blocked events, and the event stream.
417
+ * Shared API configuration for all Core runtimes.
418
+ *
419
+ * @public
420
+ */
421
+ export declare interface CoreSharedApiConfig {
422
+ /** Base URL override for Experience API requests. */
423
+ experienceBaseUrl?: ExperienceApiClientConfig['baseUrl'];
424
+ /** Base URL override for Insights API requests. */
425
+ insightsBaseUrl?: InsightsApiClientConfig['baseUrl'];
426
+ /** Experience API features enabled for outgoing requests. */
427
+ enabledFeatures?: ExperienceApiClientConfig['enabledFeatures'];
428
+ }
429
+
430
+ /**
431
+ * Core runtime that owns stateful event delivery, consent, and shared signals.
772
432
  *
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
433
  * @public
779
434
  */
780
- export declare class CoreStateful extends CoreBase implements ConsentController {
435
+ export declare class CoreStateful extends CoreStatefulEventEmitter implements ConsentController, ConsentGuard {
781
436
  private readonly singletonOwner;
782
437
  private destroyed;
783
- /** Stateful analytics product. */
784
- protected _analytics: AnalyticsStateful;
785
- /** Stateful personalization product. */
786
- protected _personalization: PersonalizationStateful;
438
+ protected readonly allowedEventTypes: EventType[];
439
+ protected readonly experienceQueue: ExperienceQueue;
440
+ protected readonly insightsQueue: InsightsQueue;
441
+ protected readonly onEventBlocked?: CoreStatefulConfig['onEventBlocked'];
787
442
  /**
788
- * Create a stateful core with optional default consent and product defaults.
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
- * ```
443
+ * Expose merged observable state for consumers.
800
444
  */
445
+ readonly states: CoreStates;
801
446
  constructor(config: CoreStatefulConfig);
447
+ private initializeEffects;
448
+ private flushQueues;
449
+ destroy(): void;
450
+ reset(): void;
451
+ flush(): Promise<void>;
452
+ consent(accept: boolean): void;
453
+ protected get online(): boolean;
454
+ protected set online(isOnline: boolean);
455
+ registerPreviewPanel(previewPanel: PreviewPanelSignalObject): void;
456
+ }
457
+
458
+ /**
459
+ * API configuration for stateful Core runtimes.
460
+ *
461
+ * @public
462
+ */
463
+ export declare interface CoreStatefulApiConfig extends CoreSharedApiConfig {
464
+ /** Beacon-like handler used by Insights event delivery when available. */
465
+ beaconHandler?: InsightsApiClientConfig['beaconHandler'];
466
+ /** Experience API IP override. */
467
+ ip?: ExperienceApiClientConfig['ip'];
468
+ /** Experience API locale override. */
469
+ locale?: ExperienceApiClientConfig['locale'];
470
+ /** Experience API plain-text request toggle. */
471
+ plainText?: ExperienceApiClientConfig['plainText'];
472
+ /** Experience API preflight request toggle. */
473
+ preflight?: ExperienceApiClientConfig['preflight'];
474
+ }
475
+
476
+ /**
477
+ * Configuration for {@link CoreStateful}.
478
+ *
479
+ * @public
480
+ */
481
+ export declare interface CoreStatefulConfig extends CoreConfig {
482
+ /**
483
+ * Unified API configuration for stateful environments.
484
+ */
485
+ api?: CoreStatefulApiConfig;
486
+ /**
487
+ * Allow-listed event type strings permitted when consent is not set.
488
+ */
489
+ allowedEventTypes?: EventType[];
490
+ /** Optional set of default values applied on initialization. */
491
+ defaults?: CoreConfigDefaults;
492
+ /** Function used to obtain an anonymous user identifier. */
493
+ getAnonymousId?: () => string | undefined;
494
+ /**
495
+ * Callback invoked whenever an event call is blocked by checks.
496
+ */
497
+ onEventBlocked?: (event: BlockedEvent) => void;
498
+ /** Unified queue policy for queued stateful work. */
499
+ queuePolicy?: QueuePolicy;
500
+ }
501
+
502
+ /**
503
+ * Shared stateful event-emission surface extracted to keep `CoreStateful.ts`
504
+ * below the local max-lines limit while preserving the public API.
505
+ *
506
+ * @internal
507
+ */
508
+ declare abstract class CoreStatefulEventEmitter extends CoreBase<CoreStatefulConfig> implements ConsentGuard {
509
+ protected readonly flagObservables: Map<string, Observable<unknown>>;
510
+ protected abstract readonly allowedEventTypes: EventType[];
511
+ protected abstract readonly experienceQueue: ExperienceQueue;
512
+ protected abstract readonly insightsQueue: InsightsQueue;
513
+ protected abstract readonly onEventBlocked?: CoreStatefulConfig['onEventBlocked'];
514
+ getFlag(name: string, changes?: ChangeArray | undefined): Json;
515
+ resolveOptimizedEntry<S extends EntrySkeletonType = EntrySkeletonType, L extends LocaleCode = LocaleCode>(entry: Entry<S, undefined, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, undefined, L>;
516
+ resolveOptimizedEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, M, L>;
517
+ getMergeTagValue(embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile | undefined): string | undefined;
802
518
  /**
803
- * Release singleton ownership for stateful runtime usage.
519
+ * Convenience wrapper for sending an `identify` event through the Experience path.
804
520
  *
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).
521
+ * @param payload - Identify builder arguments.
522
+ * @returns The resulting {@link OptimizationData} for the identified user.
523
+ * @example
524
+ * ```ts
525
+ * const data = await core.identify({ userId: 'user-123', traits: { plan: 'pro' } })
526
+ * ```
808
527
  */
809
- destroy(): void;
528
+ identify(payload: IdentifyBuilderArgs & {
529
+ profile?: PartialProfile;
530
+ }): Promise<OptimizationData | undefined>;
810
531
  /**
811
- * Expose merged observable state for consumers.
532
+ * Convenience wrapper for sending a `page` event through the Experience path.
812
533
  *
813
- * @returns The combined {@link CoreStates} observable object.
534
+ * @param payload - Page view builder arguments.
535
+ * @returns The evaluated {@link OptimizationData} for this page view.
536
+ * @example
537
+ * ```ts
538
+ * const data = await core.page({ properties: { title: 'Home' } })
539
+ * ```
814
540
  */
815
- get states(): CoreStates;
541
+ page(payload?: PageViewBuilderArgs & {
542
+ profile?: PartialProfile;
543
+ }): Promise<OptimizationData | undefined>;
816
544
  /**
817
- * Reset internal state. Consent and preview panel state are intentionally preserved.
545
+ * Convenience wrapper for sending a `screen` event through the Experience path.
818
546
  *
819
- * @remarks
820
- * Resetting personalization also resets analytics dependencies as a
821
- * consequence of the current shared-state design.
547
+ * @param payload - Screen view builder arguments.
548
+ * @returns The evaluated {@link OptimizationData} for this screen view.
822
549
  * @example
823
550
  * ```ts
824
- * core.reset()
551
+ * const data = await core.screen({ name: 'HomeScreen' })
825
552
  * ```
826
553
  */
827
- reset(): void;
554
+ screen(payload: ScreenViewBuilderArgs & {
555
+ profile?: PartialProfile;
556
+ }): Promise<OptimizationData | undefined>;
828
557
  /**
829
- * Flush the queues for both the analytics and personalization products.
830
- * @remarks
831
- * The personalization queue is only populated if events have been triggered
832
- * while a device is offline.
558
+ * Convenience wrapper for sending a custom `track` event through the Experience path.
559
+ *
560
+ * @param payload - Track builder arguments.
561
+ * @returns The evaluated {@link OptimizationData} for this event.
833
562
  * @example
834
563
  * ```ts
835
- * await core.flush()
564
+ * const data = await core.track({ event: 'button_click', properties: { label: 'Buy' } })
836
565
  * ```
837
566
  */
838
- flush(): Promise<void>;
567
+ track(payload: TrackBuilderArgs & {
568
+ profile?: PartialProfile;
569
+ }): Promise<OptimizationData | undefined>;
839
570
  /**
840
- * Update consent state
571
+ * Track an entry view through Insights and, when sticky, Experience.
841
572
  *
842
- * @param accept - `true` if the user has granted consent; `false` otherwise.
573
+ * @param payload - Entry view builder arguments. When `payload.sticky` is
574
+ * `true`, the event will also be sent through Experience as a sticky
575
+ * entry view.
576
+ * @returns A promise that resolves when all delegated calls complete.
577
+ * @remarks
578
+ * Experience receives sticky entry views only; Insights is always invoked
579
+ * regardless of `sticky`.
843
580
  * @example
844
581
  * ```ts
845
- * core.consent(true)
582
+ * await core.trackView({ componentId: 'entry-123', sticky: true })
846
583
  * ```
847
584
  */
848
- consent(accept: boolean): void;
585
+ trackView(payload: ViewBuilderArgs & {
586
+ profile?: PartialProfile;
587
+ }): Promise<OptimizationData | undefined>;
849
588
  /**
850
- * Read current online state.
589
+ * Track an entry click through Insights.
851
590
  *
591
+ * @param payload - Entry click builder arguments.
592
+ * @returns A promise that resolves when processing completes.
852
593
  * @example
853
594
  * ```ts
854
- * if (this.online) {
855
- * await this.flush()
856
- * }
595
+ * await core.trackClick({ componentId: 'entry-123' })
857
596
  * ```
858
597
  */
859
- protected get online(): boolean;
598
+ trackClick(payload: ClickBuilderArgs): Promise<void>;
860
599
  /**
861
- * Update online state.
600
+ * Track an entry hover through Insights.
862
601
  *
863
- * @param isOnline - `true` if the runtime is online; `false` otherwise.
602
+ * @param payload - Entry hover builder arguments.
603
+ * @returns A promise that resolves when processing completes.
864
604
  * @example
865
605
  * ```ts
866
- * this.online = navigator.onLine
606
+ * await core.trackHover({ componentId: 'entry-123' })
867
607
  * ```
868
608
  */
869
- protected set online(isOnline: boolean);
609
+ trackHover(payload: HoverBuilderArgs): Promise<void>;
870
610
  /**
871
- * Register a preview panel compatible object to receive direct signal access.
872
- * This enables the preview panel to modify SDK state for testing and simulation.
611
+ * Track a feature flag view through Insights.
873
612
  *
874
- * @param previewPanel - An object implementing PreviewPanelSignalObject
875
- * @remarks
876
- * This method is intended for use by the Preview Panel component.
877
- * Direct signal access allows immediate state updates without API calls.
613
+ * @param payload - Flag view builder arguments used to build the flag view event.
614
+ * @returns A promise that resolves when processing completes.
878
615
  * @example
879
616
  * ```ts
880
- * const previewBridge: PreviewPanelSignalObject = {}
881
- * core.registerPreviewPanel(previewBridge)
617
+ * await core.trackFlagView({ componentId: 'feature-flag-123' })
882
618
  * ```
883
619
  */
884
- registerPreviewPanel(previewPanel: PreviewPanelSignalObject): void;
620
+ trackFlagView(payload: FlagViewBuilderArgs): Promise<void>;
621
+ hasConsent(name: string): boolean;
622
+ onBlockedByConsent(name: string, args: readonly unknown[]): void;
623
+ protected sendExperienceEvent(method: string, args: readonly unknown[], event: ExperienceEvent, _profile?: PartialProfile): Promise<OptimizationData | undefined>;
624
+ protected sendInsightsEvent(method: string, args: readonly unknown[], event: InsightsEvent, _profile?: PartialProfile): Promise<void>;
625
+ private buildFlagViewBuilderArgs;
626
+ protected getFlagObservable(name: string): Observable<Json>;
627
+ private reportBlockedEvent;
885
628
  }
886
629
 
887
630
  /**
888
- * Stateful analytics configuration.
631
+ * Core runtime for stateless environments.
889
632
  *
890
633
  * @public
634
+ * Built on top of `CoreBase`. Request-emitting methods are exposed through
635
+ * {@link CoreStateless.forRequest}.
891
636
  */
892
- export declare type CoreStatefulAnalyticsConfig = NonNullable<CoreConfig['analytics']> & {
637
+ export declare class CoreStateless extends CoreBase<CoreStatelessConfig> {
638
+ constructor(config: CoreStatelessConfig);
893
639
  /**
894
- * Queue policy for stateful analytics event buffering and flush retries.
640
+ * Bind request-scoped Experience API options for a single stateless request.
895
641
  *
896
- * @see {@link AnalyticsProductConfig.queuePolicy}
642
+ * @param options - Request-scoped Experience API options.
643
+ * @returns A lightweight request scope for stateless event emission.
897
644
  */
898
- queuePolicy?: AnalyticsProductConfig['queuePolicy'];
899
- };
645
+ forRequest(options?: CoreStatelessRequestOptions): CoreStatelessRequestScope;
646
+ }
900
647
 
901
648
  /**
902
- * Configuration for {@link CoreStateful}.
649
+ * API configuration for stateless Core runtimes.
903
650
  *
904
651
  * @public
905
- * @see {@link CoreConfig}
906
652
  */
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.
914
- */
915
- personalization?: CoreStatefulPersonalizationConfig;
916
- /**
917
- * Allow-listed event type strings permitted when consent is not set.
918
- *
919
- * @see {@link ProductConfig.allowedEventTypes}
920
- */
921
- allowedEventTypes?: ProductConfig['allowedEventTypes'];
922
- /** Optional set of default values applied on initialization. */
923
- defaults?: CoreConfigDefaults;
924
- /** Function used to obtain an anonymous user identifier. */
925
- getAnonymousId?: PersonalizationProductConfig['getAnonymousId'];
926
- /**
927
- * Callback invoked whenever an event call is blocked by checks.
928
- */
929
- onEventBlocked?: ProductConfig['onEventBlocked'];
653
+ export declare interface CoreStatelessApiConfig extends CoreSharedApiConfig {
930
654
  }
931
655
 
932
656
  /**
933
- * Stateful personalization configuration.
657
+ * Configuration for stateless Optimization Core runtimes.
934
658
  *
935
659
  * @public
660
+ * @remarks
661
+ * This configuration extends {@link CoreConfig} but allows partial overrides
662
+ * of the event-builder configuration. SDKs commonly inject their own library
663
+ * metadata or channel definitions.
936
664
  */
937
- export declare type CoreStatefulPersonalizationConfig = NonNullable<CoreConfig['personalization']> & {
665
+ export declare interface CoreStatelessConfig extends CoreConfig {
938
666
  /**
939
- * Queue policy for stateful personalization offline event buffering.
940
- *
941
- * @see {@link PersonalizationProductConfig.queuePolicy}
667
+ * Unified API configuration for stateless environments.
942
668
  */
943
- queuePolicy?: PersonalizationProductConfig['queuePolicy'];
944
- };
669
+ api?: CoreStatelessApiConfig;
670
+ /**
671
+ * Overrides for the event builder configuration. Omits methods that are only
672
+ * useful in stateful environments.
673
+ */
674
+ eventBuilder?: Omit<EventBuilderConfig, 'getLocale' | 'getPageProperties' | 'getUserAgent'>;
675
+ }
945
676
 
946
677
  /**
947
- * Core runtime that constructs product instances for stateless environments.
678
+ * Request-bound Experience API options for stateless runtimes.
948
679
  *
949
680
  * @public
950
- * @see {@link CoreBase}
951
681
  */
952
- export declare class CoreStateless extends CoreBase {
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);
682
+ export declare interface CoreStatelessRequestOptions extends Pick<ExperienceApiClientRequestOptions, 'ip' | 'locale' | 'plainText' | 'preflight'> {
969
683
  }
970
684
 
971
685
  /**
972
- * Configuration for the Node-specific Optimization SDK.
686
+ * Stateless request scope created by {@link CoreStateless.forRequest}.
973
687
  *
974
688
  * @public
975
- * @remarks
976
- * This configuration extends {@link CoreConfig} but allows partial overrides
977
- * of the event-builder configuration. SDKs commonly inject their own library
978
- * metadata or channel definitions.
979
689
  */
980
- export declare interface CoreStatelessConfig extends CoreConfig {
690
+ export declare class CoreStatelessRequestScope {
691
+ private readonly core;
692
+ private readonly options;
693
+ constructor(core: CoreStateless, options?: CoreStatelessRequestOptions);
694
+ identify(payload: StatelessExperiencePayload<IdentifyBuilderArgs>): Promise<OptimizationData>;
695
+ page(payload?: StatelessExperiencePayload<PageViewBuilderArgs>): Promise<OptimizationData>;
696
+ screen(payload: StatelessExperiencePayload<ScreenViewBuilderArgs>): Promise<OptimizationData>;
697
+ track(payload: StatelessExperiencePayload<TrackBuilderArgs>): Promise<OptimizationData>;
981
698
  /**
982
- * Override configuration for the analytics (Insights) API client. Omits
983
- * `beaconHandler`.
699
+ * Record an entry view in a stateless runtime.
700
+ *
701
+ * @remarks
702
+ * Non-sticky entry views require `payload.profile.id` for Insights delivery.
703
+ * Sticky entry views may omit `profile`, because the returned Experience
704
+ * profile is reused for the paired Insights event.
984
705
  */
985
- analytics?: Omit<CoreConfig['analytics'], 'beaconHandler'>;
706
+ trackView(payload: StatelessStickyTrackViewPayload | StatelessNonStickyTrackViewPayload): Promise<OptimizationData | undefined>;
986
707
  /**
987
- * Overrides for the event builder configuration. Omits methods that are only
988
- * useful in stateful environments.
708
+ * Record an entry click in a stateless runtime.
709
+ *
710
+ * @remarks
711
+ * Stateless Insights delivery requires `payload.profile.id`.
989
712
  */
990
- eventBuilder?: Omit<EventBuilderConfig, 'getLocale' | 'getPageProperties' | 'getUserAgent'>;
713
+ trackClick(payload: StatelessInsightsPayload<ClickBuilderArgs>): Promise<void>;
714
+ /**
715
+ * Record an entry hover in a stateless runtime.
716
+ *
717
+ * @remarks
718
+ * Stateless Insights delivery requires `payload.profile.id`.
719
+ */
720
+ trackHover(payload: StatelessInsightsPayload<HoverBuilderArgs>): Promise<void>;
721
+ /**
722
+ * Record a Custom Flag view in a stateless runtime.
723
+ *
724
+ * @remarks
725
+ * Stateless Insights delivery requires `payload.profile.id`.
726
+ */
727
+ trackFlagView(payload: StatelessInsightsPayload<FlagViewBuilderArgs>): Promise<void>;
728
+ private sendExperienceEvent;
729
+ private sendInsightsEvent;
991
730
  }
992
731
 
993
732
  /**
994
733
  * Combined observable state exposed by the stateful core.
995
734
  *
996
735
  * @public
997
- * @see {@link AnalyticsStates}
998
- * @see {@link PersonalizationStates}
999
736
  */
1000
- export declare interface CoreStates extends AnalyticsStates, PersonalizationStates {
737
+ export declare interface CoreStates {
1001
738
  /** Current consent value (if any). */
1002
739
  consent: Observable<boolean | undefined>;
1003
740
  /** Whether the preview panel has been attached to the host runtime. */
@@ -1006,8 +743,16 @@ declare abstract class CoreBase implements ResolverMethods {
1006
743
  previewPanelOpen: Observable<boolean>;
1007
744
  /** Stream of the most recent blocked event payload. */
1008
745
  blockedEventStream: Observable<BlockedEvent | undefined>;
1009
- /** Stream of the most recent event emitted (analytics or personalization). */
746
+ /** Stream of the most recent event emitted. */
1010
747
  eventStream: Observable<InsightsEvent | ExperienceEvent | undefined>;
748
+ /** Key-scoped observable for a single Custom Flag value. */
749
+ flag: (name: string) => Observable<Json>;
750
+ /** Live view of the current profile. */
751
+ profile: Observable<Profile | undefined>;
752
+ /** Live view of selected optimizations (variants). */
753
+ selectedOptimizations: Observable<SelectedOptimizationArray | undefined>;
754
+ /** Whether optimization data is currently available. */
755
+ canOptimize: Observable<boolean>;
1011
756
  }
1012
757
 
1013
758
  /**
@@ -1017,67 +762,578 @@ declare abstract class CoreBase implements ResolverMethods {
1017
762
  */
1018
763
  export declare const DEBUG_FLAG_KEY = "__ctfl_opt_debug__";
1019
764
 
765
+ /**
766
+ * Default page properties used when no explicit page information is available.
767
+ *
768
+ * @defaultValue
769
+ * ```ts
770
+ * {
771
+ * path: '',
772
+ * query: {},
773
+ * referrer: '',
774
+ * search: '',
775
+ * title: '',
776
+ * url: '',
777
+ * }
778
+ * ```
779
+ *
780
+ * @remarks
781
+ * Values are required by the API; values may not be `undefined`. Empty values are valid.
782
+ *
783
+ * @public
784
+ */
785
+ export declare const DEFAULT_PAGE_PROPERTIES: {
786
+ path: string;
787
+ query: {};
788
+ referrer: string;
789
+ search: string;
790
+ title: string;
791
+ url: string;
792
+ };
793
+
1020
794
  export { effect }
1021
795
 
1022
- declare const event_2: Signal<InsightsEvent | ExperienceEvent | undefined>;
796
+ export declare const EntryInteractionBuilderArgsBase: z.ZodMiniObject<{
797
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
798
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
799
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
800
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
801
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
802
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
803
+ }, z.core.$strip>>;
804
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
805
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
806
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
807
+ latitude: z.ZodMiniNumber<number>;
808
+ longitude: z.ZodMiniNumber<number>;
809
+ }, z.core.$strip>>;
810
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
811
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
812
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
813
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
814
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
815
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
816
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
817
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
818
+ }, z.core.$strip>>;
819
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
820
+ path: z.ZodMiniString<string>;
821
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
822
+ referrer: z.ZodMiniString<string>;
823
+ search: z.ZodMiniString<string>;
824
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
825
+ url: z.ZodMiniString<string>;
826
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
827
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
828
+ name: z.ZodMiniString<string>;
829
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
830
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
831
+ componentId: z.ZodMiniString<string>;
832
+ experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
833
+ variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
834
+ }, z.core.$strip>;
835
+
836
+ /**
837
+ * Arguments shared by entry view, click, and hover events.
838
+ *
839
+ * @public
840
+ */
841
+ export declare type EntryInteractionBuilderArgsBase = z.infer<typeof EntryInteractionBuilderArgsBase>;
1023
842
 
1024
843
  /**
1025
- * Union of all event {@link AnalyticsEventType | type keys} that this package may emit.
844
+ * Most recent emitted optimization event.
1026
845
  *
1027
846
  * @public
1028
847
  */
1029
- declare type EventType = InsightsEventType | ExperienceEventType;
1030
-
1031
- declare const flags: ReadonlySignal<Flags | undefined>;
848
+ declare const event_2: Signal<InsightsEvent | ExperienceEvent | undefined>;
1032
849
 
1033
850
  /**
1034
- * Resolves a {@link Flags} map from a list of optimization changes.
851
+ * Helper class for building optimization events.
1035
852
  *
1036
- * @public
1037
853
  * @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.
854
+ * This class coordinates configuration and argument validation to produce
855
+ * strongly-typed event payloads compatible with
856
+ * `@contentful/optimization-api-schemas`.
857
+ *
858
+ * @see {@link EventBuilderConfig}
859
+ *
860
+ * @public
1042
861
  */
1043
- export declare const FlagsResolver: {
862
+ export declare class EventBuilder {
1044
863
  /**
1045
- * Build a flattened map of flag keys to values from a change list.
864
+ * Application metadata attached to each event.
865
+ *
866
+ * @internal
867
+ */
868
+ app?: App;
869
+ /**
870
+ * Channel value attached to each event.
871
+ *
872
+ * @internal
873
+ */
874
+ channel: Channel;
875
+ /**
876
+ * Library metadata attached to each event.
877
+ *
878
+ * @internal
879
+ */
880
+ library: Library;
881
+ /**
882
+ * Function that provides the locale when available.
883
+ *
884
+ * @internal
885
+ */
886
+ getLocale: () => string | undefined;
887
+ /**
888
+ * Function that provides baseline page properties.
889
+ *
890
+ * @internal
891
+ */
892
+ getPageProperties: () => Page;
893
+ /**
894
+ * Function that provides the user agent string when available.
895
+ *
896
+ * @internal
897
+ */
898
+ getUserAgent: () => string | undefined;
899
+ /**
900
+ * Creates a new {@link EventBuilder} instance.
901
+ *
902
+ * @param config - Configuration used to customize event payloads.
903
+ *
904
+ * @remarks
905
+ * Callers are expected to reuse a single instance when possible to avoid
906
+ * repeatedly reconfiguring the builder.
1046
907
  *
1047
- * @param changes - The change list returned by the optimization service.
1048
- * @returns A map of flag keys to their resolved values.
1049
908
  * @example
1050
909
  * ```ts
1051
- * const flags = FlagsResolver.resolve(data.changes)
1052
- * if (flags['theme'] === 'dark') enableDarkMode()
910
+ * const builder = new EventBuilder({
911
+ * channel: 'web',
912
+ * library: { name: '@contentful/optimization-sdk', version: '1.0.0' },
913
+ * })
1053
914
  * ```
915
+ */
916
+ constructor(config: EventBuilderConfig);
917
+ /**
918
+ * Builds the universal event properties shared across all event types.
919
+ *
920
+ * @param args - Arguments overriding the default context values.
921
+ * @returns A fully populated {@link UniversalEventProperties} object.
922
+ *
923
+ * @remarks
924
+ * This method is used internally by the specific event-builder methods
925
+ * (e.g. {@link EventBuilder.buildPageView}).
926
+ */
927
+ protected buildUniversalEventProperties({ campaign, locale, location, page, screen, userAgent, }: UniversalEventBuilderArgs): UniversalEventProperties;
928
+ private buildEntryInteractionBase;
929
+ /**
930
+ * Builds a `component` view event payload for entry exposure tracking.
931
+ *
932
+ * @param args - {@link ViewBuilderArgs} arguments describing the entry view.
933
+ * @returns A {@link ViewEvent} describing the view.
934
+ *
1054
935
  * @example
1055
- * // Handles wrapped values produced by the API
1056
936
  * ```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
937
+ * const event = builder.buildView({
938
+ * componentId: 'entry-123',
939
+ * viewId: crypto.randomUUID(),
940
+ * experienceId: 'experience-123',
941
+ * variantIndex: 1,
942
+ * viewDurationMs: 1_000,
943
+ * })
1061
944
  * ```
945
+ *
946
+ * @public
1062
947
  */
1063
- resolve(changes?: ChangeArray): Flags;
1064
- };
1065
-
1066
- /**
1067
- * Decorator factory that **guards** class methods behind a synchronous predicate.
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`
948
+ buildView(args: ViewBuilderArgs): ViewEvent;
949
+ /**
950
+ * Builds a `component_click` payload for entry click tracking.
951
+ *
952
+ * @param args - {@link ClickBuilderArgs} arguments describing the entry click.
953
+ * @returns A {@link ClickEvent} describing the click.
954
+ *
955
+ * @example
956
+ * ```ts
957
+ * const event = builder.buildClick({
958
+ * componentId: 'entry-123',
959
+ * experienceId: 'experience-123',
960
+ * variantIndex: 1,
961
+ * })
962
+ * ```
963
+ *
964
+ * @public
965
+ */
966
+ buildClick(args: ClickBuilderArgs): ClickEvent;
967
+ /**
968
+ * Builds a `component_hover` payload for entry hover tracking.
969
+ *
970
+ * @param args - {@link HoverBuilderArgs} arguments describing the entry hover.
971
+ * @returns A {@link HoverEvent} describing the hover.
972
+ *
973
+ * @example
974
+ * ```ts
975
+ * const event = builder.buildHover({
976
+ * componentId: 'entry-123',
977
+ * hoverId: crypto.randomUUID(),
978
+ * experienceId: 'experience-123',
979
+ * hoverDurationMs: 1_000,
980
+ * variantIndex: 1,
981
+ * })
982
+ * ```
983
+ *
984
+ * @public
985
+ */
986
+ buildHover(args: HoverBuilderArgs): HoverEvent;
987
+ /**
988
+ * Builds a `component` view event payload for Custom Flag exposure tracking.
989
+ *
990
+ * @param args - {@link FlagViewBuilderArgs} arguments describing the Custom Flag view.
991
+ * @returns A {@link ViewEvent} describing the view.
992
+ *
993
+ * @remarks
994
+ * This is a specialized variant of {@link EventBuilder.buildView}
995
+ * that sets `componentType` to `'Variable'`.
996
+ *
997
+ * @example
998
+ * ```ts
999
+ * const event = builder.buildFlagView({
1000
+ * componentId: 'feature-flag-key',
1001
+ * viewId: crypto.randomUUID(),
1002
+ * experienceId: 'experience-123',
1003
+ * viewDurationMs: 1_000,
1004
+ * })
1005
+ * ```
1006
+ *
1007
+ * @public
1008
+ */
1009
+ buildFlagView(args: FlagViewBuilderArgs): ViewEvent;
1010
+ /**
1011
+ * Builds an identify event payload to associate a user ID with traits.
1012
+ *
1013
+ * @param args - {@link IdentifyBuilderArgs} arguments describing the identified user.
1014
+ * @returns An {@link IdentifyEvent} payload.
1015
+ *
1016
+ * @remarks
1017
+ * - Traits are merged by the API; only specified properties may be overwritten.
1018
+ * - The User ID is consumer-specified and should not contain the value of any
1019
+ * ID generated by the Experience API.
1020
+ *
1021
+ * @example
1022
+ * ```ts
1023
+ * const event = builder.buildIdentify({
1024
+ * userId: 'user-123',
1025
+ * traits: { plan: 'pro' },
1026
+ * })
1027
+ * ```
1028
+ *
1029
+ * @public
1030
+ */
1031
+ buildIdentify(args: IdentifyBuilderArgs): IdentifyEvent;
1032
+ /**
1033
+ * Builds a page view event payload.
1034
+ *
1035
+ * @param args - Optional {@link PageViewBuilderArgs} overrides for the page view event.
1036
+ * @returns A {@link PageViewEvent} payload.
1037
+ *
1038
+ * @remarks
1039
+ * Page properties are created by merging:
1040
+ * 1. The base page properties from {@link EventBuilderConfig.getPageProperties}, and
1041
+ * 2. The partial `properties` argument passed in.
1042
+ *
1043
+ * The title always falls back to {@link DEFAULT_PAGE_PROPERTIES}.title when undefined.
1044
+ *
1045
+ * @example
1046
+ * ```ts
1047
+ * const event = builder.buildPageView({
1048
+ * properties: {
1049
+ * title: 'Homepage',
1050
+ * },
1051
+ * })
1052
+ * ```
1053
+ *
1054
+ * @public
1055
+ */
1056
+ buildPageView(args?: PageViewBuilderArgs): PageViewEvent;
1057
+ /**
1058
+ * Builds a screen view event payload.
1059
+ *
1060
+ * @param args - {@link ScreenViewBuilderArgs} arguments for the screen view event.
1061
+ * @returns A {@link ScreenViewEvent} payload.
1062
+ *
1063
+ * @example
1064
+ * ```ts
1065
+ * const event = builder.buildScreenView({
1066
+ * name: 'home',
1067
+ * properties: {
1068
+ * title: 'Home Screen',
1069
+ * },
1070
+ * })
1071
+ * ```
1072
+ *
1073
+ * @public
1074
+ */
1075
+ buildScreenView(args: ScreenViewBuilderArgs): ScreenViewEvent;
1076
+ /**
1077
+ * Builds a track event payload for arbitrary user actions.
1078
+ *
1079
+ * @param args - {@link TrackBuilderArgs} arguments describing the tracked event.
1080
+ * @returns A {@link TrackEvent} payload.
1081
+ *
1082
+ * @example
1083
+ * ```ts
1084
+ * const event = builder.buildTrack({
1085
+ * event: 'button_clicked',
1086
+ * properties: { id: 'primary-cta', location: 'hero' },
1087
+ * })
1088
+ * ```
1089
+ *
1090
+ * @public
1091
+ */
1092
+ buildTrack(args: TrackBuilderArgs): TrackEvent_2;
1093
+ }
1094
+
1095
+ /**
1096
+ * Configuration options for creating an {@link EventBuilder} instance.
1097
+ *
1098
+ * @remarks
1099
+ * The configuration is typically provided by the host application to adapt
1100
+ * event payloads to the runtime environment (browser, framework, etc.).
1101
+ *
1102
+ * @example
1103
+ * ```ts
1104
+ * const builder = new EventBuilder({
1105
+ * app: { name: 'my-app', version: '1.0.0' },
1106
+ * channel: 'web',
1107
+ * library: { name: '@contentful/optimization-sdk', version: '1.2.3' },
1108
+ * getLocale: () => navigator.language,
1109
+ * getPageProperties: () => ({
1110
+ * path: window.location.pathname,
1111
+ * url: window.location.href,
1112
+ * title: document.title,
1113
+ * query: {},
1114
+ * referrer: document.referrer,
1115
+ * search: window.location.search,
1116
+ * }),
1117
+ * })
1118
+ * ```
1119
+ *
1120
+ * @public
1121
+ */
1122
+ export declare interface EventBuilderConfig {
1123
+ /**
1124
+ * The application definition used to attribute events to a specific consumer app.
1125
+ *
1126
+ * @remarks
1127
+ * When not provided, events will not contain app metadata in their context.
1128
+ */
1129
+ app?: App;
1130
+ /**
1131
+ * The channel that identifies where events originate from (e.g. web, mobile).
1132
+ *
1133
+ * @see {@link Channel}
1134
+ */
1135
+ channel: Channel;
1136
+ /**
1137
+ * The client library metadata that is attached to all events.
1138
+ *
1139
+ * @remarks
1140
+ * This is typically used to record the library name and version.
1141
+ */
1142
+ library: Library;
1143
+ /**
1144
+ * Function used to resolve the locale for outgoing events.
1145
+ *
1146
+ * @remarks
1147
+ * If not provided, the builder falls back to the default `'en-US'`. Locale
1148
+ * values supplied directly as arguments to event builder methods take
1149
+ * precedence.
1150
+ *
1151
+ * @returns The locale string (e.g. `'en-US'`), or `undefined` if unavailable.
1152
+ */
1153
+ getLocale?: () => string | undefined;
1154
+ /**
1155
+ * Function that returns the current page properties.
1156
+ *
1157
+ * @remarks
1158
+ * Page properties are currently added to the context of all events, as well
1159
+ * as the `properties` of the page event. When specified, all properties of
1160
+ * the `Page` type are required, but may contain empty values.
1161
+ *
1162
+ * @returns A {@link Page} object containing information about the current page.
1163
+ * @see {@link Page}
1164
+ */
1165
+ getPageProperties?: () => Page;
1166
+ /**
1167
+ * Function used to obtain the current user agent string when applicable.
1168
+ *
1169
+ * @returns A user agent string, or `undefined` if unavailable.
1170
+ */
1171
+ getUserAgent?: () => string | undefined;
1172
+ }
1173
+
1174
+ /**
1175
+ * Union of all event type keys that stateful Core may emit.
1176
+ *
1177
+ * @public
1178
+ */
1179
+ export declare type EventType = InsightsEventType | ExperienceEventType;
1180
+
1181
+ /**
1182
+ * Internal Experience send/offline runtime used by {@link CoreStateful}.
1183
+ *
1184
+ * @internal
1185
+ */
1186
+ declare class ExperienceQueue {
1187
+ private readonly experienceApi;
1188
+ private readonly eventInterceptors;
1189
+ private readonly flushRuntime;
1190
+ private readonly getAnonymousId;
1191
+ private readonly offlineMaxEvents;
1192
+ private readonly onOfflineDrop?;
1193
+ private readonly queuedExperienceEvents;
1194
+ private readonly stateInterceptors;
1195
+ constructor(options: ExperienceQueueOptions);
1196
+ clearScheduledRetry(): void;
1197
+ send(event: ExperienceEvent): Promise<OptimizationData | undefined>;
1198
+ flush(options?: {
1199
+ force?: boolean;
1200
+ }): Promise<void>;
1201
+ private enqueueEvent;
1202
+ private dropOldestEvents;
1203
+ private invokeOfflineDropCallback;
1204
+ private tryUpsertQueuedEvents;
1205
+ private upsertProfile;
1206
+ private updateOutputSignals;
1207
+ }
1208
+
1209
+ /**
1210
+ * Context payload emitted when offline Experience events are dropped.
1211
+ *
1212
+ * @public
1213
+ */
1214
+ export declare interface ExperienceQueueDropContext {
1215
+ /** Number of dropped events. */
1216
+ droppedCount: number;
1217
+ /** Dropped events in oldest-first order. */
1218
+ droppedEvents: ExperienceEventArray;
1219
+ /** Configured queue max size. */
1220
+ maxEvents: number;
1221
+ /** Queue size after enqueueing the current event. */
1222
+ queuedEvents: number;
1223
+ }
1224
+
1225
+ declare interface ExperienceQueueOptions {
1226
+ experienceApi: {
1227
+ upsertProfile: (payload: {
1228
+ profileId?: string;
1229
+ events: ExperienceEventArray;
1230
+ }) => Promise<OptimizationData>;
1231
+ };
1232
+ eventInterceptors: LifecycleInterceptors['event'];
1233
+ flushPolicy: ResolvedQueueFlushPolicy;
1234
+ getAnonymousId: () => string | undefined;
1235
+ offlineMaxEvents: number;
1236
+ onOfflineDrop?: (context: ExperienceQueueDropContext) => void;
1237
+ stateInterceptors: LifecycleInterceptors['state'];
1238
+ }
1239
+
1240
+ /**
1241
+ * Resolves a {@link Flags} map from a list of optimization changes.
1242
+ *
1243
+ * @public
1244
+ * @remarks
1245
+ * Given an Optimization {@link ChangeArray}, this utility flattens the list into a
1246
+ * simple key–value object suitable for quick lookups in client code. When `changes`
1247
+ * is `undefined`, an empty object is returned. If a change value is wrapped in an
1248
+ * object like `{ value: { ... } }`, this resolver unwraps it to the underlying object.
1249
+ */
1250
+ export declare const FlagsResolver: {
1251
+ /**
1252
+ * Build a flattened map of flag keys to values from a change list.
1253
+ *
1254
+ * @param changes - The change list returned by the optimization service.
1255
+ * @returns A map of flag keys to their resolved values.
1256
+ * @example
1257
+ * ```ts
1258
+ * const flags = FlagsResolver.resolve(data.changes)
1259
+ * if (flags['theme'] === 'dark') enableDarkMode()
1260
+ * ```
1261
+ * @example
1262
+ * // Handles wrapped values produced by the API
1263
+ * ```ts
1264
+ * const flags = FlagsResolver.resolve([
1265
+ * { type: 'Variable', key: 'price', value: { value: { amount: 10, currency: 'USD' } } }
1266
+ * ])
1267
+ * console.log(flags.price.amount) // 10
1268
+ * ```
1269
+ */
1270
+ resolve(changes?: ChangeArray): Flags_2;
1271
+ };
1272
+
1273
+ export declare const FlagViewBuilderArgs: z.ZodMiniObject<{
1274
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
1275
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
1276
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
1277
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
1278
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
1279
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
1280
+ }, z.core.$strip>>;
1281
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
1282
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
1283
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
1284
+ latitude: z.ZodMiniNumber<number>;
1285
+ longitude: z.ZodMiniNumber<number>;
1286
+ }, z.core.$strip>>;
1287
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
1288
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1289
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
1290
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1291
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
1292
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1293
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1294
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
1295
+ }, z.core.$strip>>;
1296
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
1297
+ path: z.ZodMiniString<string>;
1298
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
1299
+ referrer: z.ZodMiniString<string>;
1300
+ search: z.ZodMiniString<string>;
1301
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
1302
+ url: z.ZodMiniString<string>;
1303
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1304
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
1305
+ name: z.ZodMiniString<string>;
1306
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1307
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1308
+ componentId: z.ZodMiniString<string>;
1309
+ experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
1310
+ variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
1311
+ viewId: z.ZodMiniOptional<z.ZodMiniString<string>>;
1312
+ viewDurationMs: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
1313
+ }, z.core.$strip>;
1314
+
1315
+ /**
1316
+ * Arguments for constructing Custom Flag view events.
1317
+ *
1318
+ * @public
1319
+ */
1320
+ export declare type FlagViewBuilderArgs = z.infer<typeof FlagViewBuilderArgs>;
1321
+
1322
+ /**
1323
+ * Decorator factory that **guards** class methods behind a synchronous predicate.
1324
+ *
1325
+ * When a decorated method is invoked:
1326
+ * - If the predicate returns a value that evaluates to **allowed** (see `invert`), the original
1327
+ * method is executed and its result is returned.
1328
+ * - If the call is **blocked**, the optional `onBlocked` hook is invoked (if configured) and:
1329
+ * - `undefined` is returned for sync methods; or
1330
+ * - `Promise<undefined>` is returned for async methods (to preserve `await` compatibility).
1331
+ *
1332
+ * @typeParam T - The instance type that owns both the predicate and the decorated method.
1333
+ *
1334
+ * @param predicateName - The name (string or symbol) of a **synchronous** instance method on `this`
1079
1335
  * 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`.
1336
+ * @param opts - Optional `GuardedByOptions` to configure inversion and `onBlocked`.
1081
1337
  *
1082
1338
  * @returns A methods-only class decorator compatible with Stage-3 decorators that wraps the method.
1083
1339
  *
@@ -1131,7 +1387,7 @@ declare abstract class CoreBase implements ResolverMethods {
1131
1387
  *
1132
1388
  * @internal
1133
1389
  */
1134
- declare type GuardedByFunction<T extends object> = <A extends readonly unknown[], R>(value: (...args: A) => R, context: ClassMethodDecoratorContext<T, (...args: A) => R>) => void;
1390
+ export declare type GuardedByFunction<T extends object> = <A extends readonly unknown[], R>(value: (...args: A) => R, context: ClassMethodDecoratorContext<T, (...args: A) => R>) => void;
1135
1391
 
1136
1392
  /**
1137
1393
  * Options that tweak the behavior of {@link guardedBy}.
@@ -1140,7 +1396,7 @@ declare abstract class CoreBase implements ResolverMethods {
1140
1396
  *
1141
1397
  * @public
1142
1398
  */
1143
- declare interface GuardedByOptions<T extends object> {
1399
+ export declare interface GuardedByOptions<T extends object> {
1144
1400
  /**
1145
1401
  * Inverts the predicate result.
1146
1402
  *
@@ -1169,6 +1425,138 @@ declare abstract class CoreBase implements ResolverMethods {
1169
1425
  readonly onBlocked?: BlockHandler | (keyof T & (string | symbol));
1170
1426
  }
1171
1427
 
1428
+ export declare const HoverBuilderArgs: z.ZodMiniObject<{
1429
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
1430
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
1431
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
1432
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
1433
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
1434
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
1435
+ }, z.core.$strip>>;
1436
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
1437
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
1438
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
1439
+ latitude: z.ZodMiniNumber<number>;
1440
+ longitude: z.ZodMiniNumber<number>;
1441
+ }, z.core.$strip>>;
1442
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
1443
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1444
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
1445
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1446
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
1447
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1448
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1449
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
1450
+ }, z.core.$strip>>;
1451
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
1452
+ path: z.ZodMiniString<string>;
1453
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
1454
+ referrer: z.ZodMiniString<string>;
1455
+ search: z.ZodMiniString<string>;
1456
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
1457
+ url: z.ZodMiniString<string>;
1458
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1459
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
1460
+ name: z.ZodMiniString<string>;
1461
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1462
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1463
+ componentId: z.ZodMiniString<string>;
1464
+ experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
1465
+ variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
1466
+ hoverId: z.ZodMiniString<string>;
1467
+ hoverDurationMs: z.ZodMiniNumber<number>;
1468
+ }, z.core.$strip>;
1469
+
1470
+ /**
1471
+ * Arguments for constructing entry hover events.
1472
+ *
1473
+ * @public
1474
+ */
1475
+ export declare type HoverBuilderArgs = z.infer<typeof HoverBuilderArgs>;
1476
+
1477
+ export declare const IdentifyBuilderArgs: z.ZodMiniObject<{
1478
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
1479
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
1480
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
1481
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
1482
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
1483
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
1484
+ }, z.core.$strip>>;
1485
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
1486
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
1487
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
1488
+ latitude: z.ZodMiniNumber<number>;
1489
+ longitude: z.ZodMiniNumber<number>;
1490
+ }, z.core.$strip>>;
1491
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
1492
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1493
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
1494
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1495
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
1496
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1497
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1498
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
1499
+ }, z.core.$strip>>;
1500
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
1501
+ path: z.ZodMiniString<string>;
1502
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
1503
+ referrer: z.ZodMiniString<string>;
1504
+ search: z.ZodMiniString<string>;
1505
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
1506
+ url: z.ZodMiniString<string>;
1507
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1508
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
1509
+ name: z.ZodMiniString<string>;
1510
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1511
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1512
+ traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>>;
1513
+ userId: z.ZodMiniString<string>;
1514
+ }, z.core.$strip>;
1515
+
1516
+ /**
1517
+ * Arguments for constructing identify events.
1518
+ *
1519
+ * @remarks
1520
+ * Traits are merged by the API; only specified properties may be overwritten.
1521
+ *
1522
+ * @public
1523
+ */
1524
+ export declare type IdentifyBuilderArgs = z.infer<typeof IdentifyBuilderArgs>;
1525
+
1526
+ /**
1527
+ * Internal Insights queueing and flush runtime used by {@link CoreStateful}.
1528
+ *
1529
+ * @internal
1530
+ */
1531
+ declare class InsightsQueue {
1532
+ private readonly eventInterceptors;
1533
+ private readonly flushIntervalMs;
1534
+ private readonly flushRuntime;
1535
+ private readonly insightsApi;
1536
+ private readonly queuedInsightsByProfile;
1537
+ private insightsPeriodicFlushTimer;
1538
+ constructor(options: InsightsQueueOptions);
1539
+ clearScheduledRetry(): void;
1540
+ clearPeriodicFlushTimer(): void;
1541
+ send(event: InsightsEvent): Promise<void>;
1542
+ flush(options?: {
1543
+ force?: boolean;
1544
+ }): Promise<void>;
1545
+ private createBatches;
1546
+ private trySendBatches;
1547
+ private getQueuedEventCount;
1548
+ private ensurePeriodicFlushTimer;
1549
+ private reconcilePeriodicFlushTimer;
1550
+ }
1551
+
1552
+ declare interface InsightsQueueOptions {
1553
+ eventInterceptors: LifecycleInterceptors['event'];
1554
+ flushPolicy: ResolvedQueueFlushPolicy;
1555
+ insightsApi: {
1556
+ sendBatchEvents: (batches: BatchInsightsEventArray) => Promise<boolean>;
1557
+ };
1558
+ }
1559
+
1172
1560
  /**
1173
1561
  * A function that receives a value of type `T` and returns a (possibly async)
1174
1562
  * value of the same type `T`. The input is marked as `readonly` to discourage
@@ -1294,782 +1682,218 @@ declare abstract class CoreBase implements ResolverMethods {
1294
1682
  * @public
1295
1683
  */
1296
1684
  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: {
1323
- /**
1324
- * Generate a list of candidate selectors for a merge-tag ID.
1325
- *
1326
- * @param id - Merge-tag identifier (segments separated by `_`).
1327
- * @returns Array of dot-path selectors to try against a profile.
1328
- * @example
1329
- * ```ts
1330
- * // "profile_name_first" -> [
1331
- * // 'profile',
1332
- * // 'profile.name',
1333
- * // 'profile.name.first'
1334
- * // ]
1335
- * const selectors = MergeTagValueResolver.normalizeSelectors('profile_name_first')
1336
- * ```
1337
- */
1338
- normalizeSelectors(id: string): string[];
1339
- /**
1340
- * Look up a merge-tag value from a profile using normalized selectors.
1341
- *
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
- * @remarks
1346
- * Only string/number/boolean primitives are returned; objects/arrays are ignored.
1347
- * @example
1348
- * ```ts
1349
- * const value = MergeTagValueResolver.getValueFromProfile('user_email', profile)
1350
- * if (value) sendEmailTo(value)
1351
- * ```
1352
- */
1353
- getValueFromProfile(id: string, profile?: Profile): string | undefined;
1354
- /**
1355
- * Resolve the display value for a merge-tag entry using the provided profile,
1356
- * falling back to the entry's configured `nt_fallback` when necessary.
1357
- *
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
- * @example
1363
- * ```ts
1364
- * const text = MergeTagValueResolver.resolve(entry, profile)
1365
- * render(text ?? 'Guest')
1366
- * ```
1367
- */
1368
- resolve(mergeTagEntry: MergeTagEntry | undefined, profile?: Profile): string | undefined;
1369
- };
1370
-
1371
- declare interface Observable<T> {
1372
- subscribe: (next: (v: T) => void) => Subscription;
1373
- }
1374
-
1375
- declare const online: Signal<boolean | undefined>;
1376
-
1377
- /**
1378
- * The package name of the Optimization Core SDK, injected at build time.
1379
- *
1380
- * @public
1381
- */
1382
- export declare const OPTIMIZATION_CORE_SDK_NAME: string;
1383
-
1384
- /**
1385
- * The current version of the Optimization Core SDK, injected at build time.
1386
- *
1387
- * @public
1388
- */
1389
- export declare const OPTIMIZATION_CORE_SDK_VERSION: string;
1390
-
1391
- /**
1392
- * Internal base for personalization products.
1393
- *
1394
- * @internal
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.
1399
- */
1400
- export declare abstract class PersonalizationBase extends ProductBase implements ResolverMethods {
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
- };
1417
- /**
1418
- * Static {@link PersonalizedEntryResolver | resolver } for personalized
1419
- * Contentful entries (e.g., entry variants targeted to a profile audience).
1420
- *
1421
- * @remarks
1422
- * Used by higher-level personalization flows to materialize entry content
1423
- * prior to event emission.
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;
1464
- /**
1465
- * Resolve a Contentful entry to a personalized variant using the current
1466
- * or provided selected personalizations.
1467
- *
1468
- * @typeParam S - Entry skeleton type.
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.
1477
- */
1478
- personalizeEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode>(entry: Entry<S, M, L>, personalizations?: SelectedPersonalizationArray): ResolvedData<S, M, L>;
1479
- /**
1480
- * Resolve a merge tag to a value based on the current (or provided) profile.
1481
- *
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
- * @remarks
1486
- * Merge tags are references to profile data that can be substituted into content. The
1487
- * profile can be sourced from the data returned when emitting any personalization event.
1488
- */
1489
- getMergeTagValue(embeddedEntryNodeTarget: MergeTagEntry, profile?: Profile): string | undefined;
1490
- /**
1491
- * Identify the current profile/visitor to associate traits with a profile.
1492
- *
1493
- * @param payload - Identify builder payload.
1494
- * @returns The resulting {@link OptimizationData} for the identified user if the device is online.
1495
- */
1496
- abstract identify(payload: IdentifyBuilderArgs): Promise<OptimizationData | undefined>;
1497
- /**
1498
- * Record a page view.
1499
- *
1500
- * @param payload - Page view builder payload.
1501
- * @returns The evaluated {@link OptimizationData} for this page view if the device is online.
1502
- */
1503
- abstract page(payload: PageViewBuilderArgs): Promise<OptimizationData | undefined>;
1504
- /**
1505
- * Record a screen view.
1506
- *
1507
- * @param payload - Screen view builder payload.
1508
- * @returns The evaluated {@link OptimizationData} for this screen view if the device is online.
1509
- */
1510
- abstract screen(payload: ScreenViewBuilderArgs): Promise<OptimizationData | undefined>;
1511
- /**
1512
- * Record a custom track event.
1513
- *
1514
- * @param payload - Track builder payload.
1515
- * @returns The evaluated {@link OptimizationData} for this event if the device is online.
1516
- */
1517
- abstract track(payload: TrackBuilderArgs): Promise<OptimizationData | undefined>;
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>;
1528
- }
1529
-
1530
- /**
1531
- * Context payload emitted when offline personalization events are dropped due to queue bounds.
1532
- *
1533
- * @public
1534
- */
1535
- export declare interface PersonalizationOfflineQueueDropContext {
1536
- /** Number of dropped events. */
1537
- droppedCount: number;
1538
- /** Dropped events in oldest-first order. */
1539
- droppedEvents: ExperienceEventArray;
1540
- /** Configured queue max size. */
1541
- maxEvents: number;
1542
- /** Queue size after enqueueing the current event. */
1543
- queuedEvents: number;
1544
- }
1545
-
1546
- /**
1547
- * Configuration for {@link PersonalizationStateful}.
1548
- *
1549
- * @public
1550
- */
1551
- export declare interface PersonalizationProductConfig extends ProductConfig {
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;
1558
- /**
1559
- * Function used to obtain an anonymous user identifier.
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
1565
- *
1566
- * @returns A string identifier, or `undefined` if no anonymous ID is available.
1567
- */
1568
- getAnonymousId?: () => string | undefined;
1569
- }
1570
-
1571
- /**
1572
- * Default state values for {@link PersonalizationStateful} applied at construction time.
1573
- *
1574
- * @public
1575
- */
1576
- export declare interface PersonalizationProductConfigDefaults {
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
- }
1586
-
1587
- /**
1588
- * Policy options for the stateful personalization offline queue.
1589
- *
1590
- * @public
1591
- */
1592
- export declare interface PersonalizationQueuePolicy {
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>;
1614
-
1615
- /**
1616
- * Storage key for cached selected personalizations.
1617
- *
1618
- * @internal
1619
- */
1620
- export declare const PERSONALIZATIONS_CACHE_KEY = "__ctfl_opt_personalizations__";
1621
-
1622
- /**
1623
- * Stateful personalization product that manages consent, profile, flags, and
1624
- * selected variants while emitting Experience events and updating state.
1625
- *
1626
- * @public
1627
- * @remarks
1628
- * The class maintains reactive signals and exposes read‑only observables via
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;
1648
- /**
1649
- * Create a new stateful personalization instance.
1650
- *
1651
- * @param options - Options to configure the personalization product for stateful environments.
1652
- * @example
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.
1660
- *
1661
- * @remarks
1662
- * Clears `changes`, `profile`, and selected `personalizations`.
1663
- * @example
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
- * ```
1687
- */
1688
- getCustomFlags(changes?: ChangeArray | undefined): Flags;
1689
- /**
1690
- * Resolve a Contentful entry to a personalized variant using the current
1691
- * or provided selections.
1692
- *
1693
- * @typeParam S - Entry skeleton type.
1694
- * @typeParam M - Chain modifiers.
1695
- * @typeParam L - Locale code.
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.
1707
- *
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
- * @remarks
1712
- * Merge tags are references to profile data that can be substituted into content.
1713
- * @example
1714
- * ```ts
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
- * ```
1730
- */
1731
- hasConsent(name: string): boolean;
1732
- /**
1733
- * Hook invoked when an operation is blocked due to missing consent.
1734
- *
1735
- * @param name - The blocked operation name.
1736
- * @param payload - The original arguments supplied to the operation.
1737
- * @example
1738
- * ```ts
1739
- * personalization.onBlockedByConsent('track', [payload])
1740
- * ```
1741
- */
1742
- onBlockedByConsent(name: string, payload: readonly unknown[]): void;
1743
- /**
1744
- * Identify the current profile/visitor to associate traits with a profile
1745
- * and update optimization state.
1746
- *
1747
- * @param payload - Identify builder payload.
1748
- * @returns The resulting {@link OptimizationData} for the identified user.
1749
- * @example
1750
- * ```ts
1751
- * const data = await personalization.identify({ userId: 'user-123' })
1752
- * ```
1753
- */
1754
- identify(payload: IdentifyBuilderArgs): Promise<OptimizationData | undefined>;
1755
- /**
1756
- * Record a page view and update optimization state.
1757
- *
1758
- * @param payload - Page view builder payload.
1759
- * @returns The evaluated {@link OptimizationData} for this page view.
1760
- * @example
1761
- * ```ts
1762
- * const data = await personalization.page({ properties: { title: 'Home' } })
1763
- * ```
1764
- */
1765
- page(payload: PageViewBuilderArgs): Promise<OptimizationData | undefined>;
1766
- /**
1767
- * Record a screen view and update optimization state.
1768
- *
1769
- * @param payload - Screen view builder payload.
1770
- * @returns The evaluated {@link OptimizationData} for this screen view.
1771
- * @example
1772
- * ```ts
1773
- * const data = await personalization.screen({ name: 'HomeScreen' })
1774
- * ```
1775
- */
1776
- screen(payload: ScreenViewBuilderArgs): Promise<OptimizationData | undefined>;
1777
- /**
1778
- * Record a custom track event and update optimization state.
1779
- *
1780
- * @param payload - Track builder payload.
1781
- * @returns The evaluated {@link OptimizationData} for this event.
1782
- * @example
1783
- * ```ts
1784
- * const data = await personalization.track({ event: 'button_click' })
1785
- * ```
1786
- */
1787
- track(payload: TrackBuilderArgs): Promise<OptimizationData | undefined>;
1788
- /**
1789
- * Record a "sticky" component view and update optimization state.
1790
- *
1791
- * @param payload - Component view builder payload.
1792
- * @returns The evaluated {@link OptimizationData} for this component view.
1793
- * @example
1794
- * ```ts
1795
- * const data = await personalization.trackComponentView({ componentId: 'hero-banner' })
1796
- * ```
1797
- */
1798
- trackComponentView(payload: ComponentViewBuilderArgs): Promise<OptimizationData | undefined>;
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;
1825
- /**
1826
- * Flush the offline queue
1827
- *
1828
- * @param options - Optional flush controls.
1829
- * @param options.force - When `true`, bypass offline/backoff/circuit gates and attempt immediately.
1830
- *
1831
- * @example
1832
- * ```ts
1833
- * await personalization.flush()
1834
- */
1835
- flush(options?: {
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
1870
- */
1871
- private updateOutputSignals;
1685
+ /** Interceptors invoked for individual events prior to validation/sending. */
1686
+ event: InterceptorManager<InsightsEvent | ExperienceEvent>;
1687
+ /** Interceptors invoked before optimization state updates. */
1688
+ state: InterceptorManager<OptimizationData>;
1872
1689
  }
1873
1690
 
1874
1691
  /**
1875
- * Options for configuring {@link PersonalizationStateful} functionality.
1692
+ * A utility type representing a value that may be synchronously available or
1693
+ * produced asynchronously.
1876
1694
  *
1695
+ * @typeParam T - The resolved value type.
1877
1696
  * @public
1878
- * @see {@link ProductBaseOptions}
1879
1697
  */
1880
- export declare type PersonalizationStatefulOptions = ProductBaseOptions & {
1881
- /** Configuration specific to the Personalization product */
1882
- config?: PersonalizationProductConfig;
1883
- };
1698
+ export declare type MaybePromise<T> = T | Promise<T>;
1884
1699
 
1885
1700
  /**
1886
- * Stateless personalization implementation that immediately validates and sends
1887
- * a single event to the Experience API, upserting the profile as needed.
1701
+ * Resolves merge tag values from a {@link Profile}.
1888
1702
  *
1889
1703
  * @public
1890
1704
  * @remarks
1891
- * Each public method constructs a strongly-typed event via the shared builder,
1892
- * runs it through event interceptors, and performs a profile upsert using the
1893
- * Experience API. If an anonymous ID is available from the builder, it will be
1894
- * preferred as the `profileId` unless an explicit profile is provided.
1705
+ * *Merge tags* are references to user profile data that may be embedded in content
1706
+ * and expanded at runtime. This resolver normalizes the merge-tag identifier into
1707
+ * a set of candidate selectors and searches the profile for a matching value.
1708
+ * Result values are returned as strings; numeric/boolean primitives are stringified.
1895
1709
  */
1896
- export declare class PersonalizationStateless extends PersonalizationBase {
1710
+ export declare const MergeTagValueResolver: {
1897
1711
  /**
1898
- * Identify the current profile/visitor to associate traits with a profile.
1712
+ * Generate a list of candidate selectors for a merge-tag ID.
1899
1713
  *
1900
- * @param payload - Identify builder arguments with an optional partial
1901
- * profile to attach to the upsert request.
1902
- * @returns The resulting {@link OptimizationData} for the identified user.
1714
+ * @param id - Merge-tag identifier (segments separated by `_`).
1715
+ * @returns Array of dot-path selectors to try against a profile.
1903
1716
  * @example
1904
1717
  * ```ts
1905
- * const data = await personalization.identify({ userId: 'user-123', profile: { id: 'anon-1' } })
1718
+ * // "profile_name_first" -> [
1719
+ * // 'profile',
1720
+ * // 'profile.name',
1721
+ * // 'profile.name.first'
1722
+ * // ]
1723
+ * const selectors = MergeTagValueResolver.normalizeSelectors('profile_name_first')
1906
1724
  * ```
1907
1725
  */
1908
- identify(payload: IdentifyBuilderArgs & {
1909
- profile?: PartialProfile;
1910
- }): Promise<OptimizationData>;
1726
+ normalizeSelectors(id: string): string[];
1911
1727
  /**
1912
- * Record a page view.
1728
+ * Look up a merge-tag value from a profile using normalized selectors.
1913
1729
  *
1914
- * @param payload - Page view builder arguments with an optional partial profile.
1915
- * @returns The evaluated {@link OptimizationData} for this page view.
1730
+ * @param id - Merge-tag identifier.
1731
+ * @param profile - Profile from which to resolve the value.
1732
+ * @returns A stringified primitive if found; otherwise `undefined`.
1733
+ * @remarks
1734
+ * Only string/number/boolean primitives are returned; objects/arrays are ignored.
1916
1735
  * @example
1917
1736
  * ```ts
1918
- * const data = await personalization.page({ properties: { title: 'Home' }, profile: { id: 'anon-1' } })
1737
+ * const value = MergeTagValueResolver.getValueFromProfile('user_email', profile)
1738
+ * if (value) sendEmailTo(value)
1919
1739
  * ```
1920
1740
  */
1921
- page(payload: PageViewBuilderArgs & {
1922
- profile?: PartialProfile;
1923
- }): Promise<OptimizationData>;
1741
+ getValueFromProfile(id: string, profile?: Profile): string | undefined;
1924
1742
  /**
1925
- * Record a screen view.
1743
+ * Resolve the display value for a merge-tag entry using the provided profile,
1744
+ * falling back to the entry's configured `nt_fallback` when necessary.
1926
1745
  *
1927
- * @param payload - Screen view builder arguments with an optional partial profile.
1928
- * @returns The evaluated {@link OptimizationData} for this screen view.
1746
+ * @param mergeTagEntry - The merge-tag entry to resolve.
1747
+ * @param profile - Optional profile used for lookup.
1748
+ * @returns The resolved string, or `undefined` if the entry is invalid and no
1749
+ * fallback is available.
1929
1750
  * @example
1930
1751
  * ```ts
1931
- * const data = await personalization.screen({ name: 'HomeScreen', profile: { id: 'anon-1' } })
1752
+ * const text = MergeTagValueResolver.resolve(entry, profile)
1753
+ * render(text ?? 'Guest')
1932
1754
  * ```
1933
1755
  */
1934
- screen(payload: ScreenViewBuilderArgs & {
1935
- profile?: PartialProfile;
1936
- }): Promise<OptimizationData>;
1756
+ resolve(mergeTagEntry: MergeTagEntry | undefined, profile?: Profile): string | undefined;
1757
+ };
1758
+
1759
+ /**
1760
+ * Minimal observable contract used by stateful Core signal streams.
1761
+ *
1762
+ * @typeParam T - Value type emitted by the observable.
1763
+ * @public
1764
+ */
1765
+ export declare interface Observable<T> {
1937
1766
  /**
1938
- * Record a custom track event.
1767
+ * Deep-cloned snapshot of the current signal value.
1939
1768
  *
1940
- * @param payload - Track builder arguments with an optional partial profile.
1941
- * @returns The evaluated {@link OptimizationData} for this event.
1942
- * @example
1943
- * ```ts
1944
- * const data = await personalization.track({ event: 'purchase', profile: { id: 'anon-1' } })
1945
- * ```
1769
+ * @remarks
1770
+ * A clone is returned to prevent accidental in-place mutations from leaking
1771
+ * back into internal signal state.
1946
1772
  */
1947
- track(payload: TrackBuilderArgs & {
1948
- profile?: PartialProfile;
1949
- }): Promise<OptimizationData>;
1773
+ readonly current: T;
1950
1774
  /**
1951
- * Record a "sticky" component view.
1775
+ * Subscribe to all value updates (including the current value immediately).
1952
1776
  *
1953
- * @param payload - Component view builder arguments with an optional partial profile.
1954
- * @returns The evaluated {@link OptimizationData} for this component view.
1955
- * @example
1956
- * ```ts
1957
- * const data = await personalization.trackComponentView({ componentId: 'hero', profile: { id: 'anon-1' } })
1958
- * ```
1777
+ * @param next - Callback invoked for each emitted value snapshot.
1778
+ * @returns A {@link Subscription} used to stop observing updates.
1779
+ *
1780
+ * @remarks
1781
+ * Values are deep-cloned before being passed to `next`.
1959
1782
  */
1960
- trackComponentView(payload: ComponentViewBuilderArgs & {
1961
- profile?: PartialProfile;
1962
- }): Promise<OptimizationData>;
1783
+ subscribe: (next: (v: T) => void) => Subscription;
1963
1784
  /**
1964
- * Intercept, validate, and upsert the profile with a single personalization
1965
- * event.
1785
+ * Subscribe to the first non-nullish value, then auto-unsubscribe.
1966
1786
  *
1967
- * @param event - The {@link PersonalizationEvent} to submit.
1968
- * @param profile - Optional partial profile. If omitted, the anonymous ID from
1969
- * the builder (when present) is used as the `profileId`.
1970
- * @returns The {@link OptimizationData} returned by the Experience API.
1971
- * @internal
1787
+ * @param next - Callback invoked exactly once with the first non-nullish value.
1788
+ * @returns A {@link Subscription} that can cancel before the first emission.
1789
+ *
1790
+ * @remarks
1791
+ * Values are deep-cloned before being passed to `next`.
1972
1792
  */
1973
- private upsertProfile;
1793
+ subscribeOnce: (next: (v: NonNullable<T>) => void) => Subscription;
1974
1794
  }
1975
1795
 
1976
1796
  /**
1977
- * Observables exposed by {@link PersonalizationStateful} that mirror internal signals.
1797
+ * Runtime online/offline signal used by queue flush logic.
1978
1798
  *
1799
+ * @defaultValue `true`
1979
1800
  * @public
1980
1801
  */
1981
- export declare interface PersonalizationStates {
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
- }
1802
+ declare const online: Signal<boolean | undefined>;
1993
1803
 
1994
1804
  /**
1995
- * Resolve a personalized Contentful entry to the correct variant for the current
1805
+ * The package name of the Optimization Core SDK, injected at build time.
1806
+ *
1807
+ * @public
1808
+ */
1809
+ export declare const OPTIMIZATION_CORE_SDK_NAME: string;
1810
+
1811
+ /**
1812
+ * The current version of the Optimization Core SDK, injected at build time.
1813
+ *
1814
+ * @public
1815
+ */
1816
+ export declare const OPTIMIZATION_CORE_SDK_VERSION: string;
1817
+
1818
+ /**
1819
+ * Resolve an optimized Contentful entry to the correct variant for the current
1996
1820
  * selections.
1997
1821
  *
1998
1822
  * @public
1999
1823
  * @remarks
2000
- * Given a baseline {@link PersonalizedEntry} and a set of selected personalizations
1824
+ * Given a baseline {@link OptimizedEntry} and a set of selected optimizations
2001
1825
  * (variants per experience), this resolver finds the matching replacement variant
2002
1826
  * for the component configured against the baseline entry.
2003
1827
  *
2004
- * **Variant indexing**: `variantIndex` in {@link SelectedPersonalization} is treated as
1828
+ * **Variant indexing**: `variantIndex` in {@link SelectedOptimization} is treated as
2005
1829
  * 1‑based (index 1 = first variant). A value of `0` indicates baseline.
2006
1830
  */
2007
- export declare const PersonalizedEntryResolver: {
1831
+ export declare const OptimizedEntryResolver: {
2008
1832
  /**
2009
- * Find the personalization entry corresponding to one of the selected experiences.
1833
+ * Find the optimization entry corresponding to one of the selected experiences.
2010
1834
  *
2011
- * @param params - Object containing the baseline personalized entry and the selections.
1835
+ * @param params - Object containing the baseline optimized entry and the selections.
2012
1836
  * @param skipValidation - When `true`, skip type/shape validation for perf.
2013
- * @returns The matching {@link PersonalizationEntry}, or `undefined` if not found/invalid.
1837
+ * @returns The matching {@link OptimizationEntry}, or `undefined` if not found/invalid.
2014
1838
  * @remarks
2015
- * A personalization entry is a personalization configuration object supplied in a
2016
- * `PersonalizedEntry.nt_experiences` array. A personalized entry may relate to
2017
- * multiple personalizations.
1839
+ * An optimization entry is an optimization configuration object supplied in an
1840
+ * `OptimizedEntry.nt_experiences` array. An optimized entry may relate to
1841
+ * multiple optimizations.
2018
1842
  * @example
2019
1843
  * ```ts
2020
- * const personalizationEntry = PersonalizedEntryResolver.getPersonalizationEntry({
2021
- * personalizedEntry: entry,
2022
- * selectedPersonalizations
1844
+ * const optimizationEntry = OptimizedEntryResolver.getOptimizationEntry({
1845
+ * optimizedEntry: entry,
1846
+ * selectedOptimizations
2023
1847
  * })
2024
1848
  * ```
2025
1849
  */
2026
- getPersonalizationEntry({ personalizedEntry, selectedPersonalizations, }: {
2027
- personalizedEntry: PersonalizedEntry_2;
2028
- selectedPersonalizations: SelectedPersonalizationArray;
2029
- }, skipValidation?: boolean): PersonalizationEntry_2 | undefined;
1850
+ getOptimizationEntry({ optimizedEntry, selectedOptimizations, }: {
1851
+ optimizedEntry: OptimizedEntry_2;
1852
+ selectedOptimizations: SelectedOptimizationArray;
1853
+ }, skipValidation?: boolean): OptimizationEntry_2 | undefined;
2030
1854
  /**
2031
- * Look up the selection metadata for a specific personalization entry.
1855
+ * Look up the selection metadata for a specific optimization entry.
2032
1856
  *
2033
- * @param params - Object with the target personalization entry and selections.
1857
+ * @param params - Object with the target optimization entry and selections.
2034
1858
  * @param skipValidation - When `true`, skip type checks.
2035
- * @returns The matching {@link SelectedPersonalization}, if present.
1859
+ * @returns The matching {@link SelectedOptimization}, if present.
2036
1860
  * @remarks
2037
- * Selected personalizations are supplied by the Experience API in the
1861
+ * Selected optimizations are supplied by the Experience API in the
2038
1862
  * `experiences` response data property.
2039
1863
  * @example
2040
1864
  * ```ts
2041
- * const selectedPersonalization = PersonalizedEntryResolver.getSelectedPersonalization({
2042
- * personalizationEntry,
2043
- * selectedPersonalizations
1865
+ * const selectedOptimization = OptimizedEntryResolver.getSelectedOptimization({
1866
+ * optimizationEntry,
1867
+ * selectedOptimizations
2044
1868
  * })
2045
1869
  * ```
2046
1870
  */
2047
- getSelectedPersonalization({ personalizationEntry, selectedPersonalizations, }: {
2048
- personalizationEntry: PersonalizationEntry_2;
2049
- selectedPersonalizations: SelectedPersonalizationArray;
2050
- }, skipValidation?: boolean): SelectedPersonalization | undefined;
1871
+ getSelectedOptimization({ optimizationEntry, selectedOptimizations, }: {
1872
+ optimizationEntry: OptimizationEntry_2;
1873
+ selectedOptimizations: SelectedOptimizationArray;
1874
+ }, skipValidation?: boolean): SelectedOptimization_2 | undefined;
2051
1875
  /**
2052
1876
  * Get the replacement variant config for the given selection index.
2053
1877
  *
2054
- * @param params - Baseline entry, personalization entry, and 1‑based variant index.
1878
+ * @param params - Baseline entry, optimization entry, and 1‑based variant index.
2055
1879
  * @param skipValidation - When `true`, skip type checks.
2056
1880
  * @returns The {@link EntryReplacementVariant} for the component, if any.
2057
1881
  * @remarks
2058
1882
  * Entry replacement variants are variant configurations specified in a
2059
- * personalization configuration component's `variants` array supplied by the
2060
- * personalized entry via its `nt_config` field.
1883
+ * optimization configuration component's `variants` array supplied by the
1884
+ * optimized entry via its `nt_config` field.
2061
1885
  * @example
2062
1886
  * ```ts
2063
- * const selectedVariant = PersonalizedEntryResolver.getSelectedVariant({
2064
- * personalizedEntry: entry,
2065
- * personalizationEntry,
1887
+ * const selectedVariant = OptimizedEntryResolver.getSelectedVariant({
1888
+ * optimizedEntry: entry,
1889
+ * optimizationEntry,
2066
1890
  * selectedVariantIndex: 2 // second variant (1‑based)
2067
1891
  * })
2068
1892
  * ```
2069
1893
  */
2070
- getSelectedVariant({ personalizedEntry, personalizationEntry, selectedVariantIndex, }: {
2071
- personalizedEntry: PersonalizedEntry_2;
2072
- personalizationEntry: PersonalizationEntry_2;
1894
+ getSelectedVariant({ optimizedEntry, optimizationEntry, selectedVariantIndex, }: {
1895
+ optimizedEntry: OptimizedEntry_2;
1896
+ optimizationEntry: OptimizationEntry_2;
2073
1897
  selectedVariantIndex: number;
2074
1898
  }, skipValidation?: boolean): EntryReplacementVariant_2 | undefined;
2075
1899
  /**
@@ -2078,44 +1902,83 @@ declare abstract class CoreBase implements ResolverMethods {
2078
1902
  * @typeParam S - Entry skeleton type.
2079
1903
  * @typeParam M - Chain modifiers.
2080
1904
  * @typeParam L - Locale code.
2081
- * @param params - Personalization entry and selected variant.
1905
+ * @param params - Optimization entry and selected variant.
2082
1906
  * @param skipValidation - When `true`, skip type checks.
2083
1907
  * @returns The resolved entry typed as {@link Entry} or `undefined`.
2084
1908
  * @remarks
2085
- * A personalized entry will resolve either to the baseline (the entry
2086
- * supplied as `personalizedEntry`) or the selected variant.
1909
+ * An optimized entry will resolve either to the baseline (the entry
1910
+ * supplied as `optimizedEntry`) or the selected variant.
2087
1911
  * @example
2088
1912
  * ```ts
2089
- * const selectedVariantEntry = PersonalizedEntryResolver.getSelectedVariantEntry<{ fields: unknown }>({
2090
- * personalizationEntry,
1913
+ * const selectedVariantEntry = OptimizedEntryResolver.getSelectedVariantEntry<{ fields: unknown }>({
1914
+ * optimizationEntry,
2091
1915
  * selectedVariant
2092
1916
  * })
2093
1917
  * ```
2094
1918
  */
2095
- getSelectedVariantEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>({ personalizationEntry, selectedVariant, }: {
2096
- personalizationEntry: PersonalizationEntry_2;
1919
+ getSelectedVariantEntry<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = string>({ optimizationEntry, selectedVariant, }: {
1920
+ optimizationEntry: OptimizationEntry_2;
2097
1921
  selectedVariant: EntryReplacementVariant_2;
2098
1922
  }, 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>;
1923
+ resolve: typeof resolve;
2117
1924
  };
2118
1925
 
1926
+ export declare const PageViewBuilderArgs: z.ZodMiniObject<{
1927
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
1928
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
1929
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
1930
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
1931
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
1932
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
1933
+ }, z.core.$strip>>;
1934
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
1935
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
1936
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
1937
+ latitude: z.ZodMiniNumber<number>;
1938
+ longitude: z.ZodMiniNumber<number>;
1939
+ }, z.core.$strip>>;
1940
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
1941
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1942
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
1943
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1944
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
1945
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
1946
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1947
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
1948
+ }, z.core.$strip>>;
1949
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
1950
+ path: z.ZodMiniString<string>;
1951
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
1952
+ referrer: z.ZodMiniString<string>;
1953
+ search: z.ZodMiniString<string>;
1954
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
1955
+ url: z.ZodMiniString<string>;
1956
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1957
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
1958
+ name: z.ZodMiniString<string>;
1959
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1960
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
1961
+ properties: z.ZodMiniOptional<z.ZodMiniObject<{
1962
+ path: z.ZodMiniOptional<z.ZodMiniString<string>>;
1963
+ query: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
1964
+ referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
1965
+ search: z.ZodMiniOptional<z.ZodMiniString<string>>;
1966
+ title: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
1967
+ url: z.ZodMiniOptional<z.ZodMiniString<string>>;
1968
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
1969
+ }, z.core.$strip>;
1970
+
1971
+ /**
1972
+ * Arguments for constructing page view events.
1973
+ *
1974
+ * @remarks
1975
+ * Any properties passed here are merged with the base page properties from
1976
+ * {@link EventBuilderConfig.getPageProperties}.
1977
+ *
1978
+ * @public
1979
+ */
1980
+ export declare type PageViewBuilderArgs = z.infer<typeof PageViewBuilderArgs>;
1981
+
2119
1982
  export declare const PREVIEW_PANEL_SIGNAL_FNS_SYMBOL: unique symbol;
2120
1983
 
2121
1984
  /**
@@ -2125,8 +1988,20 @@ declare abstract class CoreBase implements ResolverMethods {
2125
1988
  */
2126
1989
  export declare const PREVIEW_PANEL_SIGNALS_SYMBOL: unique symbol;
2127
1990
 
1991
+ /**
1992
+ * Indicates whether the preview panel bridge has been attached.
1993
+ *
1994
+ * @defaultValue `false`
1995
+ * @public
1996
+ */
2128
1997
  declare const previewPanelAttached: Signal<boolean>;
2129
1998
 
1999
+ /**
2000
+ * Indicates whether the preview panel is currently open.
2001
+ *
2002
+ * @defaultValue `false`
2003
+ * @public
2004
+ */
2130
2005
  declare const previewPanelOpen: Signal<boolean>;
2131
2006
 
2132
2007
  /**
@@ -2142,84 +2017,10 @@ declare abstract class CoreBase implements ResolverMethods {
2142
2017
  }
2143
2018
 
2144
2019
  /**
2145
- * Shared base for all product implementations.
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.
2020
+ * Active profile associated with current runtime state.
2201
2021
  *
2202
2022
  * @public
2203
2023
  */
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
2024
  declare const profile: Signal<Profile | undefined>;
2224
2025
 
2225
2026
  /**
@@ -2234,7 +2035,7 @@ declare abstract class CoreBase implements ResolverMethods {
2234
2035
  *
2235
2036
  * @public
2236
2037
  */
2237
- declare interface QueueFlushFailureContext {
2038
+ export declare interface QueueFlushFailureContext {
2238
2039
  /** Number of consecutive failed flush attempts. */
2239
2040
  consecutiveFailures: number;
2240
2041
  /** Number of queued batches at the time of the failed attempt. */
@@ -2250,7 +2051,13 @@ declare abstract class CoreBase implements ResolverMethods {
2250
2051
  *
2251
2052
  * @public
2252
2053
  */
2253
- declare interface QueueFlushPolicy {
2054
+ export declare interface QueueFlushPolicy {
2055
+ /**
2056
+ * Periodic flush interval in milliseconds while events remain queued.
2057
+ *
2058
+ * @defaultValue `30000`
2059
+ */
2060
+ flushIntervalMs?: number;
2254
2061
  /**
2255
2062
  * Base retry backoff delay in milliseconds.
2256
2063
  *
@@ -2303,13 +2110,53 @@ declare abstract class CoreBase implements ResolverMethods {
2303
2110
  *
2304
2111
  * @public
2305
2112
  */
2306
- declare interface QueueFlushRecoveredContext {
2113
+ export declare interface QueueFlushRecoveredContext {
2307
2114
  /** Consecutive failure count that existed immediately before recovery. */
2308
2115
  consecutiveFailures: number;
2309
2116
  }
2310
2117
 
2311
2118
  /**
2312
- * Result returned by {@link PersonalizedEntryResolver.resolve}.
2119
+ * Unified queue policy for stateful Core.
2120
+ *
2121
+ * @public
2122
+ */
2123
+ export declare interface QueuePolicy {
2124
+ /** Shared retry/backoff/circuit policy for queued flushes. */
2125
+ flush?: QueueFlushPolicy;
2126
+ /** Maximum number of offline Experience events retained. */
2127
+ offlineMaxEvents?: number;
2128
+ /** Callback invoked when oldest offline Experience events are dropped. */
2129
+ onOfflineDrop?: (context: ExperienceQueueDropContext) => void;
2130
+ }
2131
+
2132
+ /**
2133
+ * Resolve the selected entry (baseline or variant) for an optimized entry
2134
+ * and optional selected optimizations, returning both the entry and the
2135
+ * optimization metadata.
2136
+ *
2137
+ * @typeParam S - Entry skeleton type.
2138
+ * @typeParam L - Locale code.
2139
+ * @typeParam M - Chain modifiers for advanced/non-default Contentful clients.
2140
+ * @param entry - The baseline optimized entry.
2141
+ * @param selectedOptimizations - Optional selections for the current profile.
2142
+ * @returns An object containing the resolved entry and (if chosen) the selection.
2143
+ * @example
2144
+ * ```ts
2145
+ * const { entry: optimizedEntry, selectedOptimization } = OptimizedEntryResolver.resolve(
2146
+ * entry,
2147
+ * selections,
2148
+ * )
2149
+ * if (selectedOptimization) {
2150
+ * console.log('Variant index', selectedOptimization.variantIndex)
2151
+ * }
2152
+ * ```
2153
+ */
2154
+ declare function resolve<S extends EntrySkeletonType = EntrySkeletonType, L extends LocaleCode = LocaleCode>(entry: Entry<S, undefined, L>, selectedOptimizations?: SelectedOptimizationArray): ResolvedData<S, undefined, L>;
2155
+
2156
+ 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>;
2157
+
2158
+ /**
2159
+ * Result returned by {@link OptimizedEntryResolver.resolve}.
2313
2160
  *
2314
2161
  * @typeParam S - Entry skeleton type.
2315
2162
  * @typeParam M - Chain modifiers.
@@ -2319,114 +2166,358 @@ declare abstract class CoreBase implements ResolverMethods {
2319
2166
  export declare interface ResolvedData<S extends EntrySkeletonType, M extends ChainModifiers = ChainModifiers, L extends LocaleCode = LocaleCode> {
2320
2167
  /** The baseline or resolved variant entry. */
2321
2168
  entry: Entry<S, M, L>;
2322
- /** The selected personalization metadata, if a nonbaseline variant was chosen. */
2323
- personalization?: SelectedPersonalization;
2169
+ /** The selected optimization metadata, if a non-baseline variant was chosen. */
2170
+ selectedOptimization?: SelectedOptimization_2;
2324
2171
  }
2325
2172
 
2326
2173
  /**
2327
- * These methods assist in resolving values via Resolvers
2174
+ * Internal normalized shape of queue flush policy values.
2328
2175
  *
2329
2176
  * @internal
2330
- * @privateRemarks
2331
- * This interface exists to document that the included methods should not be
2332
- * considered static.
2333
2177
  */
2334
- export declare interface ResolverMethods {
2335
- /**
2336
- * Get the specified Custom Flag's value from the supplied changes.
2337
- * @param name - The name or key of the Custom Flag.
2338
- * @param changes - Optional changes array.
2339
- * @returns The current value of the Custom Flag if found.
2340
- * @remarks
2341
- * The changes array can be sourced from the data returned when emitting any
2342
- * personalization event.
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;
2178
+ declare interface ResolvedQueueFlushPolicy {
2179
+ flushIntervalMs: number;
2180
+ baseBackoffMs: number;
2181
+ maxBackoffMs: number;
2182
+ jitterRatio: number;
2183
+ maxConsecutiveFailures: number;
2184
+ circuitOpenMs: number;
2185
+ onCircuitOpen?: QueueFlushPolicy['onCircuitOpen'];
2186
+ onFlushFailure?: QueueFlushPolicy['onFlushFailure'];
2187
+ onFlushRecovered?: QueueFlushPolicy['onFlushRecovered'];
2380
2188
  }
2381
2189
 
2190
+ export declare const ScreenViewBuilderArgs: z.ZodMiniObject<{
2191
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
2192
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
2193
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
2194
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
2195
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
2196
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
2197
+ }, z.core.$strip>>;
2198
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
2199
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
2200
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
2201
+ latitude: z.ZodMiniNumber<number>;
2202
+ longitude: z.ZodMiniNumber<number>;
2203
+ }, z.core.$strip>>;
2204
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
2205
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2206
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
2207
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2208
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
2209
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2210
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2211
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
2212
+ }, z.core.$strip>>;
2213
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
2214
+ path: z.ZodMiniString<string>;
2215
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
2216
+ referrer: z.ZodMiniString<string>;
2217
+ search: z.ZodMiniString<string>;
2218
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
2219
+ url: z.ZodMiniString<string>;
2220
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2221
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
2222
+ name: z.ZodMiniString<string>;
2223
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2224
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2225
+ name: z.ZodMiniString<string>;
2226
+ properties: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>;
2227
+ }, z.core.$strip>;
2228
+
2229
+ /**
2230
+ * Arguments for constructing screen view events.
2231
+ *
2232
+ * @remarks
2233
+ * Any properties passed here are merged with the base screen properties supplied
2234
+ * by the runtime.
2235
+ *
2236
+ * @public
2237
+ */
2238
+ export declare type ScreenViewBuilderArgs = z.infer<typeof ScreenViewBuilderArgs>;
2239
+
2240
+ /**
2241
+ * Storage key for cached selected optimizations.
2242
+ *
2243
+ * @internal
2244
+ */
2245
+ export declare const SELECTED_OPTIMIZATIONS_CACHE_KEY = "__ctfl_opt_selected-optimizations__";
2246
+
2247
+ /**
2248
+ * Latest selected optimization variants.
2249
+ *
2250
+ * @public
2251
+ */
2252
+ declare const selectedOptimizations: Signal<{
2253
+ experienceId: string;
2254
+ variantIndex: number;
2255
+ variants: Record<string, string>;
2256
+ sticky?: boolean | undefined;
2257
+ }[] | undefined>;
2258
+
2382
2259
  export { Signal }
2383
2260
 
2261
+ /**
2262
+ * Signal utility functions shared with preview tooling and extensions.
2263
+ *
2264
+ * @public
2265
+ */
2384
2266
  export declare interface SignalFns {
2267
+ /** Execute multiple signal writes in one reactive batch. */
2385
2268
  batch: typeof batch;
2269
+ /** Create a derived computed signal. */
2386
2270
  computed: typeof computed;
2271
+ /** Register a reactive effect. */
2387
2272
  effect: typeof effect;
2273
+ /** Read signal values without dependency tracking. */
2388
2274
  untracked: typeof untracked;
2389
2275
  }
2390
2276
 
2277
+ /**
2278
+ * Pre-bundled reference to shared signal helpers.
2279
+ *
2280
+ * @public
2281
+ */
2391
2282
  export declare const signalFns: SignalFns;
2392
2283
 
2284
+ /**
2285
+ * Collection of shared stateful Core signals.
2286
+ *
2287
+ * @public
2288
+ */
2393
2289
  export declare interface Signals {
2290
+ /** Most recent blocked-event metadata. */
2394
2291
  blockedEvent: typeof blockedEvent;
2292
+ /** Latest optimization changes payload. */
2395
2293
  changes: typeof changes;
2294
+ /** Current consent signal. */
2396
2295
  consent: typeof consent;
2296
+ /** Most recent emitted event signal. */
2397
2297
  event: typeof event_2;
2398
- flags: typeof flags;
2298
+ /** Runtime connectivity signal. */
2399
2299
  online: typeof online;
2300
+ /** Preview panel attachment signal. */
2400
2301
  previewPanelAttached: typeof previewPanelAttached;
2302
+ /** Preview panel open-state signal. */
2401
2303
  previewPanelOpen: typeof previewPanelOpen;
2402
- personalizations: typeof personalizations;
2304
+ /** Selected optimization variants signal. */
2305
+ selectedOptimizations: typeof selectedOptimizations;
2306
+ /** Whether optimization selection data is currently available. */
2307
+ canOptimize: typeof canOptimize;
2308
+ /** Active profile signal. */
2403
2309
  profile: typeof profile;
2404
2310
  }
2405
2311
 
2312
+ /**
2313
+ * Pre-bundled reference to all shared signals.
2314
+ *
2315
+ * @public
2316
+ */
2406
2317
  export declare const signals: Signals;
2407
2318
 
2408
- declare interface Subscription {
2409
- unsubscribe: () => void;
2410
- }
2411
-
2412
- export declare type TrackComponentClickArgs = ComponentClickBuilderArgs & {
2319
+ declare type StatelessExperiencePayload<TPayload> = TPayload & {
2413
2320
  profile?: PartialProfile;
2414
2321
  };
2415
2322
 
2416
- export declare type TrackComponentHoverArgs = ComponentHoverBuilderArgs & {
2323
+ declare type StatelessInsightsPayload<TPayload> = TPayload & {
2324
+ profile: PartialProfile;
2325
+ };
2326
+
2327
+ declare type StatelessNonStickyTrackViewPayload = Omit<ViewBuilderArgs, 'sticky'> & {
2328
+ profile: PartialProfile;
2329
+ sticky?: false | undefined;
2330
+ };
2331
+
2332
+ declare type StatelessStickyTrackViewPayload = ViewBuilderArgs & {
2417
2333
  profile?: PartialProfile;
2334
+ sticky: true;
2418
2335
  };
2419
2336
 
2420
2337
  /**
2421
- * Arguments for tracking a component/flag view in stateless mode.
2338
+ * Disposable handle returned by observable subscriptions.
2422
2339
  *
2423
2340
  * @public
2341
+ */
2342
+ export declare interface Subscription {
2343
+ /** Stop receiving future emissions for the subscription. */
2344
+ unsubscribe: () => void;
2345
+ }
2346
+
2347
+ /**
2348
+ * Wrap a signal-like object with an {@link Observable} that suppresses
2349
+ * duplicate emissions according to a comparator.
2350
+ *
2351
+ * @typeParam T - Signal value type.
2352
+ * @param s - Signal-like source exposing a `value` property.
2353
+ * @param isEqual - Comparator that returns `true` when values are equivalent.
2354
+ * @returns Observable adapter that only emits distinct values.
2355
+ *
2424
2356
  * @remarks
2425
- * The `profile` is optional; when omitted, the APIs may infer identity via
2426
- * other means.
2357
+ * The first emission is always delivered. Subsequent emissions are skipped
2358
+ * when `isEqual(previous, current)` returns `true`.
2359
+ *
2360
+ * @public
2427
2361
  */
2428
- export declare type TrackComponentViewArgs = ComponentViewBuilderArgs & {
2429
- profile?: PartialProfile;
2430
- };
2362
+ export declare function toDistinctObservable<T>(s: {
2363
+ value: T;
2364
+ }, isEqual: (previous: T, current: T) => boolean): Observable<T>;
2365
+
2366
+ /**
2367
+ * Wrap a signal-like object with the local {@link Observable} contract.
2368
+ *
2369
+ * @typeParam T - Signal value type.
2370
+ * @param s - Signal-like source exposing a `value` property.
2371
+ * @returns Observable adapter for the given signal source.
2372
+ *
2373
+ * @remarks
2374
+ * All emitted values and `current` snapshots are deep-cloned to isolate
2375
+ * subscriber-side mutation from internal Core state.
2376
+ *
2377
+ * @public
2378
+ */
2379
+ export declare function toObservable<T>(s: {
2380
+ value: T;
2381
+ }): Observable<T>;
2382
+
2383
+ export declare const TrackBuilderArgs: z.ZodMiniObject<{
2384
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
2385
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
2386
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
2387
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
2388
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
2389
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
2390
+ }, z.core.$strip>>;
2391
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
2392
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
2393
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
2394
+ latitude: z.ZodMiniNumber<number>;
2395
+ longitude: z.ZodMiniNumber<number>;
2396
+ }, z.core.$strip>>;
2397
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
2398
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2399
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
2400
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2401
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
2402
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2403
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2404
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
2405
+ }, z.core.$strip>>;
2406
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
2407
+ path: z.ZodMiniString<string>;
2408
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
2409
+ referrer: z.ZodMiniString<string>;
2410
+ search: z.ZodMiniString<string>;
2411
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
2412
+ url: z.ZodMiniString<string>;
2413
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2414
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
2415
+ name: z.ZodMiniString<string>;
2416
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2417
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2418
+ event: z.ZodMiniString<string>;
2419
+ properties: z.ZodMiniOptional<z.ZodMiniPrefault<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>>>;
2420
+ }, z.core.$strip>;
2421
+
2422
+ /**
2423
+ * Arguments for constructing track events.
2424
+ *
2425
+ * @public
2426
+ */
2427
+ export declare type TrackBuilderArgs = z.infer<typeof TrackBuilderArgs>;
2428
+
2429
+ export declare const UniversalEventBuilderArgs: z.ZodMiniObject<{
2430
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
2431
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
2432
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
2433
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
2434
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
2435
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
2436
+ }, z.core.$strip>>;
2437
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
2438
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
2439
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
2440
+ latitude: z.ZodMiniNumber<number>;
2441
+ longitude: z.ZodMiniNumber<number>;
2442
+ }, z.core.$strip>>;
2443
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
2444
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2445
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
2446
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2447
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
2448
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2449
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2450
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
2451
+ }, z.core.$strip>>;
2452
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
2453
+ path: z.ZodMiniString<string>;
2454
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
2455
+ referrer: z.ZodMiniString<string>;
2456
+ search: z.ZodMiniString<string>;
2457
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
2458
+ url: z.ZodMiniString<string>;
2459
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2460
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
2461
+ name: z.ZodMiniString<string>;
2462
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2463
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2464
+ }, z.core.$strip>;
2465
+
2466
+ /**
2467
+ * Arguments used to construct the universal (shared) portion of all events.
2468
+ *
2469
+ * @public
2470
+ */
2471
+ export declare type UniversalEventBuilderArgs = z.infer<typeof UniversalEventBuilderArgs>;
2472
+
2473
+ export declare const ViewBuilderArgs: z.ZodMiniObject<{
2474
+ campaign: z.ZodMiniOptional<z.ZodMiniObject<{
2475
+ name: z.ZodMiniOptional<z.ZodMiniString<string>>;
2476
+ source: z.ZodMiniOptional<z.ZodMiniString<string>>;
2477
+ medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
2478
+ term: z.ZodMiniOptional<z.ZodMiniString<string>>;
2479
+ content: z.ZodMiniOptional<z.ZodMiniString<string>>;
2480
+ }, z.core.$strip>>;
2481
+ locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
2482
+ location: z.ZodMiniOptional<z.ZodMiniObject<{
2483
+ coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
2484
+ latitude: z.ZodMiniNumber<number>;
2485
+ longitude: z.ZodMiniNumber<number>;
2486
+ }, z.core.$strip>>;
2487
+ city: z.ZodMiniOptional<z.ZodMiniString<string>>;
2488
+ postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2489
+ region: z.ZodMiniOptional<z.ZodMiniString<string>>;
2490
+ regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2491
+ country: z.ZodMiniOptional<z.ZodMiniString<string>>;
2492
+ countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
2493
+ continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2494
+ timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
2495
+ }, z.core.$strip>>;
2496
+ page: z.ZodMiniOptional<z.ZodMiniObject<{
2497
+ path: z.ZodMiniString<string>;
2498
+ query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
2499
+ referrer: z.ZodMiniString<string>;
2500
+ search: z.ZodMiniString<string>;
2501
+ title: z.ZodMiniOptional<z.ZodMiniString<string>>;
2502
+ url: z.ZodMiniString<string>;
2503
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2504
+ screen: z.ZodMiniOptional<z.ZodMiniObject<{
2505
+ name: z.ZodMiniString<string>;
2506
+ }, z.core.$catchall<z.ZodMiniJSONSchema>>>;
2507
+ userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
2508
+ componentId: z.ZodMiniString<string>;
2509
+ experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
2510
+ variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
2511
+ sticky: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
2512
+ viewId: z.ZodMiniString<string>;
2513
+ viewDurationMs: z.ZodMiniNumber<number>;
2514
+ }, z.core.$strip>;
2515
+
2516
+ /**
2517
+ * Arguments for constructing entry view events.
2518
+ *
2519
+ * @public
2520
+ */
2521
+ export declare type ViewBuilderArgs = z.infer<typeof ViewBuilderArgs>;
2431
2522
 
2432
2523
  export { }