Skip to content

Commit bb24dd7

Browse files
-added experiment id and variation id to notification listener payload
-fixed unit tests to expect experiment id and variation id in notification listener payload
1 parent 85c0220 commit bb24dd7

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

lib/optimizely/index.tests.js

+18
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

+4
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,9 @@ export default class Optimizely extends BaseService implements Client {
14621462
const feature = configObj.featureKeyMap[key]
14631463
const decisionSource = decisionObj.decisionSource;
14641464
const experimentKey = decisionObj.experiment?.key ?? null;
1465+
const experimentId = decisionObj.experiment?.id ?? null;
14651466
const variationKey = decisionObj.variation?.key ?? null;
1467+
const variationId = decisionObj.variation?.id ?? null;
14661468
const flagEnabled: boolean = decision.getFeatureEnabledFromVariation(decisionObj);
14671469
const variablesMap: { [key: string]: unknown } = {};
14681470
let decisionEventDispatched = false;
@@ -1509,6 +1511,8 @@ export default class Optimizely extends BaseService implements Client {
15091511
variables: variablesMap,
15101512
reasons: reportedReasons,
15111513
decisionEventDispatched: decisionEventDispatched,
1514+
experimentId: experimentId,
1515+
variationId: variationId,
15121516
};
15131517

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

lib/optimizely_user_context/index.tests.js

+6
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,8 @@ describe('lib/optimizely_user_context', function() {
564564
userId
565565
),
566566
],
567+
experimentId: null,
568+
variationId: '3324490562'
567569
},
568570
},
569571
];
@@ -653,6 +655,8 @@ describe('lib/optimizely_user_context', function() {
653655
userId
654656
),
655657
],
658+
experimentId: '10390977673',
659+
variationId: '10416523121',
656660
},
657661
},
658662
];
@@ -733,6 +737,8 @@ describe('lib/optimizely_user_context', function() {
733737
},
734738
decisionEventDispatched: true,
735739
reasons: [],
740+
experimentId: '3332020515',
741+
variationId: '3324490633',
736742
},
737743
},
738744
];

0 commit comments

Comments
 (0)