mirror of
https://github.com/Vikeo/LifeTrinket.git
synced 2025-11-18 00:37:59 +00:00
Compare commits
1 Commits
main
...
bugfix/ext
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9607d5bb6c |
@@ -1,7 +1,11 @@
|
||||
{
|
||||
"hosting": {
|
||||
"public": "dist",
|
||||
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
|
||||
"ignore": [
|
||||
"firebase.json",
|
||||
"**/.*",
|
||||
"**/node_modules/**"
|
||||
],
|
||||
"rewrites": [
|
||||
{
|
||||
"source": "**",
|
||||
|
||||
@@ -1,30 +1,17 @@
|
||||
import { initializeApp } from 'firebase/app';
|
||||
import { Analytics, getAnalytics, logEvent } from 'firebase/analytics';
|
||||
import { getAnalytics, logEvent } from 'firebase/analytics';
|
||||
|
||||
const firebaseConfig = {
|
||||
apiKey: 'AIzaSyCZ1AHMb5zmWS4VoRnC-OBxTswUfrJ0mlY',
|
||||
authDomain: 'life-trinket.firebaseapp.com',
|
||||
projectId: 'life-trinket',
|
||||
storageBucket: 'life-trinket.firebasestorage.app',
|
||||
storageBucket: 'life-trinket.appspot.com',
|
||||
messagingSenderId: '508011650619',
|
||||
appId: '1:508011650619:web:bdc7d0b6f8707b1f9e861e',
|
||||
measurementId: 'G-BE86QSSG14',
|
||||
};
|
||||
|
||||
const app = initializeApp(firebaseConfig);
|
||||
let analytics: Analytics | null = null;
|
||||
|
||||
const getAnalyticsInstance = () => {
|
||||
if (!analytics) {
|
||||
try {
|
||||
analytics = getAnalytics(app);
|
||||
} catch (error) {
|
||||
console.error('Failed to initialize Firebase Analytics:', error);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return analytics;
|
||||
};
|
||||
const analytics = getAnalytics(app);
|
||||
|
||||
export const useAnalytics = () => {
|
||||
const trackEvent = (
|
||||
@@ -36,18 +23,12 @@ export const useAnalytics = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
const analyticsInstance = getAnalyticsInstance();
|
||||
if (!analyticsInstance) {
|
||||
console.warn('Analytics not available');
|
||||
return;
|
||||
}
|
||||
|
||||
const paramsWithVersion = {
|
||||
...eventParams,
|
||||
app_version: import.meta.env.VITE_APP_VERSION,
|
||||
};
|
||||
|
||||
logEvent(analyticsInstance, eventName, paramsWithVersion);
|
||||
logEvent(analytics, eventName, paramsWithVersion);
|
||||
};
|
||||
|
||||
return { trackEvent };
|
||||
|
||||
Reference in New Issue
Block a user