From 57e6d9165b35eb5f1b6f4d2a792af04724dc2abe Mon Sep 17 00:00:00 2001 From: Jeremias Menichelli Date: Fri, 13 Mar 2026 16:06:58 +0100 Subject: [PATCH] feat(Docs): Track AI tools usage in Docs (#43746) --- apps/docs/components/GuidesSidebar.tsx | 12 ++++++++++++ packages/common/telemetry-constants.ts | 25 +++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/apps/docs/components/GuidesSidebar.tsx b/apps/docs/components/GuidesSidebar.tsx index 24e68d7cc83..7945943892a 100644 --- a/apps/docs/components/GuidesSidebar.tsx +++ b/apps/docs/components/GuidesSidebar.tsx @@ -11,6 +11,7 @@ import { Feedback } from '~/components/Feedback' import { useTocAnchors } from '../features/docs/GuidesMdx.state' import { Chatgpt } from 'icons' import { Claude } from 'icons' +import { useSendTelemetryEvent } from '~/lib/telemetry' interface TOCHeader { id?: string @@ -22,6 +23,7 @@ interface TOCHeader { function AiTools({ className }: { className?: string }) { const [copied, setCopied] = useState(false) const path = usePathname() + const sendTelemetryEvent = useSendTelemetryEvent() async function copyMarkdown() { const mdUrl = `/docs/${path}.md` @@ -35,6 +37,10 @@ function AiTools({ className }: { className?: string }) { } catch (error) { console.error('Failed to copy markdown', error) } + + sendTelemetryEvent({ + action: 'copy_as_markdown_clicked', + }) } return ( @@ -60,6 +66,9 @@ function AiTools({ className }: { className?: string }) { + sendTelemetryEvent({ action: 'ask_ai_clicked', properties: { agent: 'chatgpt' } }) + } rel="noreferrer noopener" className="flex items-center gap-1.5 text-xs text-foreground-lighter hover:text-foreground transition-colors" > @@ -69,6 +78,9 @@ function AiTools({ className }: { className?: string }) { + sendTelemetryEvent({ action: 'ask_ai_clicked', properties: { agent: 'claude' } }) + } rel="noreferrer noopener" className="flex items-center gap-1.5 text-xs text-foreground-lighter hover:text-foreground transition-colors" > diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts index 9ff732856ea..f6f0f40c1e6 100644 --- a/packages/common/telemetry-constants.ts +++ b/packages/common/telemetry-constants.ts @@ -747,6 +747,29 @@ export interface DocsFeedbackClickedEvent { } } +/** + * User clicked 'Copy as Markdown' option on a page. + * + * @group Events + * @source docs + */ +export interface CopyAsMarkdownEvent { + action: 'copy_as_markdown_clicked' +} + +/** + * User clicked "Ask..." to open a new window to consult an agent about the current page. + * + * @group Events + * @source docs + */ +export interface AskAIEvent { + action: 'ask_ai_clicked' + properties: { + agent: 'chatgpt' | 'claude' + } +} + /** * User clicked the framework quickstart card on the homepage, leading to the specific framework documentation. * @@ -2974,6 +2997,8 @@ export type TelemetryEvent = | AssistantEditInSqlEditorClickedEvent | AssistantMessageRatingSubmittedEvent | DocsFeedbackClickedEvent + | CopyAsMarkdownEvent + | AskAIEvent | HomepageFrameworkQuickstartClickedEvent | HomepageProductCardClickedEvent | WwwPricingPlanCtaClickedEvent