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)); }