@ninetailed/experience.js 2.0.0-beta.8 → 2.0.0-beta.9
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/index.esm.js +11 -12
- package/index.umd.js +11 -12
- package/package.json +2 -2
package/index.esm.js
CHANGED
|
@@ -4587,6 +4587,14 @@ const getRandom = text => {
|
|
|
4587
4587
|
const getTrafficRandom = (profile, experience) => getRandom(`traffic-${experience.id}-${profile.id}`);
|
|
4588
4588
|
const getDistributionRandom = (profile, experience) => getRandom(`distribution-${experience.id}-${profile.id}`);
|
|
4589
4589
|
|
|
4590
|
+
const getTrafficAllocation = experience => {
|
|
4591
|
+
if (experience.type === 'nt_personalization') {
|
|
4592
|
+
return 1 - experience.trafficAllocation;
|
|
4593
|
+
}
|
|
4594
|
+
|
|
4595
|
+
return experience.trafficAllocation;
|
|
4596
|
+
};
|
|
4597
|
+
|
|
4590
4598
|
const selectExperience = ({
|
|
4591
4599
|
experiences,
|
|
4592
4600
|
activeExperiments,
|
|
@@ -4598,7 +4606,7 @@ const selectExperience = ({
|
|
|
4598
4606
|
});
|
|
4599
4607
|
const selectedExperience = eglibleExperiences.find(experience => {
|
|
4600
4608
|
const trafficRandom = getTrafficRandom(profile, experience);
|
|
4601
|
-
return experience
|
|
4609
|
+
return getTrafficAllocation(experience) > trafficRandom && (includes(profile.audiences, experience.audience.id) || // if the expriment is active already then it's selectible without further contraints to be fullfilled
|
|
4602
4610
|
find(activeExperiments, {
|
|
4603
4611
|
id: experience.id
|
|
4604
4612
|
}));
|
|
@@ -4615,19 +4623,10 @@ const selectVariant = ({
|
|
|
4615
4623
|
|
|
4616
4624
|
if (!variants.length) {
|
|
4617
4625
|
return null;
|
|
4618
|
-
}
|
|
4619
|
-
|
|
4626
|
+
}
|
|
4620
4627
|
|
|
4621
4628
|
if (experience.type === 'nt_personalization') {
|
|
4622
|
-
|
|
4623
|
-
|
|
4624
|
-
if (1 - experience.trafficAllocation > trafficRandom) {
|
|
4625
|
-
return Object.assign(Object.assign({}, baseline), {
|
|
4626
|
-
hidden: false
|
|
4627
|
-
});
|
|
4628
|
-
} // Personalization Expriences can have only one variant.
|
|
4629
|
-
|
|
4630
|
-
|
|
4629
|
+
// Personalization Expriences can have only one variant.
|
|
4631
4630
|
return variants[0];
|
|
4632
4631
|
}
|
|
4633
4632
|
|
package/index.umd.js
CHANGED
|
@@ -4498,6 +4498,14 @@
|
|
|
4498
4498
|
return getRandom("distribution-".concat(experience.id, "-").concat(profile.id));
|
|
4499
4499
|
};
|
|
4500
4500
|
|
|
4501
|
+
var getTrafficAllocation = function getTrafficAllocation(experience) {
|
|
4502
|
+
if (experience.type === 'nt_personalization') {
|
|
4503
|
+
return 1 - experience.trafficAllocation;
|
|
4504
|
+
}
|
|
4505
|
+
|
|
4506
|
+
return experience.trafficAllocation;
|
|
4507
|
+
};
|
|
4508
|
+
|
|
4501
4509
|
var selectExperience = function selectExperience(_a) {
|
|
4502
4510
|
var experiences = _a.experiences,
|
|
4503
4511
|
activeExperiments = _a.activeExperiments,
|
|
@@ -4508,7 +4516,7 @@
|
|
|
4508
4516
|
});
|
|
4509
4517
|
var selectedExperience = eglibleExperiences.find(function (experience) {
|
|
4510
4518
|
var trafficRandom = getTrafficRandom(profile, experience);
|
|
4511
|
-
return experience
|
|
4519
|
+
return getTrafficAllocation(experience) > trafficRandom && (includes__default["default"](profile.audiences, experience.audience.id) || // if the expriment is active already then it's selectible without further contraints to be fullfilled
|
|
4512
4520
|
find__default["default"](activeExperiments, {
|
|
4513
4521
|
id: experience.id
|
|
4514
4522
|
}));
|
|
@@ -4524,19 +4532,10 @@
|
|
|
4524
4532
|
|
|
4525
4533
|
if (!variants.length) {
|
|
4526
4534
|
return null;
|
|
4527
|
-
}
|
|
4528
|
-
|
|
4535
|
+
}
|
|
4529
4536
|
|
|
4530
4537
|
if (experience.type === 'nt_personalization') {
|
|
4531
|
-
|
|
4532
|
-
|
|
4533
|
-
if (1 - experience.trafficAllocation > trafficRandom) {
|
|
4534
|
-
return __assign(__assign({}, baseline), {
|
|
4535
|
-
hidden: false
|
|
4536
|
-
});
|
|
4537
|
-
} // Personalization Expriences can have only one variant.
|
|
4538
|
-
|
|
4539
|
-
|
|
4538
|
+
// Personalization Expriences can have only one variant.
|
|
4540
4539
|
return variants[0];
|
|
4541
4540
|
}
|
|
4542
4541
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ninetailed/experience.js",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"main": "./index.umd.js",
|
|
5
5
|
"module": "./index.esm.js",
|
|
6
6
|
"typings": "./index.d.ts",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"analytics": "^0.8.0",
|
|
9
|
-
"@ninetailed/experience.js-shared": "2.0.0-beta.
|
|
9
|
+
"@ninetailed/experience.js-shared": "2.0.0-beta.9",
|
|
10
10
|
"uuid": "^8.3.2",
|
|
11
11
|
"ts-toolbelt": "^9.6.0",
|
|
12
12
|
"locale-enum": "^1.1.1",
|