Unverified Commit 356bcdec authored by Thomas Wang's avatar Thomas Wang Committed by GitHub

Move `window` check to after initializing Firebase (#20764)

You can initialize the Firebase app instance without checking for window, but it is required for using the analytics module.
parent c8bc17f3
......@@ -15,13 +15,15 @@ const clientCredentials = {
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
}
// Check that `window` is in scope for the analytics module!
if (typeof window !== 'undefined' && !firebase.apps.length) {
if (!firebase.apps.length) {
firebase.initializeApp(clientCredentials)
// To enable analytics. https://firebase.google.com/docs/analytics/get-started
if ('measurementId' in clientCredentials) {
firebase.analytics()
firebase.performance()
// Check that `window` is in scope for the analytics module!
if (typeof window !== 'undefined') {
// Enable analytics. https://firebase.google.com/docs/analytics/get-started
if ('measurementId' in clientCredentials) {
firebase.analytics()
firebase.performance()
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment