From 309f4b26121d8bf3e6eefa1af9ee099df10538ba Mon Sep 17 00:00:00 2001 From: Chris Chinchilla Date: Wed, 17 Jun 2026 16:56:53 +0200 Subject: [PATCH] docs: Track 404 recommendation clicked (#46990) ## I have read the [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) file. YES ## Summary by CodeRabbit * **New Features** * Added analytics telemetry for documentation 404 recommendation clicks, recording the clicked destination and the originating page. * **Improvements** * Enhanced the ButtonCard component to optionally handle click actions via an `onClick` callback and forward it to the underlying link element. --- apps/docs/components/ButtonCard.tsx | 5 ++++- .../recommendations/NotFound.client.tsx | 16 ++++++++++---- packages/common/telemetry-constants.ts | 21 +++++++++++++++++++ 3 files changed, 37 insertions(+), 5 deletions(-) diff --git a/apps/docs/components/ButtonCard.tsx b/apps/docs/components/ButtonCard.tsx index f7df15298f3..a8e679f9b2c 100644 --- a/apps/docs/components/ButtonCard.tsx +++ b/apps/docs/components/ButtonCard.tsx @@ -1,6 +1,6 @@ -import React, { FC } from 'react' import Image from 'next/legacy/image' import Link from 'next/link' +import React, { FC } from 'react' import { cn } from 'ui' interface Props { @@ -11,6 +11,7 @@ interface Props { children?: any layout?: 'vertical' | 'horizontal' className?: string + onClick?: () => void } const ButtonCard: FC = ({ @@ -21,10 +22,12 @@ const ButtonCard: FC = ({ to, layout = 'vertical', className, + onClick, }) => { return ( > }) { + const pathname = usePathname() + const sendTelemetryEvent = useSendTelemetryEvent() + return (
    {recommendations @@ -76,6 +78,12 @@ function RecommendationsList({ to={path} title={title} description={subtitle || description || undefined} + onClick={() => + sendTelemetryEvent({ + action: 'docs_404_recommendation_clicked', + properties: { destinationPath: path, sourcePath: pathname ?? '' }, + }) + } /> ))}
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts index 9d73133da48..f5a8280f32d 100644 --- a/packages/common/telemetry-constants.ts +++ b/packages/common/telemetry-constants.ts @@ -838,6 +838,26 @@ export interface AskAIEvent { } } +/** + * User clicked a recommended page card shown on a docs "not found" page. + * + * @group Events + * @source docs + */ +export interface DocsRecommendation404ClickedEvent { + action: 'docs_404_recommendation_clicked' + properties: { + /** + * The path of the recommended page that was clicked. + */ + destinationPath: string + /** + * The path of the "not found" page where the recommendation was shown. + */ + sourcePath: string + } +} + /** * User clicked the framework quickstart card on the homepage, leading to the specific framework documentation. * @@ -3460,6 +3480,7 @@ export type TelemetryEvent = | DocsFeedbackClickedEvent | CopyAsMarkdownEvent | AskAIEvent + | DocsRecommendation404ClickedEvent | HomepageFrameworkQuickstartClickedEvent | HomepageProductCardClickedEvent | WwwPricingPlanCtaClickedEvent