Skip to content

fix(posthog): 'history_change' as a capture_pageview option#620

Merged
harlan-zw merged 1 commit intonuxt:mainfrom
zizzfizzix:posthog-capturepageview-spa
Mar 3, 2026
Merged

fix(posthog): 'history_change' as a capture_pageview option#620
harlan-zw merged 1 commit intonuxt:mainfrom
zizzfizzix:posthog-capturepageview-spa

Conversation

@zizzfizzix
Copy link
Copy Markdown
Contributor

🔗 Linked issue

❓ Type of change

  • 📖 Documentation (updates to the documentation or readme)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • 👌 Enhancement (improving an existing functionality)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

For SPAs (most Nuxt apps) when the user wants pageview events captured they need to pass history_change as the option to posthog.

Without nuxt/scripts accepting this, a user would have to resort to using the config param and pass raw options instead, despite this being a native one.

See posthog docs, here

@vercel
Copy link
Copy Markdown
Contributor

vercel bot commented Mar 3, 2026

@zizzfizzix is attempting to deploy a commit to the Nuxt Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 3, 2026

📝 Walkthrough

Walkthrough

This change extends the PostHogOptions.capturePageview property type definition from a boolean to a union type accepting either a boolean or the literal string 'history_change'. The type change is applied consistently across both the documentation file and the source implementation file, with corresponding updates to initialization logic to accept the expanded type.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The description addresses the linked issue section (empty), type of change (bug fix selected), and provides detailed explanation of why the change is needed and what problem it solves.
Title check ✅ Passed The title clearly and specifically describes the main change: enabling 'history_change' as a valid capture_pageview option in PostHog configuration.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 3, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@620

commit: 4e34482

@harlan-zw harlan-zw changed the title fix: allow passing-through 'history_change' as a posthog capture_pageview option fix(posthog) allow passing-through 'history_change' as a posthog capture_pageview option Mar 3, 2026
@harlan-zw harlan-zw changed the title fix(posthog) allow passing-through 'history_change' as a posthog capture_pageview option fix(posthog): 'history_change' as a capture_pageview option Mar 3, 2026
@harlan-zw harlan-zw merged commit f0e1129 into nuxt:main Mar 3, 2026
4 of 6 checks passed
@harlan-zw
Copy link
Copy Markdown
Collaborator

Thanks 😊

zizzfizzix added a commit to zizzfizzix/nuxt-scripts that referenced this pull request Mar 5, 2026
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.

2 participants