Skip to content

Commit 76603f2

Browse files
committed
suggested changes made.
1 parent b05d049 commit 76603f2

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

packages/optimizely-sdk/lib/core/optimizely_config/index.ts

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,19 @@ interface FeatureVariablesMap {
4343
* @param {string} datafile
4444
*/
4545
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+
*/
4656
public experimentsMap: OptimizelyExperimentsMap;
57+
4758
public featuresMap: OptimizelyFeaturesMap;
48-
public revision: string;
49-
public sdkKey: string;
50-
public environmentKey: string;
5159
public attributes: OptimizelyAttribute[];
5260
public audiences: OptimizelyAudience[];
5361
public events: OptimizelyEvent[];
@@ -99,7 +107,7 @@ export class OptimizelyConfig {
99107
});
100108

101109
(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') {
103111
audiences.push({
104112
id: audience.id,
105113
conditions: JSON.stringify(audience.conditions),
@@ -140,7 +148,7 @@ export class OptimizelyConfig {
140148
if (item instanceof Array) {
141149
subAudience = OptimizelyConfig.getSerializedAudiences(item, audiencesById);
142150
subAudience = `(${subAudience})`;
143-
} else if (DEFAULT_OPERATOR_TYPES.includes(item)) {
151+
} else if (DEFAULT_OPERATOR_TYPES.indexOf(item) > -1) {
144152
cond = item.toUpperCase();
145153
} else {
146154
// Checks if item is audience id
@@ -343,7 +351,7 @@ export class OptimizelyConfig {
343351
const experiments = configObj.experiments;
344352

345353
return (experiments || []).reduce((experimentsMap: { [id: string]: OptimizelyExperiment }, experiment) => {
346-
if (!rolloutExperimentIds.includes(experiment.id)) {
354+
if (rolloutExperimentIds.indexOf(experiment.id) === -1) {
347355
const featureIds = configObj.experimentFeatureMap[experiment.id];
348356
let featureId = '';
349357
if (featureIds && featureIds.length > 0) {
@@ -398,7 +406,7 @@ export class OptimizelyConfig {
398406
const featureExperimentMap: OptimizelyExperimentsMap = {};
399407
const experimentRules: OptimizelyExperiment[] = [];
400408
for (const key in experimentsMapById) {
401-
if (featureFlag.experimentIds.includes(key)) {
409+
if (featureFlag.experimentIds.indexOf(key) > -1) {
402410
const experiment = experimentsMapById[key];
403411
if (experiment) {
404412
featureExperimentMap[experiment.key] = experiment;

packages/optimizely-sdk/lib/core/project_config/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ import {
3232
FeatureVariable,
3333
Group,
3434
OptimizelyVariation,
35-
OptimizelyAttribute,
3635
Rollout,
3736
TrafficAllocation,
3837
Variation,
@@ -66,7 +65,7 @@ export interface ProjectConfig {
6665
sendFlagDecisions?: boolean;
6766
experimentKeyMap: { [key: string]: Experiment };
6867
featureKeyMap: {
69-
[key: string]: FeatureFlag
68+
[key: string]: FeatureFlag;
7069
};
7170
rollouts: Rollout[];
7271
featureFlags: FeatureFlag[];
@@ -83,7 +82,7 @@ export interface ProjectConfig {
8382
groupIdMap: { [id: string]: Group };
8483
groups: Group[];
8584
events: Event[];
86-
attributes: OptimizelyAttribute[];
85+
attributes: Array<{ id: string; key: string }>;
8786
typedAudiences: Audience[];
8887
rolloutIdMap: { [id: string]: Rollout };
8988
anonymizeIP?: boolean | null;

0 commit comments

Comments
 (0)