Skip to content

fix: analytics harness#232

Merged
Kinfe123 merged 5 commits into
mainfrom
fix/analytics-harness
May 29, 2026
Merged

fix: analytics harness#232
Kinfe123 merged 5 commits into
mainfrom
fix/analytics-harness

Conversation

@Kinfe123
Copy link
Copy Markdown
Member

@Kinfe123 Kinfe123 commented May 29, 2026

Summary by cubic

Adds a browser analytics harness that persists anonymous visitor and session IDs, attaches them to client events, exposes the current identity, and only enables the client hook when analytics is on. Adds a configurable Docs Cloud analytics endpoint with a safe default and forwards Docs Cloud env to the client via withDocs; Turbopack now prefers built dist entrypoints.

  • New Features

    • Supports NEXT_PUBLIC_DOCS_CLOUD_ANALYTICS_ENDPOINT/DOCS_CLOUD_ANALYTICS_ENDPOINT with a default; events post to the configured endpoint and the client falls back to public env when explicit options are stripped.
    • getDocsClientAnalyticsIdentity returns the current anonymous visitor/session; caller-provided IDs are preserved on events.
    • withDocs serializes DOCS_CLOUD_* to NEXT_PUBLIC_* only when analytics is configured and does not override user-provided env; exported isDocsClientAnalyticsEnabled.
  • Refactors

    • Hardened Docs Cloud env resolution with an allowlist and trimmed values; analytics no-ops when disabled or missing project id.
    • Turbopack workspace aliases prefer dist/*.mjs and fall back to src for @farming-labs/docs, @farming-labs/theme, and @farming-labs/next; added docs-client-hooks to build outputs and alias coverage.

Written for commit 58928f2. Summary will update on new commits.

Review in cubic

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 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 29, 2026 2:44pm
farming-labs-docs-docs-cloud Error Error May 29, 2026 2:44pm

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 chore: analytics harness fix: analytics harness May 29, 2026
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 29, 2026

Open in StackBlitz

@farming-labs/astro

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

@farming-labs/astro-theme

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

@farming-labs/docs

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

@farming-labs/theme

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

@farming-labs/next

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

@farming-labs/nuxt

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

@farming-labs/nuxt-theme

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

@farming-labs/svelte

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

@farming-labs/svelte-theme

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

@farming-labs/tanstack-start

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

commit: 58928f2

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.

2 issues found across 7 files

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/next/src/config.ts">

<violation number="1" location="packages/next/src/config.ts:286">
P1: Workspace Turbopack aliases now hardcode `dist/*.mjs` paths, which can break local dev when workspace packages are not prebuilt.</violation>
</file>

<file name="packages/fumadocs/src/client-analytics.ts">

<violation number="1" location="packages/fumadocs/src/client-analytics.ts:115">
P2: Keep the identity fields consistent when caller properties override IDs; otherwise `visitorId`/`sessionId` can diverge from `visitor.id`/`session.id` in the same event.</violation>
</file>

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

Re-trigger cubic

Comment thread packages/next/src/config.ts Outdated
Comment thread packages/fumadocs/src/client-analytics.ts Outdated
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 5 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/next/src/config.ts">

<violation number="1" location="packages/next/src/config.ts:2221">
P3: This `if` guard is dead code because the analytics env object is always non-empty.</violation>
</file>

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

Re-trigger cubic

Comment on lines +2221 to +2226
if (Object.keys(publicDocsCloudAnalyticsEnv).length > 0) {
nextConfig.env = {
...publicDocsCloudAnalyticsEnv,
...nextConfig.env,
};
}
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.

P3: This if guard is dead code because the analytics env object is always non-empty.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At packages/next/src/config.ts, line 2221:

<comment>This `if` guard is dead code because the analytics env object is always non-empty.</comment>

<file context>
@@ -2182,6 +2217,14 @@ export function withDocs(nextConfig: NextConfig = {}): NextConfig {
   }
 
+  const publicDocsCloudAnalyticsEnv = createPublicDocsCloudAnalyticsEnv();
+  if (Object.keys(publicDocsCloudAnalyticsEnv).length > 0) {
+    nextConfig.env = {
+      ...publicDocsCloudAnalyticsEnv,
</file context>
Suggested change
if (Object.keys(publicDocsCloudAnalyticsEnv).length > 0) {
nextConfig.env = {
...publicDocsCloudAnalyticsEnv,
...nextConfig.env,
};
}
nextConfig.env = {
...publicDocsCloudAnalyticsEnv,
...nextConfig.env,
};

@Kinfe123 Kinfe123 merged commit 8636a3d into main May 29, 2026
8 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