From 4ec81096cc7b9ded9fbd4393c7bf01d629eab209 Mon Sep 17 00:00:00 2001 From: isstuev Date: Mon, 24 Jul 2023 11:20:33 -0300 Subject: [PATCH] fix --- lib/mixpanel/isGoogleAnalyticsLoaded.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/mixpanel/isGoogleAnalyticsLoaded.ts b/lib/mixpanel/isGoogleAnalyticsLoaded.ts index cc89416b4f..54366e4279 100644 --- a/lib/mixpanel/isGoogleAnalyticsLoaded.ts +++ b/lib/mixpanel/isGoogleAnalyticsLoaded.ts @@ -1,10 +1,9 @@ -function wait() { - return new Promise(resolve => setTimeout(resolve, 500)); -} +import appConfig from 'configs/app/config'; +import delay from 'lib/delay'; export default function isGoogleAnalyticsLoaded(retries = 3): Promise { - if (!retries) { + if (!retries || !appConfig.googleAnalytics.propertyId) { return Promise.resolve(false); } - return typeof window.ga?.getAll === 'function' ? Promise.resolve(true) : wait().then(() => isGoogleAnalyticsLoaded(retries - 1)); + return typeof window.ga?.getAll === 'function' ? Promise.resolve(true) : delay(500).then(() => isGoogleAnalyticsLoaded(retries - 1)); }