Skip to content

Commit

Permalink
added google analytics to firebase configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguespn committed Jan 15, 2024
1 parent 938d8d2 commit d744c1f
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 3 deletions.
12 changes: 11 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
VITE_WARD_API_BASE_URL=https://wardanalyticsapi.com
VITE_WARD_API_KEY=
VITE_WARD_API_KEY=

# Firebase config
VITE_FIREBASE_API_KEY=
VITE_FIREBASE_AUTH_DOMAIN=
VITE_FIREBASE_PROJECT_ID=
VITE_FIREBASE_STORAGE_BUCKET=
VITE_FIREBASE_MESSAGING_SENDER_ID=
VITE_FIREBASE_APP_ID=
# For Google Analytics
VITE_FIREBASE_MEASUREMENT_ID=
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
"prettier-plugin-tailwindcss"
]
}
}
}
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { QueryClientProvider } from 'react-query'

import Routes from './Routes';
import useCustomQueryClient from './hooks/useCustomQueryClient';
import './firebase/firebase'

function App() {
const queryClient = useCustomQueryClient()
Expand Down
29 changes: 29 additions & 0 deletions src/firebase/firebase.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";

const {
VITE_FIREBASE_API_KEY: apiKey,
VITE_FIREBASE_AUTH_DOMAIN: authDomain,
VITE_FIREBASE_PROJECT_ID: projectId,
VITE_FIREBASE_STORAGE_BUCKET: storageBucket,
VITE_FIREBASE_MESSAGING_SENDER_ID: messagingSenderId,
VITE_FIREBASE_APP_ID: appId,
VITE_FIREBASE_MEASUREMENT_ID: measurementId,
} = import.meta.env;

const firebaseConfig = {
apiKey: apiKey,
authDomain: authDomain,
projectId: projectId,
storageBucket: storageBucket,
messagingSenderId: messagingSenderId,
appId: appId,
measurementId: measurementId,
};

// Initialize Firebase
const app = initializeApp(firebaseConfig);
const analytics = getAnalytics(app);

export default { app, analytics };
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3007,7 +3007,7 @@ [email protected], find-up@^5.0.0:

firebase@^10.7.1:
version "10.7.1"
resolved "https://registry.npmjs.org/firebase/-/firebase-10.7.1.tgz"
resolved "https://registry.yarnpkg.com/firebase/-/firebase-10.7.1.tgz#71fa17a10146f388746ecc216a3e1e477a7bf9b5"
integrity sha512-Mlt7y7zQ43FtKp4SCyYie3tnrOL3UMF2XXiV4ZXMrC0d0wtcOYmABuybhkJpJCKILpdekxr39wjnaai0DZlWFg==
dependencies:
"@firebase/analytics" "0.10.0"
Expand Down

0 comments on commit d744c1f

Please sign in to comment.