@uniformdev/context 12.2.1-alpha.177 → 13.0.1-alpha.132
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/api/api.d.ts +17 -1401
- package/dist/api/api.js +2 -2
- package/dist/api/api.mjs +2 -1
- package/dist/cli/cli.d.ts +14 -1
- package/dist/cli/cli.js +63 -52
- package/dist/cli/cli.mjs +63 -51
- package/dist/contextTypes-572b0d33.d.ts +1534 -0
- package/dist/index.d.ts +58 -23
- package/dist/index.esm.js +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/{types-1ad8439c.d.ts → types-5f88cc63.d.ts} +154 -369
- package/dist/types-c12d92cd.d.ts +772 -0
- package/dist/v2-manifest.swagger-ff2af13e.d.ts +294 -0
- package/package.json +12 -20
- package/dist/chunk-GU2YFM6V.mjs +0 -1
- package/dist/chunk-JKQJOIRC.mjs +0 -2
- package/dist/chunk-KZPEO35A.mjs +0 -1
@@ -1,3 +1,4 @@
|
|
1
|
+
import { c as components, e as external } from './v2-manifest.swagger-ff2af13e';
|
1
2
|
import * as mitt from 'mitt';
|
2
3
|
|
3
4
|
declare type StorageCommand<TID extends string = string, TData = unknown> = {
|
@@ -99,9 +100,12 @@ declare type VisitorData = {
|
|
99
100
|
controlGroup?: boolean;
|
100
101
|
};
|
101
102
|
declare const emptyVisitorData: () => VisitorData;
|
103
|
+
/**
|
104
|
+
* Expresses a 'patch' to the Uniform Context state
|
105
|
+
*/
|
102
106
|
declare type ContextState = {
|
103
107
|
cookies: Record<string, string>;
|
104
|
-
url
|
108
|
+
url?: URL;
|
105
109
|
quirks: Quirks;
|
106
110
|
enrichments: EnrichmentData[];
|
107
111
|
events: EventData[];
|
@@ -188,25 +192,65 @@ declare abstract class TransitionDataStore {
|
|
188
192
|
getClientTransitionState(): ServerToClientTransitionState | undefined;
|
189
193
|
}
|
190
194
|
|
191
|
-
declare type
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
+
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
|
196
|
+
declare type ManifestV2 = components['schemas']['ManifestV2'];
|
197
|
+
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
|
198
|
+
declare type Signal = SharedTypes['Signal'];
|
199
|
+
declare type SignalCriteriaGroup = SharedTypes['SignalCriteriaGroup'];
|
200
|
+
declare type SignalCriteria = SharedTypes['SignalCriteria'];
|
201
|
+
declare type EnrichmentCategory = SharedTypes['EnrichmentCategory'];
|
202
|
+
declare type StringMatch = SharedTypes['StringMatch'];
|
203
|
+
declare type NumberMatch = SharedTypes['NumberMatch'];
|
204
|
+
declare type TestDefinition = SharedTypes['Test'];
|
205
|
+
declare type AggregateDimension = SharedTypes['AggregateDimension'];
|
206
|
+
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
207
|
+
|
208
|
+
/**
|
209
|
+
* The result of evaluating a signal criteria.
|
210
|
+
*/
|
211
|
+
declare type CriteriaEvaluatorResult = {
|
212
|
+
/** Whether the criteria evaluated to true or not */
|
213
|
+
result: boolean;
|
214
|
+
/**
|
215
|
+
* Whether the value of the criteria changed from the previous state
|
216
|
+
* If ALL criteria on a signal have NOT changed, the signal is skipped
|
217
|
+
* and its score is left alone.
|
218
|
+
*/
|
219
|
+
changed: boolean;
|
195
220
|
};
|
196
|
-
declare type
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
221
|
+
declare type CriteriaEvaluatorParameters = {
|
222
|
+
/** The update being made to the Context state */
|
223
|
+
update: ContextStateUpdate;
|
224
|
+
/** Current criteria to evaluate the update against */
|
225
|
+
criteria: SignalCriteria;
|
226
|
+
/**
|
227
|
+
* The storage commands that will be executed by this update.
|
228
|
+
* If the evaluation requires custom commands, push them into this parameter.
|
229
|
+
* NOTE: needing to use this is very rare and should be avoided if possible.
|
230
|
+
*/
|
231
|
+
commands: StorageCommands[];
|
232
|
+
/** The parent signal containing the criteria we are evaluating */
|
233
|
+
signal: SignalData;
|
234
|
+
/** Function to emit log notices to the Context log */
|
235
|
+
onLogMessage?: (message: LogMessage) => void;
|
236
|
+
};
|
237
|
+
declare type SignalData = Signal & {
|
238
|
+
id: string;
|
201
239
|
};
|
202
240
|
/**
|
203
|
-
*
|
204
|
-
*
|
205
|
-
* if it needs to apply score decay. The data store ensures immutability already.
|
206
|
-
*
|
207
|
-
* @returns true if any decay was applied, false otherwise
|
241
|
+
* A type that evaluates a signal criteria type and
|
242
|
+
* decides if it matches the current Context state or not.
|
208
243
|
*/
|
209
|
-
declare type
|
244
|
+
declare type CriteriaEvaluator = ((parameters: CriteriaEvaluatorParameters) => CriteriaEvaluatorResult) & {
|
245
|
+
/** If true the criteria will always execute even if a short-circuit would normally skip it */
|
246
|
+
alwaysExecute?: boolean;
|
247
|
+
};
|
248
|
+
|
249
|
+
declare class GroupCriteriaEvaluator {
|
250
|
+
#private;
|
251
|
+
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
|
252
|
+
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: SignalData, onLogMessage?: (message: LogMessage) => void): CriteriaEvaluatorResult;
|
253
|
+
}
|
210
254
|
|
211
255
|
/** Defines all error codes and their parameter(s) */
|
212
256
|
declare type LogMessages = {
|
@@ -220,12 +264,16 @@ declare type LogMessages = {
|
|
220
264
|
3: MessageFunc<ScoreVector>;
|
221
265
|
/** Context emitted updated quirks */
|
222
266
|
4: MessageFunc<Quirks>;
|
267
|
+
/** Tried to set enrichment category that did not exist */
|
268
|
+
5: MessageFunc<EnrichmentData>;
|
223
269
|
/** Storage received update commands */
|
224
270
|
101: MessageFunc<StorageCommands[]>;
|
225
271
|
/** Storage data was updated */
|
226
272
|
102: MessageFunc<VisitorData>;
|
227
273
|
/** Storage data was deleted bool: fromAllDevices */
|
228
274
|
103: MessageFunc<boolean>;
|
275
|
+
/** Visitor was assigned or removed from control group */
|
276
|
+
104: MessageFunc<boolean>;
|
229
277
|
/** Storage score was truncated to its cap */
|
230
278
|
110: MessageFunc<{
|
231
279
|
dim: string;
|
@@ -236,13 +284,53 @@ declare type LogMessages = {
|
|
236
284
|
120: MessageFunc;
|
237
285
|
/** Server to client transition score data was loaded */
|
238
286
|
130: MessageFunc<ScoreVector>;
|
239
|
-
/**
|
287
|
+
/** Server to client transition data was discarded */
|
288
|
+
131: MessageFunc;
|
289
|
+
/** Decay function executed */
|
290
|
+
140: MessageFunc<string>;
|
291
|
+
/** Signals evaluation beginning */
|
292
|
+
200: MessageFunc;
|
293
|
+
/** Evaluation of a specific signal beginning */
|
294
|
+
201: MessageFunc<SignalData>;
|
295
|
+
/** Evaluation of a group beginning */
|
296
|
+
202: MessageFunc<SignalCriteriaGroup>;
|
297
|
+
203: MessageFunc<{
|
298
|
+
criteria: SignalCriteria;
|
299
|
+
result: CriteriaEvaluatorResult;
|
300
|
+
explanation: string;
|
301
|
+
}>;
|
302
|
+
/** Result of evaluating a criteria group */
|
303
|
+
204: MessageFunc<CriteriaEvaluatorResult>;
|
304
|
+
/** Personalization placement executing */
|
305
|
+
300: MessageFunc<{
|
306
|
+
name: string;
|
307
|
+
take?: number;
|
308
|
+
}>;
|
309
|
+
/** Personalization placement testing variation */
|
310
|
+
301: MessageFunc<{
|
311
|
+
id: string;
|
312
|
+
op?: string;
|
313
|
+
}>;
|
314
|
+
/** Processed a personalization criteria */
|
315
|
+
302: MessageFunc<{
|
316
|
+
matched: boolean;
|
317
|
+
description: string;
|
318
|
+
}>;
|
319
|
+
/** Final result for a personalized variation */
|
320
|
+
303: MessageFunc<boolean>;
|
321
|
+
/** A/B test placement executing */
|
322
|
+
400: MessageFunc<string>;
|
323
|
+
/** A/B Test definition did not exist */
|
240
324
|
401: MessageFunc<string>;
|
241
325
|
/** Previously shown test variant no longer in variant data */
|
242
326
|
402: MessageFunc<{
|
243
|
-
|
244
|
-
|
327
|
+
missingVariant: string;
|
328
|
+
variants: string[];
|
245
329
|
}>;
|
330
|
+
/** Selected a new A/B test variation */
|
331
|
+
403: MessageFunc<string>;
|
332
|
+
/** Displaying A/B test variation */
|
333
|
+
404: MessageFunc<string>;
|
246
334
|
/** gtag was not present on the page to emit events to */
|
247
335
|
700: MessageFunc;
|
248
336
|
/** Enabled gtag event signal redirection */
|
@@ -250,15 +338,41 @@ declare type LogMessages = {
|
|
250
338
|
};
|
251
339
|
|
252
340
|
declare type Severity = 'debug' | 'info' | 'warn' | 'error';
|
341
|
+
declare type MessageCategory = 'context' | 'storage' | 'testing' | 'personalization' | 'gtag' | 'signals';
|
253
342
|
declare type OutputSeverity = Severity | 'none';
|
254
|
-
declare type MessageFunc<TArg = void> = (arg: TArg) => [
|
255
|
-
|
343
|
+
declare type MessageFunc<TArg = void> = (arg: TArg) => [
|
344
|
+
/** Category of the message */
|
345
|
+
MessageCategory,
|
346
|
+
/** Log message text */
|
347
|
+
string,
|
348
|
+
/** Log message */
|
349
|
+
...unknown[]
|
350
|
+
];
|
351
|
+
declare type LogMessage = LogMessageSingle | LogMessageGroup;
|
352
|
+
declare type LogMessageSingle<TID extends keyof LogMessages = keyof LogMessages> = [
|
256
353
|
severity: Severity,
|
257
354
|
id: TID,
|
258
355
|
...args: Parameters<LogMessages[TID]>
|
259
356
|
];
|
357
|
+
declare type LogMessageGroup<TID extends keyof LogMessages = keyof LogMessages> = [severity: Severity, id: TID, group: 'GROUP', ...args: Parameters<LogMessages[TID]>] | [severity: Severity, id: TID, group: 'ENDGROUP'];
|
260
358
|
declare type LogDrain = (message: LogMessage) => void;
|
261
359
|
|
360
|
+
declare type DecayOptions = {
|
361
|
+
now: number;
|
362
|
+
lastUpd: number | undefined;
|
363
|
+
scores: ScoreVector;
|
364
|
+
sessionScores: ScoreVector;
|
365
|
+
onLogMessage?: (message: LogMessage) => void;
|
366
|
+
};
|
367
|
+
/**
|
368
|
+
* Computes decay of visitor scores over time.
|
369
|
+
* NOTE: it is expected that this function mutates the incoming score vectors,
|
370
|
+
* if it needs to apply score decay. The data store ensures immutability already.
|
371
|
+
*
|
372
|
+
* @returns true if any decay was applied, false otherwise
|
373
|
+
*/
|
374
|
+
declare type DecayFunction = (options: DecayOptions) => boolean;
|
375
|
+
|
262
376
|
declare type VisitorDataStoreOptions = {
|
263
377
|
/** Transition storage used to transfer server or edge side execution state to the client. Unused for client side only. */
|
264
378
|
transitionStore?: TransitionDataStore;
|
@@ -344,9 +458,10 @@ declare class VisitorDataStore {
|
|
344
458
|
declare class ManifestInstance {
|
345
459
|
#private;
|
346
460
|
readonly data: ManifestV2;
|
347
|
-
constructor({ manifest, evaluator, }: {
|
461
|
+
constructor({ manifest, evaluator, onLogMessage, }: {
|
348
462
|
manifest: ManifestV2;
|
349
463
|
evaluator?: GroupCriteriaEvaluator;
|
464
|
+
onLogMessage?: (message: LogMessage) => void;
|
350
465
|
});
|
351
466
|
rollForControlGroup(): boolean;
|
352
467
|
getTest(name: string): TestDefinition | undefined;
|
@@ -358,316 +473,6 @@ declare class ManifestInstance {
|
|
358
473
|
getDimensionByKey(scoreKey: string): EnrichmentCategory | Signal | undefined;
|
359
474
|
}
|
360
475
|
|
361
|
-
/**
|
362
|
-
* This file was auto-generated by openapi-typescript.
|
363
|
-
* Do not make direct changes to the file.
|
364
|
-
*/
|
365
|
-
interface paths {
|
366
|
-
"/api/v2/manifest": {
|
367
|
-
/**
|
368
|
-
* Fetches the Intent Manifest for a given project.
|
369
|
-
* If no manifest has ever been published, and an API key is used that has preview manifest permissions then the current preview manifest will be returned (in delivery format).
|
370
|
-
*/
|
371
|
-
get: {
|
372
|
-
parameters: {
|
373
|
-
query: {
|
374
|
-
preview?: boolean;
|
375
|
-
projectId: string;
|
376
|
-
};
|
377
|
-
};
|
378
|
-
responses: {
|
379
|
-
/** OK */
|
380
|
-
200: {
|
381
|
-
content: {
|
382
|
-
"application/json": components["schemas"]["ManifestV2"];
|
383
|
-
};
|
384
|
-
};
|
385
|
-
400: external["swagger.yml"]["components"]["responses"]["BadRequestError"];
|
386
|
-
401: external["swagger.yml"]["components"]["responses"]["UnauthorizedError"];
|
387
|
-
403: external["swagger.yml"]["components"]["responses"]["ForbiddenError"];
|
388
|
-
/** No manifest has ever been published, and the API key does not have preview permissions */
|
389
|
-
404: {
|
390
|
-
content: {
|
391
|
-
"text/plain": string;
|
392
|
-
};
|
393
|
-
};
|
394
|
-
429: external["swagger.yml"]["components"]["responses"]["RateLimitError"];
|
395
|
-
500: external["swagger.yml"]["components"]["responses"]["InternalServerError"];
|
396
|
-
};
|
397
|
-
};
|
398
|
-
};
|
399
|
-
}
|
400
|
-
interface components {
|
401
|
-
schemas: {
|
402
|
-
ManifestV2: {
|
403
|
-
project: {
|
404
|
-
pz?: components["schemas"]["PersonalizationManifest"];
|
405
|
-
/** @description A/B test settings */
|
406
|
-
test?: {
|
407
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Test"];
|
408
|
-
};
|
409
|
-
};
|
410
|
-
};
|
411
|
-
PersonalizationManifest: {
|
412
|
-
/** @description Map of all signals defined for personalization criteria */
|
413
|
-
sig?: {
|
414
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Signal"];
|
415
|
-
};
|
416
|
-
/** @description Map of all enrichment categories defined for personalization criteria */
|
417
|
-
enr?: {
|
418
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["EnrichmentCategory"];
|
419
|
-
};
|
420
|
-
/** @description Map of all aggregate dimensions (intents or audiences) defined for personalization criteria */
|
421
|
-
agg?: {
|
422
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["AggregateDimension"];
|
423
|
-
};
|
424
|
-
/** @description Percentage of visitors that will be used as a personalization control group (not shown any personalization) */
|
425
|
-
control?: number;
|
426
|
-
};
|
427
|
-
};
|
428
|
-
}
|
429
|
-
interface external {
|
430
|
-
"swagger.yml": {
|
431
|
-
paths: {};
|
432
|
-
components: {
|
433
|
-
schemas: {
|
434
|
-
Error: {
|
435
|
-
/** @description Error message(s) that occurred while processing the request */
|
436
|
-
errorMessage?: string[] | string;
|
437
|
-
};
|
438
|
-
};
|
439
|
-
responses: {
|
440
|
-
/** Request input validation failed */
|
441
|
-
BadRequestError: {
|
442
|
-
content: {
|
443
|
-
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
444
|
-
};
|
445
|
-
};
|
446
|
-
/** API key or token was not valid */
|
447
|
-
UnauthorizedError: {
|
448
|
-
content: {
|
449
|
-
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
450
|
-
};
|
451
|
-
};
|
452
|
-
/** Permission was denied */
|
453
|
-
ForbiddenError: {
|
454
|
-
content: {
|
455
|
-
"application/json": external["swagger.yml"]["components"]["schemas"]["Error"];
|
456
|
-
};
|
457
|
-
};
|
458
|
-
/** Too many requests in allowed time period */
|
459
|
-
RateLimitError: unknown;
|
460
|
-
/** Execution error occurred */
|
461
|
-
InternalServerError: unknown;
|
462
|
-
};
|
463
|
-
};
|
464
|
-
operations: {};
|
465
|
-
};
|
466
|
-
"uniform-context-types.swagger.yml": {
|
467
|
-
paths: {};
|
468
|
-
components: {
|
469
|
-
schemas: {
|
470
|
-
EnrichmentCategory: {
|
471
|
-
/** @description The maximum visitor score allowed for enrichment keys in this category */
|
472
|
-
cap: number;
|
473
|
-
};
|
474
|
-
PreviewSignal: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Signal"] & {
|
475
|
-
/** @description Friendly name of the signal */
|
476
|
-
name: string;
|
477
|
-
/** @description Description of the signal */
|
478
|
-
description?: string;
|
479
|
-
};
|
480
|
-
Signal: {
|
481
|
-
/** @description The signal strength per activation (each time its criteria are true, this score is added) */
|
482
|
-
str: number;
|
483
|
-
/** @description The maximum visitor score allowed for this signal */
|
484
|
-
cap: number;
|
485
|
-
/**
|
486
|
-
* @description How long the signal's score should persist
|
487
|
-
* 's' = current session (expires after a period of inactivity)
|
488
|
-
* 'p' = permanent (expires as far in the future as possible, may be limited by browser security settings)
|
489
|
-
* 't' = transient (score tracks the current state of the criteria every time scores are updated)
|
490
|
-
*/
|
491
|
-
dur: "s" | "p" | "t";
|
492
|
-
crit: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["RootSignalCriteriaGroup"];
|
493
|
-
};
|
494
|
-
RootSignalCriteriaGroup: {
|
495
|
-
/** @description Criteria type (Group of other criteria) */
|
496
|
-
type: "G";
|
497
|
-
/**
|
498
|
-
* @description The logical operator to apply to the criteria groups
|
499
|
-
* & = AND
|
500
|
-
* | = OR
|
501
|
-
*
|
502
|
-
* Default is `&` if unspecified.
|
503
|
-
*
|
504
|
-
* @default &
|
505
|
-
*/
|
506
|
-
op?: "&" | "|";
|
507
|
-
/** @description The criteria clauses that make up this grouping of criteria */
|
508
|
-
clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
|
509
|
-
};
|
510
|
-
SignalCriteriaGroup: {
|
511
|
-
/** @description Criteria type (Group of other criteria) */
|
512
|
-
type: "G";
|
513
|
-
/**
|
514
|
-
* @description The logical operator to apply to the criteria groups
|
515
|
-
* & = AND
|
516
|
-
* | = OR
|
517
|
-
*
|
518
|
-
* Default is `&` if unspecified.
|
519
|
-
*/
|
520
|
-
op?: "&" | "|";
|
521
|
-
/** @description The criteria clauses that make up this grouping of criteria */
|
522
|
-
clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
|
523
|
-
};
|
524
|
-
SignalCriteria: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["CookieCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["QueryStringCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["QuirkCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["EventCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["CurrentPageCriteria"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["PageViewCountCriteria"];
|
525
|
-
/** @description Matches a URL query string parameter value */
|
526
|
-
QueryStringCriteria: {
|
527
|
-
type: "QS";
|
528
|
-
/** @description The name of the query string parameter to match */
|
529
|
-
queryName: string;
|
530
|
-
/** @description The value to match the query string parameter against */
|
531
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
532
|
-
};
|
533
|
-
/** @description Matches a web cookie value */
|
534
|
-
CookieCriteria: {
|
535
|
-
type: "CK";
|
536
|
-
/** @description The name of the cookie to match */
|
537
|
-
cookieName: string;
|
538
|
-
/** @description The value to match the cookie against */
|
539
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
540
|
-
};
|
541
|
-
/** @description Matches a visitor quirk key and value */
|
542
|
-
QuirkCriteria: {
|
543
|
-
type: "QK";
|
544
|
-
/** @description The name of the quirk key to match */
|
545
|
-
key: string;
|
546
|
-
/** @description The quirk value to match against */
|
547
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
548
|
-
};
|
549
|
-
/** @description Matches an analytics event name being fired */
|
550
|
-
EventCriteria: {
|
551
|
-
type: "EVT";
|
552
|
-
/** @description How to match the event name */
|
553
|
-
event: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
554
|
-
};
|
555
|
-
/**
|
556
|
-
* @description Matches the current page's absolute path (i.e. /path/to/page.html)
|
557
|
-
* Does not include the query string or protocol and hostname (i.e. NOT https://foo.com/path/to/page.html?query=something)
|
558
|
-
*/
|
559
|
-
CurrentPageCriteria: {
|
560
|
-
type: "PV";
|
561
|
-
/** @description The page/route path to match as a page that has been visited */
|
562
|
-
path: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["StringMatch"];
|
563
|
-
};
|
564
|
-
PageViewCountCriteria: {
|
565
|
-
type: "PVC";
|
566
|
-
/** @description The expression to match the page view count against */
|
567
|
-
match: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["NumberMatch"];
|
568
|
-
};
|
569
|
-
/** @description Describes a match expression on a string */
|
570
|
-
StringMatch: {
|
571
|
-
/** @description The right hand side of the match expression */
|
572
|
-
rhs: string;
|
573
|
-
/**
|
574
|
-
* @description The match operator
|
575
|
-
* '=' = exact match
|
576
|
-
* '~' = contains match
|
577
|
-
* '//' = regular expression match
|
578
|
-
*
|
579
|
-
* Any of the above can be prefixed with '!' to invert the match (i.e. != for 'not an exact match')
|
580
|
-
*/
|
581
|
-
op: "=" | "~" | "//" | "!=" | "!~" | "!//";
|
582
|
-
/** @description The case sensitivity of the match. Defaults to false if unspecified. */
|
583
|
-
cs?: boolean;
|
584
|
-
} | {
|
585
|
-
/**
|
586
|
-
* @description The type of match to perform
|
587
|
-
* '*' = exists with any value
|
588
|
-
* '!*' = does not exist
|
589
|
-
*/
|
590
|
-
op: "*" | "!*";
|
591
|
-
};
|
592
|
-
/** @description Describes a match expression on a number */
|
593
|
-
NumberMatch: {
|
594
|
-
/** @description The right hand side of the match expression */
|
595
|
-
rhs: number;
|
596
|
-
/**
|
597
|
-
* @description The type of match to perform
|
598
|
-
* '=' = exact match
|
599
|
-
* '!=' = not an exact match
|
600
|
-
* '<' = less than match expression
|
601
|
-
* '>' = greater than match expression
|
602
|
-
*/
|
603
|
-
op: "=" | "<" | ">" | "!=";
|
604
|
-
};
|
605
|
-
/** @description Defines an aggregate dimension that is a grouping of other dimensions' scores; an intent or audience. */
|
606
|
-
AggregateDimension: {
|
607
|
-
/** @description Input dimensions to the aggregate dimension */
|
608
|
-
inputs: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["AggregateDimensionInput"][];
|
609
|
-
};
|
610
|
-
/** @description Defines an input dimension to an aggregate dimension */
|
611
|
-
AggregateDimensionInput: {
|
612
|
-
/**
|
613
|
-
* @description Dimension name to reference as an input.
|
614
|
-
* For enrichment inputs, use CATEGORY_KEY as the dimension.
|
615
|
-
* Enrichments, signals, and other aggregate dimensions may be referenced.
|
616
|
-
*
|
617
|
-
* Note that creating a cycle of aggregate dimensions is allowed, however
|
618
|
-
* the final score will _ignore_ the cycled aggregate dimension in the result.
|
619
|
-
* This can be used to create mutually exclusive aggregates.
|
620
|
-
*/
|
621
|
-
dim: string;
|
622
|
-
/**
|
623
|
-
* @description The sign of the input dimension controls how it affects the aggregate dimension's final score.
|
624
|
-
*
|
625
|
-
* '+' = add to the final score
|
626
|
-
* '-' = subtract from the final score
|
627
|
-
* 'c' = clear the final score (if the input dimension has any score at all, this aggreate will have no score regardless of other inputs)
|
628
|
-
*
|
629
|
-
* Default if unspecified: '+'
|
630
|
-
*
|
631
|
-
* @default +
|
632
|
-
*/
|
633
|
-
sign?: "+" | "-" | "c";
|
634
|
-
};
|
635
|
-
Test: {
|
636
|
-
/** @description Winning variation ID - if set, the test will not run and this variation is shown to all visitors (the test is closed) */
|
637
|
-
wv?: string;
|
638
|
-
};
|
639
|
-
};
|
640
|
-
};
|
641
|
-
operations: {};
|
642
|
-
};
|
643
|
-
}
|
644
|
-
|
645
|
-
declare type SharedTypes = external['uniform-context-types.swagger.yml']['components']['schemas'];
|
646
|
-
declare type ManifestV2 = components['schemas']['ManifestV2'];
|
647
|
-
declare type PersonalizationManifest = components['schemas']['PersonalizationManifest'];
|
648
|
-
declare type Signal = SharedTypes['Signal'];
|
649
|
-
declare type SignalCriteriaGroup = SharedTypes['SignalCriteriaGroup'];
|
650
|
-
declare type SignalCriteria = SharedTypes['SignalCriteria'];
|
651
|
-
declare type EnrichmentCategory = SharedTypes['EnrichmentCategory'];
|
652
|
-
declare type StringMatch = SharedTypes['StringMatch'];
|
653
|
-
declare type NumberMatch = SharedTypes['NumberMatch'];
|
654
|
-
declare type TestDefinition = SharedTypes['Test'];
|
655
|
-
declare type AggregateDimension = SharedTypes['AggregateDimension'];
|
656
|
-
declare type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
657
|
-
|
658
|
-
/**
|
659
|
-
* A type that evaluates a signal criteria type and
|
660
|
-
* decides if it matches the current Context state or not.
|
661
|
-
* @returns {boolean} - true for a match, false for no match
|
662
|
-
* */
|
663
|
-
declare type CriteriaEvaluator = (update: ContextStateUpdate, criteria: SignalCriteria, commands: StorageCommands[], signal: Signal, dimension: string) => boolean;
|
664
|
-
|
665
|
-
declare class GroupCriteriaEvaluator {
|
666
|
-
#private;
|
667
|
-
constructor(criteriaEvaluators: Record<string, CriteriaEvaluator>);
|
668
|
-
evaluate(update: ContextStateUpdate, crit: SignalCriteriaGroup, commands: StorageCommands[], signal: Signal, dimension: string): boolean;
|
669
|
-
}
|
670
|
-
|
671
476
|
/** Content that is tagged for adding enrichment score when triggered by behavior (i.e. being shown that content) */
|
672
477
|
declare type BehaviorTag = {
|
673
478
|
beh?: EnrichmentData[];
|
@@ -707,39 +512,6 @@ declare type TestResult<TVariant> = {
|
|
707
512
|
*/
|
708
513
|
variantAssigned: boolean;
|
709
514
|
};
|
710
|
-
/** Defines the shape of arbitrarily tagged content where the tag can be for a test, behaviour, or personalization */
|
711
|
-
declare type TaggedContent = PersonalizedVariant & TestVariant & BehaviorTag & {
|
712
|
-
/** @deprecated no longer used */
|
713
|
-
intents?: IntentTagVector;
|
714
|
-
};
|
715
|
-
/**
|
716
|
-
* A vector keyed by intent ID which contains magnitude and configuration data for each intent ID that has been tagged
|
717
|
-
* @deprecated no longer used
|
718
|
-
*/
|
719
|
-
declare type IntentTagVector = Record<string, IntentTagAxis>;
|
720
|
-
/**
|
721
|
-
* An individual intent tag magnitude value in an IntentTagVector
|
722
|
-
* @deprecated no longer used
|
723
|
-
*/
|
724
|
-
interface IntentTagAxis {
|
725
|
-
/** If this is true, don't use this intent tag when calculating personalization. If false or unspecified, personalization is allowed. */
|
726
|
-
noPn?: boolean;
|
727
|
-
/** If this is true, don't use this intent tag when calculating behavior. If false or unspecified, behavior is allowed. */
|
728
|
-
noBeh?: boolean;
|
729
|
-
/**
|
730
|
-
* If this is true, ANY strength in the tagged intent will result in selecting this variant to personalize,
|
731
|
-
* regardless of other intents' strengths. If more than one tag is override,
|
732
|
-
* they are sorted normally.
|
733
|
-
*/
|
734
|
-
override?: boolean;
|
735
|
-
/**
|
736
|
-
* Sets the minimum visitor score required to trigger this variation.
|
737
|
-
* If more than one intent tag matches, the one with the highest threshold will win.
|
738
|
-
*/
|
739
|
-
threshold?: number;
|
740
|
-
/** Strength of the intent tag. If unspecified, IntentTagStrength.Normal should be inferred */
|
741
|
-
str?: number | string;
|
742
|
-
}
|
743
515
|
|
744
516
|
declare type PersonalizeOptions<TVariant> = {
|
745
517
|
/** Name of placement (sent to analytics) */
|
@@ -748,8 +520,9 @@ declare type PersonalizeOptions<TVariant> = {
|
|
748
520
|
variations: Iterable<TVariant>;
|
749
521
|
/** Maximum number of variants to place (default: 1) */
|
750
522
|
take?: number;
|
523
|
+
onLogMessage?: (message: LogMessage) => void;
|
751
524
|
};
|
752
|
-
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ context, variations, take, }: PersonalizeOptions<TVariant> & {
|
525
|
+
declare function personalizeVariations<TVariant extends PersonalizedVariant>({ name, context, variations, take, onLogMessage, }: PersonalizeOptions<TVariant> & {
|
753
526
|
context: Context;
|
754
527
|
}): PersonalizedResult<TVariant>;
|
755
528
|
|
@@ -806,8 +579,9 @@ declare type TestOptions<TVariant extends TestVariant> = {
|
|
806
579
|
/** Variations that are being tested. */
|
807
580
|
variations: TVariant[];
|
808
581
|
};
|
809
|
-
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, }: TestOptions<TVariant> & {
|
582
|
+
declare const testVariations: <TVariant extends TestVariant>({ name, context, variations, onLogMessage, }: TestOptions<TVariant> & {
|
810
583
|
context: Context;
|
584
|
+
onLogMessage?: ((message: LogMessage) => void) | undefined;
|
811
585
|
}) => TestResult<TVariant>;
|
812
586
|
|
813
587
|
/**
|
@@ -876,7 +650,7 @@ declare type ContextEvents = {
|
|
876
650
|
* Note that event handlers attached to this event will not catch events
|
877
651
|
* logged during initialisation of the Context unless they are attached as plugins to the constructor.
|
878
652
|
*/
|
879
|
-
log: LogMessage;
|
653
|
+
log: LogMessage | LogMessageGroup;
|
880
654
|
/** Test variant has been selected */
|
881
655
|
testResult: TestEvent;
|
882
656
|
/** Personalization variants have been selected */
|
@@ -901,8 +675,19 @@ declare class Context implements Context {
|
|
901
675
|
};
|
902
676
|
};
|
903
677
|
readonly storage: VisitorDataStore;
|
678
|
+
/**
|
679
|
+
* Updates the Context with new data of any sort, such as
|
680
|
+
* new URLs, cookies, quirks, and enrichments.
|
681
|
+
*
|
682
|
+
* Only properties that are set in the data parameter will be updated.
|
683
|
+
* Properties that do not result in a changed state,
|
684
|
+
* i.e. pushing the same URL or cookies as before,
|
685
|
+
* will NOT result in a recomputation of signal state.
|
686
|
+
*/
|
904
687
|
update(newData: Partial<ContextState>): Promise<void>;
|
688
|
+
/** use test() instead */
|
905
689
|
getTestVariantId(testName: string): string | null | undefined;
|
690
|
+
/** use test() instead */
|
906
691
|
setTestVariantId(testName: string, variantId: string): void;
|
907
692
|
/**
|
908
693
|
* Writes a message to the Context log sink.
|
@@ -984,4 +769,4 @@ declare global {
|
|
984
769
|
}
|
985
770
|
}
|
986
771
|
|
987
|
-
export {
|
772
|
+
export { ContextEvents as $, AggregateDimension as A, SetTestCommand as B, ContextPlugin as C, DecayFunction as D, EnrichmentCategory as E, SetControlGroupCommand as F, GroupCriteriaEvaluator as G, DecayOptions as H, IdentifyCommand as I, VisitorDataStoreOptions as J, VisitorDataStoreEvents as K, LogDrain as L, ManifestInstance as M, NumberMatch as N, OutputSeverity as O, PersonalizationManifest as P, Quirks as Q, VisitorDataStore as R, StorageCommands as S, TransitionDataStore as T, ServerToClientTransitionState as U, VisitorData as V, SERVER_STATE_ID as W, TransitionDataStoreEvents as X, ContextOptions as Y, PersonalizationEvent as Z, TestEvent as _, TransitionDataStoreOptions as a, Context as a0, LogMessages as a1, Severity as a2, MessageCategory as a3, MessageFunc as a4, LogMessageSingle as a5, LogMessageGroup as a6, testVariations as a7, TestOptions as a8, PersonalizeOptions as a9, personalizeVariations as aa, DimensionMatch as ab, BehaviorTag as ac, PersonalizedVariant as ad, PersonalizedResult as ae, TestVariant as af, TestResult as ag, DevToolsUiVersion as ah, DevToolsState as ai, DevToolsActions as aj, DevToolsEvent as ak, DevToolsEvents as al, DevToolsLogEvent as am, DevToolsDataEvent as an, DevToolsHelloEvent as ao, DevToolsUpdateEvent as ap, DevToolsRawCommandsEvent as aq, DevToolsForgetEvent as ar, CriteriaEvaluator as b, StringMatch as c, ScoreVector as d, VariantMatchCriteria as e, LogMessage as f, ManifestV2 as g, Signal as h, SignalCriteriaGroup as i, SignalCriteria as j, TestDefinition as k, AggregateDimensionInput as l, CriteriaEvaluatorResult as m, CriteriaEvaluatorParameters as n, SignalData as o, Tests as p, EnrichmentData as q, EventData as r, emptyVisitorData as s, ContextState as t, ContextStateUpdate as u, StorageCommand as v, ModifyScoreCommand as w, ModifySessionScoreCommand as x, SetConsentCommand as y, SetQuirkCommand as z };
|