feat(firebase): Add Firebase SDK and initialize Analytics
This commit integrates the Firebase SDK into the application to enable Firebase services, starting with Google Analytics. Key changes include: - Added the `firebase` package as a dependency. - Included Firebase project configuration variables in the production environment file. - Created a new `firebase.ts` utility to centralize Firebase app initialization. - Integrated the `FirebaseAnalytics` component into the root layout to enable analytics tracking across the entire application.
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
"use client";
|
||||
|
||||
import { onMessage } from "firebase/messaging";
|
||||
import { useEffect, type PropsWithChildren } from "react";
|
||||
|
||||
import { messaging } from "@/services/firebase";
|
||||
import { toast } from "react-toastify";
|
||||
|
||||
const Notification = ({ children }: PropsWithChildren) => {
|
||||
useEffect(() => {
|
||||
onMessage(messaging, (payload) => {
|
||||
console.log("Message received. ", payload);
|
||||
if (payload.notification) {
|
||||
toast.success(payload.notification.title ?? "New Notification");
|
||||
}
|
||||
});
|
||||
}, []);
|
||||
|
||||
return <>{children}</>;
|
||||
};
|
||||
|
||||
export default Notification;
|
||||
Reference in New Issue
Block a user