-
Notifications
You must be signed in to change notification settings - Fork 4
feat: Support getFeatureVariableJSON API #8
feat: Support getFeatureVariableJSON API #8
Conversation
debugdialog.html
Outdated
@@ -193,6 +193,9 @@ | |||
break; | |||
case 'getFeatureVariable': | |||
response = optimizelyClientInstance.getFeatureVariable(key, variable, userid, attributes) | |||
if (typeof response === 'object') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I would check for variable type instead, but I couldn't figure out how to get variable type in this case. Any advice @thomaszurkan-optimizely?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d8e1386
to
933ce71
Compare
debugdialog.html
Outdated
@@ -193,6 +193,9 @@ | |||
break; | |||
case 'getFeatureVariable': | |||
response = optimizelyClientInstance.getFeatureVariable(key, variable, userid, attributes) | |||
if (typeof response === 'object') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there is a potential bug :D
debugdialog.html
Outdated
@@ -172,6 +172,11 @@ | |||
return attributes | |||
} | |||
|
|||
function getFeatureVariableType(featureKey, variableKey) { | |||
var vmap = optimizelyClientInstance.getOptimizelyConfig().featuresMap[featureKey].variablesMap; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to check if the feature key exists in the map first, otherwise you could run into a null reference exception when calling .variablesMap
. If they key is not found, then just return null or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good. one question/comment. i believe we can add the function chaining to avoid any exceptions.
} | ||
var vmap = feature.variablesMap | ||
return vmap[variableKey].type | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if vmap[variableKey] does not exist will it throw or pass back undefined? couldn't we add vmap[variableKey]?.type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@thomaszurkan-optimizely you are right, it will pass back undefined, so we can add optional chaining as you suggested to avoid exceptions.
3fb2382
to
ce77e99
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Summary