@@ -266,14 +266,6 @@ export default class Optimizely implements Client {
266
266
return this . projectConfigManager . getConfig ( ) || null ;
267
267
}
268
268
269
- /**
270
- * Returns a truthy value if this instance currently has a valid project config
271
- * @return {boolean }
272
- */
273
- private hasProjectConfig ( ) : boolean {
274
- return ! ! this . projectConfigManager . getConfig ( ) ;
275
- }
276
-
277
269
/**
278
270
* Buckets visitor and sends impression event to Optimizely.
279
271
* @param {string } experimentKey
@@ -283,7 +275,7 @@ export default class Optimizely implements Client {
283
275
*/
284
276
activate ( experimentKey : string , userId : string , attributes ?: UserAttributes ) : string | null {
285
277
try {
286
- const configObj = this . projectConfigManager . getConfig ( ) ;
278
+ const configObj = this . getProjectConfig ( ) ;
287
279
if ( ! configObj ) {
288
280
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'activate' ) ;
289
281
return null ;
@@ -348,7 +340,7 @@ export default class Optimizely implements Client {
348
340
return ;
349
341
}
350
342
351
- const configObj = this . projectConfigManager . getConfig ( ) ;
343
+ const configObj = this . getProjectConfig ( ) ;
352
344
if ( ! configObj ) {
353
345
return ;
354
346
}
@@ -389,7 +381,7 @@ export default class Optimizely implements Client {
389
381
return ;
390
382
}
391
383
392
- const configObj = this . projectConfigManager . getConfig ( ) ;
384
+ const configObj = this . getProjectConfig ( ) ;
393
385
if ( ! configObj ) {
394
386
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'track' ) ;
395
387
return ;
@@ -444,7 +436,7 @@ export default class Optimizely implements Client {
444
436
*/
445
437
getVariation ( experimentKey : string , userId : string , attributes ?: UserAttributes ) : string | null {
446
438
try {
447
- const configObj = this . projectConfigManager . getConfig ( ) ;
439
+ const configObj = this . getProjectConfig ( ) ;
448
440
if ( ! configObj ) {
449
441
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getVariation' ) ;
450
442
return null ;
@@ -504,7 +496,7 @@ export default class Optimizely implements Client {
504
496
return false ;
505
497
}
506
498
507
- const configObj = this . projectConfigManager . getConfig ( ) ;
499
+ const configObj = this . getProjectConfig ( ) ;
508
500
if ( ! configObj ) {
509
501
return false ;
510
502
}
@@ -528,7 +520,7 @@ export default class Optimizely implements Client {
528
520
return null ;
529
521
}
530
522
531
- const configObj = this . projectConfigManager . getConfig ( ) ;
523
+ const configObj = this . getProjectConfig ( ) ;
532
524
if ( ! configObj ) {
533
525
return null ;
534
526
}
@@ -611,7 +603,7 @@ export default class Optimizely implements Client {
611
603
*/
612
604
isFeatureEnabled ( featureKey : string , userId : string , attributes ?: UserAttributes ) : boolean {
613
605
try {
614
- const configObj = this . projectConfigManager . getConfig ( ) ;
606
+ const configObj = this . getProjectConfig ( ) ;
615
607
if ( ! configObj ) {
616
608
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'isFeatureEnabled' ) ;
617
609
return false ;
@@ -688,7 +680,7 @@ export default class Optimizely implements Client {
688
680
try {
689
681
const enabledFeatures : string [ ] = [ ] ;
690
682
691
- const configObj = this . projectConfigManager . getConfig ( ) ;
683
+ const configObj = this . getProjectConfig ( ) ;
692
684
if ( ! configObj ) {
693
685
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getEnabledFeatures' ) ;
694
686
return enabledFeatures ;
@@ -732,7 +724,7 @@ export default class Optimizely implements Client {
732
724
attributes ?: UserAttributes
733
725
) : FeatureVariableValue {
734
726
try {
735
- if ( ! this . hasProjectConfig ( ) ) {
727
+ if ( ! this . getProjectConfig ( ) ) {
736
728
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariable' ) ;
737
729
return null ;
738
730
}
@@ -776,7 +768,7 @@ export default class Optimizely implements Client {
776
768
return null ;
777
769
}
778
770
779
- const configObj = this . projectConfigManager . getConfig ( ) ;
771
+ const configObj = this . getProjectConfig ( ) ;
780
772
if ( ! configObj ) {
781
773
return null ;
782
774
}
@@ -862,7 +854,7 @@ export default class Optimizely implements Client {
862
854
variable : FeatureVariable ,
863
855
userId : string
864
856
) : FeatureVariableValue {
865
- const configObj = this . projectConfigManager . getConfig ( ) ;
857
+ const configObj = this . getProjectConfig ( ) ;
866
858
if ( ! configObj ) {
867
859
return null ;
868
860
}
@@ -926,7 +918,7 @@ export default class Optimizely implements Client {
926
918
attributes ?: UserAttributes
927
919
) : boolean | null {
928
920
try {
929
- if ( ! this . hasProjectConfig ( ) ) {
921
+ if ( ! this . getProjectConfig ( ) ) {
930
922
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableBoolean' ) ;
931
923
return null ;
932
924
}
@@ -964,7 +956,7 @@ export default class Optimizely implements Client {
964
956
attributes ?: UserAttributes
965
957
) : number | null {
966
958
try {
967
- if ( ! this . hasProjectConfig ( ) ) {
959
+ if ( ! this . getProjectConfig ( ) ) {
968
960
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableDouble' ) ;
969
961
return null ;
970
962
}
@@ -1002,7 +994,7 @@ export default class Optimizely implements Client {
1002
994
attributes ?: UserAttributes
1003
995
) : number | null {
1004
996
try {
1005
- if ( ! this . hasProjectConfig ( ) ) {
997
+ if ( ! this . getProjectConfig ( ) ) {
1006
998
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableInteger' ) ;
1007
999
return null ;
1008
1000
}
@@ -1040,7 +1032,7 @@ export default class Optimizely implements Client {
1040
1032
attributes ?: UserAttributes
1041
1033
) : string | null {
1042
1034
try {
1043
- if ( ! this . hasProjectConfig ( ) ) {
1035
+ if ( ! this . getProjectConfig ( ) ) {
1044
1036
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableString' ) ;
1045
1037
return null ;
1046
1038
}
@@ -1073,7 +1065,7 @@ export default class Optimizely implements Client {
1073
1065
*/
1074
1066
getFeatureVariableJSON ( featureKey : string , variableKey : string , userId : string , attributes : UserAttributes ) : unknown {
1075
1067
try {
1076
- if ( ! this . hasProjectConfig ( ) ) {
1068
+ if ( ! this . getProjectConfig ( ) ) {
1077
1069
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableJSON' ) ;
1078
1070
return null ;
1079
1071
}
@@ -1100,7 +1092,7 @@ export default class Optimizely implements Client {
1100
1092
attributes ?: UserAttributes
1101
1093
) : { [ variableKey : string ] : unknown } | null {
1102
1094
try {
1103
- const configObj = this . projectConfigManager . getConfig ( ) ;
1095
+ const configObj = this . getProjectConfig ( ) ;
1104
1096
1105
1097
if ( ! configObj ) {
1106
1098
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getAllFeatureVariables' ) ;
@@ -1201,7 +1193,7 @@ export default class Optimizely implements Client {
1201
1193
*/
1202
1194
getOptimizelyConfig ( ) : OptimizelyConfig | null {
1203
1195
try {
1204
- const configObj = this . projectConfigManager . getConfig ( ) ;
1196
+ const configObj = this . getProjectConfig ( ) ;
1205
1197
if ( ! configObj ) {
1206
1198
return null ;
1207
1199
}
@@ -1400,7 +1392,7 @@ export default class Optimizely implements Client {
1400
1392
}
1401
1393
1402
1394
decide ( user : OptimizelyUserContext , key : string , options : OptimizelyDecideOption [ ] = [ ] ) : OptimizelyDecision {
1403
- const configObj = this . projectConfigManager . getConfig ( ) ;
1395
+ const configObj = this . getProjectConfig ( ) ;
1404
1396
1405
1397
if ( ! configObj ) {
1406
1398
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'decide' ) ;
@@ -1545,7 +1537,7 @@ export default class Optimizely implements Client {
1545
1537
const flagsWithoutForcedDecision = [ ] ;
1546
1538
const validKeys = [ ] ;
1547
1539
1548
- const configObj = this . projectConfigManager . getConfig ( )
1540
+ const configObj = this . getProjectConfig ( )
1549
1541
1550
1542
if ( ! configObj ) {
1551
1543
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'decideForKeys' ) ;
@@ -1616,7 +1608,7 @@ export default class Optimizely implements Client {
1616
1608
options : OptimizelyDecideOption [ ] = [ ]
1617
1609
) : { [ key : string ] : OptimizelyDecision } {
1618
1610
const decisionMap : { [ key : string ] : OptimizelyDecision } = { } ;
1619
- const configObj = this . projectConfigManager . getConfig ( ) ;
1611
+ const configObj = this . getProjectConfig ( ) ;
1620
1612
if ( ! configObj ) {
1621
1613
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'decideAll' ) ;
1622
1614
return decisionMap ;
@@ -1631,7 +1623,7 @@ export default class Optimizely implements Client {
1631
1623
* Updates ODP Config with most recent ODP key, host, pixelUrl, and segments from the project config
1632
1624
*/
1633
1625
private updateOdpSettings ( ) : void {
1634
- const projectConfig = this . projectConfigManager . getConfig ( ) ;
1626
+ const projectConfig = this . getProjectConfig ( ) ;
1635
1627
1636
1628
if ( ! projectConfig ) {
1637
1629
return ;
@@ -1673,7 +1665,7 @@ export default class Optimizely implements Client {
1673
1665
* @returns { boolean } `true` if ODP settings were found in the datafile otherwise `false`
1674
1666
*/
1675
1667
public isOdpIntegrated ( ) : boolean {
1676
- return this . projectConfigManager . getConfig ( ) ?. odpIntegrationConfig ?. integrated ?? false ;
1668
+ return this . getProjectConfig ( ) ?. odpIntegrationConfig ?. integrated ?? false ;
1677
1669
}
1678
1670
1679
1671
/**
0 commit comments