Skip to content

Commit 5d15147

Browse files
committed
replace posthog with google analytics
1 parent 4da5603 commit 5d15147

File tree

14 files changed

+48
-196
lines changed

14 files changed

+48
-196
lines changed

.github/workflows/deploy.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ jobs:
4545
push: true
4646
tags: ghcr.io/gitranks/gitranks-ui:latest
4747
build-args: |
48-
NEXT_PUBLIC_POSTHOG_KEY=${{ vars.NEXT_PUBLIC_POSTHOG_KEY }}
4948
NEXT_PUBLIC_URI=${{ vars.NEXT_PUBLIC_URI }}
5049
INTERNAL_JWT_SECRET=${{ secrets.INTERNAL_JWT_SECRET }}
5150
URI_GITRANKS=${{ vars.URI_GITRANKS }}
@@ -77,6 +76,5 @@ jobs:
7776
-e AUTH_URL='${{ vars.AUTH_URL }}' \
7877
-e AUTH_TRUST_HOST=true \
7978
-e NEXT_PUBLIC_URI='${{ vars.NEXT_PUBLIC_URI }}' \
80-
-e NEXT_PUBLIC_POSTHOG_KEY='${{ vars.NEXT_PUBLIC_POSTHOG_KEY }}' \
8179
-p 3000:3000 \
8280
ghcr.io/gitranks/gitranks-ui:latest

Dockerfile

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ FROM node:22-alpine AS base
66
# for now just make nextjs happy by setting this variable
77
ENV MONGODB_URI_AUTH=mongodb://localhost:27020/auth
88

9-
ARG NEXT_PUBLIC_POSTHOG_KEY
10-
ENV NEXT_PUBLIC_POSTHOG_KEY=$NEXT_PUBLIC_POSTHOG_KEY
11-
129
ARG NEXT_PUBLIC_URI
1310
ENV NEXT_PUBLIC_URI=$NEXT_PUBLIC_URI
1411

app/api/badge/[login]/route.tsx

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { BadgeTemplateType } from '@/badge/badge.types';
55
import { BadgeZodSchema } from '@/badge/badge.zod';
66
import { renderMediumBadge } from '@/badge/templates/medium/medium.render';
77
import { renderSmallBadge } from '@/badge/templates/small/small.render';
8-
import { posthog } from '@/lib/posthog/posthog-node-client';
98

109
type Props = { params: Promise<{ login: string }> };
1110

@@ -37,12 +36,6 @@ export async function GET(req: NextRequest, { params }: Props) {
3736

3837
const { rankingType, template, theme } = validationResult.data;
3938

40-
posthog.capture({
41-
distinctId: login,
42-
event: 'badge_rendered',
43-
properties: { rankingType, template, theme },
44-
});
45-
4639
const svg = await getRendererByTemplate(template)({ theme, login, rankingType });
4740

4841
if (!svg) {

app/api/badge/v2/[login]/route.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { NextRequest } from 'next/server';
33

44
import { BadgeV2ZodSchema } from '@/badge/badge.zod';
55
import { renderInlineBadge } from '@/badge/templates/inline/inline.render';
6-
import { posthog } from '@/lib/posthog/posthog-node-client';
76

87
type Props = { params: Promise<{ login: string }> };
98

@@ -24,14 +23,14 @@ export async function GET(req: NextRequest, { params }: Props) {
2423
});
2524
}
2625

27-
const userAgent = req.headers.get('user-agent');
28-
const referer = req.headers.get('referer');
26+
// const userAgent = req.headers.get('user-agent');
27+
// const referer = req.headers.get('referer');
2928

30-
posthog.capture({
31-
distinctId: login,
32-
event: 'badge_v2_rendered',
33-
properties: { userAgent, referer },
34-
});
29+
// capture({
30+
// distinctId: login,
31+
// event: 'badge_v2_rendered',
32+
// properties: { userAgent, referer },
33+
// });
3534

3635
const svg = await renderInlineBadge({ login, params: validationResult.data });
3736

app/components/search-profiile.tsx

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,29 @@
22

33
import { Search } from 'lucide-react';
44
import { useRouter } from 'next/navigation';
5-
import { usePostHog } from 'posthog-js/react';
65
import { useState } from 'react';
76
import { ClipLoader } from 'react-spinners';
87

98
import { Button } from '@/components/ui/button';
109
import { Input } from '@/components/ui/input';
11-
import { graphqlClient } from '@/lib/graphql/graphql-client';
12-
import { ProfileIdByLoginDocument } from '@/types/generated/graphql';
1310

