Skip to content

Commit

Permalink
Fix validation issue breaking L&G
Browse files Browse the repository at this point in the history
  • Loading branch information
econti committed Jun 18, 2020
1 parent de97c33 commit 3e54edd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion static/js/banditLocal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ let bandit = new banditml.BanditAPI(
config = {
debugMode: true,
banditHostUrl: "http://localhost:8000/api/",
debugOptions: {forceVariantSlug: "bandit"}
debugOptions: {forceVariantSlug: "tf"}
}
);
7 changes: 5 additions & 2 deletions static/js/banditMl.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ banditml.BanditAPI = function (apiKey, recClassByExperimentId = {}, config = {})

// URLs & hosts
this.ipUrl = "https://api.ipify.org?format=json";

// special features known to backend
this.reservedFeatures = ["ipAddress", "currentlyViewingProduct"]
};

banditml.BanditAPI.prototype.addDecisionHandler = function (context, decision, experimentId) {
Expand Down Expand Up @@ -282,8 +285,8 @@ banditml.BanditAPI.prototype.validateAndFilterFeaturesInContext = function (cont
};
let filteredFeatures = {};
for (const featureName in context) {
if (featureName === "ipAddress") {
filteredFeatures.ipAddress = context.ipAddress;
if (self.reservedFeatures.includes(featureName)) {
filteredFeatures[featureName] = context[featureName];
continue;
}

Expand Down

0 comments on commit 3e54edd

Please sign in to comment.