Skip to content

refactor: migrate forwardingStatsUploader module to TS - #1333

Open
jaissica12 wants to merge 1 commit into
developmentfrom
refactor/SDKE-1194-migrate-forwardingStatsUploader-to-TS
Open

refactor: migrate forwardingStatsUploader module to TS#1333
jaissica12 wants to merge 1 commit into
developmentfrom
refactor/SDKE-1194-migrate-forwardingStatsUploader-to-TS

Conversation

@jaissica12

Copy link
Copy Markdown
Contributor

Background

  • Continuing the effort to migrate remaining JavaScript modules in the mParticle Web SDK to TypeScript for improved type safety and developer experience. forwardingStatsUploader.js was one of the remaining JS modules.

What Has Changed

  • Converted src/forwardingStatsUploader.js to src/forwardingStatsUploader.ts with type annotations
  • Added IForwardingStatsUploader interface and wired it in src/mp-instance.ts
  • No intentional runtime behavior, public API, or functional changes

Screenshots/Video

  • N/A

Checklist

  • I have performed a self-review of my own code.
  • I have made corresponding changes to the documentation.
  • I have added tests that prove my fix is effective or that my feature works.
  • I have tested this locally.

Additional Notes

Reference Issue (For employees only. Ignore if you are an outside contributor)

@jaissica12
jaissica12 requested a review from a team as a code owner August 19, 2026 00:42
@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Type-only refactor of internal forwarding-stats batching with no intended API or runtime behavior changes.

Overview
Migrates forwardingStatsUploader from JavaScript to TypeScript as part of the ongoing SDK TS migration.

The module now exposes IForwardingStatsUploader (with startForwardingStatsTimer()), takes IMParticleWebSDKInstance, and adds explicit typings on the batch upload path (queues, persistence table, XHR callbacks). mp-instance types _ForwardingStatsUploader against that interface instead of the concrete constructor.

For typing, the forwarding-stats interval is stored on (window.mParticle as Dictionary)._forwardingStatsTimer, and forwarderStatsTimeout is read via a Dictionary cast on SDKConfig. Upload batching and retry behavior are unchanged.

Reviewed by Cursor Bugbot for commit e4f7fab. Bugbot is set up for automated code reviews on this repo. Configure here.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 188c97d. Configure here.

Comment thread src/mp-instance.ts
Comment thread src/mp-instance.ts
@jaissica12
jaissica12 force-pushed the refactor/SDKE-1194-migrate-forwardingStatsUploader-to-TS branch from 188c97d to e4f7fab Compare August 19, 2026 00:57
@sonarqubecloud

Copy link
Copy Markdown

@jaissica12 jaissica12 self-assigned this Aug 19, 2026
@rmi22186

Copy link
Copy Markdown
Member

Tests: unchanged (no test/ files). Core/Jest green.

Migration looks faithful — IForwardingStatsUploader wiring in mp-instance.ts is good, and window.mParticle is a clearer stand-in for the old bare global.

Nit (same theme as #1262): prefer typing the surface instead of casting:

  • add forwarderStatsTimeout to SDKConfig (it’s already in Constants defaults) so you can drop (mpInstance._Store.SDKConfig as Dictionary).forwarderStatsTimeout
  • type _forwardingStatsTimer on the manager/mParticle surface instead of (window.mParticle as Dictionary)

Not blocking if you want to land the rename first and follow up on types. Bugbot hits on mp-instance.ts look unrelated to this diff (import/type swap only).

mpInstance: IMParticleWebSDKInstance
): void {
this.startForwardingStatsTimer = function(): void {
(window.mParticle as Dictionary)._forwardingStatsTimer = setInterval(

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.

Can we use IMParticleWebSDKInstance here or does that cause too many cascading issues?

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

Looks good overall. Only one question that isn't a blocker IMO

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.

3 participants