Skip to content

fix(analytics): keep frontend metadata separate from optional arguments - #2649

Merged
PatrykKuniczak merged 6 commits into
wxt-dev:mainfrom
creeperkatze:fix/analytics-frontend-metadata
Nov 2, 2026
Merged

PatrykKuniczak merged 6 commits into
wxt-dev:mainfrom
creeperkatze:fix/analytics-frontend-metadata

Conversation

@creeperkatze

Copy link
Copy Markdown
Contributor

Overview

Calls from the popup, options pages or content scripts that left out an optional argument, like track('some-event') or identify('some-user-id') from the README, received the page metadata in that argument's place. The metadata is now sent as its own field.

Manual Testing

  1. In the demo popup (packages/analytics/entrypoints/popup/main.ts), add void analytics.track('no-props');.
  2. Run bun run dev:build in packages/analytics and load .output/chrome-mv3 in Chrome.
  3. Open the popup and check the background's console. The logged track event should have no properties, and meta should have the popup's URL and a session ID. Before this change, the metadata showed up in event.properties and meta.url was background.js.

@netlify

netlify Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit 9eadc74
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/6ae8c523c9cca7882fd5e9ef
😎 Deploy Preview https://deploy-preview-2649--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.

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 35c0cc09-8af9-4291-98a3-cd48f1e48de1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c9c9d681-ec87-4727-b97f-756203c7f78c
📥 Commits

Reviewing files that changed from the base of the PR and between 6ee6031 and a0f7d09.

📒 Files selected for processing (1)
  • packages/analytics/modules/analytics/client.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough
📝 Walkthrough

Walkthrough

Analytics messages now carry event metadata separately from method arguments. The background port handler explicitly dispatches analytics methods and passes metadata to event methods in the correct parameter position.

Changes

Analytics metadata forwarding

Layer / File(s) Summary
Message shape and dispatch
packages/analytics/modules/analytics/client.ts
AnalyticsMessage now includes a separate meta field. The frontend forwarder sends metadata separately from args. The background port handler explicitly dispatches identify, page, track, captureException, and setEnabled.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: Minimal · previous review a0f7d

The metadata forwarding change is ready to merge after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to a0f7d

The change corrects metadata placement while preserving the observed opt-out controls and narrowing method dispatch. Compatibility between clients running different versions remains unverified, so the assessment is low risk rather than risk-free.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — A caller able to open the matching internal analytics port can affect the background’s shared analytics identity and enabled flag, and submit events to configured providers when enabled. The inspected path does not establish reachability from arbitrary websites, other extensions, tenants, or services.

Trust Boundaries and Controls

  • observed — The listener remains browser.runtime.onConnect and routes by port name; no new external connection listener is introduced. Additional sender authorization and runtime payload validation are absent in both inspected versions. Explicit method dispatch narrows the former dynamic lookup, while provider enabled checks remain intact. These existing boundary limitations were not shown to gain new exposure or authority through this PR.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: keeping frontend metadata separate from optional analytics arguments.
Description check ✅ Passed The description includes an overview and concrete manual testing steps with expected results. The template’s Related Issue section is omitted, but it is conditional and does not prevent the descriptio…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@PatrykKuniczak PatrykKuniczak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think it can be simplified.

But again, so sorry, but i don't understand, and don't see difference:

Before:
Image

After:
Image

After all, it seems it's breaking change and it's not fix it's feat/chore.

Let's send me more details please.

@PatrykKuniczak PatrykKuniczak left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM

@pkg-pr-new

pkg-pr-new Bot commented Nov 2, 2026

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@2649

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@2649

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@2649

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@2649

@wxt-dev/is-background

npm i https://pkg.pr.new/@wxt-dev/is-background@2649

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@2649

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@2649

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@2649

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@2649

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@2649

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@2649

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@2649

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@2649

wxt

npm i https://pkg.pr.new/wxt@2649

commit: 9eadc74

@codecov

codecov Bot commented Nov 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 80.41%. Comparing base (635e18a) to head (9eadc74).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2649      +/-   ##
==========================================
+ Coverage   80.32%   80.41%   +0.09%     
==========================================
  Files         139      139              
  Lines        4162     4162              
  Branches      961      961              
==========================================
+ Hits         3343     3347       +4     
+ Misses        720      717       -3     
+ Partials       99       98       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@PatrykKuniczak
PatrykKuniczak merged commit 40c55ef into wxt-dev:main Nov 2, 2026
19 checks passed
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Thanks for helping make WXT better!

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.

3 participants