diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index 2ae12f8..7a4c5db 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -775,6 +775,11 @@ var constructor = function () { function finishBrazeInitialization(forwarderSettings) { braze.addSdkMetadata(['mp']); primeBrazeWebPush(); + + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity != null && mParticle.Identity.getCurrentUser().getMPID() != null) { + onUserIdentified(mParticle.Identity.getCurrentUser()) + } + openSession(forwarderSettings); } diff --git a/test/tests.js b/test/tests.js index 7094941..08e2666 100644 --- a/test/tests.js +++ b/test/tests.js @@ -244,7 +244,22 @@ describe('Braze Forwarder', function() { }; }, reportService = new ReportingService(); - + mParticle.Identity = { + getCurrentUser: function () { + return { + getMPID: function () { + return 'MPID123'; + }, + getUserIdentities: function () { + return { + userIdentities: { + customerid: 'abc', + }, + }; + }, + }; + }, + }; before(function() { // expandCommerceEvent is tightly coupled to mParticle being loaded // as well as having a few parameters on the Store. @@ -1698,6 +1713,16 @@ USD, purchaseEventProperties.should.eql(expectedPurchaseEvent); }); + it('should call changeUser and openSession on init with userIdentificationType MPID passed in forwarding settings', function() { + mParticle.forwarder.init({ + apiKey: '123456', + userIdentificationType: 'MPID', + }); + + window.braze.userId.should.equal('MPID123'); + window.braze.should.have.property('openSessionCalled', true); + }); + describe('promotion events', function() { const mpPromotionEvent = { EventName: 'eCommerce - PromotionClick',