@@ -273,14 +273,6 @@ export default class Optimizely extends BaseService implements Client {
273
273
return this . projectConfigManager . getConfig ( ) || null ;
274
274
}
275
275
276
- /**
277
- * Returns a truthy value if this instance currently has a valid project config
278
- * @return {boolean }
279
- */
280
- private hasProjectConfig ( ) : boolean {
281
- return ! ! this . projectConfigManager . getConfig ( ) ;
282
- }
283
-
284
276
/**
285
277
* Buckets visitor and sends impression event to Optimizely.
286
278
* @param {string } experimentKey
@@ -290,7 +282,7 @@ export default class Optimizely extends BaseService implements Client {
290
282
*/
291
283
activate ( experimentKey : string , userId : string , attributes ?: UserAttributes ) : string | null {
292
284
try {
293
- const configObj = this . projectConfigManager . getConfig ( ) ;
285
+ const configObj = this . getProjectConfig ( ) ;
294
286
if ( ! configObj ) {
295
287
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'activate' ) ;
296
288
return null ;
@@ -355,7 +347,7 @@ export default class Optimizely extends BaseService implements Client {
355
347
return ;
356
348
}
357
349
358
- const configObj = this . projectConfigManager . getConfig ( ) ;
350
+ const configObj = this . getProjectConfig ( ) ;
359
351
if ( ! configObj ) {
360
352
return ;
361
353
}
@@ -396,7 +388,7 @@ export default class Optimizely extends BaseService implements Client {
396
388
return ;
397
389
}
398
390
399
- const configObj = this . projectConfigManager . getConfig ( ) ;
391
+ const configObj = this . getProjectConfig ( ) ;
400
392
if ( ! configObj ) {
401
393
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'track' ) ;
402
394
return ;
@@ -451,7 +443,7 @@ export default class Optimizely extends BaseService implements Client {
451
443
*/
452
444
getVariation ( experimentKey : string , userId : string , attributes ?: UserAttributes ) : string | null {
453
445
try {
454
- const configObj = this . projectConfigManager . getConfig ( ) ;
446
+ const configObj = this . getProjectConfig ( ) ;
455
447
if ( ! configObj ) {
456
448
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getVariation' ) ;
457
449
return null ;
@@ -511,7 +503,7 @@ export default class Optimizely extends BaseService implements Client {
511
503
return false ;
512
504
}
513
505
514
- const configObj = this . projectConfigManager . getConfig ( ) ;
506
+ const configObj = this . getProjectConfig ( ) ;
515
507
if ( ! configObj ) {
516
508
return false ;
517
509
}
@@ -535,7 +527,7 @@ export default class Optimizely extends BaseService implements Client {
535
527
return null ;
536
528
}
537
529
538
- const configObj = this . projectConfigManager . getConfig ( ) ;
530
+ const configObj = this . getProjectConfig ( ) ;
539
531
if ( ! configObj ) {
540
532
return null ;
541
533
}
@@ -618,7 +610,7 @@ export default class Optimizely extends BaseService implements Client {
618
610
*/
619
611
isFeatureEnabled ( featureKey : string , userId : string , attributes ?: UserAttributes ) : boolean {
620
612
try {
621
- const configObj = this . projectConfigManager . getConfig ( ) ;
613
+ const configObj = this . getProjectConfig ( ) ;
622
614
if ( ! configObj ) {
623
615
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'isFeatureEnabled' ) ;
624
616
return false ;
@@ -695,7 +687,7 @@ export default class Optimizely extends BaseService implements Client {
695
687
try {
696
688
const enabledFeatures : string [ ] = [ ] ;
697
689
698
- const configObj = this . projectConfigManager . getConfig ( ) ;
690
+ const configObj = this . getProjectConfig ( ) ;
699
691
if ( ! configObj ) {
700
692
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getEnabledFeatures' ) ;
701
693
return enabledFeatures ;
@@ -739,7 +731,7 @@ export default class Optimizely extends BaseService implements Client {
739
731
attributes ?: UserAttributes
740
732
) : FeatureVariableValue {
741
733
try {
742
- if ( ! this . hasProjectConfig ( ) ) {
734
+ if ( ! this . getProjectConfig ( ) ) {
743
735
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariable' ) ;
744
736
return null ;
745
737
}
@@ -783,7 +775,7 @@ export default class Optimizely extends BaseService implements Client {
783
775
return null ;
784
776
}
785
777
786
- const configObj = this . projectConfigManager . getConfig ( ) ;
778
+ const configObj = this . getProjectConfig ( ) ;
787
779
if ( ! configObj ) {
788
780
return null ;
789
781
}
@@ -869,7 +861,7 @@ export default class Optimizely extends BaseService implements Client {
869
861
variable : FeatureVariable ,
870
862
userId : string
871
863
) : FeatureVariableValue {
872
- const configObj = this . projectConfigManager . getConfig ( ) ;
864
+ const configObj = this . getProjectConfig ( ) ;
873
865
if ( ! configObj ) {
874
866
return null ;
875
867
}
@@ -933,7 +925,7 @@ export default class Optimizely extends BaseService implements Client {
933
925
attributes ?: UserAttributes
934
926
) : boolean | null {
935
927
try {
936
- if ( ! this . hasProjectConfig ( ) ) {
928
+ if ( ! this . getProjectConfig ( ) ) {
937
929
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableBoolean' ) ;
938
930
return null ;
939
931
}
@@ -971,7 +963,7 @@ export default class Optimizely extends BaseService implements Client {
971
963
attributes ?: UserAttributes
972
964
) : number | null {
973
965
try {
974
- if ( ! this . hasProjectConfig ( ) ) {
966
+ if ( ! this . getProjectConfig ( ) ) {
975
967
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableDouble' ) ;
976
968
return null ;
977
969
}
@@ -1009,7 +1001,7 @@ export default class Optimizely extends BaseService implements Client {
1009
1001
attributes ?: UserAttributes
1010
1002
) : number | null {
1011
1003
try {
1012
- if ( ! this . hasProjectConfig ( ) ) {
1004
+ if ( ! this . getProjectConfig ( ) ) {
1013
1005
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableInteger' ) ;
1014
1006
return null ;
1015
1007
}
@@ -1047,7 +1039,7 @@ export default class Optimizely extends BaseService implements Client {
1047
1039
attributes ?: UserAttributes
1048
1040
) : string | null {
1049
1041
try {
1050
- if ( ! this . hasProjectConfig ( ) ) {
1042
+ if ( ! this . getProjectConfig ( ) ) {
1051
1043
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableString' ) ;
1052
1044
return null ;
1053
1045
}
@@ -1080,7 +1072,7 @@ export default class Optimizely extends BaseService implements Client {
1080
1072
*/
1081
1073
getFeatureVariableJSON ( featureKey : string , variableKey : string , userId : string , attributes : UserAttributes ) : unknown {
1082
1074
try {
1083
- if ( ! this . hasProjectConfig ( ) ) {
1075
+ if ( ! this . getProjectConfig ( ) ) {
1084
1076
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getFeatureVariableJSON' ) ;
1085
1077
return null ;
1086
1078
}
@@ -1107,7 +1099,7 @@ export default class Optimizely extends BaseService implements Client {
1107
1099
attributes ?: UserAttributes
1108
1100
) : { [ variableKey : string ] : unknown } | null {
1109
1101
try {
1110
- const configObj = this . projectConfigManager . getConfig ( ) ;
1102
+ const configObj = this . getProjectConfig ( ) ;
1111
1103
1112
1104
if ( ! configObj ) {
1113
1105
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'getAllFeatureVariables' ) ;
@@ -1208,7 +1200,7 @@ export default class Optimizely extends BaseService implements Client {
1208
1200
*/
1209
1201
getOptimizelyConfig ( ) : OptimizelyConfig | null {
1210
1202
try {
1211
- const configObj = this . projectConfigManager . getConfig ( ) ;
1203
+ const configObj = this . getProjectConfig ( ) ;
1212
1204
if ( ! configObj ) {
1213
1205
return null ;
1214
1206
}
@@ -1388,7 +1380,7 @@ export default class Optimizely extends BaseService implements Client {
1388
1380
}
1389
1381
1390
1382
decide ( user : OptimizelyUserContext , key : string , options : OptimizelyDecideOption [ ] = [ ] ) : OptimizelyDecision {
1391
- const configObj = this . projectConfigManager . getConfig ( ) ;
1383
+ const configObj = this . getProjectConfig ( ) ;
1392
1384
1393
1385
if ( ! configObj ) {
1394
1386
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'decide' ) ;
@@ -1533,7 +1525,7 @@ export default class Optimizely extends BaseService implements Client {
1533
1525
const flagsWithoutForcedDecision = [ ] ;
1534
1526
const validKeys = [ ] ;
1535
1527
1536
- const configObj = this . projectConfigManager . getConfig ( )
1528
+ const configObj = this . getProjectConfig ( )
1537
1529
1538
1530
if ( ! configObj ) {
1539
1531
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'decideForKeys' ) ;
@@ -1604,7 +1596,7 @@ export default class Optimizely extends BaseService implements Client {
1604
1596
options : OptimizelyDecideOption [ ] = [ ]
1605
1597
) : { [ key : string ] : OptimizelyDecision } {
1606
1598
const decisionMap : { [ key : string ] : OptimizelyDecision } = { } ;
1607
- const configObj = this . projectConfigManager . getConfig ( ) ;
1599
+ const configObj = this . getProjectConfig ( ) ;
1608
1600
if ( ! configObj ) {
1609
1601
this . errorReporter . report ( NO_PROJECT_CONFIG_FAILURE , 'decideAll' ) ;
1610
1602
return decisionMap ;
@@ -1619,7 +1611,7 @@ export default class Optimizely extends BaseService implements Client {
1619
1611
* Updates ODP Config with most recent ODP key, host, pixelUrl, and segments from the project config
1620
1612
*/
1621
1613
private updateOdpSettings ( ) : void {
1622
- const projectConfig = this . projectConfigManager . getConfig ( ) ;
1614
+ const projectConfig = this . getProjectConfig ( ) ;
1623
1615
1624
1616
if ( ! projectConfig ) {
1625
1617
return ;
@@ -1661,7 +1653,7 @@ export default class Optimizely extends BaseService implements Client {
1661
1653
* @returns { boolean } `true` if ODP settings were found in the datafile otherwise `false`
1662
1654
*/
1663
1655
public isOdpIntegrated ( ) : boolean {
1664
- return this . projectConfigManager . getConfig ( ) ?. odpIntegrationConfig ?. integrated ?? false ;
1656
+ return this . getProjectConfig ( ) ?. odpIntegrationConfig ?. integrated ?? false ;
1665
1657
}
1666
1658
1667
1659
/**
0 commit comments