From dd4c425facb5250e7b379e8740fda6da5f91c304 Mon Sep 17 00:00:00 2001 From: Robert Ing Date: Thu, 2 May 2024 16:43:39 -0400 Subject: [PATCH] Add case for when brazeUserIDType is null/undefined --- src/BrazeKit-dev.js | 6 ++++-- test/tests.js | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) 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',