Skip to content

armgit / E2B

Public Imported from GitHub
0

Open-source, secure environment with real-world tools for enterprise-grade agents.

Fix GA error

Tomas Valenta7b66365cd6ff
diff --git a/components/Layout.tsx b/components/Layout.tsx
index d699f514f..16a94429b 100644
--- a/components/Layout.tsx
+++ b/components/Layout.tsx
@@ -35,8 +35,6 @@ function Layout({ children }: PropsWithChildren) {
const [distinctID, setDistinctID] = useState<string>()
useEffect(() => {
- if (!distinctID) return
-
const handleRouteChange = (url: string) => {
gtag.pageview(url, distinctID)
}
@@ -64,20 +62,42 @@ function Layout({ children }: PropsWithChildren) {
}
}, [posthog, user])
+ const gaScript = (<>
+ <Script id="google-analytics">
+ {`
+ window.dataLayer = window.dataLayer || [];
+ function gtag(){dataLayer.push(arguments);}
+ gtag('js', new Date());
+
+ gtag('config', '${gtag.GA_TRACKING_ID}', {
+ page_path: window.location.pathname,
+ ${distinctID ? `user_id: ${distinctID}` : ''}
+ });
+ `}
+ </Script>
+ <Script
+ src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`}
+ />
+ </>
+ )
+
if (router.pathname.startsWith('/agent') || router.pathname.startsWith('/sign')) {
return (
- <div className={clsx(
- inter.variable,
- 'font-sans',
- 'flex',
- 'h-full',
- 'w-full',
- 'flex-1',
- 'flex-col',
- 'overflow-hidden',
- )}>
- {children}
- </div>
+ <>
+ {gaScript}
+ <div className={clsx(
+ inter.variable,
+ 'font-sans',
+ 'flex',
+ 'h-full',
+ 'w-full',
+ 'flex-1',
+ 'flex-col',
+ 'overflow-hidden',
+ )}>
+ {children}
+ </div>
+ </>
)
}
@@ -93,25 +113,7 @@ function Layout({ children }: PropsWithChildren) {
return (
<>
- {distinctID &&
- <>
- <Script
- src={`https://www.googletagmanager.com/gtag/js?id=${gtag.GA_TRACKING_ID}`}
- />
- <Script id="google-analytics">
- {`
- window.dataLayer = window.dataLayer || [];
- function gtag(){dataLayer.push(arguments);}
- gtag('js', new Date());
-
- gtag('config', '${gtag.GA_TRACKING_ID}', {
- page_path: window.location.pathname,
- user_id: '${distinctID}',
- });
- `}
- </Script>
- </>
- }
+ {gaScript}
<style jsx global>
{`
:root {
diff --git a/pages/_app.tsx b/pages/_app.tsx
index 39fe43713..033405bd5 100644
--- a/pages/_app.tsx
+++ b/pages/_app.tsx
@@ -35,9 +35,11 @@ function App({ Component, pageProps }: AppProps<{ initialSession?: Session, proj
const [supabaseClient] = useState(() => createBrowserSupabaseClient<Database>(clientCreds))
const router = useRouter()
+ const isAgent = router.pathname.startsWith('/agent')
+
const meta = {
- title: 'Dashboard | e2b',
- description: 'e2b Dashboard',
+ title: isAgent ? 'Smol Developer | e2b' : 'Dashboard | e2b',
+ description: isAgent ? 'Smol Developer on e2b' : 'e2b Dashboard',
}
useEffect(function trackPageViews() {
@@ -52,6 +54,7 @@ function App({ Component, pageProps }: AppProps<{ initialSession?: Session, proj
}
}, [])
+
return (
<PostHogProvider
client={process.env.NEXT_PUBLIC_POSTHOG_KEY ? posthog : undefined}
@@ -62,7 +65,7 @@ function App({ Component, pageProps }: AppProps<{ initialSession?: Session, proj
>
<Head>
<title>{meta.title}</title>
- <link rel="icon" href="/favicon.png" sizes="any"/>
+ <link rel="icon" href="/favicon.png" sizes="any" />
<meta
content="follow, index"
name="robots"
diff --git a/utils/gtag.js b/utils/gtag.js
index e53912bf1..50d62f547 100644
--- a/utils/gtag.js
+++ b/utils/gtag.js
@@ -6,5 +6,5 @@ export const pageview = (url, user_id) => {
page_path: url,
user_id: user_id,
})
- console.log('tracked pageview', url, user_id)
+ // console.log('tracked pageview', url, user_id)
}