diff --git a/__tests__/main.test.js b/__tests__/main.test.js index 9ec8d811..d920cf83 100644 --- a/__tests__/main.test.js +++ b/__tests__/main.test.js @@ -185,7 +185,7 @@ describe("MixpanelMain", () => { const optOutTrackingDefault = false; const superProperties = {superProp1: "value1", superProp2: "value2"}; const serverURL = "https://api.mixpanel.com"; - console.info("here111"); + await mixpanelMain.initialize( token, trackAutomaticEvents, diff --git a/javascript/mixpanel-queue.js b/javascript/mixpanel-queue.js index 0f1f587b..a86e2adf 100644 --- a/javascript/mixpanel-queue.js +++ b/javascript/mixpanel-queue.js @@ -2,11 +2,18 @@ import {MixpanelPersistent} from "./mixpanel-persistent"; export const MixpanelQueueManager = (() => { let _queues = {}; - const mixpanelPersistent = MixpanelPersistent.getInstance(); + let mixpanelPersistent; + + const getPersistent = () => { + if (!mixpanelPersistent) { + mixpanelPersistent = MixpanelPersistent.getInstance(); + } + return mixpanelPersistent; + }; const initialize = async (token, type) => { if (!_queues[token] || !_queues[token][type]) { - const queue = await mixpanelPersistent.loadQueue(token, type); + const queue = await getPersistent().loadQueue(token, type); _queues[token] = { ..._queues[token], [type]: queue, @@ -18,7 +25,7 @@ export const MixpanelQueueManager = (() => { if (!_queues[token] || !_queues[token][type]) { return; } - await mixpanelPersistent.saveQueue(token, type, _queues[token][type]); + await getPersistent().saveQueue(token, type, _queues[token][type]); }; const enqueue = async (token, type, data) => {