From 3e54eddeef74790fdfc391772daa1f62d5b4d74a Mon Sep 17 00:00:00 2001 From: Edoardo Conti Date: Wed, 17 Jun 2020 19:29:52 -0700 Subject: [PATCH] Fix validation issue breaking L&G --- static/js/banditLocal.js | 2 +- static/js/banditMl.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/static/js/banditLocal.js b/static/js/banditLocal.js index fa1c99d..fd0b673 100644 --- a/static/js/banditLocal.js +++ b/static/js/banditLocal.js @@ -5,6 +5,6 @@ let bandit = new banditml.BanditAPI( config = { debugMode: true, banditHostUrl: "http://localhost:8000/api/", - debugOptions: {forceVariantSlug: "bandit"} + debugOptions: {forceVariantSlug: "tf"} } ); diff --git a/static/js/banditMl.js b/static/js/banditMl.js index 20cca75..490cf2e 100644 --- a/static/js/banditMl.js +++ b/static/js/banditMl.js @@ -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) { @@ -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; }