Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

move posthog to app only

Steven Tey60d2d0974f68
diff --git a/apps/web/app/app.dub.co/(dashboard)/providers.tsx b/apps/web/app/app.dub.co/(dashboard)/providers.tsx
index 9c4006aa3a..1e878de8d5 100644
--- a/apps/web/app/app.dub.co/(dashboard)/providers.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/providers.tsx
@@ -4,15 +4,28 @@ import ModalProvider from "@/ui/modals/provider";
import { KeyboardShortcutProvider } from "@dub/ui";
import { Analytics as VercelAnalytics } from "@vercel/analytics/react";
import { SessionProvider } from "next-auth/react";
+import posthog from "posthog-js";
+import { PostHogProvider } from "posthog-js/react";
import { ReactNode } from "react";
+if (typeof window !== "undefined") {
+ posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
+ api_host: "/_proxy/ingest",
+ person_profiles: "identified_only",
+ capture_pageview: false, // Disable automatic pageview capture, as we capture manually
+ capture_pageleave: true, // Enable pageleave capture
+ });
+}
+
export default function Providers({ children }: { children: ReactNode }) {
return (
- <SessionProvider>
- <ModalProvider>
- <KeyboardShortcutProvider>{children}</KeyboardShortcutProvider>
- </ModalProvider>
- <VercelAnalytics />
- </SessionProvider>
+ <PostHogProvider client={posthog}>
+ <SessionProvider>
+ <ModalProvider>
+ <KeyboardShortcutProvider>{children}</KeyboardShortcutProvider>
+ </ModalProvider>
+ <VercelAnalytics />
+ </SessionProvider>
+ </PostHogProvider>
);
}
diff --git a/apps/web/app/providers.tsx b/apps/web/app/providers.tsx
deleted file mode 100644
index ef79bf461c..0000000000
--- a/apps/web/app/providers.tsx
+++ /dev/null
@@ -1,42 +0,0 @@
-"use client";
-
-import { Analytics as DubAnalytics } from "@dub/analytics/react";
-import { PosthogPageview } from "@dub/ui";
-import { TooltipProvider } from "@dub/ui/src/tooltip";
-import { Analytics as VercelAnalytics } from "@vercel/analytics/react";
-import posthog from "posthog-js";
-import { PostHogProvider } from "posthog-js/react";
-import { Toaster } from "sonner";
-
-if (typeof window !== "undefined") {
- posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
- api_host: "/_proxy/ingest",
- person_profiles: "identified_only",
- capture_pageview: false, // Disable automatic pageview capture, as we capture manually
- capture_pageleave: true, // Enable pageleave capture
- });
-}
-
-export default function RootProviders({
- children,
-}: {
- children: React.ReactNode;
-}) {
- return (
- <PostHogProvider client={posthog}>
- <TooltipProvider>
- <Toaster closeButton className="pointer-events-auto" />
- <PosthogPageview />
- {children}
- <DubAnalytics
- cookieOptions={{
- domain: process.env.NEXT_PUBLIC_VERCEL_ENV
- ? `.${process.env.NEXT_PUBLIC_APP_DOMAIN}`
- : undefined,
- }}
- />
- <VercelAnalytics />
- </TooltipProvider>
- </PostHogProvider>
- );
-}