Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/site/src/app/not-found.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import GlitchParticles from "@/components/glitch-particles";
import { NotFoundTracker } from "@/components/not-found-tracker";
import type { Metadata } from "next";
import Link from "next/link";

export const metadata: Metadata = {
title: "404 - Page Not Found",
Expand All @@ -10,6 +10,7 @@ export const metadata: Metadata = {
export default function NotFound() {
return (
<main className="flex-1 w-full max-w-249 mx-auto px-4 py-8 z-1">
<NotFoundTracker />
<h1 className="pointer-events-none absolute opacity-0 stretch-display text-4xl font-bold mb-2 landing-h1 text-center mt-9 font-sans-display">
Prisma Website | 404
</h1>
Expand Down
15 changes: 15 additions & 0 deletions apps/site/src/components/not-found-tracker.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use client";

import posthog from "posthog-js";
import { useEffect } from "react";

export function NotFoundTracker() {
useEffect(() => {
posthog.capture("site:404_not_found", {
$current_url: window.location.href,
pathname: window.location.pathname,
Comment on lines +8 to +10
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid sending raw full URL in the 404 analytics payload.

$current_url: window.location.href can include sensitive query/hash data (tokens, emails, IDs). For a 404 signal, pathname is usually sufficient and safer.

🔧 Suggested change
   useEffect(() => {
     posthog.capture("site:404_not_found", {
-      $current_url: window.location.href,
       pathname: window.location.pathname,
     });
   }, []);
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
posthog.capture("site:404_not_found", {
$current_url: window.location.href,
pathname: window.location.pathname,
useEffect(() => {
posthog.capture("site:404_not_found", {
pathname: window.location.pathname,
});
}, []);
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/site/src/components/not-found-tracker.tsx` around lines 8 - 10, The
posthog.capture call in components/not-found-tracker.tsx is sending
window.location.href (raw full URL) which may leak sensitive query/hash data;
update the payload used by posthog.capture("site:404_not_found", ...) to omit
the full href and instead use only the safe path (window.location.pathname) or a
sanitized URL built from window.location.origin + window.location.pathname
(explicitly excluding window.location.search and window.location.hash). Locate
the posthog.capture invocation and remove or replace the $current_url field
accordingly so only pathname or the sanitized origin+pathname is sent.

});
}, []);

return null;
}
Loading