Skip to content
This repository was archived by the owner on Sep 28, 2023. It is now read-only.

feat: Support getFeatureVariableJSON API #8

Merged
merged 6 commits into from
Aug 19, 2020

Conversation

yavorona
Copy link
Contributor

Summary

  • Update to optimizely-sdk version 4.1.0
  • Add getFeatureVariableJSON API

@yavorona yavorona self-assigned this Jul 25, 2020
@yavorona yavorona changed the title feat: Include getFeatureVariableJSON API feat: Support getFeatureVariableJSON API Jul 25, 2020
debugdialog.html Outdated
@@ -193,6 +193,9 @@
break;
case 'getFeatureVariable':
response = optimizelyClientInstance.getFeatureVariable(key, variable, userid, attributes)
if (typeof response === 'object') {
Copy link
Contributor Author

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?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yavorona yavorona removed their assignment Jul 25, 2020
@yavorona yavorona force-pushed the pnguen/add-variable-json-support branch from d8e1386 to 933ce71 Compare July 25, 2020 02:37
debugdialog.html Outdated
@@ -193,6 +193,9 @@
break;
case 'getFeatureVariable':
response = optimizelyClientInstance.getFeatureVariable(key, variable, userid, attributes)
if (typeof response === 'object') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@mikeproeng37 mikeproeng37 left a 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;

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

@yavorona yavorona requested a review from mikeproeng37 July 29, 2020 18:50
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a 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
}
Copy link
Contributor

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

Copy link
Contributor Author

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.

@yavorona yavorona force-pushed the pnguen/add-variable-json-support branch from 3fb2382 to ce77e99 Compare August 18, 2020 21:29
Copy link
Contributor

@thomaszurkan-optimizely thomaszurkan-optimizely left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thomaszurkan-optimizely thomaszurkan-optimizely merged commit 1e1477e into master Aug 19, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants