Skip to content

Commit

Permalink
new google analytics event on search address
Browse files Browse the repository at this point in the history
  • Loading branch information
Rodriguespn committed Jan 15, 2024
1 parent d744c1f commit 0059f48
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/components/Graph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ import TransactionTooltip, {
} from "./TransactionTooltip";
import { Transition } from "@headlessui/react";

import { default as firebase } from "../../firebase/firebase"
import { logEvent } from "firebase/analytics";

/* Pan on drag settings */
const panOnDrag = [1, 2];

Expand Down Expand Up @@ -394,6 +397,14 @@ const GraphProvided: FC<GraphProvidedProps> = ({ initialNodes }) => {
const Graph: FC = () => {
const [searchedAddress, setSearchedAddress] = useState<string | null>(null);

const onSetSearchedAddress = (newAddress: string) => {
setSearchedAddress(newAddress);

logEvent(firebase.analytics, "search_address", {
address: newAddress,
});
}

return (
<div className="overflow-hidden">
<Transition
Expand All @@ -404,7 +415,7 @@ const Graph: FC = () => {
leaveTo="opacity-0 scale-50"
className="fixed flex h-full w-full flex-col items-center justify-center"
>
<LandingPage setSearchedAddress={setSearchedAddress} />
<LandingPage setSearchedAddress={onSetSearchedAddress} />
</Transition>
<Transition
show={searchedAddress !== null}
Expand Down
13 changes: 8 additions & 5 deletions src/firebase/firebase.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Import the functions you need from the SDKs you need
import { initializeApp } from "firebase/app";
import { getAnalytics } from "firebase/analytics";
import { Analytics, getAnalytics } from "firebase/analytics";
import { FirebaseApp, initializeApp } from "firebase/app";

const {
VITE_FIREBASE_API_KEY: apiKey,
Expand All @@ -23,7 +23,10 @@ const firebaseConfig = {
};

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

export default { app, analytics };
export default {
app,
analytics,
};

0 comments on commit 0059f48

Please sign in to comment.