Skip to content

Commit

Permalink
fix: dont allow double initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bgiori committed Oct 9, 2024
1 parent 818cee7 commit d0c8ecc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions packages/experiment-browser/src/integration/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,9 @@ export class PersistentTrackingQueue {
constructor(instanceName: string, maxQueueSize: number = MAX_QUEUE_SIZE) {
this.storageKey = `EXP_unsent_${instanceName}`;
this.maxQueueSize = maxQueueSize;
this.loadQueue();
this.flush();
this.storeQueue();
}

push(event: ExperimentEvent): void {
Expand Down
9 changes: 6 additions & 3 deletions packages/experiment-tag/src/experiment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,16 @@ const appliedMutations: MutationController[] = [];
let previousUrl: string | undefined = undefined;

export const initializeExperiment = (apiKey: string, initialFlags: string) => {
WindowMessenger.setup();
const experimentStorageName = `EXP_${apiKey.slice(0, 10)}`;
const globalScope = getGlobalScope();

if (globalScope?.webExperiment) {
return;
}
WindowMessenger.setup();
if (!isLocalStorageAvailable() || !globalScope) {
return;
}

const experimentStorageName = `EXP_${apiKey.slice(0, 10)}`;
let user: ExperimentUser;
try {
user = JSON.parse(
Expand Down

0 comments on commit d0c8ecc

Please sign in to comment.