diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index 3bd7828..5bd2358 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -632,9 +632,11 @@ var constructor = function () { ]; } - kitLogger('braze.changeUser', brazeUserIDType); + if (brazeUserIDType) { + kitLogger('braze.changeUser', brazeUserIDType); - braze.changeUser(brazeUserIDType); + braze.changeUser(brazeUserIDType); + } if (userIdentities.email) { kitLogger('braze.getUser().setEmail', userIdentities.email); diff --git a/test/tests.js b/test/tests.js index b572c6d..2098679 100644 --- a/test/tests.js +++ b/test/tests.js @@ -981,6 +981,15 @@ describe('Braze Forwarder', function() { window.braze.getUser().emailSet.should.equal('email@gmail.com'); }); + it('should not attempt to set an identity on braze if the userIdentificationType does not exist on the customer', function() { + mParticle.forwarder.init({ + apiKey: '123456', + userIdentificationType: 'other2', + }); + + Should(window.braze.userId).equal(null); + }); + it('should set main braze user identity from userIdentificationType ', function() { mParticle.forwarder.init({ apiKey: '123456',