Skip to content

feat(analytics): add server-side Blog page views - #177

Open
DR-Univer wants to merge 1 commit into
devfrom
feat/blog-server-tracking
Open

DR-Univer wants to merge 1 commit into
devfrom
feat/blog-server-tracking

Conversation

@DR-Univer

Copy link
Copy Markdown
Member

Summary

Blog index and article visits are missing from the existing documentation analytics. This change sends them through the same server-side on_view_docs event.

  • Extract the existing page-view capture into a shared server-only helper and reuse it from documentation feedback and both Blog pages.
  • Preserve event properties, locale handling, bot/prefetch/Server Action exclusions, and deferred capture with after().
  • Document the optional server-side configuration and add dependency-injected tests. No dependency changes or browser analytics SDK.

Validation

  • 12 tests passed: node --experimental-test-module-mocks --test lib/docs/__tests__/page-view.spec.mjs.
  • TypeScript check and focused lint/format checks passed.
  • Production build passed for the two Blog routes only.
  • Chinese Blog index/article HTTP smoke tests and an unknown-article 404 check passed.
  • Generated browser assets contained no PostHog SDK, server key configuration, or test key markers.

Notes

  • Page views are collected only in production when NEXT_POSTHOG_APIKEY is configured. Without it, page-view tracking is a no-op.
  • Enabling tracking renders Blog pages per request, matching existing tracked documentation pages. Existing anonymous event identity is preserved; this does not add unique-visitor tracking.
  • Local HTTP verification of the English entry point encountered a locale redirect loop and remains pending. This change does not modify routing or proxy configuration.

This branch has not been deployed

No deployments
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