1411
export const SearchProfile = () => {
1512
const [login, setLogin] = useState('');
1613
const [loading, setLoading] = useState(false);
1714
const router = useRouter();
18-
const posthog = usePostHog();
1915

2016
const onSearch = async () => {
2117
if (!login) {
2218
return;
2319
}
2420

2521
setLoading(true);
26-
const data = await graphqlClient(ProfileIdByLoginDocument, { login });
27-
28-
const profileFound = data.globalRankByLogin?.githubId;
29-
30-
posthog.capture('landingPage.search', {
31-
login,
32-
profileFound,
33-
});
22+
// const data = await graphqlClient(ProfileIdByLoginDocument, { login });
23+
// const profileFound = data.globalRankByLogin?.githubId;
24+
// capture('landingPage.search', {
25+
// login,
26+
// profileFound,
27+
// });
3428

3529
return router.push(`/profile/${login}`);
3630
};

app/layout.tsx

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { GoogleAnalytics } from '@next/third-parties/google';
12
import type { Metadata } from 'next';
23
import { Inter } from 'next/font/google';
34
import { SessionProvider } from 'next-auth/react';
@@ -6,7 +7,6 @@ import { NuqsAdapter } from 'nuqs/adapters/next/app';
67
import { Footer } from '@/components/footer/footer';
78
import { ThemeProvider } from '@/components/theme-provider/theme-provider';
89
import { Toaster } from '@/components/ui/sonner';
9-
import { PostHogClientOnlyProvider } from '@/lib/posthog/post-hog-client-only';
1010

1111
import { FlagEmojiPolyfill } from './components/flag-emoji-polyfill';
1212

@@ -31,20 +31,19 @@ export default function RootLayout({ children }: LayoutProps<'/'>) {
3131
style={{ ...inter.style, fontFamily: `'Twemoji Country Flags', ${inter.style.fontFamily}` }}
3232
>
3333
<SessionProvider>
34-
<PostHogClientOnlyProvider>
35-
<NuqsAdapter>
36-
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
37-
<FlagEmojiPolyfill />
38-
<div className="flex flex-col min-h-screen">
39-
<div className="flex-grow">{children}</div>
40-
<Footer />
41-
</div>
42-
<Toaster richColors position="top-right" />
43-
</ThemeProvider>
44-
</NuqsAdapter>
45-
</PostHogClientOnlyProvider>
34+
<NuqsAdapter>
35+
<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange>
36+
<FlagEmojiPolyfill />
37+
<div className="flex flex-col min-h-screen">
38+
<div className="flex-grow">{children}</div>
39+
<Footer />
40+
</div>
41+
<Toaster richColors position="top-right" />
42+
</ThemeProvider>
43+
</NuqsAdapter>
4644
</SessionProvider>
4745
</body>
46+
<GoogleAnalytics gaId="G-YKY54NVEGK" />
4847
</html>
4948
);
5049
}

app/profile/[login]/components/fetch-user-button.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import { RefreshCw } from 'lucide-react';
44
import { useParams } from 'next/navigation';
55
import { signIn, useSession } from 'next-auth/react';
6-
import { usePostHog } from 'posthog-js/react';
76
import {
87
Children,
98
cloneElement,
@@ -54,7 +53,6 @@ export const FetchUserButton: FC<FetchUserButtonProps> = ({
5453
}) => {
5554
const { data: session } = useSession();
5655
const { login } = useParams<{ login: string }>();
57-
const posthog = usePostHog();
5856
const fetchAttempt = useRef(0);
5957
const timerRef = useRef<NodeJS.Timeout | null>(null);
6058
const [loadingLabel, setLoadingLabel] = useState(FETCH_MESSAGES[fetchAttempt.current]);
@@ -109,7 +107,7 @@ export const FetchUserButton: FC<FetchUserButtonProps> = ({
109107
const fetchUser = async () => {
110108
setFetchingDuration(0);
111109

112-
posthog.capture('profile.fetch', { login });
110+
// capture('profile.fetch', { login });
113111

114112
// immediately invalidate the cache, so if the user reloads the page, the latest data is fetched
115113
fetch(`/api/revalidate?tag=${encodeURIComponent(`profile:${login}`)}`);

components/header/components/main-menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
} from '@/components/ui/navigation-menu';
1919
import { cn } from '@/lib/utils';
2020

21-
export function MainMenu({ className }: { className?: string }) {
21+
export function MainMenu({ className }: Readonly<{ className?: string }>) {
2222
return (
2323
<NavigationMenu className={className}>
2424
<NavigationMenuList>

lib/posthog/post-hog-client-only.tsx

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

lib/posthog/post-hog-provider.tsx

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

0 commit comments

Comments
 (0)