-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} |