Skip to content

Conversation

@rmi22186
Copy link
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)

@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

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

See analysis details on SonarQube Cloud

Copy link
Contributor

@jaissica12 jaissica12 left a 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

@rmi22186 rmi22186 changed the base branch from master to development December 19, 2025 21:40
@rmi22186
Copy link
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!

Copy link

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

destinationMpid: 'b',
startTime: new Date().getTime(),
endTime: new Date().getTime(),
scope: 'scope',
Copy link

Copilot AI Jan 5, 2026

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.

Suggested change
scope: 'scope',
scope: 'device',

Copilot uses AI. Check for mistakes.
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
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?

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.

4 participants