@contentful/optimization-api-client 0.1.0-alpha6 → 0.1.0-alpha8
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.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1390 -0
- package/dist/index.d.mts +1390 -0
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/insights/InsightsApiClient.d.ts.map +1 -1
- package/dist/insights/InsightsApiClient.js +2 -1
- package/dist/insights/InsightsApiClient.js.map +1 -1
- package/package.json +11 -6
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,1390 @@
|
|
|
1
|
+
import { App } from '@contentful/optimization-api-schemas';
|
|
2
|
+
import { BatchExperienceData } from '@contentful/optimization-api-schemas';
|
|
3
|
+
import { BatchExperienceEventArray } from '@contentful/optimization-api-schemas';
|
|
4
|
+
import { BatchInsightsEventArray } from '@contentful/optimization-api-schemas';
|
|
5
|
+
import { Channel } from '@contentful/optimization-api-schemas';
|
|
6
|
+
import { ComponentViewEvent } from '@contentful/optimization-api-schemas';
|
|
7
|
+
import { ExperienceEventArray } from '@contentful/optimization-api-schemas';
|
|
8
|
+
import { IdentifyEvent } from '@contentful/optimization-api-schemas';
|
|
9
|
+
import { Library } from '@contentful/optimization-api-schemas';
|
|
10
|
+
import { OptimizationData } from '@contentful/optimization-api-schemas';
|
|
11
|
+
import { Page } from '@contentful/optimization-api-schemas';
|
|
12
|
+
import { PageViewEvent } from '@contentful/optimization-api-schemas';
|
|
13
|
+
import { ScreenViewEvent } from '@contentful/optimization-api-schemas';
|
|
14
|
+
import { TrackEvent as TrackEvent_2 } from '@contentful/optimization-api-schemas';
|
|
15
|
+
import { UniversalEventProperties } from '@contentful/optimization-api-schemas';
|
|
16
|
+
import * as z from 'zod/mini';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Aggregated API client providing access to Experience and Insights APIs.
|
|
20
|
+
*
|
|
21
|
+
* @public
|
|
22
|
+
*
|
|
23
|
+
* @remarks
|
|
24
|
+
* This client encapsulates shared configuration and exposes dedicated
|
|
25
|
+
* sub-clients for personalization and analytics use cases.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```ts
|
|
29
|
+
* const client = new ApiClient({
|
|
30
|
+
* clientId: 'org-id',
|
|
31
|
+
* environment: 'main',
|
|
32
|
+
* preview: false,
|
|
33
|
+
* personalization: {
|
|
34
|
+
* // experience-specific overrides
|
|
35
|
+
* },
|
|
36
|
+
* analytics: {
|
|
37
|
+
* // insights-specific overrides
|
|
38
|
+
* },
|
|
39
|
+
* })
|
|
40
|
+
*
|
|
41
|
+
* const profile = await client.experience.getProfile('profile-id')
|
|
42
|
+
* const batch = await client.insights.upsertManyProfiles({ events: batchEvents })
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export declare class ApiClient {
|
|
46
|
+
/**
|
|
47
|
+
* Shared configuration applied to both Experience and Insights clients.
|
|
48
|
+
*/
|
|
49
|
+
readonly config: ApiConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Client for personalization and experience-related operations.
|
|
52
|
+
*/
|
|
53
|
+
readonly experience: ExperienceApiClient;
|
|
54
|
+
/**
|
|
55
|
+
* Client for analytics and insights-related operations.
|
|
56
|
+
*/
|
|
57
|
+
readonly insights: InsightsApiClient;
|
|
58
|
+
/**
|
|
59
|
+
* Creates a new aggregated {@link ApiClient} instance.
|
|
60
|
+
*
|
|
61
|
+
* @param config - Global API client configuration with optional per-client overrides.
|
|
62
|
+
*/
|
|
63
|
+
constructor(config: ApiClientConfig);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Base class for API clients that provides shared configuration and error logging.
|
|
68
|
+
*
|
|
69
|
+
* @internal
|
|
70
|
+
*
|
|
71
|
+
* @remarks
|
|
72
|
+
* This abstract class is intended for internal use within the package and
|
|
73
|
+
* should not be treated as part of the public API surface.
|
|
74
|
+
*
|
|
75
|
+
* Concrete API clients should extend this class to inherit consistent logging
|
|
76
|
+
* behavior and fetch configuration.
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```ts
|
|
80
|
+
* interface MyClientConfig extends ApiConfig {
|
|
81
|
+
* // additional config
|
|
82
|
+
* }
|
|
83
|
+
*
|
|
84
|
+
* class MyClient extends ApiClientBase {
|
|
85
|
+
* constructor(config: MyClientConfig) {
|
|
86
|
+
* super('MyClient', config)
|
|
87
|
+
* }
|
|
88
|
+
*
|
|
89
|
+
* async getSomething() {
|
|
90
|
+
* const response = await this.fetch('https://example.com', { method: 'GET' })
|
|
91
|
+
* return response.json()
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
declare abstract class ApiClientBase {
|
|
97
|
+
/**
|
|
98
|
+
* Name of the API client, used in log messages and as the `apiName` for fetch.
|
|
99
|
+
*/
|
|
100
|
+
protected readonly name: string;
|
|
101
|
+
/**
|
|
102
|
+
* Client identifier used for authentication or tracking.
|
|
103
|
+
*/
|
|
104
|
+
protected readonly clientId: string;
|
|
105
|
+
/**
|
|
106
|
+
* Contentful environment associated with this client.
|
|
107
|
+
*/
|
|
108
|
+
protected readonly environment: string;
|
|
109
|
+
/**
|
|
110
|
+
* Protected fetch method used by the client to perform HTTP requests.
|
|
111
|
+
*/
|
|
112
|
+
protected readonly fetch: FetchMethod;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a new API client base instance.
|
|
115
|
+
*
|
|
116
|
+
* @param name - Human-readable name of the client (used for logging and `apiName`).
|
|
117
|
+
* @param config - Configuration options for the client.
|
|
118
|
+
*/
|
|
119
|
+
constructor(name: string, { fetchOptions, clientId, environment }: ApiConfig);
|
|
120
|
+
/**
|
|
121
|
+
* Logs errors that occur during API requests with standardized messages.
|
|
122
|
+
*
|
|
123
|
+
* @param error - The error thrown by the underlying operation.
|
|
124
|
+
* @param options - Additional metadata about the request.
|
|
125
|
+
* @param options.requestName - Human-readable name of the request operation.
|
|
126
|
+
*
|
|
127
|
+
* @protected
|
|
128
|
+
*
|
|
129
|
+
* @remarks
|
|
130
|
+
* Abort errors are logged at `warn` level and other errors at `error` level.
|
|
131
|
+
* The log message includes the client name for better debugging context.
|
|
132
|
+
*/
|
|
133
|
+
protected logRequestError(error: unknown, { requestName }: {
|
|
134
|
+
requestName: string;
|
|
135
|
+
}): void;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Configuration for the high-level {@link ApiClient}.
|
|
140
|
+
*
|
|
141
|
+
* @public
|
|
142
|
+
*/
|
|
143
|
+
export declare interface ApiClientConfig extends Pick<ApiConfig, GlobalApiConfigProperties> {
|
|
144
|
+
/**
|
|
145
|
+
* Configuration for the personalization (Experience) API client.
|
|
146
|
+
*
|
|
147
|
+
* @remarks
|
|
148
|
+
* Any properties shared with {@link ApiConfig} are taken from the top-level
|
|
149
|
+
* config and overridden by this object when specified.
|
|
150
|
+
*/
|
|
151
|
+
personalization?: Omit<ExperienceApiClientConfig, GlobalApiConfigProperties>;
|
|
152
|
+
/**
|
|
153
|
+
* Configuration for the analytics (Insights) API client.
|
|
154
|
+
*
|
|
155
|
+
* @remarks
|
|
156
|
+
* Any properties shared with {@link ApiConfig} are taken from the top-level
|
|
157
|
+
* config and overridden by this object when specified.
|
|
158
|
+
*/
|
|
159
|
+
analytics?: Omit<InsightsApiClientConfig, GlobalApiConfigProperties>;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Configuration options for API clients extending {@link ApiClientBase}.
|
|
164
|
+
*
|
|
165
|
+
* @public
|
|
166
|
+
*/
|
|
167
|
+
export declare interface ApiConfig {
|
|
168
|
+
/**
|
|
169
|
+
* Base URL for the API.
|
|
170
|
+
*
|
|
171
|
+
* @remarks
|
|
172
|
+
* When omitted, the concrete client is expected to construct full URLs
|
|
173
|
+
* internally.
|
|
174
|
+
*/
|
|
175
|
+
baseUrl?: string;
|
|
176
|
+
/**
|
|
177
|
+
* Contentful environment identifier.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* Defaults to `main` when not provided.
|
|
181
|
+
*/
|
|
182
|
+
environment?: string;
|
|
183
|
+
/**
|
|
184
|
+
* Options used to configure the underlying protected fetch method.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* `apiName` is derived from the client name and must not be provided here.
|
|
188
|
+
*/
|
|
189
|
+
fetchOptions?: Omit<ProtectedFetchMethodOptions, 'apiName'>;
|
|
190
|
+
/**
|
|
191
|
+
* Client identifier used for authentication or tracking.
|
|
192
|
+
*/
|
|
193
|
+
clientId: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Base options shared across fetch method factories.
|
|
198
|
+
*
|
|
199
|
+
* @public
|
|
200
|
+
*/
|
|
201
|
+
declare interface BaseFetchMethodOptions {
|
|
202
|
+
/**
|
|
203
|
+
* Human-readable name of the API being called.
|
|
204
|
+
*
|
|
205
|
+
* @remarks
|
|
206
|
+
* Used primarily for logging and error messages.
|
|
207
|
+
*/
|
|
208
|
+
apiName?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Custom fetch implementation to use instead of the global `fetch`.
|
|
211
|
+
*
|
|
212
|
+
* @remarks
|
|
213
|
+
* This is useful for providing polyfills, mocks, or instrumented fetch
|
|
214
|
+
* implementations.
|
|
215
|
+
*/
|
|
216
|
+
fetchMethod?: FetchMethod;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* Parameters used when performing a batch profile update.
|
|
221
|
+
*/
|
|
222
|
+
declare interface BatchUpdateProfileParams {
|
|
223
|
+
/**
|
|
224
|
+
* Batch of events to process.
|
|
225
|
+
*/
|
|
226
|
+
events: BatchExperienceEventArray;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Arguments for constructing component view events.
|
|
231
|
+
*
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
234
|
+
export declare type ComponentViewBuilderArgs = z.infer<typeof ComponentViewBuilderArgs_2>;
|
|
235
|
+
|
|
236
|
+
declare const ComponentViewBuilderArgs_2: z.ZodMiniObject<{
|
|
237
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
238
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
239
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
240
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
241
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
242
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
243
|
+
}, z.core.$strip>>;
|
|
244
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
245
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
246
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
247
|
+
latitude: z.ZodMiniNumber<number>;
|
|
248
|
+
longitude: z.ZodMiniNumber<number>;
|
|
249
|
+
}, z.core.$strip>>;
|
|
250
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
251
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
252
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
253
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
254
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
255
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
256
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
257
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
258
|
+
}, z.core.$strip>>;
|
|
259
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
260
|
+
path: z.ZodMiniString<string>;
|
|
261
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
262
|
+
referrer: z.ZodMiniString<string>;
|
|
263
|
+
search: z.ZodMiniString<string>;
|
|
264
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
265
|
+
url: z.ZodMiniString<string>;
|
|
266
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
267
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
268
|
+
name: z.ZodMiniString<string>;
|
|
269
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
270
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
271
|
+
componentId: z.ZodMiniString<string>;
|
|
272
|
+
experienceId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
273
|
+
variantIndex: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
|
|
274
|
+
sticky: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
275
|
+
}, z.core.$strip>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Arguments for constructing component view events.
|
|
279
|
+
*
|
|
280
|
+
* @public
|
|
281
|
+
*/
|
|
282
|
+
declare type ComponentViewBuilderArgs = z.infer<typeof ComponentViewBuilderArgs_2>;
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Parameters used when creating a profile.
|
|
286
|
+
*/
|
|
287
|
+
declare interface CreateProfileParams {
|
|
288
|
+
/**
|
|
289
|
+
* Events used to aggregate the profile state.
|
|
290
|
+
*/
|
|
291
|
+
events: ExperienceEventArray;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Default page properties used when no explicit page information is available.
|
|
296
|
+
*
|
|
297
|
+
* @public
|
|
298
|
+
*
|
|
299
|
+
* @defaultValue
|
|
300
|
+
* ```ts
|
|
301
|
+
* {
|
|
302
|
+
* path: '',
|
|
303
|
+
* query: {},
|
|
304
|
+
* referrer: '',
|
|
305
|
+
* search: '',
|
|
306
|
+
* title: '',
|
|
307
|
+
* url: '',
|
|
308
|
+
* }
|
|
309
|
+
* ```
|
|
310
|
+
*
|
|
311
|
+
* @remarks
|
|
312
|
+
* Values are required by the API; values may not be `undefined`. Empty values are valid.
|
|
313
|
+
*/
|
|
314
|
+
export declare const DEFAULT_PAGE_PROPERTIES: {
|
|
315
|
+
path: string;
|
|
316
|
+
query: {};
|
|
317
|
+
referrer: string;
|
|
318
|
+
search: string;
|
|
319
|
+
title: string;
|
|
320
|
+
url: string;
|
|
321
|
+
};
|
|
322
|
+
|
|
323
|
+
/**
|
|
324
|
+
* Internal helper class for building analytics and personalization events.
|
|
325
|
+
*
|
|
326
|
+
* @remarks
|
|
327
|
+
* This class coordinates configuration and argument validation to produce
|
|
328
|
+
* strongly-typed event payloads compatible with
|
|
329
|
+
* `@contentful/optimization-api-schemas`.
|
|
330
|
+
*
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
export declare class EventBuilder {
|
|
334
|
+
/**
|
|
335
|
+
* Application metadata attached to each event.
|
|
336
|
+
*
|
|
337
|
+
* @internal
|
|
338
|
+
*/
|
|
339
|
+
app?: App;
|
|
340
|
+
/**
|
|
341
|
+
* Channel value attached to each event.
|
|
342
|
+
*
|
|
343
|
+
* @internal
|
|
344
|
+
*/
|
|
345
|
+
channel: Channel;
|
|
346
|
+
/**
|
|
347
|
+
* Library metadata attached to each event.
|
|
348
|
+
*
|
|
349
|
+
* @internal
|
|
350
|
+
*/
|
|
351
|
+
library: Library;
|
|
352
|
+
/**
|
|
353
|
+
* Function that provides the locale when available.
|
|
354
|
+
*
|
|
355
|
+
* @internal
|
|
356
|
+
*/
|
|
357
|
+
getLocale: () => string | undefined;
|
|
358
|
+
/**
|
|
359
|
+
* Function that provides baseline page properties.
|
|
360
|
+
*
|
|
361
|
+
* @internal
|
|
362
|
+
*/
|
|
363
|
+
getPageProperties: () => Page;
|
|
364
|
+
/**
|
|
365
|
+
* Function that provides the user agent string when available.
|
|
366
|
+
*
|
|
367
|
+
* @internal
|
|
368
|
+
*/
|
|
369
|
+
getUserAgent: () => string | undefined;
|
|
370
|
+
/**
|
|
371
|
+
* Creates a new {@link EventBuilder} instance.
|
|
372
|
+
*
|
|
373
|
+
* @param config - Configuration used to customize event payloads.
|
|
374
|
+
*
|
|
375
|
+
* @internal
|
|
376
|
+
* @remarks
|
|
377
|
+
* Callers are expected to reuse a single instance when possible to avoid
|
|
378
|
+
* repeatedly reconfiguring the builder.
|
|
379
|
+
*
|
|
380
|
+
* @example
|
|
381
|
+
* ```ts
|
|
382
|
+
* const builder = new EventBuilder({
|
|
383
|
+
* channel: 'web',
|
|
384
|
+
* library: { name: '@contentful/optimization-sdk', version: '1.0.0' },
|
|
385
|
+
* })
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
388
|
+
constructor(config: EventBuilderConfig);
|
|
389
|
+
/**
|
|
390
|
+
* Builds the universal event properties shared across all event types.
|
|
391
|
+
*
|
|
392
|
+
* @param args - Arguments overriding the default context values.
|
|
393
|
+
* @returns A fully populated {@link UniversalEventProperties} object.
|
|
394
|
+
*
|
|
395
|
+
* @protected
|
|
396
|
+
*
|
|
397
|
+
* @remarks
|
|
398
|
+
* This method is used internally by the specific event-builder methods
|
|
399
|
+
* (e.g. {@link EventBuilder.buildPageView}).
|
|
400
|
+
*/
|
|
401
|
+
protected buildUniversalEventProperties({ campaign, locale, location, page, screen, userAgent, }: UniversalEventBuilderArgs): UniversalEventProperties;
|
|
402
|
+
/**
|
|
403
|
+
* Builds a component view event payload for a Contentful entry-based component.
|
|
404
|
+
*
|
|
405
|
+
* @param args - {@link ComponentViewBuilderArgs} arguments describing the component view.
|
|
406
|
+
* @returns A {@link ComponentViewEvent} describing the view.
|
|
407
|
+
*
|
|
408
|
+
* @public
|
|
409
|
+
*
|
|
410
|
+
* @example
|
|
411
|
+
* ```ts
|
|
412
|
+
* const event = builder.buildComponentView({
|
|
413
|
+
* componentId: 'entry-123',
|
|
414
|
+
* experienceId: 'personalization-123',
|
|
415
|
+
* variantIndex: 1,
|
|
416
|
+
* })
|
|
417
|
+
* ```
|
|
418
|
+
*/
|
|
419
|
+
buildComponentView(args: ComponentViewBuilderArgs): ComponentViewEvent;
|
|
420
|
+
/**
|
|
421
|
+
* Builds a component view event payload for a Custom Flag component.
|
|
422
|
+
*
|
|
423
|
+
* @param args - {@link ComponentViewBuilderArgs} arguments describing the Custom Flag view.
|
|
424
|
+
* @returns A {@link ComponentViewEvent} describing the view.
|
|
425
|
+
*
|
|
426
|
+
* @public
|
|
427
|
+
*
|
|
428
|
+
* @remarks
|
|
429
|
+
* This is a specialized variant of {@link EventBuilder.buildComponentView}
|
|
430
|
+
* that sets `componentType` to `'Variable'`.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```ts
|
|
434
|
+
* const event = builder.buildFlagView({
|
|
435
|
+
* componentId: 'feature-flag-key',
|
|
436
|
+
* experienceId: 'personalization-123',
|
|
437
|
+
* })
|
|
438
|
+
* ```
|
|
439
|
+
*/
|
|
440
|
+
buildFlagView(args: ComponentViewBuilderArgs): ComponentViewEvent;
|
|
441
|
+
/**
|
|
442
|
+
* Builds an identify event payload to associate a user ID with traits.
|
|
443
|
+
*
|
|
444
|
+
* @param args - {@link IdentifyBuilderArgs} arguments describing the identified user.
|
|
445
|
+
* @returns An {@link IdentifyEvent} payload.
|
|
446
|
+
*
|
|
447
|
+
* @public
|
|
448
|
+
*
|
|
449
|
+
* @remarks
|
|
450
|
+
* - Traits are merged by the API; only specified properties may be overwritten.
|
|
451
|
+
* - The User ID is consumer-specified and should not contain the value of any
|
|
452
|
+
* ID generated by the Experience API.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```ts
|
|
456
|
+
* const event = builder.buildIdentify({
|
|
457
|
+
* userId: 'user-123',
|
|
458
|
+
* traits: { plan: 'pro' },
|
|
459
|
+
* })
|
|
460
|
+
* ```
|
|
461
|
+
*/
|
|
462
|
+
buildIdentify(args: IdentifyBuilderArgs): IdentifyEvent;
|
|
463
|
+
/**
|
|
464
|
+
* Builds a page view event payload.
|
|
465
|
+
*
|
|
466
|
+
* @param args - Optional {@link PageViewBuilderArgs} overrides for the page view event.
|
|
467
|
+
* @returns A {@link PageViewEvent} payload.
|
|
468
|
+
*
|
|
469
|
+
* @public
|
|
470
|
+
*
|
|
471
|
+
* @remarks
|
|
472
|
+
* Page properties are created by merging:
|
|
473
|
+
* 1. The base page properties from {@link EventBuilderConfig.getPageProperties}, and
|
|
474
|
+
* 2. The partial `properties` argument passed in.
|
|
475
|
+
*
|
|
476
|
+
* The title always falls back to {@link DEFAULT_PAGE_PROPERTIES}.title when undefined.
|
|
477
|
+
*
|
|
478
|
+
* @example
|
|
479
|
+
* ```ts
|
|
480
|
+
* const event = builder.buildPageView({
|
|
481
|
+
* properties: {
|
|
482
|
+
* title: 'Homepage',
|
|
483
|
+
* },
|
|
484
|
+
* })
|
|
485
|
+
* ```
|
|
486
|
+
*/
|
|
487
|
+
buildPageView(args?: PageViewBuilderArgs): PageViewEvent;
|
|
488
|
+
/**
|
|
489
|
+
* Builds a screen view event payload.
|
|
490
|
+
*
|
|
491
|
+
* @param args - {@link ScreenViewBuilderArgs} arguments for the screen view event.
|
|
492
|
+
* @returns A {@link ScreenViewEvent} payload.
|
|
493
|
+
*
|
|
494
|
+
* @public
|
|
495
|
+
*
|
|
496
|
+
* @example
|
|
497
|
+
* ```ts
|
|
498
|
+
* const event = builder.buildScreenView({
|
|
499
|
+
* name: 'home',
|
|
500
|
+
* properties: {
|
|
501
|
+
* title: 'Home Screen',
|
|
502
|
+
* },
|
|
503
|
+
* })
|
|
504
|
+
* ```
|
|
505
|
+
*/
|
|
506
|
+
buildScreenView(args: ScreenViewBuilderArgs): ScreenViewEvent;
|
|
507
|
+
/**
|
|
508
|
+
* Builds a track event payload for arbitrary user actions.
|
|
509
|
+
*
|
|
510
|
+
* @param args - {@link TrackBuilderArgs} arguments describing the tracked event.
|
|
511
|
+
* @returns A {@link TrackEvent} payload.
|
|
512
|
+
*
|
|
513
|
+
* @public
|
|
514
|
+
*
|
|
515
|
+
* @example
|
|
516
|
+
* ```ts
|
|
517
|
+
* const event = builder.buildTrack({
|
|
518
|
+
* event: 'button_clicked',
|
|
519
|
+
* properties: { id: 'primary-cta', location: 'hero' },
|
|
520
|
+
* })
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
buildTrack(args: TrackBuilderArgs): TrackEvent_2;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Configuration options for creating an {@link EventBuilder} instance.
|
|
528
|
+
*
|
|
529
|
+
* @public
|
|
530
|
+
* @remarks
|
|
531
|
+
* The configuration is typically provided by the host application to adapt
|
|
532
|
+
* event payloads to the runtime environment (browser, framework, etc.).
|
|
533
|
+
*
|
|
534
|
+
* @example
|
|
535
|
+
* ```ts
|
|
536
|
+
* const builder = new EventBuilder({
|
|
537
|
+
* app: { name: 'my-app', version: '1.0.0' },
|
|
538
|
+
* channel: 'web',
|
|
539
|
+
* library: { name: '@contentful/optimization-sdk', version: '1.2.3' },
|
|
540
|
+
* getLocale: () => navigator.language,
|
|
541
|
+
* getPageProperties: () => ({
|
|
542
|
+
* path: window.location.pathname,
|
|
543
|
+
* url: window.location.href,
|
|
544
|
+
* title: document.title,
|
|
545
|
+
* query: {},
|
|
546
|
+
* referrer: document.referrer,
|
|
547
|
+
* search: window.location.search,
|
|
548
|
+
* }),
|
|
549
|
+
* })
|
|
550
|
+
* ```
|
|
551
|
+
*/
|
|
552
|
+
export declare interface EventBuilderConfig {
|
|
553
|
+
/**
|
|
554
|
+
* The application definition used to attribute events to a specific consumer app.
|
|
555
|
+
*
|
|
556
|
+
* @remarks
|
|
557
|
+
* When not provided, events will not contain app metadata in their context.
|
|
558
|
+
*/
|
|
559
|
+
app?: App;
|
|
560
|
+
/**
|
|
561
|
+
* The channel that identifies where events originate from (e.g. web, mobile).
|
|
562
|
+
*
|
|
563
|
+
* @see {@link Channel}
|
|
564
|
+
*/
|
|
565
|
+
channel: Channel;
|
|
566
|
+
/**
|
|
567
|
+
* The client library metadata that is attached to all events.
|
|
568
|
+
*
|
|
569
|
+
* @remarks
|
|
570
|
+
* This is typically used to record the library name and version.
|
|
571
|
+
*/
|
|
572
|
+
library: Library;
|
|
573
|
+
/**
|
|
574
|
+
* Function used to resolve the locale for outgoing events.
|
|
575
|
+
*
|
|
576
|
+
* @remarks
|
|
577
|
+
* If not provided, the builder falls back to the default `'en-US'`. Locale
|
|
578
|
+
* values supplied directly as arguments to event builder methods take
|
|
579
|
+
* precedence.
|
|
580
|
+
*
|
|
581
|
+
* @returns The locale string (e.g. `'en-US'`), or `undefined` if unavailable.
|
|
582
|
+
*/
|
|
583
|
+
getLocale?: () => string | undefined;
|
|
584
|
+
/**
|
|
585
|
+
* Function that returns the current page properties.
|
|
586
|
+
*
|
|
587
|
+
* @remarks
|
|
588
|
+
* Page properties are currently added to the context of all events, as well
|
|
589
|
+
* as the `properties` of the page event. When specified, all properties of
|
|
590
|
+
* the `Page` type are required, but may contain empty values.
|
|
591
|
+
*
|
|
592
|
+
* @returns A {@link Page} object containing information about the current page.
|
|
593
|
+
* @see {@link Page}
|
|
594
|
+
*/
|
|
595
|
+
getPageProperties?: () => Page;
|
|
596
|
+
/**
|
|
597
|
+
* Function used to obtain the current user agent string when applicable.
|
|
598
|
+
*
|
|
599
|
+
* @returns A user agent string, or `undefined` if unavailable.
|
|
600
|
+
*/
|
|
601
|
+
getUserAgent?: () => string | undefined;
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Default base URL for the Experience API.
|
|
606
|
+
*
|
|
607
|
+
* @public
|
|
608
|
+
*/
|
|
609
|
+
export declare const EXPERIENCE_BASE_URL = "https://experience.ninetailed.co/";
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Client for interacting with the Experience API.
|
|
613
|
+
*
|
|
614
|
+
* @public
|
|
615
|
+
*
|
|
616
|
+
* @remarks
|
|
617
|
+
* This client is responsible for reading and mutating Ninetailed profiles
|
|
618
|
+
* using the Experience API.
|
|
619
|
+
*
|
|
620
|
+
* @example
|
|
621
|
+
* ```ts
|
|
622
|
+
* const client = new ExperienceApiClient({
|
|
623
|
+
* clientId: 'org-id',
|
|
624
|
+
* environment: 'main',
|
|
625
|
+
* })
|
|
626
|
+
*
|
|
627
|
+
* const profile = await client.getProfile('profile-id')
|
|
628
|
+
* ```
|
|
629
|
+
*/
|
|
630
|
+
declare class ExperienceApiClient extends ApiClientBase {
|
|
631
|
+
/**
|
|
632
|
+
* Base URL used for Experience API requests.
|
|
633
|
+
*/
|
|
634
|
+
protected readonly baseUrl: string;
|
|
635
|
+
private readonly enabledFeatures?;
|
|
636
|
+
private readonly ip?;
|
|
637
|
+
private readonly locale?;
|
|
638
|
+
private readonly plainText?;
|
|
639
|
+
private readonly preflight?;
|
|
640
|
+
/**
|
|
641
|
+
* Creates a new {@link ExperienceApiClient} instance.
|
|
642
|
+
*
|
|
643
|
+
* @param config - Configuration for the Experience API client.
|
|
644
|
+
*/
|
|
645
|
+
constructor(config: ExperienceApiClientConfig);
|
|
646
|
+
/**
|
|
647
|
+
* Retrieves a profile by ID.
|
|
648
|
+
*
|
|
649
|
+
* @param id - The profile ID to retrieve.
|
|
650
|
+
* @param options - Optional request options. `preflight` and `plainText` are not allowed here.
|
|
651
|
+
* @returns The current optimization data for the profile.
|
|
652
|
+
*
|
|
653
|
+
* @throws {@link Error}
|
|
654
|
+
* Thrown if `id` is missing or the underlying request fails.
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
* ```ts
|
|
658
|
+
* const profile = await client.getProfile('profile-id', {
|
|
659
|
+
* locale: 'en-US',
|
|
660
|
+
* })
|
|
661
|
+
* ```
|
|
662
|
+
*/
|
|
663
|
+
getProfile(id: string, options?: Omit<RequestOptions, 'preflight' | 'plainText'>): Promise<OptimizationData>;
|
|
664
|
+
/**
|
|
665
|
+
* Sends a POST request to mutate a profile or profiles.
|
|
666
|
+
*
|
|
667
|
+
* @param request - Mutation request options including URL, body, and request options.
|
|
668
|
+
* @returns The raw {@link Response} from the underlying fetch.
|
|
669
|
+
*
|
|
670
|
+
* @internal
|
|
671
|
+
*/
|
|
672
|
+
private makeProfileMutationRequest;
|
|
673
|
+
/**
|
|
674
|
+
* Creates a profile and returns the resulting optimization data.
|
|
675
|
+
*
|
|
676
|
+
* @param params - Parameters containing the events to aggregate into the profile.
|
|
677
|
+
* @param options - Optional request options.
|
|
678
|
+
* @returns The optimization data for the newly created profile.
|
|
679
|
+
*
|
|
680
|
+
* @remarks
|
|
681
|
+
* The returned profile ID can be used for subsequent update requests.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* ```ts
|
|
685
|
+
* const data = await client.createProfile({
|
|
686
|
+
* events: [{ type: 'identify', userId: 'user-123' }],
|
|
687
|
+
* })
|
|
688
|
+
* ```
|
|
689
|
+
*/
|
|
690
|
+
createProfile({ events }: CreateProfileParams, options?: RequestOptions): Promise<OptimizationData>;
|
|
691
|
+
/**
|
|
692
|
+
* Updates an existing profile with the given profile ID.
|
|
693
|
+
*
|
|
694
|
+
* @param params - Parameters including the profile ID and events.
|
|
695
|
+
* @param options - Optional request options.
|
|
696
|
+
* @returns The updated optimization data for the profile.
|
|
697
|
+
*
|
|
698
|
+
* @throws {@link Error}
|
|
699
|
+
* Thrown if `profileId` is missing or the underlying request fails.
|
|
700
|
+
*
|
|
701
|
+
* @example
|
|
702
|
+
* ```ts
|
|
703
|
+
* const data = await client.updateProfile({
|
|
704
|
+
* profileId: 'profile-id',
|
|
705
|
+
* events: [{ type: 'track', event: 'viewed_video' }],
|
|
706
|
+
* })
|
|
707
|
+
* ```
|
|
708
|
+
*/
|
|
709
|
+
updateProfile({ profileId, events }: UpdateProfileParams, options?: RequestOptions): Promise<OptimizationData>;
|
|
710
|
+
/**
|
|
711
|
+
* Creates or updates a profile depending on whether a `profileId` is provided.
|
|
712
|
+
*
|
|
713
|
+
* @param params - Parameters including optional profile ID and events.
|
|
714
|
+
* @param options - Optional request options.
|
|
715
|
+
* @returns The resulting optimization data.
|
|
716
|
+
*
|
|
717
|
+
* @example
|
|
718
|
+
* ```ts
|
|
719
|
+
* // Create
|
|
720
|
+
* await client.upsertProfile({ events })
|
|
721
|
+
*
|
|
722
|
+
* // Update
|
|
723
|
+
* await client.upsertProfile({ profileId: 'profile-id', events })
|
|
724
|
+
* ```
|
|
725
|
+
*/
|
|
726
|
+
upsertProfile({ profileId, events }: UpsertProfileParams, options?: RequestOptions): Promise<OptimizationData>;
|
|
727
|
+
/**
|
|
728
|
+
* Sends multiple events to the Ninetailed Experience API to upsert many profiles.
|
|
729
|
+
*
|
|
730
|
+
* @param params - Parameters containing the batch of events.
|
|
731
|
+
* @param options - Optional request options.
|
|
732
|
+
* @returns The list of profiles affected by the batch operation.
|
|
733
|
+
*
|
|
734
|
+
* @remarks
|
|
735
|
+
* Every event must contain an anonymous ID. Profiles will be created or
|
|
736
|
+
* updated according to the anonymous ID.
|
|
737
|
+
*
|
|
738
|
+
* This method is intended to be used from server environments.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```ts
|
|
742
|
+
* const profiles = await client.upsertManyProfiles({
|
|
743
|
+
* events: [
|
|
744
|
+
* [{ type: 'identify', userId: 'user-1' }],
|
|
745
|
+
* [{ type: 'identify', userId: 'user-2' }],
|
|
746
|
+
* ],
|
|
747
|
+
* })
|
|
748
|
+
* ```
|
|
749
|
+
*/
|
|
750
|
+
upsertManyProfiles({ events }: BatchUpdateProfileParams, options?: RequestOptions): Promise<BatchExperienceData['profiles']>;
|
|
751
|
+
/**
|
|
752
|
+
* Constructs a request URL with query parameters derived from request options.
|
|
753
|
+
*
|
|
754
|
+
* @param path - Path relative to the Experience API base URL.
|
|
755
|
+
* @param options - Request options that may influence query parameters.
|
|
756
|
+
* @returns The fully constructed URL as a string.
|
|
757
|
+
*
|
|
758
|
+
* @internal
|
|
759
|
+
*/
|
|
760
|
+
private constructUrl;
|
|
761
|
+
/**
|
|
762
|
+
* Constructs request headers based on request options and default configuration.
|
|
763
|
+
*
|
|
764
|
+
* @param options - Request options that may influence headers.
|
|
765
|
+
* @returns A record of HTTP headers to send with the request.
|
|
766
|
+
*
|
|
767
|
+
* @internal
|
|
768
|
+
*/
|
|
769
|
+
private constructHeaders;
|
|
770
|
+
/**
|
|
771
|
+
* Constructs the `options` section of the request body for profile mutations.
|
|
772
|
+
*
|
|
773
|
+
* @param options - Request options that may specify enabled features.
|
|
774
|
+
* @returns Experience API body options including feature flags.
|
|
775
|
+
*
|
|
776
|
+
* @internal
|
|
777
|
+
*/
|
|
778
|
+
private readonly constructBodyOptions;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Configuration for {@link ExperienceApiClient}.
|
|
783
|
+
*/
|
|
784
|
+
export declare interface ExperienceApiClientConfig extends ApiConfig, RequestOptions {
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
/**
|
|
788
|
+
* Feature flags supported by the Experience API.
|
|
789
|
+
*/
|
|
790
|
+
declare type Feature = 'ip-enrichment' | 'location';
|
|
791
|
+
|
|
792
|
+
/**
|
|
793
|
+
* Signature of a fetch method used by the API clients.
|
|
794
|
+
*
|
|
795
|
+
* @param url - The request URL.
|
|
796
|
+
* @param init - Initialization options passed to `fetch`.
|
|
797
|
+
* @returns A promise that resolves with the {@link Response}.
|
|
798
|
+
*
|
|
799
|
+
* @public
|
|
800
|
+
*
|
|
801
|
+
* @remarks
|
|
802
|
+
* This abstraction allows the underlying implementation to be replaced,
|
|
803
|
+
* for example in tests or different runtime environments.
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* ```ts
|
|
807
|
+
* const method: FetchMethod = async (url, init) => {
|
|
808
|
+
* return fetch(url, init)
|
|
809
|
+
* }
|
|
810
|
+
* ```
|
|
811
|
+
*/
|
|
812
|
+
declare type FetchMethod = (url: string | URL, init: RequestInit) => Promise<Response>;
|
|
813
|
+
|
|
814
|
+
/**
|
|
815
|
+
* Options passed to callback functions invoked by fetch wrappers.
|
|
816
|
+
*
|
|
817
|
+
* @public
|
|
818
|
+
*
|
|
819
|
+
* @remarks
|
|
820
|
+
* Not all fields are guaranteed to be present in all callback scenarios.
|
|
821
|
+
*/
|
|
822
|
+
declare interface FetchMethodCallbackOptions {
|
|
823
|
+
/**
|
|
824
|
+
* Name of the API associated with the request.
|
|
825
|
+
*/
|
|
826
|
+
apiName?: string;
|
|
827
|
+
/**
|
|
828
|
+
* Error that caused the callback to be invoked, if available.
|
|
829
|
+
*/
|
|
830
|
+
error?: Error;
|
|
831
|
+
/**
|
|
832
|
+
* The current attempt number (for retry callbacks).
|
|
833
|
+
*/
|
|
834
|
+
attemptNumber?: number;
|
|
835
|
+
/**
|
|
836
|
+
* Number of retry attempts remaining (for retry callbacks).
|
|
837
|
+
*/
|
|
838
|
+
retriesLeft?: number;
|
|
839
|
+
}
|
|
840
|
+
|
|
841
|
+
/**
|
|
842
|
+
* Properties that may be shared between global and per-client API configuration.
|
|
843
|
+
*
|
|
844
|
+
* @public
|
|
845
|
+
*/
|
|
846
|
+
export declare type GlobalApiConfigProperties = 'environment' | 'fetchOptions' | 'clientId';
|
|
847
|
+
|
|
848
|
+
/**
|
|
849
|
+
* Arguments for constructing identify events.
|
|
850
|
+
*
|
|
851
|
+
* @public
|
|
852
|
+
* @remarks
|
|
853
|
+
* Traits are merged by the API; only specified properties may be overwritten.
|
|
854
|
+
*/
|
|
855
|
+
export declare type IdentifyBuilderArgs = z.infer<typeof IdentifyBuilderArgs_2>;
|
|
856
|
+
|
|
857
|
+
declare const IdentifyBuilderArgs_2: z.ZodMiniObject<{
|
|
858
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
859
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
860
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
861
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
862
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
863
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
864
|
+
}, z.core.$strip>>;
|
|
865
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
866
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
867
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
868
|
+
latitude: z.ZodMiniNumber<number>;
|
|
869
|
+
longitude: z.ZodMiniNumber<number>;
|
|
870
|
+
}, z.core.$strip>>;
|
|
871
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
872
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
873
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
874
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
875
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
876
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
877
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
878
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
879
|
+
}, z.core.$strip>>;
|
|
880
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
881
|
+
path: z.ZodMiniString<string>;
|
|
882
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
883
|
+
referrer: z.ZodMiniString<string>;
|
|
884
|
+
search: z.ZodMiniString<string>;
|
|
885
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
886
|
+
url: z.ZodMiniString<string>;
|
|
887
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
888
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
889
|
+
name: z.ZodMiniString<string>;
|
|
890
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
891
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
892
|
+
traits: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>>;
|
|
893
|
+
userId: z.ZodMiniString<string>;
|
|
894
|
+
}, z.core.$strip>;
|
|
895
|
+
|
|
896
|
+
/**
|
|
897
|
+
* Arguments for constructing identify events.
|
|
898
|
+
*
|
|
899
|
+
* @public
|
|
900
|
+
* @remarks
|
|
901
|
+
* Traits are merged by the API; only specified properties may be overwritten.
|
|
902
|
+
*/
|
|
903
|
+
declare type IdentifyBuilderArgs = z.infer<typeof IdentifyBuilderArgs_2>;
|
|
904
|
+
|
|
905
|
+
/**
|
|
906
|
+
* Default base URL for the Insights ingest API.
|
|
907
|
+
*
|
|
908
|
+
* @public
|
|
909
|
+
*/
|
|
910
|
+
export declare const INSIGHTS_BASE_URL = "https://ingest.insights.ninetailed.co/";
|
|
911
|
+
|
|
912
|
+
/**
|
|
913
|
+
* Client for sending analytics and insights events to the Ninetailed Insights API.
|
|
914
|
+
*
|
|
915
|
+
* @public
|
|
916
|
+
*
|
|
917
|
+
* @remarks
|
|
918
|
+
* This client is optimized for sending batched events, optionally using a
|
|
919
|
+
* custom beacon-like handler when available.
|
|
920
|
+
*
|
|
921
|
+
* @example
|
|
922
|
+
* ```ts
|
|
923
|
+
* const insightsClient = new InsightsApiClient({
|
|
924
|
+
* clientId: 'org-id',
|
|
925
|
+
* environment: 'main',
|
|
926
|
+
* preview: false,
|
|
927
|
+
* })
|
|
928
|
+
*
|
|
929
|
+
* await insightsClient.sendBatchEvents([
|
|
930
|
+
* {
|
|
931
|
+
* profile: { id: 'profile-123', ... },
|
|
932
|
+
* events: [
|
|
933
|
+
* {
|
|
934
|
+
* type: 'track',
|
|
935
|
+
* event: 'button_clicked',
|
|
936
|
+
* properties: { id: 'primary-cta' },
|
|
937
|
+
* },
|
|
938
|
+
* ],
|
|
939
|
+
* }
|
|
940
|
+
* ])
|
|
941
|
+
* ```
|
|
942
|
+
*/
|
|
943
|
+
declare class InsightsApiClient extends ApiClientBase {
|
|
944
|
+
/**
|
|
945
|
+
* Base URL used for Insights API requests.
|
|
946
|
+
*/
|
|
947
|
+
protected readonly baseUrl: string;
|
|
948
|
+
/**
|
|
949
|
+
* Optional handler used to enqueue events via the Beacon API or a similar mechanism.
|
|
950
|
+
*/
|
|
951
|
+
private readonly beaconHandler;
|
|
952
|
+
/**
|
|
953
|
+
* Creates a new {@link InsightsApiClient} instance.
|
|
954
|
+
*
|
|
955
|
+
* @param config - Configuration for the Insights API client.
|
|
956
|
+
*
|
|
957
|
+
* @example
|
|
958
|
+
* ```ts
|
|
959
|
+
* const client = new InsightsApiClient({
|
|
960
|
+
* clientId: 'org-id',
|
|
961
|
+
* environment: 'main',
|
|
962
|
+
* beaconHandler: (url, data) => {
|
|
963
|
+
* return navigator.sendBeacon(url.toString(), JSON.stringify(data))
|
|
964
|
+
* },
|
|
965
|
+
* })
|
|
966
|
+
* ```
|
|
967
|
+
*/
|
|
968
|
+
constructor(config: InsightsApiClientConfig);
|
|
969
|
+
/**
|
|
970
|
+
* Sends batches of insights events to the Ninetailed Insights API.
|
|
971
|
+
*
|
|
972
|
+
* @param batches - Array of event batches to send.
|
|
973
|
+
* @param options - Optional request options, including a per-call `beaconHandler`.
|
|
974
|
+
* @returns A promise that resolves when the events have been sent or queued.
|
|
975
|
+
*
|
|
976
|
+
* @remarks
|
|
977
|
+
* If a `beaconHandler` is provided (either in the method call or in the
|
|
978
|
+
* client configuration) it will be invoked first. When the handler returns
|
|
979
|
+
* `true`, the events are considered successfully queued and no network
|
|
980
|
+
* request is made by this method.
|
|
981
|
+
*
|
|
982
|
+
* If the handler is missing or returns `false`, the events are emitted
|
|
983
|
+
* immediately via `fetch`.
|
|
984
|
+
*
|
|
985
|
+
* @returns A boolean value that is true when either the event batch is successfully
|
|
986
|
+
* queued by the beacon handler or a direct request is successfully sent.
|
|
987
|
+
*
|
|
988
|
+
* @example
|
|
989
|
+
* ```ts
|
|
990
|
+
* const success = await insightsClient.sendBatchEvents(batches)
|
|
991
|
+
* ```
|
|
992
|
+
*
|
|
993
|
+
* @example
|
|
994
|
+
* ```ts
|
|
995
|
+
* // Override beaconHandler for a single call
|
|
996
|
+
* const success = await insightsClient.sendBatchEvents(batches, {
|
|
997
|
+
* beaconHandler: (url, data) => {
|
|
998
|
+
* return navigator.sendBeacon(url.toString(), JSON.stringify(data))
|
|
999
|
+
* },
|
|
1000
|
+
* })
|
|
1001
|
+
* ```
|
|
1002
|
+
*/
|
|
1003
|
+
sendBatchEvents(batches: BatchInsightsEventArray, options?: RequestOptions_2): Promise<boolean>;
|
|
1004
|
+
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* Configuration for {@link InsightsApiClient}.
|
|
1008
|
+
*
|
|
1009
|
+
* @public
|
|
1010
|
+
*/
|
|
1011
|
+
export declare interface InsightsApiClientConfig extends ApiConfig, RequestOptions_2 {
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/**
|
|
1015
|
+
* Arguments for constructing page view events.
|
|
1016
|
+
*
|
|
1017
|
+
* @public
|
|
1018
|
+
* @remarks
|
|
1019
|
+
* Any properties passed here are merged with the base page properties from
|
|
1020
|
+
* {@link EventBuilderConfig.getPageProperties}.
|
|
1021
|
+
*/
|
|
1022
|
+
export declare type PageViewBuilderArgs = z.infer<typeof PageViewBuilderArgs_2>;
|
|
1023
|
+
|
|
1024
|
+
declare const PageViewBuilderArgs_2: z.ZodMiniObject<{
|
|
1025
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1026
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1027
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1028
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1029
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1030
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1031
|
+
}, z.core.$strip>>;
|
|
1032
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1033
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1034
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1035
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1036
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1037
|
+
}, z.core.$strip>>;
|
|
1038
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1039
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1040
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1041
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1042
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1043
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1044
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1045
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1046
|
+
}, z.core.$strip>>;
|
|
1047
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1048
|
+
path: z.ZodMiniString<string>;
|
|
1049
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1050
|
+
referrer: z.ZodMiniString<string>;
|
|
1051
|
+
search: z.ZodMiniString<string>;
|
|
1052
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1053
|
+
url: z.ZodMiniString<string>;
|
|
1054
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1055
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1056
|
+
name: z.ZodMiniString<string>;
|
|
1057
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1058
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1059
|
+
properties: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1060
|
+
path: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1061
|
+
query: z.ZodMiniOptional<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>>;
|
|
1062
|
+
referrer: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1063
|
+
search: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1064
|
+
title: z.ZodMiniOptional<z.ZodMiniOptional<z.ZodMiniString<string>>>;
|
|
1065
|
+
url: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1066
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1067
|
+
}, z.core.$strip>;
|
|
1068
|
+
|
|
1069
|
+
/**
|
|
1070
|
+
* Arguments for constructing page view events.
|
|
1071
|
+
*
|
|
1072
|
+
* @public
|
|
1073
|
+
* @remarks
|
|
1074
|
+
* Any properties passed here are merged with the base page properties from
|
|
1075
|
+
* {@link EventBuilderConfig.getPageProperties}.
|
|
1076
|
+
*/
|
|
1077
|
+
declare type PageViewBuilderArgs = z.infer<typeof PageViewBuilderArgs_2>;
|
|
1078
|
+
|
|
1079
|
+
/**
|
|
1080
|
+
* Options for {@link createProtectedFetchMethod}, combining timeout and retry behavior.
|
|
1081
|
+
*/
|
|
1082
|
+
declare interface ProtectedFetchMethodOptions extends RetryFetchMethodOptions, TimeoutFetchMethodOptions {
|
|
1083
|
+
}
|
|
1084
|
+
|
|
1085
|
+
/**
|
|
1086
|
+
* Options that control how requests to the Experience API are handled.
|
|
1087
|
+
*/
|
|
1088
|
+
declare interface RequestOptions {
|
|
1089
|
+
/**
|
|
1090
|
+
* Enabled features (for example, `"ip-enrichment"`) which the API should use for this request.
|
|
1091
|
+
*
|
|
1092
|
+
* @remarks
|
|
1093
|
+
* When omitted, a default set of features may be applied.
|
|
1094
|
+
*/
|
|
1095
|
+
enabledFeatures?: Feature[];
|
|
1096
|
+
/**
|
|
1097
|
+
* IP address to override the API behavior for IP analysis.
|
|
1098
|
+
*
|
|
1099
|
+
* @remarks
|
|
1100
|
+
* Commonly used in ESR or SSR environments, as the API would otherwise use
|
|
1101
|
+
* the server IP.
|
|
1102
|
+
*/
|
|
1103
|
+
ip?: string;
|
|
1104
|
+
/**
|
|
1105
|
+
* Locale used to translate `location.city` and `location.country`.
|
|
1106
|
+
*
|
|
1107
|
+
* @remarks
|
|
1108
|
+
* When omitted, a server-side default may be used.
|
|
1109
|
+
*/
|
|
1110
|
+
locale?: string;
|
|
1111
|
+
/**
|
|
1112
|
+
* When `true`, sends performance-critical endpoints in plain text.
|
|
1113
|
+
*
|
|
1114
|
+
* @remarks
|
|
1115
|
+
* The Ninetailed API accepts certain endpoints in plain text to avoid CORS
|
|
1116
|
+
* preflight requests, which can improve performance in browser environments.
|
|
1117
|
+
*/
|
|
1118
|
+
plainText?: boolean;
|
|
1119
|
+
/**
|
|
1120
|
+
* When `true`, instructs the API to aggregate a new profile state but not store it.
|
|
1121
|
+
*
|
|
1122
|
+
* @remarks
|
|
1123
|
+
* This is commonly used in ESR or SSR environments where you want to
|
|
1124
|
+
* preview the result without persisting changes.
|
|
1125
|
+
*/
|
|
1126
|
+
preflight?: boolean;
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
/**
|
|
1130
|
+
* Options that control how Insights events are sent.
|
|
1131
|
+
*
|
|
1132
|
+
* @public
|
|
1133
|
+
*/
|
|
1134
|
+
declare interface RequestOptions_2 {
|
|
1135
|
+
/**
|
|
1136
|
+
* Handler used to enqueue events via the Beacon API or a similar mechanism.
|
|
1137
|
+
*
|
|
1138
|
+
* @param url - Target URL for the batched events.
|
|
1139
|
+
* @param data - Array of batched insights events to be sent.
|
|
1140
|
+
* @returns `true` if the events were successfully queued, `false` otherwise.
|
|
1141
|
+
*
|
|
1142
|
+
* @remarks
|
|
1143
|
+
* When provided, this handler is preferred over direct `fetch` calls. If it
|
|
1144
|
+
* returns `false`, the client falls back to emitting events immediately via
|
|
1145
|
+
* `fetch`.
|
|
1146
|
+
*/
|
|
1147
|
+
beaconHandler?: (url: string | URL, data: BatchInsightsEventArray) => boolean;
|
|
1148
|
+
}
|
|
1149
|
+
|
|
1150
|
+
/**
|
|
1151
|
+
* Configuration options for {@link createRetryFetchMethod}.
|
|
1152
|
+
*/
|
|
1153
|
+
declare interface RetryFetchMethodOptions extends BaseFetchMethodOptions {
|
|
1154
|
+
/**
|
|
1155
|
+
* Delay (in milliseconds) between retry attempts.
|
|
1156
|
+
*
|
|
1157
|
+
* @remarks
|
|
1158
|
+
* Defaults to {@link DEFAULT_INTERVAL_TIMEOUT}.
|
|
1159
|
+
*/
|
|
1160
|
+
intervalTimeout?: number;
|
|
1161
|
+
/**
|
|
1162
|
+
* Callback invoked whenever a retry attempt fails.
|
|
1163
|
+
*
|
|
1164
|
+
* @param options - Information about the failed attempt.
|
|
1165
|
+
*
|
|
1166
|
+
* @remarks
|
|
1167
|
+
* This callback is invoked with additional metadata such as the attempt
|
|
1168
|
+
* number and the number of retries left.
|
|
1169
|
+
*/
|
|
1170
|
+
onFailedAttempt?: (options: FetchMethodCallbackOptions) => void;
|
|
1171
|
+
/**
|
|
1172
|
+
* Maximum number of retry attempts.
|
|
1173
|
+
*
|
|
1174
|
+
* @remarks
|
|
1175
|
+
* Defaults to {@link DEFAULT_RETRY_COUNT}.
|
|
1176
|
+
*/
|
|
1177
|
+
retries?: number;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1180
|
+
/**
|
|
1181
|
+
* Arguments for constructing screen view events.
|
|
1182
|
+
*
|
|
1183
|
+
* @public
|
|
1184
|
+
* @remarks
|
|
1185
|
+
* Any properties passed here are merged with the base screen properties from
|
|
1186
|
+
* {@link EventBuilderConfig.getScreenProperties}.
|
|
1187
|
+
*/
|
|
1188
|
+
export declare type ScreenViewBuilderArgs = z.infer<typeof ScreenViewBuilderArgs_2>;
|
|
1189
|
+
|
|
1190
|
+
declare const ScreenViewBuilderArgs_2: z.ZodMiniObject<{
|
|
1191
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1192
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1193
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1194
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1195
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1196
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1197
|
+
}, z.core.$strip>>;
|
|
1198
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1199
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1200
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1201
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1202
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1203
|
+
}, z.core.$strip>>;
|
|
1204
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1205
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1206
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1207
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1208
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1209
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1210
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1211
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1212
|
+
}, z.core.$strip>>;
|
|
1213
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1214
|
+
path: z.ZodMiniString<string>;
|
|
1215
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1216
|
+
referrer: z.ZodMiniString<string>;
|
|
1217
|
+
search: z.ZodMiniString<string>;
|
|
1218
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1219
|
+
url: z.ZodMiniString<string>;
|
|
1220
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1221
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1222
|
+
name: z.ZodMiniString<string>;
|
|
1223
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1224
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1225
|
+
name: z.ZodMiniString<string>;
|
|
1226
|
+
properties: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>;
|
|
1227
|
+
}, z.core.$strip>;
|
|
1228
|
+
|
|
1229
|
+
/**
|
|
1230
|
+
* Arguments for constructing screen view events.
|
|
1231
|
+
*
|
|
1232
|
+
* @public
|
|
1233
|
+
* @remarks
|
|
1234
|
+
* Any properties passed here are merged with the base screen properties from
|
|
1235
|
+
* {@link EventBuilderConfig.getScreenProperties}.
|
|
1236
|
+
*/
|
|
1237
|
+
declare type ScreenViewBuilderArgs = z.infer<typeof ScreenViewBuilderArgs_2>;
|
|
1238
|
+
|
|
1239
|
+
/**
|
|
1240
|
+
* Configuration options for {@link createTimeoutFetchMethod}.
|
|
1241
|
+
*/
|
|
1242
|
+
declare interface TimeoutFetchMethodOptions extends BaseFetchMethodOptions {
|
|
1243
|
+
/**
|
|
1244
|
+
* Callback invoked when a request exceeds the configured timeout.
|
|
1245
|
+
*
|
|
1246
|
+
* @param options - Information about the timed-out request.
|
|
1247
|
+
*
|
|
1248
|
+
* @remarks
|
|
1249
|
+
* If this callback is not provided, a default error is logged.
|
|
1250
|
+
*
|
|
1251
|
+
* @see {@link FetchMethodCallbackOptions}
|
|
1252
|
+
*/
|
|
1253
|
+
onRequestTimeout?: (options: FetchMethodCallbackOptions) => void;
|
|
1254
|
+
/**
|
|
1255
|
+
* Maximum time (in milliseconds) to wait for a response before aborting the request.
|
|
1256
|
+
*
|
|
1257
|
+
* @remarks
|
|
1258
|
+
* Defaults to {@link DEFAULT_REQUEST_TIMEOUT}.
|
|
1259
|
+
*/
|
|
1260
|
+
requestTimeout?: number;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
/**
|
|
1264
|
+
* Arguments for constructing track events.
|
|
1265
|
+
*
|
|
1266
|
+
* @public
|
|
1267
|
+
*/
|
|
1268
|
+
export declare type TrackBuilderArgs = z.infer<typeof TrackBuilderArgs_2>;
|
|
1269
|
+
|
|
1270
|
+
declare const TrackBuilderArgs_2: z.ZodMiniObject<{
|
|
1271
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1272
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1273
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1274
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1275
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1276
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1277
|
+
}, z.core.$strip>>;
|
|
1278
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1279
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1280
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1281
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1282
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1283
|
+
}, z.core.$strip>>;
|
|
1284
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1285
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1286
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1287
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1288
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1289
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1290
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1291
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1292
|
+
}, z.core.$strip>>;
|
|
1293
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1294
|
+
path: z.ZodMiniString<string>;
|
|
1295
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1296
|
+
referrer: z.ZodMiniString<string>;
|
|
1297
|
+
search: z.ZodMiniString<string>;
|
|
1298
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1299
|
+
url: z.ZodMiniString<string>;
|
|
1300
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1301
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1302
|
+
name: z.ZodMiniString<string>;
|
|
1303
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1304
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1305
|
+
event: z.ZodMiniString<string>;
|
|
1306
|
+
properties: z.ZodMiniOptional<z.ZodMiniPrefault<z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniJSONSchema>>>;
|
|
1307
|
+
}, z.core.$strip>;
|
|
1308
|
+
|
|
1309
|
+
/**
|
|
1310
|
+
* Arguments for constructing track events.
|
|
1311
|
+
*
|
|
1312
|
+
* @public
|
|
1313
|
+
*/
|
|
1314
|
+
declare type TrackBuilderArgs = z.infer<typeof TrackBuilderArgs_2>;
|
|
1315
|
+
|
|
1316
|
+
/**
|
|
1317
|
+
* Arguments used to construct the universal (shared) portion of all events.
|
|
1318
|
+
*
|
|
1319
|
+
* @public
|
|
1320
|
+
*/
|
|
1321
|
+
export declare type UniversalEventBuilderArgs = z.infer<typeof UniversalEventBuilderArgs_2>;
|
|
1322
|
+
|
|
1323
|
+
declare const UniversalEventBuilderArgs_2: z.ZodMiniObject<{
|
|
1324
|
+
campaign: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1325
|
+
name: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1326
|
+
source: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1327
|
+
medium: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1328
|
+
term: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1329
|
+
content: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1330
|
+
}, z.core.$strip>>;
|
|
1331
|
+
locale: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1332
|
+
location: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1333
|
+
coordinates: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1334
|
+
latitude: z.ZodMiniNumber<number>;
|
|
1335
|
+
longitude: z.ZodMiniNumber<number>;
|
|
1336
|
+
}, z.core.$strip>>;
|
|
1337
|
+
city: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1338
|
+
postalCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1339
|
+
region: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1340
|
+
regionCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1341
|
+
country: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1342
|
+
countryCode: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1343
|
+
continent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1344
|
+
timezone: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1345
|
+
}, z.core.$strip>>;
|
|
1346
|
+
page: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1347
|
+
path: z.ZodMiniString<string>;
|
|
1348
|
+
query: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniString<string>>;
|
|
1349
|
+
referrer: z.ZodMiniString<string>;
|
|
1350
|
+
search: z.ZodMiniString<string>;
|
|
1351
|
+
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1352
|
+
url: z.ZodMiniString<string>;
|
|
1353
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1354
|
+
screen: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
1355
|
+
name: z.ZodMiniString<string>;
|
|
1356
|
+
}, z.core.$catchall<z.ZodMiniJSONSchema>>>;
|
|
1357
|
+
userAgent: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
1358
|
+
}, z.core.$strip>;
|
|
1359
|
+
|
|
1360
|
+
/**
|
|
1361
|
+
* Arguments used to construct the universal (shared) portion of all events.
|
|
1362
|
+
*
|
|
1363
|
+
* @public
|
|
1364
|
+
*/
|
|
1365
|
+
declare type UniversalEventBuilderArgs = z.infer<typeof UniversalEventBuilderArgs_2>;
|
|
1366
|
+
|
|
1367
|
+
/**
|
|
1368
|
+
* Parameters used when updating an existing profile.
|
|
1369
|
+
*/
|
|
1370
|
+
declare interface UpdateProfileParams extends CreateProfileParams {
|
|
1371
|
+
/**
|
|
1372
|
+
* ID of the profile to update.
|
|
1373
|
+
*/
|
|
1374
|
+
profileId: string;
|
|
1375
|
+
}
|
|
1376
|
+
|
|
1377
|
+
/**
|
|
1378
|
+
* Parameters used when creating or updating a profile.
|
|
1379
|
+
*/
|
|
1380
|
+
declare interface UpsertProfileParams extends CreateProfileParams {
|
|
1381
|
+
/**
|
|
1382
|
+
* Optional ID of the profile; when omitted, a new profile is created.
|
|
1383
|
+
*/
|
|
1384
|
+
profileId?: string;
|
|
1385
|
+
}
|
|
1386
|
+
|
|
1387
|
+
|
|
1388
|
+
export * from "@contentful/optimization-api-schemas";
|
|
1389
|
+
|
|
1390
|
+
export { }
|