Skip to content

armgit / E2B

Public Imported from GitHub
0

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

Change file to ts

Tomas Valenta477c9476e455
diff --git a/utils/gtag.js b/utils/gtag.js
deleted file mode 100644
index 50d62f547..000000000
--- a/utils/gtag.js
+++ /dev/null
@@ -1,10 +0,0 @@
-export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID
-
-// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
-export const pageview = (url, user_id) => {
- window.gtag('config', GA_TRACKING_ID, {
- page_path: url,
- user_id: user_id,
- })
- // console.log('tracked pageview', url, user_id)
-}
diff --git a/utils/gtag.ts b/utils/gtag.ts
new file mode 100644
index 000000000..b764a1bbc
--- /dev/null
+++ b/utils/gtag.ts
@@ -0,0 +1,15 @@
+export const GA_TRACKING_ID = process.env.NEXT_PUBLIC_GA_ID
+
+// https://developers.google.com/analytics/devguides/collection/gtagjs/pages
+export const pageview = (url: string, user_id?: string) => {
+ if (user_id === undefined) {
+ (window as any).gtag('config', GA_TRACKING_ID, {
+ page_path: url,
+ })
+ } else {
+ (window as any).gtag('config', GA_TRACKING_ID, {
+ page_path: url,
+ user_id: user_id,
+ })
+ }
+}