File tree Expand file tree Collapse file tree 1 file changed +21
-8
lines changed
Expand file tree Collapse file tree 1 file changed +21
-8
lines changed Original file line number Diff line number Diff 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
5366export default app ;
You can’t perform that action at this time.
0 commit comments