@uniformdev/context 19.79.1-alpha.25 → 19.79.1-alpha.26
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 +213 -292
- package/dist/index.js +213 -292
- package/dist/index.mjs +213 -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.esm.js
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,10 @@ var createInsightsClient = ({ endpoint }) => {
|
|
2600
2510
|
};
|
2601
2511
|
return sendMessage(message);
|
2602
2512
|
},
|
2603
|
-
testResult: (options) => {
|
2513
|
+
testResult: async (options) => {
|
2514
|
+
if (!options.variantAssigned) {
|
2515
|
+
return;
|
2516
|
+
}
|
2604
2517
|
const message = {
|
2605
2518
|
action: "test_result",
|
2606
2519
|
version: "1",
|
@@ -2616,6 +2529,9 @@ var createInsightsClient = ({ endpoint }) => {
|
|
2616
2529
|
return sendMessage(message);
|
2617
2530
|
},
|
2618
2531
|
personalizationResult: async (options) => {
|
2532
|
+
if (!options.changed) {
|
2533
|
+
return;
|
2534
|
+
}
|
2619
2535
|
const messages = options.variantIds.map((variant) => {
|
2620
2536
|
const message = {
|
2621
2537
|
action: "personalization_result",
|
@@ -2709,6 +2625,7 @@ var createInsights = ({
|
|
2709
2625
|
const storage = createInsightsStorage();
|
2710
2626
|
let storageData = void 0;
|
2711
2627
|
let pageId = generatePageId();
|
2628
|
+
let previousUrl = void 0;
|
2712
2629
|
return {
|
2713
2630
|
init: () => {
|
2714
2631
|
storageData = storage.get();
|
@@ -2736,6 +2653,11 @@ var createInsights = ({
|
|
2736
2653
|
console.error("Insights not initialized");
|
2737
2654
|
return;
|
2738
2655
|
}
|
2656
|
+
if (previousUrl === window.location.href) {
|
2657
|
+
return;
|
2658
|
+
}
|
2659
|
+
previousUrl = window.location.href;
|
2660
|
+
pageId = generatePageId();
|
2739
2661
|
client.pageHit({
|
2740
2662
|
visitorId: storageData.visitorId,
|
2741
2663
|
sessionId: storageData.sessionId,
|
@@ -2753,7 +2675,6 @@ var createInsights = ({
|
|
2753
2675
|
sessionId: storageData.sessionId,
|
2754
2676
|
pageId
|
2755
2677
|
});
|
2756
|
-
pageId = generatePageId();
|
2757
2678
|
},
|
2758
2679
|
personalizationResult: (result) => {
|
2759
2680
|
if (!storageData) {
|