Skip to content

Commit 795ed3a

Browse files
committed
update
1 parent bb87136 commit 795ed3a

3 files changed

Lines changed: 22 additions & 2 deletions

File tree

lib/project_config/project_config.spec.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ const getHoldoutDatafile = () => {
329329
key: 'holdout_2',
330330
status: 'Running',
331331
includedFlags: [],
332-
excludedFlags: ['44829230000'],
332+
excludedFlags: [],
333333
audienceIds: [],
334334
audienceConditions: [],
335335
variations: [
@@ -350,7 +350,7 @@ const getHoldoutDatafile = () => {
350350
id: 'holdout_id_3',
351351
key: 'holdout_3',
352352
status: 'Draft',
353-
includedFlags: ['4482920077'],
353+
includedFlags: [],
354354
excludedFlags: [],
355355
audienceIds: [],
356356
audienceConditions: [],
@@ -402,6 +402,18 @@ describe('createProjectConfig - holdouts', () => {
402402
expect(configObj.holdouts).toEqual([]);
403403
expect(configObj.holdoutIdMap).toEqual({});
404404
});
405+
406+
it('should handle undefined includedFlags and excludedFlags in holdout', function() {
407+
const datafile = getHoldoutDatafile();
408+
datafile.holdouts[0].includedFlags = undefined;
409+
datafile.holdouts[0].excludedFlags = undefined;
410+
411+
const configObj = projectConfig.createProjectConfig(JSON.parse(JSON.stringify(datafile)));
412+
413+
expect(configObj.holdouts).toHaveLength(3);
414+
expect(configObj.holdouts[0].includedFlags).toEqual([]);
415+
expect(configObj.holdouts[0].excludedFlags).toEqual([]);
416+
});
405417
});
406418

407419
describe('getExperimentId', () => {

lib/project_config/project_config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,12 @@ const parseHoldoutsConfig = (projectConfig: ProjectConfig): void => {
388388
projectConfig.holdoutIdMap = keyBy(projectConfig.holdouts, 'id');
389389

390390
projectConfig.holdouts.forEach((holdout) => {
391+
392+
// Original design of the global holdouts made use of the includeFlags and excludeFlags fields to identify local holdouts.
393+
// But this was never released. In the current design, these fields are no longer user. These fields are kept
394+
// and assinged empty array to keep the published type `Holdout` unchanged.
395+
holdout.includedFlags = [];
396+
holdout.excludedFlags = [];
391397
holdout.variationKeyMap = keyBy(holdout.variations, 'key');
392398
assignBy(holdout.variations, 'id', projectConfig.variationIdMap);
393399
});

lib/shared_types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ export type HoldoutStatus = 'Draft' | 'Running' | 'Concluded' | 'Archived';
174174

175175
export interface Holdout extends ExperimentCore {
176176
status: HoldoutStatus;
177+
includedFlags: string[];
178+
excludedFlags: string[];
177179
}
178180

179181
export function isHoldout(obj: Experiment | Holdout): obj is Holdout {

0 commit comments

Comments
 (0)