@@ -43,11 +43,19 @@ interface FeatureVariablesMap {
43
43
* @param {string } datafile
44
44
*/
45
45
export class OptimizelyConfig {
46
+ public environmentKey : string ;
47
+ public sdkKey : string ;
48
+ public revision : string ;
49
+
50
+ /**
51
+ * This experimentsMap is for experiments of legacy projects only
52
+ * For flag projects, experiment keys are not guaranteed to be unique
53
+ * across multiple flags, so this map may not include all experiments
54
+ * when keys conflict.
55
+ */
46
56
public experimentsMap : OptimizelyExperimentsMap ;
57
+
47
58
public featuresMap : OptimizelyFeaturesMap ;
48
- public revision : string ;
49
- public sdkKey : string ;
50
- public environmentKey : string ;
51
59
public attributes : OptimizelyAttribute [ ] ;
52
60
public audiences : OptimizelyAudience [ ] ;
53
61
public events : OptimizelyEvent [ ] ;
@@ -99,7 +107,7 @@ export class OptimizelyConfig {
99
107
} ) ;
100
108
101
109
( configObj . audiences || [ ] ) . forEach ( ( audience ) => {
102
- if ( ! typedAudienceIds . includes ( audience . id ) && audience . id != '$opt_dummy_audience' ) {
110
+ if ( typedAudienceIds . indexOf ( audience . id ) === - 1 && audience . id != '$opt_dummy_audience' ) {
103
111
audiences . push ( {
104
112
id : audience . id ,
105
113
conditions : JSON . stringify ( audience . conditions ) ,
@@ -140,7 +148,7 @@ export class OptimizelyConfig {
140
148
if ( item instanceof Array ) {
141
149
subAudience = OptimizelyConfig . getSerializedAudiences ( item , audiencesById ) ;
142
150
subAudience = `(${ subAudience } )` ;
143
- } else if ( DEFAULT_OPERATOR_TYPES . includes ( item ) ) {
151
+ } else if ( DEFAULT_OPERATOR_TYPES . indexOf ( item ) > - 1 ) {
144
152
cond = item . toUpperCase ( ) ;
145
153
} else {
146
154
// Checks if item is audience id
@@ -343,7 +351,7 @@ export class OptimizelyConfig {
343
351
const experiments = configObj . experiments ;
344
352
345
353
return ( experiments || [ ] ) . reduce ( ( experimentsMap : { [ id : string ] : OptimizelyExperiment } , experiment ) => {
346
- if ( ! rolloutExperimentIds . includes ( experiment . id ) ) {
354
+ if ( rolloutExperimentIds . indexOf ( experiment . id ) === - 1 ) {
347
355
const featureIds = configObj . experimentFeatureMap [ experiment . id ] ;
348
356
let featureId = '' ;
349
357
if ( featureIds && featureIds . length > 0 ) {
@@ -398,7 +406,7 @@ export class OptimizelyConfig {
398
406
const featureExperimentMap : OptimizelyExperimentsMap = { } ;
399
407
const experimentRules : OptimizelyExperiment [ ] = [ ] ;
400
408
for ( const key in experimentsMapById ) {
401
- if ( featureFlag . experimentIds . includes ( key ) ) {
409
+ if ( featureFlag . experimentIds . indexOf ( key ) > - 1 ) {
402
410
const experiment = experimentsMapById [ key ] ;
403
411
if ( experiment ) {
404
412
featureExperimentMap [ experiment . key ] = experiment ;
0 commit comments