mirror of
https://github.com/Vikeo/LifeTrinket.git
synced 2025-11-11 21:56:25 +00:00
31 lines
842 B
TypeScript
31 lines
842 B
TypeScript
import { initializeApp } from 'firebase/app';
|
|
import { getAnalytics, logEvent } from 'firebase/analytics';
|
|
|
|
const firebaseConfig = {
|
|
apiKey: 'AIzaSyCZ1AHMb5zmWS4VoRnC-OBxTswUfrJ0mlY',
|
|
authDomain: 'life-trinket.firebaseapp.com',
|
|
projectId: 'life-trinket',
|
|
storageBucket: 'life-trinket.appspot.com',
|
|
messagingSenderId: '508011650619',
|
|
appId: '1:508011650619:web:bdc7d0b6f8707b1f9e861e',
|
|
};
|
|
|
|
const app = initializeApp(firebaseConfig);
|
|
const analytics = getAnalytics(app);
|
|
|
|
export const useAnalytics = () => {
|
|
const trackEvent = (
|
|
eventName: string,
|
|
eventParams?: { [key: string]: unknown }
|
|
) => {
|
|
if (process.env.NODE_ENV === 'development') {
|
|
console.info('Event not tracked:', { eventName, eventParams });
|
|
return;
|
|
}
|
|
|
|
logEvent(analytics, eventName, eventParams);
|
|
};
|
|
|
|
return { trackEvent };
|
|
};
|