-
Notifications
You must be signed in to change notification settings - Fork 57
feat: Support scope in alias requests #1138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: development
Are you sure you want to change the base?
Conversation
|
jaissica12
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
| destinationMpid: 'b', | ||
| startTime: new Date().getTime(), | ||
| endTime: new Date().getTime(), | ||
| scope: 'scope', |
Copilot
AI
Jan 5, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The stub function should return 'device' as the default scope value to be consistent with the actual implementation. The value 'scope' appears to be a placeholder string rather than the intended default value.
| scope: 'scope', | |
| scope: 'device', |
| 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?


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)