Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
isstuev committed Jul 24, 2023
1 parent 197acc6 commit 4ec8109
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/mixpanel/isGoogleAnalyticsLoaded.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
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));
}

0 comments on commit 4ec8109

Please sign in to comment.