Skip to content
Open
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
35 changes: 35 additions & 0 deletions packages/fern-docs/bundle/src/app/[host]/[domain]/error.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"use client";

import { FernButton } from "@fern-docs/components/FernButton";
import GradientExclamation from "@fern-docs/components/GradientExclamation";
import { HiddenSidebar } from "@fern-docs/components/theming/HiddenSidebar";
import { useEffect } from "react";

import { NotFound404Tracker } from "@/components/analytics/NotFound404Tracker";
import ReturnHomeButton from "@/components/ReturnHomeButton";

export default function ErrorBoundary({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
useEffect(() => {
console.error(`[domain-error-boundary] ${JSON.stringify(error)}`);
}, [error]);

return (
<>
<NotFound404Tracker />
Copy link
Contributor

Choose a reason for hiding this comment

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

The error boundary incorrectly uses NotFound404Tracker, which will track all rendering errors as "not_found" events in analytics instead of just actual 404 errors.

View Details
📝 Patch Details
diff --git a/packages/fern-docs/bundle/src/app/[host]/[domain]/error.tsx b/packages/fern-docs/bundle/src/app/[host]/[domain]/error.tsx
index 996a4b0f3..707d9a88a 100644
--- a/packages/fern-docs/bundle/src/app/[host]/[domain]/error.tsx
+++ b/packages/fern-docs/bundle/src/app/[host]/[domain]/error.tsx
@@ -5,7 +5,7 @@ import GradientExclamation from "@fern-docs/components/GradientExclamation";
 import { HiddenSidebar } from "@fern-docs/components/theming/HiddenSidebar";
 import { useEffect } from "react";
 
-import { NotFound404Tracker } from "@/components/analytics/NotFound404Tracker";
+
 import ReturnHomeButton from "@/components/ReturnHomeButton";
 
 export default function ErrorBoundary({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
@@ -15,7 +15,6 @@ export default function ErrorBoundary({ error, reset }: { error: Error & { diges
 
     return (
         <>
-            <NotFound404Tracker />
             <HiddenSidebar />
             <div className="flex h-[calc(100svh-var(--header-height)-6rem)] w-screen flex-col items-center justify-center gap-6">
                 <GradientExclamation />

Analysis

Error boundary incorrectly tracks rendering errors as 404 events in analytics

What fails: ErrorBoundary in packages/fern-docs/bundle/src/app/[host]/[domain]/error.tsx uses NotFound404Tracker component, which sends "not_found" events to PostHog for all rendering errors instead of actual 404 scenarios

How to reproduce:

  1. Trigger any rendering error in a [host]/[domain] route (e.g., component crash, JavaScript error)
  2. Check PostHog analytics - error will be logged as "not_found" event instead of error event

Result: All rendering errors tracked as 404 events, polluting 404 analytics and making it impossible to distinguish actual missing pages from component failures

Expected: Error boundaries should not track analytics events, consistent with other error boundaries in the codebase (see packages/fern-docs/bundle/src/app/error.tsx which has no analytics tracking). NotFound404Tracker should only be used in actual not-found.tsx files per its JSDoc documentation: "Should be added to not-found pages to capture analytics when users hit a 404"

<HiddenSidebar />
<div className="flex h-[calc(100svh-var(--header-height)-6rem)] w-screen flex-col items-center justify-center gap-6">
<GradientExclamation />
<div className="flex flex-col text-center">
<h1>We&apos;ve encountered an error!</h1>
<p className="text-(color:--grayscale-a9)">Please try again. If the problem persists, contact support.</p>
</div>
<div className="flex flex-col gap-3 sm:flex-row">
<FernButton intent="primary" onClick={reset}>
Try again
</FernButton>
<ReturnHomeButton />
</div>
</div>
</>
);
}
Loading