@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.js
CHANGED
@@ -147,74 +147,183 @@ function computeAggregateDimension(primitiveScores, aggregateDimension, allAggre
|
|
147
147
|
// src/manifest/constants.ts
|
148
148
|
var ENR_SEPARATOR = "_";
|
149
149
|
|
150
|
-
// src/manifest/
|
151
|
-
|
152
|
-
|
153
|
-
if (typeof lhs === "undefined" || lhs === null) {
|
154
|
-
return false;
|
155
|
-
}
|
156
|
-
const lhsValue = Number(lhs);
|
157
|
-
if (isNaN(lhsValue)) {
|
158
|
-
return false;
|
159
|
-
}
|
160
|
-
switch ((_a = match == null ? void 0 : match.op) != null ? _a : "=") {
|
161
|
-
case "=":
|
162
|
-
return lhsValue === match.rhs;
|
163
|
-
case "!=":
|
164
|
-
return lhsValue !== match.rhs;
|
165
|
-
case ">":
|
166
|
-
return lhsValue > match.rhs;
|
167
|
-
case "<":
|
168
|
-
return lhsValue < match.rhs;
|
169
|
-
default:
|
170
|
-
console.warn(`Unknown match type ${match.op} is false.`);
|
171
|
-
return false;
|
172
|
-
}
|
173
|
-
}
|
174
|
-
function explainNumberMatch(lhs, match) {
|
175
|
-
return `${lhs} ${explainNumberMatchCriteria(match)}`;
|
176
|
-
}
|
177
|
-
function explainNumberMatchCriteria(match) {
|
178
|
-
return `${match.op} ${match.rhs}`;
|
179
|
-
}
|
180
|
-
|
181
|
-
// src/manifest/utils/getEnrichmentVectorKey.ts
|
182
|
-
function getEnrichmentVectorKey(category, value) {
|
183
|
-
return `${category}${ENR_SEPARATOR}${value}`;
|
184
|
-
}
|
185
|
-
|
186
|
-
// src/manifest/goals/evaluators/EnrichmentGoalEvaluator.ts
|
187
|
-
var _goal, _id;
|
188
|
-
var EnrichmentGoalEvaluator = class {
|
150
|
+
// src/manifest/goals/evaluators/SignalGoalEvaluator.ts
|
151
|
+
var _signal, _id;
|
152
|
+
var SignalGoalEvaluator = class {
|
189
153
|
constructor(options) {
|
190
|
-
__privateAdd(this,
|
154
|
+
__privateAdd(this, _signal, void 0);
|
191
155
|
__privateAdd(this, _id, void 0);
|
192
|
-
__privateSet(this, _goal, options.goal);
|
193
156
|
__privateSet(this, _id, options.id);
|
157
|
+
__privateSet(this, _signal, options.signal);
|
194
158
|
}
|
195
159
|
get id() {
|
196
160
|
return __privateGet(this, _id);
|
197
161
|
}
|
198
|
-
evaluate({ scores }) {
|
199
|
-
const
|
200
|
-
const
|
201
|
-
|
202
|
-
return {
|
203
|
-
triggered: false
|
204
|
-
};
|
205
|
-
}
|
206
|
-
const isMatch = isNumberMatch(score, {
|
207
|
-
op: __privateGet(this, _goal).op,
|
208
|
-
rhs: __privateGet(this, _goal).score
|
209
|
-
});
|
162
|
+
evaluate({ scores, quirks }) {
|
163
|
+
const score = scores == null ? void 0 : scores[__privateGet(this, _id)];
|
164
|
+
const key = `goal_${__privateGet(this, _id)}_triggered`;
|
165
|
+
const hasGoalTriggered = (quirks == null ? void 0 : quirks[key]) === "1";
|
210
166
|
return {
|
211
|
-
|
167
|
+
key,
|
168
|
+
triggered: typeof score === "number" && !hasGoalTriggered
|
212
169
|
};
|
213
170
|
}
|
214
171
|
};
|
215
|
-
|
172
|
+
_signal = new WeakMap();
|
216
173
|
_id = new WeakMap();
|
217
174
|
|
175
|
+
// src/manifest/signals/SignalInstance.ts
|
176
|
+
var _evaluator, _onLogMessage;
|
177
|
+
var SignalInstance = class {
|
178
|
+
constructor(data, evaluator, onLogMessage) {
|
179
|
+
__privateAdd(this, _evaluator, void 0);
|
180
|
+
__privateAdd(this, _onLogMessage, void 0);
|
181
|
+
__publicField(this, "signal");
|
182
|
+
this.signal = data;
|
183
|
+
__privateSet(this, _evaluator, evaluator);
|
184
|
+
__privateSet(this, _onLogMessage, onLogMessage);
|
185
|
+
}
|
186
|
+
/** Computes storage update commands to take based on a state update and the signal's criteria */
|
187
|
+
computeSignal(update, commands) {
|
188
|
+
const isAtCap = update.scores[this.signal.id] >= this.signal.cap;
|
189
|
+
if (isAtCap && this.signal.dur !== "t") {
|
190
|
+
return;
|
191
|
+
}
|
192
|
+
const criteriaMatchUpdate = __privateGet(this, _evaluator).evaluate(
|
193
|
+
update,
|
194
|
+
this.signal.crit,
|
195
|
+
commands,
|
196
|
+
this.signal,
|
197
|
+
__privateGet(this, _onLogMessage)
|
198
|
+
);
|
199
|
+
const scoreCommand = this.signal.dur === "s" || this.signal.dur === "t" ? "modscoreS" : "modscore";
|
200
|
+
if (!criteriaMatchUpdate.changed) {
|
201
|
+
return;
|
202
|
+
}
|
203
|
+
if (criteriaMatchUpdate.result) {
|
204
|
+
commands.push({
|
205
|
+
type: scoreCommand,
|
206
|
+
data: { dimension: this.signal.id, delta: this.signal.str }
|
207
|
+
});
|
208
|
+
} else if (this.signal.dur === "t") {
|
209
|
+
const sessionScore = update.visitor.sessionScores[this.signal.id];
|
210
|
+
if (sessionScore) {
|
211
|
+
commands.push({
|
212
|
+
type: scoreCommand,
|
213
|
+
data: { dimension: this.signal.id, delta: -sessionScore }
|
214
|
+
});
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
};
|
219
|
+
_evaluator = new WeakMap();
|
220
|
+
_onLogMessage = new WeakMap();
|
221
|
+
|
222
|
+
// src/manifest/utils/control.ts
|
223
|
+
var rollForControlGroup = (value) => {
|
224
|
+
let control = value;
|
225
|
+
if (control >= 1) {
|
226
|
+
control = control / 100;
|
227
|
+
}
|
228
|
+
return Math.random() < control;
|
229
|
+
};
|
230
|
+
|
231
|
+
// src/manifest/ManifestInstance.ts
|
232
|
+
var _mf, _signalInstances, _goalEvaluators, _onLogMessage2;
|
233
|
+
var ManifestInstance = class {
|
234
|
+
constructor({
|
235
|
+
manifest,
|
236
|
+
evaluator = new GroupCriteriaEvaluator({}),
|
237
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
238
|
+
onLogMessage = () => {
|
239
|
+
}
|
240
|
+
}) {
|
241
|
+
__publicField(this, "data");
|
242
|
+
__privateAdd(this, _mf, void 0);
|
243
|
+
__privateAdd(this, _signalInstances, void 0);
|
244
|
+
__privateAdd(this, _goalEvaluators, []);
|
245
|
+
__privateAdd(this, _onLogMessage2, void 0);
|
246
|
+
var _a, _b, _c, _d, _e;
|
247
|
+
__privateSet(this, _mf, (_a = manifest.project) != null ? _a : {});
|
248
|
+
this.data = manifest;
|
249
|
+
__privateSet(this, _signalInstances, Object.entries((_c = (_b = __privateGet(this, _mf).pz) == null ? void 0 : _b.sig) != null ? _c : []).map(
|
250
|
+
([id, signal]) => new SignalInstance({ ...signal, id }, evaluator, onLogMessage)
|
251
|
+
));
|
252
|
+
Object.entries((_e = (_d = __privateGet(this, _mf).pz) == null ? void 0 : _d.sig) != null ? _e : []).forEach(([id, signal]) => {
|
253
|
+
if (signal.conversion) {
|
254
|
+
__privateGet(this, _goalEvaluators).push(new SignalGoalEvaluator({ id, signal }));
|
255
|
+
}
|
256
|
+
});
|
257
|
+
__privateSet(this, _onLogMessage2, onLogMessage);
|
258
|
+
}
|
259
|
+
rollForControlGroup() {
|
260
|
+
var _a;
|
261
|
+
return rollForControlGroup(((_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) || 0);
|
262
|
+
}
|
263
|
+
getTest(name) {
|
264
|
+
var _a;
|
265
|
+
return (_a = __privateGet(this, _mf).test) == null ? void 0 : _a[name];
|
266
|
+
}
|
267
|
+
computeSignals(update) {
|
268
|
+
const commands = [];
|
269
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "GROUP"]);
|
270
|
+
try {
|
271
|
+
__privateGet(this, _signalInstances).forEach((signal) => {
|
272
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "GROUP", signal.signal]);
|
273
|
+
try {
|
274
|
+
signal.computeSignal(update, commands);
|
275
|
+
} finally {
|
276
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "ENDGROUP"]);
|
277
|
+
}
|
278
|
+
});
|
279
|
+
} finally {
|
280
|
+
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "ENDGROUP"]);
|
281
|
+
}
|
282
|
+
return commands;
|
283
|
+
}
|
284
|
+
computeGoals(data) {
|
285
|
+
const commands = [];
|
286
|
+
__privateGet(this, _goalEvaluators).forEach((evaluator) => {
|
287
|
+
const { triggered, key } = evaluator.evaluate(data);
|
288
|
+
if (triggered) {
|
289
|
+
commands.push({
|
290
|
+
type: "setgoal",
|
291
|
+
data: {
|
292
|
+
goal: evaluator.id
|
293
|
+
}
|
294
|
+
});
|
295
|
+
commands.push({
|
296
|
+
type: "setquirk",
|
297
|
+
data: {
|
298
|
+
key,
|
299
|
+
value: "1"
|
300
|
+
}
|
301
|
+
});
|
302
|
+
}
|
303
|
+
});
|
304
|
+
return commands;
|
305
|
+
}
|
306
|
+
/**
|
307
|
+
* Computes aggregated scores based on other dimensions
|
308
|
+
*/
|
309
|
+
computeAggregateDimensions(primitiveScores) {
|
310
|
+
var _a, _b;
|
311
|
+
return computeAggregateDimensions(primitiveScores, (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) != null ? _b : {});
|
312
|
+
}
|
313
|
+
getDimensionByKey(scoreKey) {
|
314
|
+
var _a, _b, _c, _d;
|
315
|
+
const enrichmentIndex = scoreKey.indexOf(ENR_SEPARATOR);
|
316
|
+
if (enrichmentIndex <= 0) {
|
317
|
+
return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.sig) == null ? void 0 : _b[scoreKey];
|
318
|
+
}
|
319
|
+
return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
|
320
|
+
}
|
321
|
+
};
|
322
|
+
_mf = new WeakMap();
|
323
|
+
_signalInstances = new WeakMap();
|
324
|
+
_goalEvaluators = new WeakMap();
|
325
|
+
_onLogMessage2 = new WeakMap();
|
326
|
+
|
218
327
|
// src/manifest/signals/criteria/evaluators/cookieEvaluator.ts
|
219
328
|
var import_lite = require("dequal/lite");
|
220
329
|
|
@@ -332,6 +441,42 @@ var eventEvaluator = ({ update, criteria, onLogMessage }) => {
|
|
332
441
|
return finalResult;
|
333
442
|
};
|
334
443
|
|
444
|
+
// src/manifest/utils/getEnrichmentVectorKey.ts
|
445
|
+
function getEnrichmentVectorKey(category, value) {
|
446
|
+
return `${category}${ENR_SEPARATOR}${value}`;
|
447
|
+
}
|
448
|
+
|
449
|
+
// src/manifest/signals/criteria/util/isNumberMatch.ts
|
450
|
+
function isNumberMatch(lhs, match) {
|
451
|
+
var _a;
|
452
|
+
if (typeof lhs === "undefined" || lhs === null) {
|
453
|
+
return false;
|
454
|
+
}
|
455
|
+
const lhsValue = Number(lhs);
|
456
|
+
if (isNaN(lhsValue)) {
|
457
|
+
return false;
|
458
|
+
}
|
459
|
+
switch ((_a = match == null ? void 0 : match.op) != null ? _a : "=") {
|
460
|
+
case "=":
|
461
|
+
return lhsValue === match.rhs;
|
462
|
+
case "!=":
|
463
|
+
return lhsValue !== match.rhs;
|
464
|
+
case ">":
|
465
|
+
return lhsValue > match.rhs;
|
466
|
+
case "<":
|
467
|
+
return lhsValue < match.rhs;
|
468
|
+
default:
|
469
|
+
console.warn(`Unknown match type ${match.op} is false.`);
|
470
|
+
return false;
|
471
|
+
}
|
472
|
+
}
|
473
|
+
function explainNumberMatch(lhs, match) {
|
474
|
+
return `${lhs} ${explainNumberMatchCriteria(match)}`;
|
475
|
+
}
|
476
|
+
function explainNumberMatchCriteria(match) {
|
477
|
+
return `${match.op} ${match.rhs}`;
|
478
|
+
}
|
479
|
+
|
335
480
|
// src/manifest/signals/criteria/evaluators/pageViewCountEvaluator.ts
|
336
481
|
var pageViewCountDimension = getEnrichmentVectorKey("$pvc", "v");
|
337
482
|
var pageViewCountEvaluator = ({ update, criteria, commands, onLogMessage }) => {
|
@@ -461,241 +606,6 @@ var GroupCriteriaEvaluator = class {
|
|
461
606
|
};
|
462
607
|
_evaluators = new WeakMap();
|
463
608
|
|
464
|
-
// src/manifest/goals/evaluators/QuirkGoalEvaluator.ts
|
465
|
-
var _goal2, _id2;
|
466
|
-
var QuirkGoalEvaluator = class {
|
467
|
-
constructor(options) {
|
468
|
-
__privateAdd(this, _goal2, void 0);
|
469
|
-
__privateAdd(this, _id2, void 0);
|
470
|
-
__privateSet(this, _goal2, options.goal);
|
471
|
-
__privateSet(this, _id2, options.id);
|
472
|
-
}
|
473
|
-
get id() {
|
474
|
-
return __privateGet(this, _id2);
|
475
|
-
}
|
476
|
-
evaluate({ quirks }) {
|
477
|
-
const quirkValue = quirks == null ? void 0 : quirks[__privateGet(this, _goal2).id];
|
478
|
-
if (typeof quirkValue !== "string") {
|
479
|
-
return {
|
480
|
-
triggered: false
|
481
|
-
};
|
482
|
-
}
|
483
|
-
const isMatch = isStringMatch(quirkValue, {
|
484
|
-
op: __privateGet(this, _goal2).op,
|
485
|
-
rhs: __privateGet(this, _goal2).value,
|
486
|
-
cs: __privateGet(this, _goal2).cs
|
487
|
-
});
|
488
|
-
return {
|
489
|
-
triggered: isMatch
|
490
|
-
};
|
491
|
-
}
|
492
|
-
};
|
493
|
-
_goal2 = new WeakMap();
|
494
|
-
_id2 = new WeakMap();
|
495
|
-
|
496
|
-
// src/manifest/goals/evaluators/SignalGoalEvaluator.ts
|
497
|
-
var _goal3, _id3;
|
498
|
-
var SignalGoalEvaluator = class {
|
499
|
-
constructor(options) {
|
500
|
-
__privateAdd(this, _goal3, void 0);
|
501
|
-
__privateAdd(this, _id3, void 0);
|
502
|
-
__privateSet(this, _id3, options.id);
|
503
|
-
__privateSet(this, _goal3, options.goal);
|
504
|
-
}
|
505
|
-
get id() {
|
506
|
-
return __privateGet(this, _id3);
|
507
|
-
}
|
508
|
-
evaluate({ scores }) {
|
509
|
-
const score = scores == null ? void 0 : scores[__privateGet(this, _goal3).id];
|
510
|
-
if (typeof score !== "number") {
|
511
|
-
return {
|
512
|
-
triggered: false
|
513
|
-
};
|
514
|
-
}
|
515
|
-
const isMatch = isNumberMatch(score, {
|
516
|
-
op: __privateGet(this, _goal3).op,
|
517
|
-
rhs: __privateGet(this, _goal3).score
|
518
|
-
});
|
519
|
-
return {
|
520
|
-
triggered: isMatch
|
521
|
-
};
|
522
|
-
}
|
523
|
-
};
|
524
|
-
_goal3 = new WeakMap();
|
525
|
-
_id3 = new WeakMap();
|
526
|
-
|
527
|
-
// src/manifest/goals/evaluators/index.ts
|
528
|
-
var resolveGoalEvaluator = ({ id, goal }) => {
|
529
|
-
let evaluator;
|
530
|
-
if (goal.type === "sig") {
|
531
|
-
evaluator = new SignalGoalEvaluator({
|
532
|
-
id,
|
533
|
-
goal
|
534
|
-
});
|
535
|
-
} else if (goal.type === "enr") {
|
536
|
-
evaluator = new EnrichmentGoalEvaluator({
|
537
|
-
id,
|
538
|
-
goal
|
539
|
-
});
|
540
|
-
} else if (goal.type === "qrk") {
|
541
|
-
evaluator = new QuirkGoalEvaluator({
|
542
|
-
id,
|
543
|
-
goal
|
544
|
-
});
|
545
|
-
}
|
546
|
-
return evaluator;
|
547
|
-
};
|
548
|
-
|
549
|
-
// src/manifest/signals/SignalInstance.ts
|
550
|
-
var _evaluator, _onLogMessage;
|
551
|
-
var SignalInstance = class {
|
552
|
-
constructor(data, evaluator, onLogMessage) {
|
553
|
-
__privateAdd(this, _evaluator, void 0);
|
554
|
-
__privateAdd(this, _onLogMessage, void 0);
|
555
|
-
__publicField(this, "signal");
|
556
|
-
this.signal = data;
|
557
|
-
__privateSet(this, _evaluator, evaluator);
|
558
|
-
__privateSet(this, _onLogMessage, onLogMessage);
|
559
|
-
}
|
560
|
-
/** Computes storage update commands to take based on a state update and the signal's criteria */
|
561
|
-
computeSignal(update, commands) {
|
562
|
-
const isAtCap = update.scores[this.signal.id] >= this.signal.cap;
|
563
|
-
if (isAtCap && this.signal.dur !== "t") {
|
564
|
-
return;
|
565
|
-
}
|
566
|
-
const criteriaMatchUpdate = __privateGet(this, _evaluator).evaluate(
|
567
|
-
update,
|
568
|
-
this.signal.crit,
|
569
|
-
commands,
|
570
|
-
this.signal,
|
571
|
-
__privateGet(this, _onLogMessage)
|
572
|
-
);
|
573
|
-
const scoreCommand = this.signal.dur === "s" || this.signal.dur === "t" ? "modscoreS" : "modscore";
|
574
|
-
if (!criteriaMatchUpdate.changed) {
|
575
|
-
return;
|
576
|
-
}
|
577
|
-
if (criteriaMatchUpdate.result) {
|
578
|
-
commands.push({
|
579
|
-
type: scoreCommand,
|
580
|
-
data: { dimension: this.signal.id, delta: this.signal.str }
|
581
|
-
});
|
582
|
-
} else if (this.signal.dur === "t") {
|
583
|
-
const sessionScore = update.visitor.sessionScores[this.signal.id];
|
584
|
-
if (sessionScore) {
|
585
|
-
commands.push({
|
586
|
-
type: scoreCommand,
|
587
|
-
data: { dimension: this.signal.id, delta: -sessionScore }
|
588
|
-
});
|
589
|
-
}
|
590
|
-
}
|
591
|
-
}
|
592
|
-
};
|
593
|
-
_evaluator = new WeakMap();
|
594
|
-
_onLogMessage = new WeakMap();
|
595
|
-
|
596
|
-
// src/manifest/utils/control.ts
|
597
|
-
var rollForControlGroup = (value) => {
|
598
|
-
let control = value;
|
599
|
-
if (control >= 1) {
|
600
|
-
control = control / 100;
|
601
|
-
}
|
602
|
-
return Math.random() < control;
|
603
|
-
};
|
604
|
-
|
605
|
-
// src/manifest/ManifestInstance.ts
|
606
|
-
var _mf, _signalInstances, _goalEvaluators, _onLogMessage2;
|
607
|
-
var ManifestInstance = class {
|
608
|
-
constructor({
|
609
|
-
manifest,
|
610
|
-
evaluator = new GroupCriteriaEvaluator({}),
|
611
|
-
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
612
|
-
onLogMessage = () => {
|
613
|
-
}
|
614
|
-
}) {
|
615
|
-
__publicField(this, "data");
|
616
|
-
__privateAdd(this, _mf, void 0);
|
617
|
-
__privateAdd(this, _signalInstances, void 0);
|
618
|
-
__privateAdd(this, _goalEvaluators, void 0);
|
619
|
-
__privateAdd(this, _onLogMessage2, void 0);
|
620
|
-
var _a, _b, _c, _d;
|
621
|
-
__privateSet(this, _mf, (_a = manifest.project) != null ? _a : {});
|
622
|
-
this.data = manifest;
|
623
|
-
__privateSet(this, _signalInstances, Object.entries((_c = (_b = __privateGet(this, _mf).pz) == null ? void 0 : _b.sig) != null ? _c : []).map(
|
624
|
-
([id, signal]) => new SignalInstance({ ...signal, id }, evaluator, onLogMessage)
|
625
|
-
));
|
626
|
-
__privateSet(this, _goalEvaluators, Object.entries((_d = __privateGet(this, _mf).goal) != null ? _d : {}).map(([id, goal]) => {
|
627
|
-
const evaluator2 = resolveGoalEvaluator({
|
628
|
-
id,
|
629
|
-
goal
|
630
|
-
});
|
631
|
-
if (!evaluator2) {
|
632
|
-
console.warn(`Unable to resolve goal evaluator for goal ${id}`);
|
633
|
-
}
|
634
|
-
return evaluator2;
|
635
|
-
}).filter((evaluator2) => !!evaluator2));
|
636
|
-
__privateSet(this, _onLogMessage2, onLogMessage);
|
637
|
-
}
|
638
|
-
rollForControlGroup() {
|
639
|
-
var _a;
|
640
|
-
return rollForControlGroup(((_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.control) || 0);
|
641
|
-
}
|
642
|
-
getTest(name) {
|
643
|
-
var _a;
|
644
|
-
return (_a = __privateGet(this, _mf).test) == null ? void 0 : _a[name];
|
645
|
-
}
|
646
|
-
computeSignals(update) {
|
647
|
-
const commands = [];
|
648
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "GROUP"]);
|
649
|
-
try {
|
650
|
-
__privateGet(this, _signalInstances).forEach((signal) => {
|
651
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "GROUP", signal.signal]);
|
652
|
-
try {
|
653
|
-
signal.computeSignal(update, commands);
|
654
|
-
} finally {
|
655
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 201, "ENDGROUP"]);
|
656
|
-
}
|
657
|
-
});
|
658
|
-
} finally {
|
659
|
-
__privateGet(this, _onLogMessage2).call(this, ["debug", 200, "ENDGROUP"]);
|
660
|
-
}
|
661
|
-
return commands;
|
662
|
-
}
|
663
|
-
computeGoals(data) {
|
664
|
-
const commands = [];
|
665
|
-
__privateGet(this, _goalEvaluators).forEach((evaluator) => {
|
666
|
-
const { triggered } = evaluator.evaluate(data);
|
667
|
-
if (triggered) {
|
668
|
-
commands.push({
|
669
|
-
type: "setgoal",
|
670
|
-
data: {
|
671
|
-
goal: evaluator.id
|
672
|
-
}
|
673
|
-
});
|
674
|
-
}
|
675
|
-
});
|
676
|
-
return commands;
|
677
|
-
}
|
678
|
-
/**
|
679
|
-
* Computes aggregated scores based on other dimensions
|
680
|
-
*/
|
681
|
-
computeAggregateDimensions(primitiveScores) {
|
682
|
-
var _a, _b;
|
683
|
-
return computeAggregateDimensions(primitiveScores, (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.agg) != null ? _b : {});
|
684
|
-
}
|
685
|
-
getDimensionByKey(scoreKey) {
|
686
|
-
var _a, _b, _c, _d;
|
687
|
-
const enrichmentIndex = scoreKey.indexOf(ENR_SEPARATOR);
|
688
|
-
if (enrichmentIndex <= 0) {
|
689
|
-
return (_b = (_a = __privateGet(this, _mf).pz) == null ? void 0 : _a.sig) == null ? void 0 : _b[scoreKey];
|
690
|
-
}
|
691
|
-
return (_d = (_c = __privateGet(this, _mf).pz) == null ? void 0 : _c.enr) == null ? void 0 : _d[scoreKey.substring(0, enrichmentIndex)];
|
692
|
-
}
|
693
|
-
};
|
694
|
-
_mf = new WeakMap();
|
695
|
-
_signalInstances = new WeakMap();
|
696
|
-
_goalEvaluators = new WeakMap();
|
697
|
-
_onLogMessage2 = new WeakMap();
|
698
|
-
|
699
609
|
// src/placement/criteria/evaluateVariantMatch.ts
|
700
610
|
function evaluateVariantMatch(variantId, match, vec, onLogMessage) {
|
701
611
|
onLogMessage == null ? void 0 : onLogMessage(["info", 301, "GROUP", { id: variantId, op: match == null ? void 0 : match.op }]);
|
@@ -2671,7 +2581,7 @@ var createInsightsClient = ({ endpoint }) => {
|
|
2671
2581
|
};
|
2672
2582
|
return sendMessage(message);
|
2673
2583
|
},
|
2674
|
-
testResult: (options) => {
|
2584
|
+
testResult: async (options) => {
|
2675
2585
|
const message = {
|
2676
2586
|
action: "test_result",
|
2677
2587
|
version: "1",
|
@@ -2687,6 +2597,9 @@ var createInsightsClient = ({ endpoint }) => {
|
|
2687
2597
|
return sendMessage(message);
|
2688
2598
|
},
|
2689
2599
|
personalizationResult: async (options) => {
|
2600
|
+
if (!options.changed) {
|
2601
|
+
return;
|
2602
|
+
}
|
2690
2603
|
const messages = options.variantIds.map((variant) => {
|
2691
2604
|
const message = {
|
2692
2605
|
action: "personalization_result",
|
@@ -2780,6 +2693,8 @@ var createInsights = ({
|
|
2780
2693
|
const storage = createInsightsStorage();
|
2781
2694
|
let storageData = void 0;
|
2782
2695
|
let pageId = generatePageId();
|
2696
|
+
let previousUrl = void 0;
|
2697
|
+
let receivedPageHit = false;
|
2783
2698
|
return {
|
2784
2699
|
init: () => {
|
2785
2700
|
storageData = storage.get();
|
@@ -2807,6 +2722,12 @@ var createInsights = ({
|
|
2807
2722
|
console.error("Insights not initialized");
|
2808
2723
|
return;
|
2809
2724
|
}
|
2725
|
+
receivedPageHit = true;
|
2726
|
+
if (previousUrl === window.location.href) {
|
2727
|
+
return;
|
2728
|
+
}
|
2729
|
+
previousUrl = window.location.href;
|
2730
|
+
pageId = generatePageId();
|
2810
2731
|
client.pageHit({
|
2811
2732
|
visitorId: storageData.visitorId,
|
2812
2733
|
sessionId: storageData.sessionId,
|
@@ -2824,9 +2745,11 @@ var createInsights = ({
|
|
2824
2745
|
sessionId: storageData.sessionId,
|
2825
2746
|
pageId
|
2826
2747
|
});
|
2827
|
-
pageId = generatePageId();
|
2828
2748
|
},
|
2829
2749
|
personalizationResult: (result) => {
|
2750
|
+
if (!receivedPageHit) {
|
2751
|
+
return;
|
2752
|
+
}
|
2830
2753
|
if (!storageData) {
|
2831
2754
|
console.error("Insights not initialized");
|
2832
2755
|
return;
|