Skip to content

refactor: migrate filteredMparticleUser module to TS - #1334

Open
jaissica12 wants to merge 1 commit into
developmentfrom
refactor/SDKE-1193-migrate-filteredMparticleUser-to-TS
Open

refactor: migrate filteredMparticleUser module to TS#1334
jaissica12 wants to merge 1 commit into
developmentfrom
refactor/SDKE-1193-migrate-filteredMparticleUser-to-TS

Conversation

@jaissica12

@jaissica12 jaissica12 commented Aug 19, 2026

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. filteredMparticleUser.js was one of the remaining JS modules used by forwarders and Rokt filtered-user construction.

What Has Changed

  • Converted src/filteredMparticleUser.js to src/filteredMparticleUser.ts with type annotations
  • Added IFilteredMparticleUser interface
  • Filtering logic for identities/attributes is preserved
  • No intentional 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

  • No dedicated unit/integration tests exist specifically for this module
  • getAllUserAttributes is referenced via a local function so the module typechecks when invoked without new (same call pattern as production call sites)

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:43
@cursor

cursor Bot commented Aug 19, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Mechanical TypeScript migration with preserved filtering logic; no new runtime paths beyond typing and a structural refactor of getAllUserAttributes.

Overview
Migrates filteredMparticleUser from JavaScript to TypeScript by removing filteredMparticleUser.js and adding filteredMparticleUser.ts, with no intended behavior change for forwarders and Rokt filtered-user construction.

The factory and returned object are now typed via IFilteredMparticleUser, with parameters annotated (MPID, MPForwarder / partial forwarder shape, IMParticleWebSDKInstance, optional KitBlocker). getAllUserAttributes is implemented as a local function referenced on the returned object (instead of closing over self), matching existing call sites that invoke the factory without new. Helper calls on _Helpers use casts so filterUserAttributes and filterUserIdentitiesForForwarders still compile against loosely typed internals.

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

@jaissica12
jaissica12 force-pushed the refactor/SDKE-1193-migrate-filteredMparticleUser-to-TS branch from 4885be2 to 7fe4563 Compare August 19, 2026 01:08
@jaissica12
jaissica12 force-pushed the refactor/SDKE-1193-migrate-filteredMparticleUser-to-TS branch from c1a74eb to 8300f32 Compare August 19, 2026 01:15
@sonarqubecloud

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Member

Tests: unchanged (no test/ files).

Request: add filterUserAttributes / filterUserIdentitiesForForwarders to SDKHelpersApi and call them typed, instead of:

((mpInstance._Helpers as Dictionary).filterUserAttributes as Function)(...)

Those casts undo most of the typing win from the migration.

Union MPForwarder | { userAttributeFilters: number[] } is fine for the Rokt path; a tiny shared filter-config type would be cleaner but optional.

Merge this before #1336 (already approved).

}
}

userAttributesCopy = ((mpInstance._Helpers as Dictionary)

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.

We should have an IHelpersAPI interface or something similar that can be used here.

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