Skip to content

Commit a4ed24c

Browse files
authored
Merge pull request #3453 from ava-labs/hub/404-tracking
Implement PostHog tracking on 404 page
2 parents 4b1605d + c180788 commit a4ed24c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

app/not-found.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { baseOptions } from "@/app/layout.config";
66
import { Button } from "@/components/ui/button";
77
import { useEffect, useState } from 'react';
88
import newGithubIssueUrl from "new-github-issue-url";
9+
import posthog from 'posthog-js';
910

1011
function createGitHubIssueURL(path: string | null) {
1112
return newGithubIssueUrl({
@@ -28,7 +29,15 @@ export default function NotFound() {
2829
useEffect(() => {
2930
if (typeof window !== 'undefined') {
3031
const path = window.location.pathname;
32+
const referrer = document.referrer;
3133
setCurrentPath(path);
34+
35+
// Track 404 page view in PostHog
36+
posthog.capture('404_page_not_found', {
37+
path: path,
38+
referrer: referrer || 'direct',
39+
url: window.location.href,
40+
});
3241
}
3342
}, []);
3443

@@ -84,4 +93,4 @@ export default function NotFound() {
8493
</div>
8594
</HomeLayout>
8695
);
87-
}
96+
}

0 commit comments

Comments
 (0)