@uniformdev/context 19.79.1-alpha.25 → 19.79.1-alpha.27
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.mts +16 -160
- package/dist/api/api.d.ts +16 -160
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.esm.js +215 -292
- package/dist/index.js +215 -292
- package/dist/index.mjs +215 -292
- package/dist/{types-D4Fs5NVm.d.mts → types-C1eZBD3H.d.mts} +6 -62
- package/dist/{types-D4Fs5NVm.d.ts → types-C1eZBD3H.d.ts} +6 -62
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
@@ -76,74 +76,183 @@ function computeAggregateDimension(primitiveScores, aggregateDimension, allAggre
|
|
76
76
|
// src/manifest/constants.ts
|
77
77
|
var ENR_SEPARATOR = "_";
|
78
78
|
|
79
|
-
// src/manifest/
|
80
|
-
|
81
|
-
|
82
|
-
if (typeof lhs === "undefined" || lhs === null) {
|
83
|
-
return false;
|
84
|
-
}
|
85
|
-
const lhsValue = Number(lhs);
|
86
|
-
if (isNaN(lhsValue)) {
|
87
|
-
return false;
|
88
|
-
}
|
89
|
-
switch ((_a = match == null ? void 0 : match.op) != null ? _a : "=") {
|
90
|
-
case "=":
|
91
|
-
return lhsValue === match.rhs;
|
92
|
-
case "!=":
|
93
|
-
return lhsValue !== match.rhs;
|
94
|
-
case ">":
|
95
|
-
return lhsValue > match.rhs;
|
96
|
-
case "<":
|
97
|
-
return lhsValue < match.rhs;
|
98
|
-
default:
|
99
|
-
console.warn(`Unknown match type ${match.op} is false.`);
|
100
|
-
return false;
|
101
|
-
}
|
102
|
-
}
|
103
|
-
function explainNumberMatch(lhs, match) {
|
104
|
-
return `${lhs} ${explainNumberMatchCriteria(match)}`;
|
105
|
-
}
|
106
|
-
function explainNumberMatchCriteria(match) {
|
107
|
-
return `${match.op} ${match.rhs}`;
|
108
|
-
}
|
109
|
-
|
110
|
-
// src/manifest/utils/getEnrichmentVectorKey.ts
|
111
|
-
function getEnrichmentVectorKey(category, value) {
|
112
|
-
return `${category}${ENR_SEPARATOR}${value}`;
|
113
|
-
}
|
114
|
-
|
115
|
-
// src/manifest/goals/evaluators/EnrichmentGoalEvaluator.ts
|
116
|
-
var _goal, _id;
|
117
|
-
var EnrichmentGoalEvaluator = class {
|
79
|
+
// src/manifest/goals/evaluators/SignalGoalEvaluator.ts
|
80
|
+
var _signal, _id;
|
81
|
+
var SignalGoalEvaluator = class {
|
118
82
|
constructor(options) {
|
119
|
-
__privateAdd(this,
|
83
|
+
__privateAdd(this, _signal, void 0);
|
120
84
|
__privateAdd(this, _id, void 0);
|
121
|
-
__privateSet(this, _goal, options.goal);
|
122
85
|
__privateSet(this, _id, options.id);
|
86
|
+
__privateSet(this, _signal, options.signal);
|
123
87
|
}
|
124
88
|
get id() {
|
125
89
|
return __privateGet(this, _id);
|
126
90
|
}
|
127
|
-
evaluate({ scores }) {
|
128
|
-
const
|
129
|
-
const
|
130
|
-
|
131
|
-
return {
|
132
|
-
triggered: false
|
133
|
-
};
|
134
|
-
}
|
135
|
-
const isMatch = isNumberMatch(score, {
|
136
|
-
op: __privateGet(this, _goal).op,
|
137
|
-
rhs: __privateGet(this, _goal).score
|
138
|
-
});
|
91
|
+
evaluate({ scores, quirks }) {
|
92
|
+
const score = scores == null ? void 0 : scores[__privateGet(this, _id)];
|
93
|
+
const key = `goal_${__privateGet(this, _id)}_triggered`;
|
94
|
+
const hasGoalTriggered = (quirks == null ? void 0 : quirks[key]) === "1";
|
139
95
|
return {
|
140
|
-
|
96
|
+
key,
|
97
|
+
triggered: typeof score === "number" && !hasGoalTriggered
|
141
98
|
};
|
142
99
|
}
|
143
100
|
};
|
144
|
-
|
101
|
+
_signal = new WeakMap();
|
145
102
|
_id = new WeakMap();
|
146
103
|
|
104
|
+
// src/manifest/signals/SignalInstance.ts
|
105
|
+
var _evaluator, _onLogMessage;
|
106
|
+
var SignalInstance = class {
|
107
|
+
constructor(data, evaluator, onLogMessage) {
|
108
|
+
__privateAdd(this, _evaluator, void 0);
|
109
|
+
__privateAdd(this, _onLogMessage, void 0);
|
110
|
+
__publicField(this, "signal");
|
111
|
+
this.signal = data;
|
112
|
+
__privateSet(this, _evaluator, evaluator);
|
113
|
+
__privateSet(this, _onLogMessage, onLogMessage);
|
114
|
+
}
|
115
|
+
/** Computes storage update commands to take based on a state update and the signal's criteria */
|
116
|
+
computeSignal(update, commands) {
|
117
|
+
const isAtCap = update.scores[this.signal.id] >= this.signal.cap;
|
118
|
+
if (isAtCap && this.signal.dur !== "t") {
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
const criteriaMatchUpdate = __privateGet(this, _evaluator).evaluate(
|
122
|
+
update,
|
123
|
+
this.signal.crit,
|
124
|
+
commands,
|
125
|
+
this.signal,
|
126
|
+
__privateGet(this, _onLogMessage)
|
127
|
+
);
|
128
|
+
const scoreCommand = this.signal.dur === "s" || this.signal.dur === "t" ? "modscoreS" : "modscore";
|
129
|
+
if (!criteriaMatchUpdate.changed) {
|
130
|
+
return;
|
131
|
+
}
|
132
|
+
if (criteriaMatchUpdate.result) {
|
133
|
+
commands.push({
|
134
|
+
type: scoreCommand,
|
135
|
+
data: { dimension: this.signal.id, delta: this.signal.str }
|
136
|
+
});
|
137
|
+
} else if (this.signal.dur === "t") {
|
138
|
+
const sessionScore = update.visitor.sessionScores[this.signal.id];
|
139
|
+
if (sessionScore) {
|
140
|
+
commands.push({
|
141
|
+
type: scoreCommand,
|
142
|
+
data: { dimension: this.signal.id, delta: -sessionScore }
|
143
|
+
});
|
144
|
+
}
|
145
|
+
}
|
146
|
+
}
|
147
|
+
};
|
148
|
+
_evaluator = new WeakMap();
|
149
|
+
_onLogMessage = new WeakMap();
|
150
|
+
|
151
|
+
// src/manifest/utils/control.ts
|
152
|
+
var rollForControlGroup = (value) => {
|
153
|
+
let control = value;
|
154
|
+
if (control >= 1) {
|
155
|
+
control = control / 100;
|
156
|
+
}
|
157
|
+
return Math.random() < control;
|
158
|
+
};
|
159
|
+
|
160
|
+
// src/manifest/ManifestInstance.ts
|
161
|
+
var _mf, _signalInstances, _goalEvaluators, _onLogMessage2;
|
162
|
+
var ManifestInstance = class {
|
163
|
+
constructor({
|
164
|
+
manifest,
|
165
|
+
evaluator = new GroupCriteriaEvaluator({}),
|
166
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
167
|
+
onLogMessage = () => {
|
168
|
+
}
|
169
|
+
}) {
|
170
|
+
__publicField(this, "data");
|
171
|
+
__privateAdd(this, _mf, void 0);
|
172
|
+
__privateAdd(this, _signalInstances, void 0);
|
173
|
+
__privateAdd(this, _goalEvaluators, []);
|
174
|
+
__privateAdd(this, _onLogMessage2, void 0);
|
175
|
+
var _a, _b, _c, _d, _e;
|
176
|
+
__privateSet(this, _mf, (_a = manifest.project) != null ? _a : {});
|
177
|
+
this.data = manifest;
|
178
|
+
__privateSet(this, _signalInstances, Object.entries((_c = (_b = __privateGet(this, _mf).pz) == null ? void 0 : _b.sig) != null ? _c : []).map(
|
179
|
+
([id, signal]) => new SignalInstance({ ...signal, id }, evaluator, onLogMessage)
|
180
|
+
));
|
181
|
+
Object.entries((_e = (_d = __privateGet(this, _mf).pz) == null ? void 0 : _d.sig) != null ? _e : []).forEach(([id, signal]) => {
|
182
|
+
if (signal.conversion) {
|
183
|
+
__privateGet(this, _goalEvaluators).push(new SignalGoalEvaluator({ id, signal }));
|
184
|
+
}
|
185
|
+
});
|
186
|
+
__privateSet(this, _onLogMessage2, onLogMessage);
|
187
|
+
}
|
188
|
+
rollForControlGroup() {
|
189
|
+
var _a;
|
190
|
+
return rollForControlGroup(((_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) || 0);
|
191
|
+
}
|
192
|
+
getTest(name) {
|
193
|
+
var _a;
|
194
|
+
return (_a = __privateGet(this, _mf).test) == null ? void 0 : _a[name];
|
195
|
+
}
|
196
|
+
computeSignals(update) {
|
197
|
+
const commands = [];
|
198
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "GROUP"]);
|
199
|
+
try {
|
200
|
+
__privateGet(this, _signalInstances).forEach((signal) => {
|
201
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "GROUP", signal.signal]);
|
202
|
+
try {
|
203
|
+
signal.computeSignal(update, commands);
|
204
|
+
} finally {
|
205
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "ENDGROUP"]);
|
206
|
+
}
|
207
|
+
});
|
208
|
+
} finally {
|
209
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "ENDGROUP"]);
|
210
|
+
}
|
211
|
+
return commands;
|
212
|
+
}
|
213
|
+
computeGoals(data) {
|
214
|
+
const commands = [];
|
215
|
+
__privateGet(this, _goalEvaluators).forEach((evaluator) => {
|
216
|
+
const { triggered, key } = evaluator.evaluate(data);
|
217
|
+
if (triggered) {
|
218
|
+
commands.push({
|
219
|
+
type: "setgoal",
|
220
|
+
data: {
|
221
|
+
goal: evaluator.id
|
222
|
+
}
|
223
|
+
});
|
224
|
+
commands.push({
|
225
|
+
type: "setquirk",
|
226
|
+
data: {
|
227
|
+
key,
|
228
|
+
value: "1"
|
229
|
+
}
|
230
|
+
});
|
231
|
+
}
|
232
|
+
});
|
233
|
+
return commands;
|
234
|
+
}
|
235
|
+
/**
|
236
|
+
* Computes aggregated scores based on other dimensions
|
237
|
+
*/
|
238
|
+
computeAggregateDimensions(primitiveScores) {
|
239
|
+
var _a, _b;
|
240
|
+
return computeAggregateDimensions(primitiveScores, (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) != null ? _b : {});
|
241
|
+
}
|
242
|
+
getDimensionByKey(scoreKey) {
|
243
|
+
var _a, _b, _c, _d;
|
244
|
+
const enrichmentIndex = scoreKey.indexOf(ENR_SEPARATOR);
|
245
|
+
if (enrichmentIndex <= 0) {
|
246
|
+
return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.sig) == null ? void 0 : _b[scoreKey];
|
247
|
+
}
|
248
|
+
return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
|
249
|
+
}
|
250
|
+
};
|
251
|
+
_mf = new WeakMap();
|
252
|
+
_signalInstances = new WeakMap();
|
253
|
+
_goalEvaluators = new WeakMap();
|
254
|
+
_onLogMessage2 = new WeakMap();
|
255
|
+
|
147
256
|
// src/manifest/signals/criteria/evaluators/cookieEvaluator.ts
|
148
257
|
import { dequal } from "dequal/lite";
|
149
258
|
|
@@ -261,6 +370,42 @@ var eventEvaluator = ({ update, criteria, onLogMessage }) => {
|
|
261
370
|
return finalResult;
|
262
371
|
};
|
263
372
|
|
373
|
+
// src/manifest/utils/getEnrichmentVectorKey.ts
|
374
|
+
function getEnrichmentVectorKey(category, value) {
|
375
|
+
return `${category}${ENR_SEPARATOR}${value}`;
|
376
|
+
}
|
377
|
+
|
378
|
+
// src/manifest/signals/criteria/util/isNumberMatch.ts
|
379
|
+
function isNumberMatch(lhs, match) {
|
380
|
+
var _a;
|
381
|
+
if (typeof lhs === "undefined" || lhs === null) {
|
382
|
+
return false;
|
383
|
+
}
|
384
|
+
const lhsValue = Number(lhs);
|
385
|
+
if (isNaN(lhsValue)) {
|
386
|
+
return false;
|
387
|
+
}
|
388
|
+
switch ((_a = match == null ? void 0 : match.op) != null ? _a : "=") {
|
389
|
+
case "=":
|
390
|
+
return lhsValue === match.rhs;
|
391
|
+
case "!=":
|
392
|
+
return lhsValue !== match.rhs;
|
393
|
+
case ">":
|
394
|
+
return lhsValue > match.rhs;
|
395
|
+
case "<":
|
396
|
+
return lhsValue < match.rhs;
|
397
|
+
default:
|
398
|
+
console.warn(`Unknown match type ${match.op} is false.`);
|
399
|
+
return false;
|
400
|
+
}
|
401
|
+
}
|
402
|
+
function explainNumberMatch(lhs, match) {
|
403
|
+
return `${lhs} ${explainNumberMatchCriteria(match)}`;
|
404
|
+
}
|
405
|
+
function explainNumberMatchCriteria(match) {
|
406
|
+
return `${match.op} ${match.rhs}`;
|
407
|
+
}
|
408
|
+
|
264
409
|
// src/manifest/signals/criteria/evaluators/pageViewCountEvaluator.ts
|
265
410
|
var pageViewCountDimension = getEnrichmentVectorKey("$pvc", "v");
|
266
411
|
var pageViewCountEvaluator = ({ update, criteria, commands, onLogMessage }) => {
|
@@ -390,241 +535,6 @@ var GroupCriteriaEvaluator = class {
|
|
390
535
|
};
|
391
536
|
_evaluators = new WeakMap();
|
392
537
|
|
393
|
-
// src/manifest/goals/evaluators/QuirkGoalEvaluator.ts
|
394
|
-
var _goal2, _id2;
|
395
|
-
var QuirkGoalEvaluator = class {
|
396
|
-
constructor(options) {
|
397
|
-
__privateAdd(this, _goal2, void 0);
|
398
|
-
__privateAdd(this, _id2, void 0);
|
399
|
-
__privateSet(this, _goal2, options.goal);
|
400
|
-
__privateSet(this, _id2, options.id);
|
401
|
-
}
|
402
|
-
get id() {
|
403
|
-
return __privateGet(this, _id2);
|
404
|
-
}
|
405
|
-
evaluate({ quirks }) {
|
406
|
-
const quirkValue = quirks == null ? void 0 : quirks[__privateGet(this, _goal2).id];
|
407
|
-
if (typeof quirkValue !== "string") {
|
408
|
-
return {
|
409
|
-
triggered: false
|
410
|
-
};
|
411
|
-
}
|
412
|
-
const isMatch = isStringMatch(quirkValue, {
|
413
|
-
op: __privateGet(this, _goal2).op,
|
414
|
-
rhs: __privateGet(this, _goal2).value,
|
415
|
-
cs: __privateGet(this, _goal2).cs
|
416
|
-
});
|
417
|
-
return {
|
418
|
-
triggered: isMatch
|
419
|
-
};
|
420
|
-
}
|
421
|
-
};
|
422
|
-
_goal2 = new WeakMap();
|
423
|
-
_id2 = new WeakMap();
|
424
|
-
|
425
|
-
// src/manifest/goals/evaluators/SignalGoalEvaluator.ts
|
426
|
-
var _goal3, _id3;
|
427
|
-
var SignalGoalEvaluator = class {
|
428
|
-
constructor(options) {
|
429
|
-
__privateAdd(this, _goal3, void 0);
|
430
|
-
__privateAdd(this, _id3, void 0);
|
431
|
-
__privateSet(this, _id3, options.id);
|
432
|
-
__privateSet(this, _goal3, options.goal);
|
433
|
-
}
|
434
|
-
get id() {
|
435
|
-
return __privateGet(this, _id3);
|
436
|
-
}
|
437
|
-
evaluate({ scores }) {
|
438
|
-
const score = scores == null ? void 0 : scores[__privateGet(this, _goal3).id];
|
439
|
-
if (typeof score !== "number") {
|
440
|
-
return {
|
441
|
-
triggered: false
|
442
|
-
};
|
443
|
-
}
|
444
|
-
const isMatch = isNumberMatch(score, {
|
445
|
-
op: __privateGet(this, _goal3).op,
|
446
|
-
rhs: __privateGet(this, _goal3).score
|
447
|
-
});
|
448
|
-
return {
|
449
|
-
triggered: isMatch
|
450
|
-
};
|
451
|
-
}
|
452
|
-
};
|
453
|
-
_goal3 = new WeakMap();
|
454
|
-
_id3 = new WeakMap();
|
455
|
-
|
456
|
-
// src/manifest/goals/evaluators/index.ts
|
457
|
-
var resolveGoalEvaluator = ({ id, goal }) => {
|
458
|
-
let evaluator;
|
459
|
-
if (goal.type === "sig") {
|
460
|
-
evaluator = new SignalGoalEvaluator({
|
461
|
-
id,
|
462
|
-
goal
|
463
|
-
});
|
464
|
-
} else if (goal.type === "enr") {
|
465
|
-
evaluator = new EnrichmentGoalEvaluator({
|
466
|
-
id,
|
467
|
-
goal
|
468
|
-
});
|
469
|
-
} else if (goal.type === "qrk") {
|
470
|
-
evaluator = new QuirkGoalEvaluator({
|
471
|
-
id,
|
472
|
-
goal
|
473
|
-
});
|
474
|
-
}
|
475
|
-
return evaluator;
|
476
|
-
};
|
477
|
-
|
478
|
-
// src/manifest/signals/SignalInstance.ts
|
479
|
-
var _evaluator, _onLogMessage;
|
480
|
-
var SignalInstance = class {
|
481
|
-
constructor(data, evaluator, onLogMessage) {
|
482
|
-
__privateAdd(this, _evaluator, void 0);
|
483
|
-
__privateAdd(this, _onLogMessage, void 0);
|
484
|
-
__publicField(this, "signal");
|
485
|
-
this.signal = data;
|
486
|
-
__privateSet(this, _evaluator, evaluator);
|
487
|
-
__privateSet(this, _onLogMessage, onLogMessage);
|
488
|
-
}
|
489
|
-
/** Computes storage update commands to take based on a state update and the signal's criteria */
|
490
|
-
computeSignal(update, commands) {
|
491
|
-
const isAtCap = update.scores[this.signal.id] >= this.signal.cap;
|
492
|
-
if (isAtCap && this.signal.dur !== "t") {
|
493
|
-
return;
|
494
|
-
}
|
495
|
-
const criteriaMatchUpdate = __privateGet(this, _evaluator).evaluate(
|
496
|
-
update,
|
497
|
-
this.signal.crit,
|
498
|
-
commands,
|
499
|
-
this.signal,
|
500
|
-
__privateGet(this, _onLogMessage)
|
501
|
-
);
|
502
|
-
const scoreCommand = this.signal.dur === "s" || this.signal.dur === "t" ? "modscoreS" : "modscore";
|
503
|
-
if (!criteriaMatchUpdate.changed) {
|
504
|
-
return;
|
505
|
-
}
|
506
|
-
if (criteriaMatchUpdate.result) {
|
507
|
-
commands.push({
|
508
|
-
type: scoreCommand,
|
509
|
-
data: { dimension: this.signal.id, delta: this.signal.str }
|
510
|
-
});
|
511
|
-
} else if (this.signal.dur === "t") {
|
512
|
-
const sessionScore = update.visitor.sessionScores[this.signal.id];
|
513
|
-
if (sessionScore) {
|
514
|
-
commands.push({
|
515
|
-
type: scoreCommand,
|
516
|
-
data: { dimension: this.signal.id, delta: -sessionScore }
|
517
|
-
});
|
518
|
-
}
|
519
|
-
}
|
520
|
-
}
|
521
|
-
};
|
522
|
-
_evaluator = new WeakMap();
|
523
|
-
_onLogMessage = new WeakMap();
|
524
|
-
|
525
|
-
// src/manifest/utils/control.ts
|
526
|
-
var rollForControlGroup = (value) => {
|
527
|
-
let control = value;
|
528
|
-
if (control >= 1) {
|
529
|
-
control = control / 100;
|
530
|
-
}
|
531
|
-
return Math.random() < control;
|
532
|
-
};
|
533
|
-
|
534
|
-
// src/manifest/ManifestInstance.ts
|
535
|
-
var _mf, _signalInstances, _goalEvaluators, _onLogMessage2;
|
536
|
-
var ManifestInstance = class {
|
537
|
-
constructor({
|
538
|
-
manifest,
|
539
|
-
evaluator = new GroupCriteriaEvaluator({}),
|
540
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
541
|
-
onLogMessage = () => {
|
542
|
-
}
|
543
|
-
}) {
|
544
|
-
__publicField(this, "data");
|
545
|
-
__privateAdd(this, _mf, void 0);
|
546
|
-
__privateAdd(this, _signalInstances, void 0);
|
547
|
-
__privateAdd(this, _goalEvaluators, void 0);
|
548
|
-
__privateAdd(this, _onLogMessage2, void 0);
|
549
|
-
var _a, _b, _c, _d;
|
550
|
-
__privateSet(this, _mf, (_a = manifest.project) != null ? _a : {});
|
551
|
-
this.data = manifest;
|
552
|
-
__privateSet(this, _signalInstances, Object.entries((_c = (_b = __privateGet(this, _mf).pz) == null ? void 0 : _b.sig) != null ? _c : []).map(
|
553
|
-
([id, signal]) => new SignalInstance({ ...signal, id }, evaluator, onLogMessage)
|
554
|
-
));
|
555
|
-
__privateSet(this, _goalEvaluators, Object.entries((_d = __privateGet(this, _mf).goal) != null ? _d : {}).map(([id, goal]) => {
|
556
|
-
const evaluator2 = resolveGoalEvaluator({
|
557
|
-
id,
|
558
|
-
goal
|
559
|
-
});
|
560
|
-
if (!evaluator2) {
|
561
|
-
console.warn(`Unable to resolve goal evaluator for goal ${id}`);
|
562
|
-
}
|
563
|
-
return evaluator2;
|
564
|
-
}).filter((evaluator2) => !!evaluator2));
|
565
|
-
__privateSet(this, _onLogMessage2, onLogMessage);
|
566
|
-
}
|
567
|
-
rollForControlGroup() {
|
568
|
-
var _a;
|
569
|
-
return rollForControlGroup(((_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) || 0);
|
570
|
-
}
|
571
|
-
getTest(name) {
|
572
|
-
var _a;
|
573
|
-
return (_a = __privateGet(this, _mf).test) == null ? void 0 : _a[name];
|
574
|
-
}
|
575
|
-
computeSignals(update) {
|
576
|
-
const commands = [];
|
577
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "GROUP"]);
|
578
|
-
try {
|
579
|
-
__privateGet(this, _signalInstances).forEach((signal) => {
|
580
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "GROUP", signal.signal]);
|
581
|
-
try {
|
582
|
-
signal.computeSignal(update, commands);
|
583
|
-
} finally {
|
584
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "ENDGROUP"]);
|
585
|
-
}
|
586
|
-
});
|
587
|
-
} finally {
|
588
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "ENDGROUP"]);
|
589
|
-
}
|
590
|
-
return commands;
|
591
|
-
}
|
592
|
-
computeGoals(data) {
|
593
|
-
const commands = [];
|
594
|
-
__privateGet(this, _goalEvaluators).forEach((evaluator) => {
|
595
|
-
const { triggered } = evaluator.evaluate(data);
|
596
|
-
if (triggered) {
|
597
|
-
commands.push({
|
598
|
-
type: "setgoal",
|
599
|
-
data: {
|
600
|
-
goal: evaluator.id
|
601
|
-
}
|
602
|
-
});
|
603
|
-
}
|
604
|
-
});
|
605
|
-
return commands;
|
606
|
-
}
|
607
|
-
/**
|
608
|
-
* Computes aggregated scores based on other dimensions
|
609
|
-
*/
|
610
|
-
computeAggregateDimensions(primitiveScores) {
|
611
|
-
var _a, _b;
|
612
|
-
return computeAggregateDimensions(primitiveScores, (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) != null ? _b : {});
|
613
|
-
}
|
614
|
-
getDimensionByKey(scoreKey) {
|
615
|
-
var _a, _b, _c, _d;
|
616
|
-
const enrichmentIndex = scoreKey.indexOf(ENR_SEPARATOR);
|
617
|
-
if (enrichmentIndex <= 0) {
|
618
|
-
return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.sig) == null ? void 0 : _b[scoreKey];
|
619
|
-
}
|
620
|
-
return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
|
621
|
-
}
|
622
|
-
};
|
623
|
-
_mf = new WeakMap();
|
624
|
-
_signalInstances = new WeakMap();
|
625
|
-
_goalEvaluators = new WeakMap();
|
626
|
-
_onLogMessage2 = new WeakMap();
|
627
|
-
|
628
538
|
// src/placement/criteria/evaluateVariantMatch.ts
|
629
539
|
function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
630
540
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variantId, op: match == null ? void 0 : match.op }]);
|
@@ -2600,7 +2510,7 @@ var createInsightsClient = ({ endpoint }) => {
|
|
2600
2510
|
};
|
2601
2511
|
return sendMessage(message);
|
2602
2512
|
},
|
2603
|
-
testResult: (options) => {
|
2513
|
+
testResult: async (options) => {
|
2604
2514
|
const message = {
|
2605
2515
|
action: "test_result",
|
2606
2516
|
version: "1",
|
@@ -2616,6 +2526,9 @@ var createInsightsClient = ({ endpoint }) => {
|
|
2616
2526
|
return sendMessage(message);
|
2617
2527
|
},
|
2618
2528
|
personalizationResult: async (options) => {
|
2529
|
+
if (!options.changed) {
|
2530
|
+
return;
|
2531
|
+
}
|
2619
2532
|
const messages = options.variantIds.map((variant) => {
|
2620
2533
|
const message = {
|
2621
2534
|
action: "personalization_result",
|
@@ -2709,6 +2622,8 @@ var createInsights = ({
|
|
2709
2622
|
const storage = createInsightsStorage();
|
2710
2623
|
let storageData = void 0;
|
2711
2624
|
let pageId = generatePageId();
|
2625
|
+
let previousUrl = void 0;
|
2626
|
+
let receivedPageHit = false;
|
2712
2627
|
return {
|
2713
2628
|
init: () => {
|
2714
2629
|
storageData = storage.get();
|
@@ -2736,6 +2651,12 @@ var createInsights = ({
|
|
2736
2651
|
console.error("Insights not initialized");
|
2737
2652
|
return;
|
2738
2653
|
}
|
2654
|
+
receivedPageHit = true;
|
2655
|
+
if (previousUrl === window.location.href) {
|
2656
|
+
return;
|
2657
|
+
}
|
2658
|
+
previousUrl = window.location.href;
|
2659
|
+
pageId = generatePageId();
|
2739
2660
|
client.pageHit({
|
2740
2661
|
visitorId: storageData.visitorId,
|
2741
2662
|
sessionId: storageData.sessionId,
|
@@ -2753,9 +2674,11 @@ var createInsights = ({
|
|
2753
2674
|
sessionId: storageData.sessionId,
|
2754
2675
|
pageId
|
2755
2676
|
});
|
2756
|
-
pageId = generatePageId();
|
2757
2677
|
},
|
2758
2678
|
personalizationResult: (result) => {
|
2679
|
+
if (!receivedPageHit) {
|
2680
|
+
return;
|
2681
|
+
}
|
2759
2682
|
if (!storageData) {
|
2760
2683
|
console.error("Insights not initialized");
|
2761
2684
|
return;
|
@@ -423,10 +423,6 @@ interface components {
|
|
423
423
|
test?: {
|
424
424
|
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Test"];
|
425
425
|
};
|
426
|
-
/** @description Goal settings */
|
427
|
-
goal?: {
|
428
|
-
[key: string]: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Goal"];
|
429
|
-
};
|
430
426
|
};
|
431
427
|
};
|
432
428
|
PersonalizationManifest: {
|
@@ -519,6 +515,7 @@ interface external {
|
|
519
515
|
*/
|
520
516
|
dur: "s" | "p" | "t";
|
521
517
|
crit: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["RootSignalCriteriaGroup"];
|
518
|
+
conversion?: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["Conversion"];
|
522
519
|
};
|
523
520
|
RootSignalCriteriaGroup: {
|
524
521
|
/**
|
@@ -540,6 +537,10 @@ interface external {
|
|
540
537
|
/** @description The criteria clauses that make up this grouping of criteria */
|
541
538
|
clauses: (external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteriaGroup"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalCriteria"])[];
|
542
539
|
};
|
540
|
+
Conversion: {
|
541
|
+
/** @enum {string} */
|
542
|
+
freq: "O";
|
543
|
+
};
|
543
544
|
SignalCriteriaGroup: {
|
544
545
|
/**
|
545
546
|
* @description Criteria type (Group of other criteria)
|
@@ -687,59 +688,6 @@ interface external {
|
|
687
688
|
/** @description Winning variation ID - if set, the test will not run and this variation is shown to all visitors (the test is closed) */
|
688
689
|
wv?: string;
|
689
690
|
};
|
690
|
-
Goal: external["uniform-context-types.swagger.yml"]["components"]["schemas"]["SignalGoal"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["EnrichmentGoal"] | external["uniform-context-types.swagger.yml"]["components"]["schemas"]["QuirkGoal"];
|
691
|
-
SignalGoal: {
|
692
|
-
/** @enum {string} */
|
693
|
-
type: "sig";
|
694
|
-
id: string;
|
695
|
-
/**
|
696
|
-
* @description The type of match to perform
|
697
|
-
* '=' = exact match
|
698
|
-
* '!=' = not an exact match
|
699
|
-
* '<' = less than match expression
|
700
|
-
* '>' = greater than match expression
|
701
|
-
*
|
702
|
-
* @enum {string}
|
703
|
-
*/
|
704
|
-
op: "=" | "<" | ">" | "!=";
|
705
|
-
score: number;
|
706
|
-
};
|
707
|
-
EnrichmentGoal: {
|
708
|
-
/** @enum {string} */
|
709
|
-
type: "enr";
|
710
|
-
cat: string;
|
711
|
-
value: string;
|
712
|
-
/**
|
713
|
-
* @description The type of match to perform
|
714
|
-
* '=' = exact match
|
715
|
-
* '!=' = not an exact match
|
716
|
-
* '<' = less than match expression
|
717
|
-
* '>' = greater than match expression
|
718
|
-
*
|
719
|
-
* @enum {string}
|
720
|
-
*/
|
721
|
-
op: "=" | "<" | ">" | "!=";
|
722
|
-
score: number;
|
723
|
-
};
|
724
|
-
QuirkGoal: {
|
725
|
-
/** @enum {string} */
|
726
|
-
type: "qrk";
|
727
|
-
id: string;
|
728
|
-
/**
|
729
|
-
* @description The match operator
|
730
|
-
* '=' = exact match
|
731
|
-
* '~' = contains match
|
732
|
-
* '//' = regular expression match
|
733
|
-
*
|
734
|
-
* Any of the above can be prefixed with '!' to invert the match (i.e. != for 'not an exact match')
|
735
|
-
*
|
736
|
-
* @enum {string}
|
737
|
-
*/
|
738
|
-
op: "=" | "~" | "//" | "!=" | "!~" | "!//";
|
739
|
-
/** @description The case sensitivity of the match. Defaults to false if unspecified. */
|
740
|
-
cs?: boolean;
|
741
|
-
value: string;
|
742
|
-
};
|
743
691
|
};
|
744
692
|
};
|
745
693
|
operations: {};
|
@@ -758,10 +706,6 @@ type NumberMatch = SharedTypes['NumberMatch'];
|
|
758
706
|
type TestDefinition = SharedTypes['Test'];
|
759
707
|
type AggregateDimension = SharedTypes['AggregateDimension'];
|
760
708
|
type AggregateDimensionInput = SharedTypes['AggregateDimensionInput'];
|
761
|
-
type Goal = SharedTypes['Goal'];
|
762
|
-
type SignalGoal = SharedTypes['SignalGoal'];
|
763
|
-
type EnrichmentGoal = SharedTypes['EnrichmentGoal'];
|
764
|
-
type QuirkGoal = SharedTypes['QuirkGoal'];
|
765
709
|
|
766
710
|
declare class GroupCriteriaEvaluator {
|
767
711
|
#private;
|
@@ -1260,4 +1204,4 @@ declare global {
|
|
1260
1204
|
}
|
1261
1205
|
}
|
1262
1206
|
|
1263
|
-
export { type
|
1207
|
+
export { type TestOptions as $, type AggregateDimension as A, type MessageFunc as B, type ContextPlugin as C, type DecayFunction as D, type LogMessageSingle as E, type LogMessageGroup as F, ManifestInstance as G, GroupCriteriaEvaluator as H, type CriteriaEvaluatorResult as I, type CriteriaEvaluatorParameters as J, type SignalData as K, type LogDrain as L, type MessageCategory as M, type ManifestV2 as N, type OutputSeverity as O, type PersonalizationEvent as P, type PersonalizationManifest as Q, type Signal as R, type ScoreVector as S, TransitionDataStore as T, type SignalCriteriaGroup as U, type VisitorData as V, type SignalCriteria as W, type EnrichmentCategory as X, type NumberMatch as Y, type TestDefinition as Z, type AggregateDimensionInput as _, type StorageCommands as a, testVariations as a0, type DimensionMatch as a1, type PersonalizeOptions as a2, personalizeVariations as a3, type BehaviorTag as a4, type PersonalizedVariant as a5, type PersonalizedResult as a6, type TestVariant as a7, type TestResult as a8, type StorageCommand as a9, type GoalStateUpdate as aA, type paths as aB, type SetGoalCommand as aa, type ModifyScoreCommand as ab, type ModifySessionScoreCommand as ac, type SetConsentCommand as ad, type SetQuirkCommand as ae, type SetTestCommand as af, type IdentifyCommand as ag, type SetControlGroupCommand as ah, type SetPersonalizeVariantControlCommand as ai, type ServerToClientTransitionState as aj, SERVER_STATE_ID as ak, type TransitionDataStoreEvents as al, type DecayOptions as am, type VisitorDataStoreOptions as an, type VisitorDataStoreEvents as ao, VisitorDataStore as ap, type Quirks as aq, type Tests as ar, type Goals as as, type EnrichmentData as at, type PersonalizeControlVariant as au, type PersonalizeVariants as av, type EventData as aw, emptyVisitorData as ax, type ContextState as ay, type ContextStateUpdate as az, type TransitionDataStoreOptions as b, type CriteriaEvaluator as c, type StringMatch as d, type VariantMatchCriteria as e, type LogMessage as f, type DevToolsEvents as g, CONTEXTUAL_EDITING_TEST_NAME as h, CONTEXTUAL_EDITING_TEST_SELECTED_VARIANT_ID as i, type ContextOptions as j, type TestEvent as k, type ContextEvents as l, type ContextInstance as m, Context as n, type DevToolsUiVersion as o, type DevToolsState as p, type DevToolsActions as q, type DevToolsEvent as r, type DevToolsLogEvent as s, type DevToolsDataEvent as t, type DevToolsHelloEvent as u, type DevToolsUpdateEvent as v, type DevToolsRawCommandsEvent as w, type DevToolsForgetEvent as x, type LogMessages as y, type Severity as z };
|