Skip to content

Commit 553b9d0

Browse files
authored
Merge 88d0a1c into b5f96dd
2 parents b5f96dd + 88d0a1c commit 553b9d0

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

packages/remote-config/src/abt/experiment.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class Experiment {
3939
const currentActiveExperiments =
4040
(await this.storage.getActiveExperiments()) || new Set<string>();
4141
const experimentInfoMap = this.createExperimentInfoMap(latestExperiments);
42-
this.addActiveExperiments(currentActiveExperiments, experimentInfoMap);
42+
this.addActiveExperiments(experimentInfoMap);
4343
this.removeInactiveExperiments(currentActiveExperiments, experimentInfoMap);
4444
return this.storage.setActiveExperiments(new Set(experimentInfoMap.keys()));
4545
}
@@ -55,14 +55,11 @@ export class Experiment {
5555
}
5656

5757
private addActiveExperiments(
58-
currentActiveExperiments: Set<string>,
5958
experimentInfoMap: Map<string, FirebaseExperimentDescription>
6059
): void {
6160
const customProperty: Record<string, string | null> = {};
6261
for (const [experimentId, experimentInfo] of experimentInfoMap.entries()) {
63-
if (!currentActiveExperiments.has(experimentId)) {
64-
customProperty[experimentId] = experimentInfo.variantId;
65-
}
62+
customProperty[`firebase${experimentId}`] = experimentInfo.variantId;
6663
}
6764
this.addExperimentToAnalytics(customProperty);
6865
}
@@ -74,7 +71,7 @@ export class Experiment {
7471
const customProperty: Record<string, string | null> = {};
7572
for (const experimentId of currentActiveExperiments) {
7673
if (!experimentInfoMap.has(experimentId)) {
77-
customProperty[experimentId] = null;
74+
customProperty[`firebase${experimentId}`] = null;
7875
}
7976
}
8077
this.addExperimentToAnalytics(customProperty);
@@ -89,7 +86,8 @@ export class Experiment {
8986
try {
9087
const analytics = this.analyticsProvider.getImmediate({ optional: true });
9188
if (analytics) {
92-
analytics.setUserProperties({ properties: customProperty });
89+
analytics.setUserProperties(customProperty);
90+
analytics.logEvent(`set_firebase_experiment_state`);
9391
} else {
9492
this.logger.warn(`Analytics import failed`);
9593
}

packages/remote-config/test/abt/experiment.test.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ describe('Experiment', () => {
4141
storage.getActiveExperiments = sinon.stub();
4242
storage.setActiveExperiments = sinon.stub();
4343
analyticsProvider.getImmediate = sinon.stub().returns({
44-
setUserProperties: sinon.stub()
44+
setUserProperties: sinon.stub(),
45+
logEvent: sinon.stub()
4546
});
4647
});
4748

@@ -81,7 +82,9 @@ describe('Experiment', () => {
8182
expectedStoredExperiments
8283
);
8384
expect(analytics.setUserProperties).to.have.been.calledWith({
84-
properties: { '_exp_3': '1' }
85+
'firebase_exp_3': '1',
86+
'firebase_exp_1': '2',
87+
'firebase_exp_2': '1'
8588
});
8689
});
8790

@@ -107,7 +110,7 @@ describe('Experiment', () => {
107110
expectedStoredExperiments
108111
);
109112
expect(analytics.setUserProperties).to.have.been.calledWith({
110-
properties: { '_exp_2': null }
113+
'firebase_exp_2': null
111114
});
112115
});
113116
});

0 commit comments

Comments
 (0)