Skip to content

Commit c477d60

Browse files
[FSSDK-11446] update: experiment_id and variation_id added to notification listener payloads (#1030)
* -added experiment id and variation id to notification listener payload -fixed unit tests to expect experiment id and variation id in notification listener payload * Type changed of notification listener payload
1 parent 6f983eb commit c477d60

File tree

4 files changed

+30
-0
lines changed

4 files changed

+30
-0
lines changed

lib/notification_center/type.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ export type FlagDecisionInfo = {
9494
variables: VariablesMap,
9595
reasons: string[],
9696
decisionEventDispatched: boolean,
97+
experimentId: string | null,
98+
variationId: string | null,
9799
};
98100

99101
export type DecisionInfo = {

lib/optimizely/index.tests.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4602,6 +4602,8 @@ describe('lib/optimizely', function() {
46024602
variables: { i_42: 42 },
46034603
decisionEventDispatched: true,
46044604
reasons: [],
4605+
experimentId: '10420810910',
4606+
variationId: '10418551353',
46054607
},
46064608
},
46074609
];
@@ -4652,6 +4654,8 @@ describe('lib/optimizely', function() {
46524654
variables: { i_42: 42 },
46534655
decisionEventDispatched: false,
46544656
reasons: [],
4657+
experimentId: '10420810910',
4658+
variationId: '10418551353',
46554659
},
46564660
},
46574661
];
@@ -4704,6 +4708,8 @@ describe('lib/optimizely', function() {
47044708
variables: {},
47054709
decisionEventDispatched: false,
47064710
reasons: [],
4711+
experimentId: '10420810910',
4712+
variationId: '10418551353',
47074713
},
47084714
},
47094715
];
@@ -4754,6 +4760,8 @@ describe('lib/optimizely', function() {
47544760
variables: expectedVariables,
47554761
decisionEventDispatched: true,
47564762
reasons: [],
4763+
experimentId: '18322080788',
4764+
variationId: '18257766532',
47574765
},
47584766
},
47594767
];
@@ -4807,6 +4815,8 @@ describe('lib/optimizely', function() {
48074815
variables: expectedVariables,
48084816
decisionEventDispatched: false,
48094817
reasons: [],
4818+
experimentId: '18322080788',
4819+
variationId: '18257766532',
48104820
},
48114821
},
48124822
];
@@ -4857,6 +4867,8 @@ describe('lib/optimizely', function() {
48574867
variables: expectedVariables,
48584868
decisionEventDispatched: true,
48594869
reasons: [],
4870+
experimentId: null,
4871+
variationId: null,
48604872
},
48614873
},
48624874
];
@@ -4907,6 +4919,8 @@ describe('lib/optimizely', function() {
49074919
variables: {},
49084920
decisionEventDispatched: true,
49094921
reasons: [],
4922+
experimentId: "10420810910",
4923+
variationId: "10418551353",
49104924
},
49114925
},
49124926
];
@@ -4955,6 +4969,8 @@ describe('lib/optimizely', function() {
49554969
variables: {},
49564970
decisionEventDispatched: false,
49574971
reasons: [],
4972+
experimentId: '10420810910',
4973+
variationId: '10418551353',
49584974
},
49594975
},
49604976
];
@@ -5024,6 +5040,8 @@ describe('lib/optimizely', function() {
50245040
variables: expectedVariables,
50255041
decisionEventDispatched: false,
50265042
reasons: [],
5043+
experimentId: '10420810910',
5044+
variationId: '10418551353',
50275045
},
50285046
},
50295047
];

lib/optimizely/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,9 @@ export default class Optimizely extends BaseService implements Client {
14691469
const feature = configObj.featureKeyMap[key]
14701470
const decisionSource = decisionObj.decisionSource;
14711471
const experimentKey = decisionObj.experiment?.key ?? null;
1472+
const experimentId = decisionObj.experiment?.id ?? null;
14721473
const variationKey = decisionObj.variation?.key ?? null;
1474+
const variationId = decisionObj.variation?.id ?? null;
14731475
const flagEnabled: boolean = decision.getFeatureEnabledFromVariation(decisionObj);
14741476
const variablesMap: { [key: string]: unknown } = {};
14751477
let decisionEventDispatched = false;
@@ -1516,6 +1518,8 @@ export default class Optimizely extends BaseService implements Client {
15161518
variables: variablesMap,
15171519
reasons: reportedReasons,
15181520
decisionEventDispatched: decisionEventDispatched,
1521+
experimentId: experimentId,
1522+
variationId: variationId,
15191523
};
15201524

15211525
this.notificationCenter.sendNotifications(NOTIFICATION_TYPES.DECISION, {

lib/optimizely_user_context/index.tests.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ describe('lib/optimizely_user_context', function() {
565565
userId
566566
),
567567
],
568+
experimentId: null,
569+
variationId: '3324490562'
568570
},
569571
},
570572
];
@@ -654,6 +656,8 @@ describe('lib/optimizely_user_context', function() {
654656
userId
655657
),
656658
],
659+
experimentId: '10390977673',
660+
variationId: '10416523121',
657661
},
658662
},
659663
];
@@ -734,6 +738,8 @@ describe('lib/optimizely_user_context', function() {
734738
},
735739
decisionEventDispatched: true,
736740
reasons: [],
741+
experimentId: '3332020515',
742+
variationId: '3324490633',
737743
},
738744
},
739745
];

0 commit comments

Comments
 (0)