From f3be4c88da67b89dc7bc999606293c11c2a99986 Mon Sep 17 00:00:00 2001 From: Sol Irvine Date: Wed, 6 Sep 2023 16:25:27 -0700 Subject: [PATCH] Delete google-provider.tsx --- app/context/google-provider.tsx | 54 --------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 app/context/google-provider.tsx diff --git a/app/context/google-provider.tsx b/app/context/google-provider.tsx deleted file mode 100644 index 4b2c5c77a..000000000 --- a/app/context/google-provider.tsx +++ /dev/null @@ -1,54 +0,0 @@ -'use client'; - -import { FunctionComponent, useEffect } from 'react'; - -import { useRouter } from 'next/navigation'; -import ReactGA from 'react-ga'; -import TagManager from 'react-gtm-module'; - -type GoogleLayerProps = { - isShowing: boolean; - /* eslint-disable-next-line no-undef */ - children: JSX.Element | JSX.Element[] | string; -}; - -export function logPageView() { - ReactGA.pageview(window.location.pathname); -} - -export function logEvent(action: any, category: any, label: any) { - ReactGA.event({ action, category, label }); -} - -export const GoogleProvider: FunctionComponent = ({ isShowing, children }) => { - const router = useRouter(); - - useEffect(() => { - const onRouteChangeComplete = async () => { - logPageView(); - }; - - if (isShowing) { - if (process.env.NEXT_PUBLIC_GA_UA_ID) { - ReactGA.initialize(process.env.NEXT_PUBLIC_GA_UA_ID, { - debug: false - }); - //* Record current pageview following initialization - onRouteChangeComplete(); - //* Record a pageview when route changes - router.events.on('routeChangeComplete', onRouteChangeComplete); - } - if (process.env.NEXT_PUBLIC_GTM_ID) { - TagManager.initialize({ - gtmId: process.env.NEXT_PUBLIC_GTM_ID - }); - } - } - //* Unassign event listener - return () => { - router.events.off('routeChangeComplete', onRouteChangeComplete); - }; - }, [isShowing, router]); - - return <>{children}; -};