Skip to content

Commit 86af43e

Browse files
author
Athira M
committed
Bug fixes
1 parent b5f96dd commit 86af43e

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

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

Lines changed: 3 additions & 5 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[experimentId] = experimentInfo.variantId;
6663
}
6764
this.addExperimentToAnalytics(customProperty);
6865
}
@@ -90,6 +87,7 @@ export class Experiment {
9087
const analytics = this.analyticsProvider.getImmediate({ optional: true });
9188
if (analytics) {
9289
analytics.setUserProperties({ properties: customProperty });
90+
analytics.logEvent(`Received ABT experiment update`);
9391
} else {
9492
this.logger.warn(`Analytics import failed`);
9593
}

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

Lines changed: 3 additions & 2 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,7 @@ describe('Experiment', () => {
8182
expectedStoredExperiments
8283
);
8384
expect(analytics.setUserProperties).to.have.been.calledWith({
84-
properties: { '_exp_3': '1' }
85+
properties: { '_exp_3': '1', '_exp_1': '2', '_exp_2': '1' }
8586
});
8687
});
8788

0 commit comments

Comments
 (0)