Skip to content

fix(analytics): change method return types from void to Promise<void>#2409

Open
muhammedaksam wants to merge 5 commits into
wxt-dev:mainfrom
muhammedaksam:fix/analytics-await-return-types
Open

fix(analytics): change method return types from void to Promise<void>#2409
muhammedaksam wants to merge 5 commits into
wxt-dev:mainfrom
muhammedaksam:fix/analytics-await-return-types

Conversation

@muhammedaksam

Copy link
Copy Markdown
Contributor

Overview

The Analytics interface declared track(), page(), identify(), and setEnabled() as returning void. The background implementation is async so it actually returns Promise<void>, but the frontend implementation returns void. TypeScript allows Promise<void> to be assigned to void (no error on the background side), but users calling await analytics.track() see TS80007 because the declared return type is void.
Changed the interface return types to Promise<void> and updated the MethodForwarder type and frontend implementation accordingly.

Manual Testing

  1. Use await analytics.track(...), await analytics.page(...), await analytics.identify(...), or await analytics.setEnabled(...) in a WXT project using this analytics module — TS80007 should no longer appear
  2. Call the same methods without await — they should still work in both background and frontend contexts
  3. Verify the build passes: bun run --filter @wxt-dev/analytics build

Related Issue

This PR closes #2408

The Analytics interface declared track(), page(), identify(), and setEnabled()
as returning void. The background implementation returns Promise<void> (async
functions), which is assignable to void. But users calling await analytics.track()
get TS80007 since the declared type is void.

Changed the interface return types to Promise<void> and updated the
MethodForwarder type and implementation accordingly.
@muhammedaksam muhammedaksam requested a review from aklinker1 as a code owner June 9, 2026 12:52
@github-actions github-actions Bot added the pkg/analytics Includes changes to the `packages/analytics` directory label Jun 9, 2026
@netlify

netlify Bot commented Jun 9, 2026

Copy link
Copy Markdown

Deploy Preview for creative-fairy-df92c4 ready!

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

@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.

Nice catch.

Thanks

@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

@wxt-dev/analytics

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

@wxt-dev/auto-icons

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

@wxt-dev/browser

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

@wxt-dev/i18n

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

@wxt-dev/is-background

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

@wxt-dev/module-react

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

@wxt-dev/module-solid

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

@wxt-dev/module-svelte

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

@wxt-dev/module-vue

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

@wxt-dev/runner

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

@wxt-dev/storage

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

@wxt-dev/unocss

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

@wxt-dev/webextension-polyfill

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

wxt

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

commit: 9643667

@codecov

codecov Bot commented Jun 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.49%. Comparing base (8cb973c) to head (9643667).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2409      +/-   ##
==========================================
+ Coverage   78.41%   78.49%   +0.07%     
==========================================
  Files         133      133              
  Lines        3882     3882              
  Branches      875      875              
==========================================
+ Hits         3044     3047       +3     
+ Misses        749      747       -2     
+ Partials       89       88       -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.

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.

await analytics.track() produces TS80007 because Analytics interface returns void instead of Promise<void>

2 participants