Skip to content

feat: add Mixpanel analytics to script registry#633

Open
harlan-zw wants to merge 2 commits intomainfrom
worktree-feat/604-add-mixpanel
Open

feat: add Mixpanel analytics to script registry#633
harlan-zw wants to merge 2 commits intomainfrom
worktree-feat/604-add-mixpanel

Conversation

@harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Mar 6, 2026

🔗 Linked issue

Resolves #604

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Adds Mixpanel as a new registry script with useScriptMixpanelAnalytics() composable. Follows the existing analytics script pattern (Segment, PostHog) with method queueing before load, mixpanel.init(token) on client init, and Partytown forward support. Includes documentation page.

@vercel
Copy link
Contributor

vercel bot commented Mar 6, 2026

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

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview, Comment Mar 6, 2026 4:01am

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 6, 2026

Open in StackBlitz

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

commit: 582afd3

@coderabbitai
Copy link

coderabbitai bot commented Mar 6, 2026

📝 Walkthrough

Walkthrough

Adds Mixpanel analytics integration to the script registry. Changes include: a new Partytown forward mapping for Mixpanel APIs, JSON registry types entries for Mixpanel options and API, a registry entry for the Mixpanel provider (CDN src, label, category, logo, and composable import), a runtime module that registers the Mixpanel script, exposes and polyfills window.mixpanel with expected methods and a client init that auto-initializes with a token, a schema for Mixpanel options, and documentation for usage.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat: add Mixpanel analytics to script registry' clearly and concisely describes the main change: adding Mixpanel as a new analytics provider to the script registry.
Description check ✅ Passed The PR description covers the essential aspects: summary of changes, what is being added, and a test plan. However, it does not follow the repository's PR template structure with sections like 'Type of change'.
Linked Issues check ✅ Passed The PR successfully implements all coding requirements from #604: adds useScriptMixpanelAnalytics composable, loads Mixpanel SDK from CDN, proxies required methods, validates token configuration, and integrates with registry infrastructure.
Out of Scope Changes check ✅ Passed All changes are directly related to implementing Mixpanel support as specified in #604. No unrelated modifications to other analytics providers or unrelated features were introduced.

✏️ 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
  • Commit unit tests in branch worktree-feat/604-add-mixpanel

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
src/registry.ts (1)

125-134: Consider adding proxy field for first-party mode support.

The Mixpanel registry entry is missing the proxy field that other analytics integrations (Plausible, Fathom, Segment, PostHog) include. Without it, Mixpanel won't benefit from first-party proxy mode, meaning:

  • User IPs will be visible to Mixpanel
  • Requests may be blocked by ad blockers
  • Third-party cookies apply

If first-party support for Mixpanel is planned for a future iteration, this is fine. Otherwise, consider adding proxy configuration to match other analytics integrations.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/registry.ts` around lines 125 - 134, The Mixpanel registry entry (the
object with label 'Mixpanel' and import name 'useScriptMixpanelAnalytics') lacks
the same proxy configuration other analytics entries use; add a proxy field to
that object mirroring the structure used by Plausible/Fathom/Segment/PostHog
(e.g., a proxy object with the same keys those entries use such as endpoint/path
and any env key names) so Mixpanel can operate in first‑party/proxy mode and
avoid third‑party tracking issues.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/registry.ts`:
- Around line 125-134: The Mixpanel registry entry (the object with label
'Mixpanel' and import name 'useScriptMixpanelAnalytics') lacks the same proxy
configuration other analytics entries use; add a proxy field to that object
mirroring the structure used by Plausible/Fathom/Segment/PostHog (e.g., a proxy
object with the same keys those entries use such as endpoint/path and any env
key names) so Mixpanel can operate in first‑party/proxy mode and avoid
third‑party tracking issues.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4b411c0a-8795-4d84-b3b4-cca87ff0bca5

📥 Commits

Reviewing files that changed from the base of the PR and between 9431643 and b868ae8.

📒 Files selected for processing (5)
  • src/module.ts
  • src/registry-types.json
  • src/registry.ts
  • src/runtime/registry/mixpanel-analytics.ts
  • src/runtime/registry/schemas.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
docs/content/scripts/mixpanel.md (1)

26-40: Rename this section or add a real composable example.

“Composable Usage” currently shows nuxt.config registry setup, not a composable invocation. That makes the page harder to scan because the first actual useScriptMixpanelAnalytics() usage only appears later on Line 46. Consider renaming this to “Nuxt Config Usage” or adding a top-level composable example here instead.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/content/scripts/mixpanel.md` around lines 26 - 40, The "Composable
Usage" heading is misleading because it shows nuxt.config registry setup instead
of a composable call; rename the heading to "Nuxt Config Usage" or replace/add
content showing the composable invocation useScriptMixpanelAnalytics() at the
top of the section so readers see the actual composable usage immediately (keep
the existing nuxt.config example as a separate subsection or follow the
composable example with it).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@docs/content/scripts/mixpanel.md`:
- Around line 26-40: The "Composable Usage" heading is misleading because it
shows nuxt.config registry setup instead of a composable call; rename the
heading to "Nuxt Config Usage" or replace/add content showing the composable
invocation useScriptMixpanelAnalytics() at the top of the section so readers see
the actual composable usage immediately (keep the existing nuxt.config example
as a separate subsection or follow the composable example with it).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: be25396f-7034-4d5c-a356-6dc95814839b

📥 Commits

Reviewing files that changed from the base of the PR and between b868ae8 and e7a85a5.

📒 Files selected for processing (1)
  • docs/content/scripts/mixpanel.md

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.

Add mixpanel scripts to script registry

1 participant