Skip to content

feat: Support scope in alias requests#1138

Merged
rmi22186 merged 6 commits into
developmentfrom
fix/SDKE-695-support-scope
Jan 13, 2026
Merged

feat: Support scope in alias requests#1138
rmi22186 merged 6 commits into
developmentfrom
fix/SDKE-695-support-scope

Conversation

@rmi22186

Copy link
Copy Markdown
Member

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 our createAliasRequest helper method.

What Has Changed

Add scope throughout alias request code paths, including adding device as default when not provided in order to simplify the code.

Screenshots/Video

  • {Include any screenshots or video demonstrating the new feature or fix, if applicable}

Checklist

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

Additional Notes

  • {Any additional information or context relevant to this PR}

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

@jaissica12 jaissica12 left a comment

Copy link
Copy Markdown
Contributor

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

@rmi22186 rmi22186 changed the base branch from master to development December 19, 2025 21:40
@rmi22186

Copy link
Copy Markdown
Member Author

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!

Copilot AI 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.

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 scope parameter to the createAliasRequest public 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.

Comment thread src/stub/mparticle.stub.js Outdated
Comment thread test/src/tests-native-sdk.js Outdated
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"}'

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.

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?

rmi22186 and others added 2 commits January 12, 2026 16:31
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@rmi22186

Copy link
Copy Markdown
Member Author

@alexs-mparticle @jaissica12 good for another look

@jaissica12 jaissica12 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
36.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@rmi22186 rmi22186 merged commit b3c937a into development Jan 13, 2026
27 of 32 checks passed
github-actions Bot pushed a commit that referenced this pull request Jan 13, 2026
# [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))
@mparticle-automation

Copy link
Copy Markdown
Collaborator

🎉 This PR is included in version 2.52.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants