Skip to content

fix: analytics harness & identity detections#235

Merged
Kinfe123 merged 6 commits into
mainfrom
fix/analytics-harness-with-test
May 31, 2026
Merged

fix: analytics harness & identity detections#235
Kinfe123 merged 6 commits into
mainfrom
fix/analytics-harness-with-test

Conversation

@Kinfe123
Copy link
Copy Markdown
Member

@Kinfe123 Kinfe123 commented May 30, 2026

  • fix: analytics harness tests and prefix catch
  • chore: format

Summary by cubic

Improves Docs Cloud analytics to reliably tag agent/bot traffic and infer provider names from user-agent and protocol hints. Passes userAgent through packages/docs and packages/fumadocs so events are normalized server-side without extra work.

  • New Features

    • Server-side hints: infer provider from user-agent (ChatGPT, Claude, Perplexity, Cursor, Copilot, GPTBot, common crawlers), protocol/source (mcp or mcp_*), and agent-facing types (agent_*, agents_request, llms_request, markdown_request, skill_request).
    • Set trafficType="agent" and fill agentName/botProvider only when not provided; use "MCP client", "Docs agent", or "Docs reader" as needed.
    • Add getDocsRequestAnalyticsProperties(request) in packages/docs (exported from index and server); include userAgent across packages/fumadocs endpoints (spec, markdown, llms, search, feedback) and Ask AI.
  • Bug Fixes

    • Fix analytics harness for header-based detection and expand tests to assert UA capture, provider tagging (e.g., ClaudeBot/1.0), and avoid false positives for normal browsers (Mozilla/5.0).

Written for commit 0240048. Summary will update on new commits.

Review in cubic

@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs-website Ready Ready Preview, Comment May 31, 2026 12:02am
farming-labs-docs-docs-cloud Building Building Preview, Comment May 31, 2026 12:02am

Request Review

Copy link
Copy Markdown

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

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

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@Kinfe123 Kinfe123 changed the title fix/analytics harness with test fix: analytics harness with test May 30, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 30, 2026

Open in StackBlitz

@farming-labs/astro

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro@235

@farming-labs/astro-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/astro-theme@235

@farming-labs/docs

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/docs@235

@farming-labs/theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/theme@235

@farming-labs/next

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/next@235

@farming-labs/nuxt

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt@235

@farming-labs/nuxt-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/nuxt-theme@235

@farming-labs/svelte

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte@235

@farming-labs/svelte-theme

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/svelte-theme@235

@farming-labs/tanstack-start

pnpm add https://pkg.pr.new/farming-labs/docs/@farming-labs/tanstack-start@235

commit: 0240048

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/docs/src/cloud-analytics.ts Outdated
@Kinfe123 Kinfe123 changed the title fix: analytics harness with test fix: analytics harness & identity detections May 30, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 7 files (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/docs/src/cloud-analytics.ts">

<violation number="1" location="packages/docs/src/cloud-analytics.ts:190">
P1: Agent-type events are no longer auto-classified unless `trafficType` is already set or the event is MCP, which regresses analytics tagging for existing `agent_`/`llms_request`/`markdown_request`/`skill_request` flows.</violation>
</file>

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

asString(properties.crawler) ??
asString(asRecord(properties.bot).provider) ??
detectedAgent ??
(protocolAgent || explicitAgent ? inferAgentProvider(event) : undefined);
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.

P1: Agent-type events are no longer auto-classified unless trafficType is already set or the event is MCP, which regresses analytics tagging for existing agent_/llms_request/markdown_request/skill_request flows.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/docs/src/cloud-analytics.ts, line 190:

<comment>Agent-type events are no longer auto-classified unless `trafficType` is already set or the event is MCP, which regresses analytics tagging for existing `agent_`/`llms_request`/`markdown_request`/`skill_request` flows.</comment>

<file context>
@@ -137,20 +132,66 @@ function inferAgentProvider(event: DocsAnalyticsEvent) {
     asString(asRecord(properties.bot).provider) ??
-    inferAgentProvider(event);
+    detectedAgent ??
+    (protocolAgent || explicitAgent ? inferAgentProvider(event) : undefined);
+
+  if (!explicitAgent && !protocolAgent && !detectedAgent && !agentProvider) {
</file context>
Suggested change
(protocolAgent || explicitAgent ? inferAgentProvider(event) : undefined);
inferAgentProvider(event);

@Kinfe123 Kinfe123 merged commit a092fb6 into main May 31, 2026
9 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant