@@ -76,7 +76,7 @@ function Optimizely(config) {
76
76
skipJSONValidation : config . skipJSONValidation ,
77
77
} ) ;
78
78
79
- this . __disposeOnUpdate = this . projectConfigManager . onUpdate ( function ( configObj ) {
79
+ this . __disposeOnUpdate = this . projectConfigManager . onUpdate ( function ( configObj ) {
80
80
this . logger . log ( LOG_LEVEL . INFO , jsSdkUtils . sprintf ( LOG_MESSAGES . UPDATED_OPTIMIZELY_CONFIG , MODULE_NAME , configObj . revision , configObj . projectId ) ) ;
81
81
this . notificationCenter . sendNotifications ( NOTIFICATION_TYPES . OPTIMIZELY_CONFIG_UPDATE ) ;
82
82
} . bind ( this ) ) ;
@@ -124,7 +124,7 @@ function Optimizely(config) {
124
124
* constructor was also valid.
125
125
* @return {* }
126
126
*/
127
- Optimizely . prototype . __isValidInstance = function ( ) {
127
+ Optimizely . prototype . __isValidInstance = function ( ) {
128
128
return this . __isOptimizelyConfigValid && this . projectConfigManager . getConfig ( ) ;
129
129
} ;
130
130
@@ -135,7 +135,7 @@ Optimizely.prototype.__isValidInstance = function() {
135
135
* @param {Object } attributes
136
136
* @return {string|null } variation key
137
137
*/
138
- Optimizely . prototype . activate = function ( experimentKey , userId , attributes ) {
138
+ Optimizely . prototype . activate = function ( experimentKey , userId , attributes ) {
139
139
try {
140
140
if ( ! this . __isValidInstance ( ) ) {
141
141
this . logger . log ( LOG_LEVEL . ERROR , jsSdkUtils . sprintf ( LOG_MESSAGES . INVALID_OBJECT , MODULE_NAME , 'activate' ) ) ;
@@ -194,7 +194,7 @@ Optimizely.prototype.activate = function(experimentKey, userId, attributes) {
194
194
* @param {string } userId ID of user to whom the variation was shown
195
195
* @param {Object } attributes Optional user attributes
196
196
*/
197
- Optimizely . prototype . _sendImpressionEvent = function ( experimentKey , variationKey , userId , attributes ) {
197
+ Optimizely . prototype . _sendImpressionEvent = function ( experimentKey , variationKey , userId , attributes ) {
198
198
var configObj = this . projectConfigManager . getConfig ( ) ;
199
199
if ( ! configObj ) {
200
200
return ;
@@ -221,7 +221,7 @@ Optimizely.prototype._sendImpressionEvent = function(experimentKey, variationKey
221
221
* @param {string } userId ID of user to whom the variation was shown
222
222
* @param {Object } attributes Optional user attributes
223
223
*/
224
- Optimizely . prototype . __emitNotificationCenterActivate = function ( experimentKey , variationKey , userId , attributes ) {
224
+ Optimizely . prototype . __emitNotificationCenterActivate = function ( experimentKey , variationKey , userId , attributes ) {
225
225
var configObj = this . projectConfigManager . getConfig ( ) ;
226
226
if ( ! configObj ) {
227
227
return ;
@@ -268,7 +268,7 @@ Optimizely.prototype.__emitNotificationCenterActivate = function(experimentKey,
268
268
* @param {string } attributes
269
269
* @param {Object } eventTags Values associated with the event.
270
270
*/
271
- Optimizely . prototype . track = function ( eventKey , userId , attributes , eventTags ) {
271
+ Optimizely . prototype . track = function ( eventKey , userId , attributes , eventTags ) {
272
272
try {
273
273
if ( ! this . __isValidInstance ( ) ) {
274
274
this . logger . log ( LOG_LEVEL . ERROR , jsSdkUtils . sprintf ( LOG_MESSAGES . INVALID_OBJECT , MODULE_NAME , 'track' ) ) ;
@@ -318,7 +318,7 @@ Optimizely.prototype.track = function(eventKey, userId, attributes, eventTags) {
318
318
* @param {string } attributes
319
319
* @param {Object } eventTags Values associated with the event.
320
320
*/
321
- Optimizely . prototype . __emitNotificationCenterTrack = function ( eventKey , userId , attributes , eventTags ) {
321
+ Optimizely . prototype . __emitNotificationCenterTrack = function ( eventKey , userId , attributes , eventTags ) {
322
322
try {
323
323
var configObj = this . projectConfigManager . getConfig ( ) ;
324
324
if ( ! configObj ) {
@@ -357,7 +357,7 @@ Optimizely.prototype.__emitNotificationCenterTrack = function(eventKey, userId,
357
357
* @param {Object } attributes
358
358
* @return {string|null } variation key
359
359
*/
360
- Optimizely . prototype . getVariation = function ( experimentKey , userId , attributes ) {
360
+ Optimizely . prototype . getVariation = function ( experimentKey , userId , attributes ) {
361
361
try {
362
362
if ( ! this . __isValidInstance ( ) ) {
363
363
this . logger . log ( LOG_LEVEL . ERROR , jsSdkUtils . sprintf ( LOG_MESSAGES . INVALID_OBJECT , MODULE_NAME , 'getVariation' ) ) ;
@@ -417,7 +417,7 @@ Optimizely.prototype.getVariation = function(experimentKey, userId, attributes)
417
417
* @param {string|null } variationKey user will be forced into. If null, then clear the existing experiment-to-variation mapping.
418
418
* @return boolean A boolean value that indicates if the set completed successfully.
419
419
*/
420
- Optimizely . prototype . setForcedVariation = function ( experimentKey , userId , variationKey ) {
420
+ Optimizely . prototype . setForcedVariation = function ( experimentKey , userId , variationKey ) {
421
421
if ( ! this . __validateInputs ( { experiment_key : experimentKey , user_id : userId } ) ) {
422
422
return false ;
423
423
}
@@ -442,7 +442,7 @@ Optimizely.prototype.setForcedVariation = function(experimentKey, userId, variat
442
442
* @param {string } userId
443
443
* @return {string|null } The forced variation key.
444
444
*/
445
- Optimizely . prototype . getForcedVariation = function ( experimentKey , userId ) {
445
+ Optimizely . prototype . getForcedVariation = function ( experimentKey , userId ) {
446
446
if ( ! this . __validateInputs ( { experiment_key : experimentKey , user_id : userId } ) ) {
447
447
return null ;
448
448
}
@@ -469,7 +469,7 @@ Optimizely.prototype.getForcedVariation = function(experimentKey, userId) {
469
469
* @return {boolean } True if inputs are valid
470
470
*
471
471
*/
472
- Optimizely . prototype . __validateInputs = function ( stringInputs , userAttributes , eventTags ) {
472
+ Optimizely . prototype . __validateInputs = function ( stringInputs , userAttributes , eventTags ) {
473
473
try {
474
474
// Null, undefined or non-string user Id is invalid.
475
475
if ( stringInputs . hasOwnProperty ( 'user_id' ) ) {
@@ -508,7 +508,7 @@ Optimizely.prototype.__validateInputs = function(stringInputs, userAttributes, e
508
508
* @param userId
509
509
* @return {null }
510
510
*/
511
- Optimizely . prototype . __notActivatingExperiment = function ( experimentKey , userId ) {
511
+ Optimizely . prototype . __notActivatingExperiment = function ( experimentKey , userId ) {
512
512
var failedActivationLogMessage = jsSdkUtils . sprintf ( LOG_MESSAGES . NOT_ACTIVATING_USER , MODULE_NAME , userId , experimentKey ) ;
513
513
this . logger . log ( LOG_LEVEL . INFO , failedActivationLogMessage ) ;
514
514
return null ;
@@ -519,7 +519,7 @@ Optimizely.prototype.__notActivatingExperiment = function(experimentKey, userId)
519
519
* @param map
520
520
* @returns {Object } map
521
521
*/
522
- Optimizely . prototype . __filterEmptyValues = function ( map ) {
522
+ Optimizely . prototype . __filterEmptyValues = function ( map ) {
523
523
for ( var key in map ) {
524
524
if ( map . hasOwnProperty ( key ) && ( map [ key ] === null || map [ key ] === undefined ) ) {
525
525
delete map [ key ] ;
@@ -535,7 +535,7 @@ Optimizely.prototype.__filterEmptyValues = function(map) {
535
535
* @param {Object } attributes Optional user attributes
536
536
* @return {boolean } True if the feature is enabled for the user, false otherwise
537
537
*/
538
- Optimizely . prototype . isFeatureEnabled = function ( featureKey , userId , attributes ) {
538
+ Optimizely . prototype . isFeatureEnabled = function ( featureKey , userId , attributes ) {
539
539
try {
540
540
if ( ! this . __isValidInstance ( ) ) {
541
541
this . logger . log ( LOG_LEVEL . ERROR , jsSdkUtils . sprintf ( LOG_MESSAGES . INVALID_OBJECT , MODULE_NAME , 'isFeatureEnabled' ) ) ;
@@ -612,7 +612,7 @@ Optimizely.prototype.isFeatureEnabled = function(featureKey, userId, attributes)
612
612
* @param {Object } attributes
613
613
* @return {Array } Array of feature keys (strings)
614
614
*/
615
- Optimizely . prototype . getEnabledFeatures = function ( userId , attributes ) {
615
+ Optimizely . prototype . getEnabledFeatures = function ( userId , attributes ) {
616
616
try {
617
617
var enabledFeatures = [ ] ;
618
618
if ( ! this . __isValidInstance ( ) ) {
@@ -658,7 +658,7 @@ Optimizely.prototype.getEnabledFeatures = function(userId, attributes) {
658
658
* the variable key is invalid
659
659
*/
660
660
661
- Optimizely . prototype . getFeatureVariable = function ( featureKey , variableKey , userId , attributes ) {
661
+ Optimizely . prototype . getFeatureVariable = function ( featureKey , variableKey , userId , attributes ) {
662
662
try {
663
663
return this . _getFeatureVariableForType ( featureKey , variableKey , null , userId , attributes ) ;
664
664
} catch ( e ) {
@@ -690,7 +690,7 @@ Optimizely.prototype.getFeatureVariable = function(featureKey, variableKey, user
690
690
* variable key is invalid, or there is a mismatch
691
691
* with the type of the variable
692
692
*/
693
- Optimizely . prototype . _getFeatureVariableForType = function ( featureKey , variableKey , variableType , userId , attributes ) {
693
+ Optimizely . prototype . _getFeatureVariableForType = function ( featureKey , variableKey , variableType , userId , attributes ) {
694
694
if ( ! this . __isValidInstance ( ) ) {
695
695
var apiName = ( variableType ) ? 'getFeatureVariable' + variableType . charAt ( 0 ) . toUpperCase ( ) + variableType . slice ( 1 ) : 'getFeatureVariable' ;
696
696
this . logger . log ( LOG_LEVEL . ERROR , jsSdkUtils . sprintf ( LOG_MESSAGES . INVALID_OBJECT , MODULE_NAME , apiName ) ) ;
@@ -792,7 +792,7 @@ Optimizely.prototype._getFeatureVariableForType = function(featureKey, variableK
792
792
* invalid, or there is a mismatch with the type
793
793
* of the variable
794
794
*/
795
- Optimizely . prototype . getFeatureVariableBoolean = function ( featureKey , variableKey , userId , attributes ) {
795
+ Optimizely . prototype . getFeatureVariableBoolean = function ( featureKey , variableKey , userId , attributes ) {
796
796
try {
797
797
return this . _getFeatureVariableForType ( featureKey , variableKey , FEATURE_VARIABLE_TYPES . BOOLEAN , userId , attributes ) ;
798
798
} catch ( e ) {
@@ -816,7 +816,7 @@ Optimizely.prototype.getFeatureVariableBoolean = function(featureKey, variableKe
816
816
* invalid, or there is a mismatch with the type
817
817
* of the variable
818
818
*/
819
- Optimizely . prototype . getFeatureVariableDouble = function ( featureKey , variableKey , userId , attributes ) {
819
+ Optimizely . prototype . getFeatureVariableDouble = function ( featureKey , variableKey , userId , attributes ) {
820
820
try {
821
821
return this . _getFeatureVariableForType ( featureKey , variableKey , FEATURE_VARIABLE_TYPES . DOUBLE , userId , attributes ) ;
822
822
} catch ( e ) {
@@ -840,7 +840,7 @@ Optimizely.prototype.getFeatureVariableDouble = function(featureKey, variableKey
840
840
* invalid, or there is a mismatch with the type
841
841
* of the variable
842
842
*/
843
- Optimizely . prototype . getFeatureVariableInteger = function ( featureKey , variableKey , userId , attributes ) {
843
+ Optimizely . prototype . getFeatureVariableInteger = function ( featureKey , variableKey , userId , attributes ) {
844
844
try {
845
845
return this . _getFeatureVariableForType ( featureKey , variableKey , FEATURE_VARIABLE_TYPES . INTEGER , userId , attributes ) ;
846
846
} catch ( e ) {
@@ -864,7 +864,7 @@ Optimizely.prototype.getFeatureVariableInteger = function(featureKey, variableKe
864
864
* invalid, or there is a mismatch with the type
865
865
* of the variable
866
866
*/
867
- Optimizely . prototype . getFeatureVariableString = function ( featureKey , variableKey , userId , attributes ) {
867
+ Optimizely . prototype . getFeatureVariableString = function ( featureKey , variableKey , userId , attributes ) {
868
868
try {
869
869
return this . _getFeatureVariableForType ( featureKey , variableKey , FEATURE_VARIABLE_TYPES . STRING , userId , attributes ) ;
870
870
} catch ( e ) {
@@ -910,7 +910,7 @@ Optimizely.prototype.getFeatureVariableString = function(featureKey, variableKey
910
910
* }
911
911
* }
912
912
*/
913
- Optimizely . prototype . getOptimizelyConfig = function ( ) {
913
+ Optimizely . prototype . getOptimizelyConfig = function ( ) {
914
914
try {
915
915
var configObj = this . projectConfigManager . getConfig ( ) ;
916
916
if ( ! configObj ) {
@@ -955,7 +955,7 @@ Optimizely.prototype.getOptimizelyConfig = function() {
955
955
*
956
956
* @return {Promise }
957
957
*/
958
- Optimizely . prototype . close = function ( ) {
958
+ Optimizely . prototype . close = function ( ) {
959
959
try {
960
960
var eventProcessorStoppedPromise = this . eventProcessor . stop ( ) ;
961
961
if ( this . __disposeOnUpdate ) {
@@ -965,19 +965,19 @@ Optimizely.prototype.close = function() {
965
965
if ( this . projectConfigManager ) {
966
966
this . projectConfigManager . stop ( ) ;
967
967
}
968
- Object . keys ( this . __readyTimeouts ) . forEach ( function ( readyTimeoutId ) {
968
+ Object . keys ( this . __readyTimeouts ) . forEach ( function ( readyTimeoutId ) {
969
969
var readyTimeoutRecord = this . __readyTimeouts [ readyTimeoutId ] ;
970
970
clearTimeout ( readyTimeoutRecord . readyTimeout ) ;
971
971
readyTimeoutRecord . onClose ( ) ;
972
972
} . bind ( this ) ) ;
973
973
this . __readyTimeouts = { } ;
974
974
return eventProcessorStoppedPromise . then (
975
- function ( ) {
975
+ function ( ) {
976
976
return {
977
977
success : true ,
978
978
} ;
979
979
} ,
980
- function ( err ) {
980
+ function ( err ) {
981
981
return {
982
982
success : false ,
983
983
reason : String ( err ) ,
@@ -1021,7 +1021,7 @@ Optimizely.prototype.close = function() {
1021
1021
* @param {number|undefined } options.timeout
1022
1022
* @return {Promise }
1023
1023
*/
1024
- Optimizely . prototype . onReady = function ( options ) {
1024
+ Optimizely . prototype . onReady = function ( options ) {
1025
1025
var timeout ;
1026
1026
if ( typeof options === 'object' && options !== null ) {
1027
1027
timeout = options . timeout ;
@@ -1031,22 +1031,22 @@ Optimizely.prototype.onReady = function(options) {
1031
1031
}
1032
1032
1033
1033
var resolveTimeoutPromise ;
1034
- var timeoutPromise = new Promise ( function ( resolve ) {
1034
+ var timeoutPromise = new Promise ( function ( resolve ) {
1035
1035
resolveTimeoutPromise = resolve ;
1036
1036
} ) ;
1037
1037
1038
1038
var timeoutId = this . __nextReadyTimeoutId ;
1039
1039
this . __nextReadyTimeoutId ++ ;
1040
1040
1041
- var onReadyTimeout = function ( ) {
1041
+ var onReadyTimeout = function ( ) {
1042
1042
delete this . __readyTimeouts [ timeoutId ] ;
1043
1043
resolveTimeoutPromise ( {
1044
1044
success : false ,
1045
1045
reason : jsSdkUtils . sprintf ( 'onReady timeout expired after %s ms' , timeout ) ,
1046
1046
} ) ;
1047
1047
} . bind ( this ) ;
1048
1048
var readyTimeout = setTimeout ( onReadyTimeout , timeout ) ;
1049
- var onClose = function ( ) {
1049
+ var onClose = function ( ) {
1050
1050
resolveTimeoutPromise ( {
1051
1051
success : false ,
1052
1052
reason : 'Instance closed' ,
@@ -1058,7 +1058,7 @@ Optimizely.prototype.onReady = function(options) {
1058
1058
onClose : onClose ,
1059
1059
} ;
1060
1060
1061
- this . __readyPromise . then ( function ( ) {
1061
+ this . __readyPromise . then ( function ( ) {
1062
1062
clearTimeout ( readyTimeout ) ;
1063
1063
delete this . __readyTimeouts [ timeoutId ] ;
1064
1064
resolveTimeoutPromise ( {
0 commit comments