From 9944f473fb9054cf95e4c0409c393681649f917b Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Thu, 22 Aug 2024 16:21:59 +0530 Subject: [PATCH 1/2] fix: userId in braze hyrbrid --- .../src/integrations/Braze/browser.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/analytics-js-integrations/src/integrations/Braze/browser.js b/packages/analytics-js-integrations/src/integrations/Braze/browser.js index 27f4632e02..9fa8e9ad4b 100644 --- a/packages/analytics-js-integrations/src/integrations/Braze/browser.js +++ b/packages/analytics-js-integrations/src/integrations/Braze/browser.js @@ -110,12 +110,14 @@ class Braze { */ // eslint-disable-next-line sonarjs/cognitive-complexity identify(rudderElement) { + const { message } = rudderElement; + const { userId } = message; + if (this.isHybridModeEnabled) { + window.braze.changeUser(userId); return; } - const { message } = rudderElement; - const { userId } = message; const { context } = message; const email = context?.traits?.email; const firstName = context?.traits?.firstName || context?.traits?.firstname; From df1968dd231682790cca355fcf8a4562b2442d59 Mon Sep 17 00:00:00 2001 From: AASHISH MALIK Date: Tue, 27 Aug 2024 10:34:26 +0530 Subject: [PATCH 2/2] fix: test fix --- .../__tests__/integrations/Braze/browser.test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/analytics-js-integrations/__tests__/integrations/Braze/browser.test.js b/packages/analytics-js-integrations/__tests__/integrations/Braze/browser.test.js index 81f62cfbdb..caacf1273f 100644 --- a/packages/analytics-js-integrations/__tests__/integrations/Braze/browser.test.js +++ b/packages/analytics-js-integrations/__tests__/integrations/Braze/browser.test.js @@ -1083,7 +1083,7 @@ describe('hybrid mode', () => { expect(window.braze.changeUser).toBeCalledTimes(0); }); - it('should not call the necessary Braze methods for identify call', () => { + it('should call the necessary Braze methods for identify call', () => { const config = { appKey: 'APP_KEY', trackAnonymousUser: true, @@ -1118,6 +1118,6 @@ describe('hybrid mode', () => { braze.identify(rudderElement); // Expect the necessary Braze methods to be called with the correct values - expect(window.braze.changeUser).toBeCalledTimes(0); + expect(window.braze.changeUser).toBeCalledTimes(1); }); });