@ninetailed/experience.js 2.0.0-beta.12 → 2.0.0-beta.14

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 CHANGED
@@ -3890,10 +3890,16 @@ const selectExperience = ({
3890
3890
  const selectedExperience = eglibleExperiences.find(experience => {
3891
3891
  const trafficRandom = getTrafficRandom(profile, experience);
3892
3892
  log(`The traffic random factor for experience ${experience.id} is ${trafficRandom}. It's traffic allocation is set to ${experience.trafficAllocation}.`);
3893
- return experience.trafficAllocation > trafficRandom && (includes(profile.audiences, experience.audience.id) || // if the expriment is active already then it's selectible without further contraints to be fullfilled
3894
- find(activeExperiments, {
3893
+ const isInTrafficRange = experience.trafficAllocation > trafficRandom;
3894
+ const matchesAudience = experience.audience && includes(profile.audiences, experience.audience.id);
3895
+ const hasActiveExperiment = find(activeExperiments, {
3895
3896
  id: experience.id
3896
- }));
3897
+ });
3898
+ log(`Is the profile in traffic allocation range? ${isInTrafficRange ? 'yes' : 'no'}.\n
3899
+ Does the profile match the audience of the experience? ${matchesAudience ? 'yes' : 'no'}.\n
3900
+ Is there an active experiment for this profile? ${hasActiveExperiment ? 'yes' : 'no'}.`);
3901
+ return isInTrafficRange && (matchesAudience || // if the expriment is active already then it's selectible without further contraints to be fullfilled
3902
+ hasActiveExperiment);
3897
3903
  });
3898
3904
  return selectedExperience;
3899
3905
  };
package/index.umd.js CHANGED
@@ -3816,10 +3816,14 @@
3816
3816
  var selectedExperience = eglibleExperiences.find(function (experience) {
3817
3817
  var trafficRandom = getTrafficRandom(profile, experience);
3818
3818
  log("The traffic random factor for experience ".concat(experience.id, " is ").concat(trafficRandom, ". It's traffic allocation is set to ").concat(experience.trafficAllocation, "."));
3819
- return experience.trafficAllocation > 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
3820
- find__default["default"](activeExperiments, {
3819
+ var isInTrafficRange = experience.trafficAllocation > trafficRandom;
3820
+ var matchesAudience = experience.audience && includes__default["default"](profile.audiences, experience.audience.id);
3821
+ var hasActiveExperiment = find__default["default"](activeExperiments, {
3821
3822
  id: experience.id
3822
- }));
3823
+ });
3824
+ log("Is the profile in traffic allocation range? ".concat(isInTrafficRange ? 'yes' : 'no', ".\n\n Does the profile match the audience of the experience? ").concat(matchesAudience ? 'yes' : 'no', ".\n\n Is there an active experiment for this profile? ").concat(hasActiveExperiment ? 'yes' : 'no', "."));
3825
+ return isInTrafficRange && (matchesAudience || // if the expriment is active already then it's selectible without further contraints to be fullfilled
3826
+ hasActiveExperiment);
3823
3827
  });
3824
3828
  return selectedExperience;
3825
3829
  };
package/package.json CHANGED
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@ninetailed/experience.js",
3
- "version": "2.0.0-beta.12",
3
+ "version": "2.0.0-beta.14",
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.12",
9
+ "@ninetailed/experience.js-shared": "2.0.0-beta.14",
10
10
  "uuid": "^8.3.2",
11
11
  "ts-toolbelt": "^9.6.0",
12
12
  "locale-enum": "^1.1.1",