Skip to content

Commit a41687a

Browse files
Fix: Build error on Vercel
Fixed a build error on Vercel related to top-level await in the Firebase configuration.
1 parent a181113 commit a41687a

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/lib/firebase.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,30 @@ googleProvider.setCustomParameters({
3737
prompt: 'select_account'
3838
});
3939

40-
// Analytics avec vérification de support
41-
export const analytics = await (async () => {
40+
// Analytics avec gestion asynchrone sans top-level await
41+
let analyticsInstance: any = null;
42+
43+
const initializeAnalytics = async () => {
4244
try {
43-
if (typeof window !== 'undefined' && firebaseConfig.measurementId && await isSupported()) {
44-
return getAnalytics(app);
45+
if (typeof window !== 'undefined' && firebaseConfig.measurementId) {
46+
const supported = await isSupported();
47+
if (supported) {
48+
analyticsInstance = getAnalytics(app);
49+
console.log('✅ Firebase Analytics initialisé');
50+
} else {
51+
console.warn('⚠️ Firebase Analytics non supporté dans cet environnement');
52+
}
4553
}
46-
return null;
4754
} catch (error) {
48-
console.warn('Analytics non disponible dans cet environnement');
49-
return null;
55+
console.warn('⚠️ Erreur lors de l\'initialisation d\'Analytics:', error);
5056
}
51-
})();
57+
};
58+
59+
// Initialiser Analytics de manière asynchrone
60+
if (typeof window !== 'undefined') {
61+
initializeAnalytics();
62+
}
63+
64+
export const getAnalyticsInstance = () => analyticsInstance;
5265

5366
export default app;

0 commit comments

Comments
 (0)