aboutsummaryrefslogtreecommitdiff
path: root/apps/web
diff options
context:
space:
mode:
authorDhravya Shah <[email protected]>2024-08-06 12:55:43 -0700
committerDhravya Shah <[email protected]>2024-08-06 12:55:43 -0700
commitbe05d4fe7f7bc8edc2aad18daecdb8e67f28b29f (patch)
treef24556e993ec21a3b6aa78ffadf418aa279511f4 /apps/web
parentuncomment (diff)
downloadsupermemory-be05d4fe7f7bc8edc2aad18daecdb8e67f28b29f.tar.xz
supermemory-be05d4fe7f7bc8edc2aad18daecdb8e67f28b29f.zip
posthog
Diffstat (limited to 'apps/web')
-rw-r--r--apps/web/app/layout.tsx23
-rw-r--r--apps/web/app/providers.js14
-rw-r--r--apps/web/cf-env.d.ts2
-rw-r--r--apps/web/package.json1
-rw-r--r--apps/web/tsconfig.json3
5 files changed, 32 insertions, 11 deletions
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsx
index 94a538ed..b3a0b485 100644
--- a/apps/web/app/layout.tsx
+++ b/apps/web/app/layout.tsx
@@ -6,6 +6,7 @@ import { GeistSans } from "geist/font/sans";
import { GeistMono } from "geist/font/mono";
import { cn } from "@repo/ui/lib/utils";
import { Toaster } from "@repo/ui/shadcn/toaster";
+import { CSPostHogProvider } from "./providers";
const inter = Inter({ subsets: ["latin"] });
@@ -75,16 +76,18 @@ export default function RootLayout({
></script>
</head>
{/* TODO: when lightmode support is added, remove the 'dark' class from the body tag */}
- <body
- className={cn(
- `${inter.className} dark`,
- GeistMono.variable,
- GeistSans.variable,
- )}
- >
- {children}
- <Toaster />
- </body>
+ <CSPostHogProvider>
+ <body
+ className={cn(
+ `${inter.className} dark`,
+ GeistMono.variable,
+ GeistSans.variable,
+ )}
+ >
+ {children}
+ <Toaster />
+ </body>
+ </CSPostHogProvider>
</html>
);
}
diff --git a/apps/web/app/providers.js b/apps/web/app/providers.js
new file mode 100644
index 00000000..3715157f
--- /dev/null
+++ b/apps/web/app/providers.js
@@ -0,0 +1,14 @@
+"use client";
+import posthog from "posthog-js";
+import { PostHogProvider } from "posthog-js/react";
+
+if (typeof window !== "undefined") {
+ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY, {
+ api_host: process.env.NEXT_PUBLIC_POSTHOG_HOST,
+ person_profiles: "identified_only",
+ });
+}
+
+const CSPostHogProvider = ({ children }) => {
+ return <PostHogProvider client={posthog}>{children}</PostHogProvider>;
+};
diff --git a/apps/web/cf-env.d.ts b/apps/web/cf-env.d.ts
index 09b0690b..10891f9b 100644
--- a/apps/web/cf-env.d.ts
+++ b/apps/web/cf-env.d.ts
@@ -26,6 +26,8 @@ declare global {
RATELIMITER: {
limit: ({ key: string }) => { success: boolean };
};
+ NEXT_PUBLIC_POSTHOG_KEY: string;
+ NEXT_PUBLIC_POSTHOG_HOST: string;
}
}
}
diff --git a/apps/web/package.json b/apps/web/package.json
index d3bf1f48..4c0d57cd 100644
--- a/apps/web/package.json
+++ b/apps/web/package.json
@@ -30,6 +30,7 @@
"next": "^14.1.1",
"novel": "^0.4.2",
"nuqs": "^1.17.4",
+ "posthog-js": "^1.154.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-resizable-panels": "^2.0.19",
diff --git a/apps/web/tsconfig.json b/apps/web/tsconfig.json
index 7072be89..ac67adbb 100644
--- a/apps/web/tsconfig.json
+++ b/apps/web/tsconfig.json
@@ -19,7 +19,8 @@
".next/types/**/*.ts",
"../../packages/ui/",
"../../packages/shared-types",
- "./components"
+ "./components",
+ "app/providers.js"
],
"exclude": ["node_modules/"]
}