Skip to content

fix: Analytics plugin - #2624

Open
creeperkatze wants to merge 1 commit into
wxt-dev:mainfrom
creeperkatze:fix-analytics-plugin-main-world
Open

creeperkatze wants to merge 1 commit into
wxt-dev:mainfrom
creeperkatze:fix-analytics-plugin-main-world

Conversation

@creeperkatze

Copy link
Copy Markdown
Contributor

Overview

The analytics plugin ran in every entrypoint, including MAIN-world content scripts without browser.runtime access. It imported #analytics at the top of the file, so createAnalytics() threw during module load and crashed the entrypoint before its own code ran. Now the import is dynamic and guarded by a browser.runtime.id check, so it's skipped where there's no runtime access instead of crashing.

Manual Testing

Added a MAIN-world content script next to the analytics module and confirmed it no longer crashes, while analytics still works in the background, popup, and isolated content scripts.

Related Issue

This PR closes #1847

@netlify

netlify Bot commented Sep 18, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit c8302b4
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6aadacf5f80dd6000833bc20
😎 Deploy Preview https://deploy-preview-2624--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added the pkg/analytics Includes changes to the `packages/analytics` directory label Sep 18, 2026
@creeperkatze

Copy link
Copy Markdown
Contributor Author
image

@creeperkatze

Copy link
Copy Markdown
Contributor Author

Once addWxtPlugin supports filtering by entrypoint type, the background-plugin could just be registered as background-only instead of guarding itself at runtime. That would fix it properly. This PR is a fix for the immediate crash.

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

pkg/analytics Includes changes to the `packages/analytics` directory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot use WXT analytics in contexts without access to the browser.runtime APIs

1 participant