feat: Support scope in alias requests#1138
Conversation
jaissica12
left a comment
There was a problem hiding this comment.
Is there a specific reason for merging this into master instead of development? I believe this should go into development
@jaissica12 - good catch. My mistake! |
There was a problem hiding this comment.
Pull request overview
This PR adds comprehensive support for the scope parameter in alias requests throughout the mParticle Web SDK. The implementation simplifies the API by defaulting scope to 'device' when not explicitly provided, aligning with the documented API specification.
Key Changes
- Added
scopeparameter to thecreateAliasRequestpublic API method signature - Implemented default value of 'device' for scope across all alias request code paths
- Added comprehensive test coverage for both default and custom scope values
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/identity.js | Added scope defaulting logic (` |
| src/identity.interfaces.ts | Updated SDKIdentityApi.createAliasRequest interface to include optional scope parameter |
| src/mparticle-instance-manager.ts | Updated method signature to pass through the scope parameter |
| src/stub/mparticle.stub.js | Added scope field to stub's createAliasRequest return value |
| test/src/tests-identity.ts | Added two new tests verifying scope behavior: one for custom scope ('mpid') and one for default scope ('device') |
| test/src/tests-native-sdk.js | Updated existing tests to verify default scope and added new tests for custom scope on both Android and iOS native SDK bridges |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| JSON.parse(mParticleIOSV2Bridge.data[0]).value | ||
| ).should.equal( | ||
| '{"DestinationMpid":"101","SourceMpid":"202","StartUnixtimeMs":300,"EndUnixtimeMs":400}' | ||
| '{"DestinationMpid":"101","SourceMpid":"202","StartUnixtimeMs":300,"EndUnixtimeMs":400,"Scope":"mpid"}' |
There was a problem hiding this comment.
It seems like we use this specific string in several places, and it's difficult to read. Maybe we extract this into an fixture earlier in the file that gets stringified?
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
@alexs-mparticle @jaissica12 good for another look |
|
# [2.52.0](v2.51.0...v2.52.0) (2026-01-13) ### Bug Fixes * Append domain query parameter to Trade Desk cookie syncs ([#1115](#1115)) ([1379816](1379816)) ### Features * Add hashSha256 method for SHA-256 hashing ([#1116](#1116)) ([89c5baa](89c5baa)) * Support scope in alias requests ([#1138](#1138)) ([b3c937a](b3c937a))
|
🎉 This PR is included in version 2.52.0 🎉 The release is available on:
Your semantic-release bot 📦🚀 |


Background
Per our updated docs, alias requests support a parameter
scope, which was only partially implemented in the web sdk previously. This update supports scope throughout the full SDK, including adding it to the public API tio make it easier for developers to pass it in as opposed to adding it as a property after an alias request is made using ourcreateAliasRequesthelper method.What Has Changed
Add
scopethroughout alias request code paths, including addingdeviceas default when not provided in order to simplify the code.Screenshots/Video
Checklist
Additional Notes
Reference Issue (For employees only. Ignore if you are an outside contributor)