Skip to content

Commit 9592c96

Browse files
authored
Merge pull request #3432 from dubinc/remove-posthog
Remove posthog from codebase
2 parents 0ebd7c2 + 5679daf commit 9592c96

File tree

19 files changed

+20
-197
lines changed

19 files changed

+20
-197
lines changed

apps/web/app/app.dub.co/(dashboard)/[slug]/links/page-client.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,12 @@ import {
3636
useRouterStuff,
3737
} from "@dub/ui";
3838
import { Download, Globe, TableIcon, Tag } from "@dub/ui/icons";
39-
import { useSession } from "next-auth/react";
4039
import { useRouter, useSearchParams } from "next/navigation";
41-
import posthog from "posthog-js";
4240
import { ReactNode, useEffect, useState } from "react";
4341

4442
export default function WorkspaceLinksClient() {
45-
const { data: session } = useSession();
4643
const { folderId } = useCurrentFolderId();
4744

48-
useEffect(() => {
49-
if (session?.user) {
50-
posthog.identify(session.user["id"], {
51-
email: session.user.email,
52-
name: session.user.name,
53-
});
54-
}
55-
}, [session?.user]);
56-
5745
return (
5846
<PageContentWithSidePanel
5947
title={

apps/web/app/app.dub.co/(invites)/[slug]/invite/accept-invite-button.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { mutatePrefix } from "@/lib/swr/mutate";
44
import { Button, useKeyboardShortcut } from "@dub/ui";
55
import { useSession } from "next-auth/react";
66
import { useParams, useRouter } from "next/navigation";
7-
import posthog from "posthog-js";
87
import { useState } from "react";
98
import { toast } from "sonner";
109

@@ -31,17 +30,6 @@ export function AcceptInviteButton() {
3130
return;
3231
}
3332

34-
if (session?.user) {
35-
posthog.identify(session.user["id"], {
36-
email: session.user.email,
37-
name: session.user.name,
38-
});
39-
}
40-
41-
posthog.capture("accepted_workspace_invite", {
42-
workspace: slug,
43-
});
44-
4533
await mutatePrefix(["/api/workspaces", "/api/programs"]);
4634
router.replace(`/${slug}`);
4735
toast.success("You now are a part of this workspace!");

apps/web/app/app.dub.co/(onboarding)/onboarding/welcome/track-signup.tsx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { useSession } from "next-auth/react";
44
import { usePlausible } from "next-plausible";
5-
import posthog from "posthog-js";
65
import { useEffect } from "react";
76

87
export default function TrackSignup() {
@@ -11,13 +10,6 @@ export default function TrackSignup() {
1110

1211
useEffect(() => {
1312
plausible("Signed Up");
14-
if (session?.user) {
15-
posthog.identify(session.user["id"], {
16-
email: session.user.email,
17-
name: session.user.name,
18-
});
19-
posthog.capture("user_signed_up");
20-
}
2113
}, [session?.user]);
2214

2315
return null;

apps/web/app/providers.tsx

Lines changed: 16 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,28 @@
11
"use client";
22

3-
import { PosthogPageview } from "@/ui/layout/posthog-pageview";
43
import { Analytics as DubAnalytics } from "@dub/analytics/react";
5-
import {
6-
KeyboardShortcutProvider,
7-
TooltipProvider,
8-
useRemoveGAParams,
9-
} from "@dub/ui";
4+
import { KeyboardShortcutProvider, TooltipProvider } from "@dub/ui";
105
import PlausibleProvider from "next-plausible";
11-
import posthog from "posthog-js";
12-
import { PostHogProvider } from "posthog-js/react";
136
import { ReactNode } from "react";
147
import { Toaster } from "sonner";
158

16-
if (typeof window !== "undefined" && process.env.NEXT_PUBLIC_POSTHOG_KEY) {
17-
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY!, {
18-
ui_host: "https://us.posthog.com",
19-
person_profiles: "identified_only",
20-
capture_pageview: false, // Disable automatic pageview capture, as we capture manually
21-
capture_pageleave: true, // Enable pageleave capture
22-
});
23-
}
24-
259
export default function RootProviders({ children }: { children: ReactNode }) {
26-
useRemoveGAParams();
27-
2810
return (
29-
<PostHogProvider client={posthog}>
11+
<TooltipProvider>
3012
<PlausibleProvider domain="dub.co" revenue />
31-
<TooltipProvider>
32-
<KeyboardShortcutProvider>
33-
<Toaster className="pointer-events-auto" closeButton />
34-
<PosthogPageview />
35-
{children}
36-
<DubAnalytics
37-
apiHost="/_proxy/dub"
38-
cookieOptions={{
39-
domain: process.env.VERCEL === "1" ? ".dub.co" : "localhost",
40-
}}
41-
domainsConfig={{
42-
refer: "refer.dub.co",
43-
}}
44-
/>
45-
</KeyboardShortcutProvider>
46-
</TooltipProvider>
47-
</PostHogProvider>
13+
<KeyboardShortcutProvider>
14+
<Toaster className="pointer-events-auto" closeButton />
15+
{children}
16+
<DubAnalytics
17+
apiHost="/_proxy/dub"
18+
cookieOptions={{
19+
domain: process.env.VERCEL === "1" ? ".dub.co" : "localhost",
20+
}}
21+
domainsConfig={{
22+
refer: "refer.dub.co",
23+
}}
24+
/>
25+
</KeyboardShortcutProvider>
26+
</TooltipProvider>
4827
);
4928
}

apps/web/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@
108108
"openapi-types": "^12.1.3",
109109
"openapi3-ts": "^4.2.1",
110110
"openid-client": "^6.8.0",
111-
"posthog-js": "^1.164.1",
112111
"react": "19.1.3",
113112
"react-colorful": "^5.6.1",
114113
"react-dom": "19.1.3",

apps/web/ui/analytics/use-analytics-filters.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ import {
5050
REGIONS,
5151
} from "@dub/utils";
5252
import { useParams } from "next/navigation";
53-
import posthog from "posthog-js";
5453
import {
5554
ComponentProps,
5655
ContextType,
@@ -839,10 +838,6 @@ export function useAnalyticsFilters({
839838
});
840839
}
841840
}
842-
posthog.capture("ai_filters_generated", {
843-
prompt,
844-
filters: activeFilters,
845-
});
846841
setStreaming(false);
847842
} else {
848843
queryParams({

apps/web/ui/domains/add-edit-domain-form.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ import {
3030
TextCursorInput,
3131
} from "lucide-react";
3232
import { motion } from "motion/react";
33-
import posthog from "posthog-js";
3433
import { FormEvent, useEffect, useMemo, useRef, useState } from "react";
3534
import { Controller, useForm } from "react-hook-form";
3635
import { toast } from "sonner";
@@ -249,7 +248,6 @@ export function AddEditDomainForm({
249248
mutatePrefix("/api/links"),
250249
]);
251250
const data = await res.json();
252-
posthog.capture(props ? "domain_updated" : "domain_created", data);
253251
toast.success(endpoint.successMessage);
254252
onSuccess?.(data);
255253
} else {

apps/web/ui/layout/posthog-pageview.tsx

Lines changed: 0 additions & 31 deletions
This file was deleted.

apps/web/ui/links/link-builder/tag-select.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import {
1515
Tooltip,
1616
} from "@dub/ui";
1717
import { cn } from "@dub/utils";
18-
import posthog from "posthog-js";
1918
import { memo, useEffect, useMemo, useState } from "react";
2019
import { useFormContext, useWatch } from "react-hook-form";
2120
import { toast } from "sonner";
@@ -241,10 +240,6 @@ export const TagSelect = memo(() => {
241240
setSuggestedTags((tags) =>
242241
tags.filter(({ id }) => id !== tag.id),
243242
);
244-
posthog.capture("ai_suggested_tag_selected", {
245-
tag: tag.name,
246-
url: url,
247-
});
248243
}}
249244
className="group flex items-center transition-all active:scale-95"
250245
>

apps/web/ui/links/link-builder/use-link-builder-submit.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { mutatePrefix } from "@/lib/swr/mutate";
22
import { UpgradeRequiredToast } from "@/ui/shared/upgrade-required-toast";
33
import { Button, useCopyToClipboard } from "@dub/ui";
44
import { useRouter } from "next/navigation";
5-
import posthog from "posthog-js";
65
import { useCallback } from "react";
76
import { useFormContext } from "react-hook-form";
87
import { toast } from "sonner";
@@ -80,7 +79,6 @@ export function useLinkBuilderSubmit({
8079
// if updating root domain link, mutate domains as well
8180
...(getValues("key") === "_root" ? ["/api/domains"] : []),
8281
]);
83-
posthog.capture(props ? "link_updated" : "link_created", data);
8482

8583
// copy shortlink to clipboard when adding a new link
8684
if (!props) {

0 commit comments

Comments
 (0)