From 3fa074169cc0956c435d86e57d6f12c643a4a0d6 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 6 Jul 2023 12:31:43 -0700 Subject: [PATCH 01/10] this is a test --- src/BrazeKit-dev.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index 2ae12f8..3714143 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -755,6 +755,10 @@ var constructor = function () { } } + if (true) { + //updated + } + if (testMode !== true) { braze.initialize(forwarderSettings.apiKey, options); finishBrazeInitialization(forwarderSettings); From b972edec928f7205427aafd0b7016d4682f7d663 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 6 Jul 2023 14:09:03 -0700 Subject: [PATCH 02/10] fix: call changeUser prior to openSession with MPID on init --- src/BrazeKit-dev.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index 3714143..e43321c 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -755,8 +755,8 @@ var constructor = function () { } } - if (true) { - //updated + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentuser().getMPID() != null) { + onUserIdentified(mParitcle.Identity.getCurrentuser()) } if (testMode !== true) { From 76ed620a33fa2e9bcde40bb30f3bf7c23a0a3187 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:16:10 -0700 Subject: [PATCH 03/10] fixes typo in accessing the current user --- src/BrazeKit-dev.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index e43321c..3faa215 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -752,7 +752,7 @@ var constructor = function () { var brazeFlags = mpCustomFlags[moduleId.toString()]; if (typeof brazeFlags.initOptions === 'function') { brazeFlags.initOptions(options); - } + }git } if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentuser().getMPID() != null) { From 0d56d4dac42da05d92514508abeded3966da60e4 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:18:13 -0700 Subject: [PATCH 04/10] type adjustment --- src/BrazeKit-dev.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index 3faa215..c8dfc84 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -756,7 +756,7 @@ var constructor = function () { } if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentuser().getMPID() != null) { - onUserIdentified(mParitcle.Identity.getCurrentuser()) + onUserIdentified(mParticle.Identity.getCurrentuser()) } if (testMode !== true) { From dda081ab3d4fd8f9f39236f38b1c1245beee2518 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 6 Jul 2023 15:20:11 -0700 Subject: [PATCH 05/10] typo adjustment --- src/BrazeKit-dev.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index c8dfc84..d250b2d 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -752,7 +752,7 @@ var constructor = function () { var brazeFlags = mpCustomFlags[moduleId.toString()]; if (typeof brazeFlags.initOptions === 'function') { brazeFlags.initOptions(options); - }git + } } if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentuser().getMPID() != null) { From 4bdd030f71094e9c4e9fd54fc0215d725a50ebbb Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:01:42 -0700 Subject: [PATCH 06/10] updates onUserIdentified call to the finishBrazeInitialization method and adds tests --- dist/BrazeKit.common.js | 22 +++++++++++++++++++++- dist/BrazeKit.iife.js | 22 +++++++++++++++++++++- src/BrazeKit-dev.js | 11 ++++++----- test/tests.js | 30 +++++++++++++++++++++++++++++- 4 files changed, 77 insertions(+), 8 deletions(-) diff --git a/dist/BrazeKit.common.js b/dist/BrazeKit.common.js index ad46518..cad5690 100644 --- a/dist/BrazeKit.common.js +++ b/dist/BrazeKit.common.js @@ -9914,7 +9914,7 @@ var constructor = function () { finishBrazeInitialization(forwarderSettings); } else { if (!braze.initialize(forwarderSettings.apiKey, options)) { - return 'Failed to initialize: ' + name; + return 'Failed to initialize: ' + name;corrects; } finishBrazeInitialization(forwarderSettings); } @@ -9929,6 +9929,26 @@ var constructor = function () { function finishBrazeInitialization(forwarderSettings) { braze.addSdkMetadata(['mp']); primeBrazeWebPush(); + + // var user = { + // getUserIdentities: function() { + // return { + // userIdentities: { + // customerid: 'abc123', + // email: 'test@test.com', + // facebook: 'fbID1', + // }, + // }; + // }, + // getMPID: function() { + // return 'MPID123'; + // }, + // }; + + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentUser().getMPID() != null) { + onUserIdentified(mParticle.Identity.getCurrentUser()); + } + openSession(forwarderSettings); } diff --git a/dist/BrazeKit.iife.js b/dist/BrazeKit.iife.js index 05279c8..36502f3 100644 --- a/dist/BrazeKit.iife.js +++ b/dist/BrazeKit.iife.js @@ -9914,7 +9914,7 @@ var mpBrazeKitV4 = (function (exports) { finishBrazeInitialization(forwarderSettings); } else { if (!braze.initialize(forwarderSettings.apiKey, options)) { - return 'Failed to initialize: ' + name; + return 'Failed to initialize: ' + name;corrects; } finishBrazeInitialization(forwarderSettings); } @@ -9929,6 +9929,26 @@ var mpBrazeKitV4 = (function (exports) { function finishBrazeInitialization(forwarderSettings) { braze.addSdkMetadata(['mp']); primeBrazeWebPush(); + + // var user = { + // getUserIdentities: function() { + // return { + // userIdentities: { + // customerid: 'abc123', + // email: 'test@test.com', + // facebook: 'fbID1', + // }, + // }; + // }, + // getMPID: function() { + // return 'MPID123'; + // }, + // }; + + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentUser().getMPID() != null) { + onUserIdentified(mParticle.Identity.getCurrentUser()); + } + openSession(forwarderSettings); } diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index d250b2d..82cff7e 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -755,16 +755,12 @@ var constructor = function () { } } - if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentuser().getMPID() != null) { - onUserIdentified(mParticle.Identity.getCurrentuser()) - } - if (testMode !== true) { braze.initialize(forwarderSettings.apiKey, options); finishBrazeInitialization(forwarderSettings); } else { if (!braze.initialize(forwarderSettings.apiKey, options)) { - return 'Failed to initialize: ' + name; + return 'Failed to initialize: ' + name;corrects } finishBrazeInitialization(forwarderSettings); } @@ -779,6 +775,11 @@ var constructor = function () { function finishBrazeInitialization(forwarderSettings) { braze.addSdkMetadata(['mp']); primeBrazeWebPush(); + + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentUser().getMPID() != null) { + onUserIdentified(mParticle.Identity.getCurrentUser()) + } + openSession(forwarderSettings); } diff --git a/test/tests.js b/test/tests.js index 7094941..655e9a4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -244,10 +244,26 @@ 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. + // debugger; mParticle.init('test-key'); mParticle.getInstance()._Store.sessionId = 'foo-session-id'; mParticle.getInstance()._Store.dateLastEventSent = new Date(); @@ -1698,6 +1714,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', @@ -2065,5 +2091,7 @@ USD, impressionEvent.should.eql(expectedImpressionEvent); }); + + }); }); From 1df2cfacbd6f043bb79fa7ad2eb48daac67b099a Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 13 Jul 2023 11:05:12 -0700 Subject: [PATCH 07/10] adds check for mParticle.Identity --- dist/BrazeKit.common.js | 19 ++----------------- dist/BrazeKit.iife.js | 19 ++----------------- src/BrazeKit-dev.js | 2 +- 3 files changed, 5 insertions(+), 35 deletions(-) diff --git a/dist/BrazeKit.common.js b/dist/BrazeKit.common.js index cad5690..a298fa1 100644 --- a/dist/BrazeKit.common.js +++ b/dist/BrazeKit.common.js @@ -9929,23 +9929,8 @@ var constructor = function () { function finishBrazeInitialization(forwarderSettings) { braze.addSdkMetadata(['mp']); primeBrazeWebPush(); - - // var user = { - // getUserIdentities: function() { - // return { - // userIdentities: { - // customerid: 'abc123', - // email: 'test@test.com', - // facebook: 'fbID1', - // }, - // }; - // }, - // getMPID: function() { - // return 'MPID123'; - // }, - // }; - - if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentUser().getMPID() != null) { + + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity != null && mParticle.Identity.getCurrentUser().getMPID() != null) { onUserIdentified(mParticle.Identity.getCurrentUser()); } diff --git a/dist/BrazeKit.iife.js b/dist/BrazeKit.iife.js index 36502f3..692a31a 100644 --- a/dist/BrazeKit.iife.js +++ b/dist/BrazeKit.iife.js @@ -9929,23 +9929,8 @@ var mpBrazeKitV4 = (function (exports) { function finishBrazeInitialization(forwarderSettings) { braze.addSdkMetadata(['mp']); primeBrazeWebPush(); - - // var user = { - // getUserIdentities: function() { - // return { - // userIdentities: { - // customerid: 'abc123', - // email: 'test@test.com', - // facebook: 'fbID1', - // }, - // }; - // }, - // getMPID: function() { - // return 'MPID123'; - // }, - // }; - - if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentUser().getMPID() != null) { + + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity != null && mParticle.Identity.getCurrentUser().getMPID() != null) { onUserIdentified(mParticle.Identity.getCurrentUser()); } diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index 82cff7e..b045919 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -776,7 +776,7 @@ var constructor = function () { braze.addSdkMetadata(['mp']); primeBrazeWebPush(); - if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity.getCurrentUser().getMPID() != null) { + if (forwarderSettings.userIdentificationType === 'MPID' && mParticle.Identity != null && mParticle.Identity.getCurrentUser().getMPID() != null) { onUserIdentified(mParticle.Identity.getCurrentUser()) } From 26b4093a16e77ea1deac775d8c3b0464659d3772 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Fri, 14 Jul 2023 10:16:27 -0700 Subject: [PATCH 08/10] removes extra spacing and erroneous comments --- src/BrazeKit-dev.js | 2 +- test/tests.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/BrazeKit-dev.js b/src/BrazeKit-dev.js index b045919..7a4c5db 100644 --- a/src/BrazeKit-dev.js +++ b/src/BrazeKit-dev.js @@ -760,7 +760,7 @@ var constructor = function () { finishBrazeInitialization(forwarderSettings); } else { if (!braze.initialize(forwarderSettings.apiKey, options)) { - return 'Failed to initialize: ' + name;corrects + return 'Failed to initialize: ' + name; } finishBrazeInitialization(forwarderSettings); } diff --git a/test/tests.js b/test/tests.js index 655e9a4..08e2666 100644 --- a/test/tests.js +++ b/test/tests.js @@ -263,7 +263,6 @@ describe('Braze Forwarder', function() { before(function() { // expandCommerceEvent is tightly coupled to mParticle being loaded // as well as having a few parameters on the Store. - // debugger; mParticle.init('test-key'); mParticle.getInstance()._Store.sessionId = 'foo-session-id'; mParticle.getInstance()._Store.dateLastEventSent = new Date(); @@ -2091,7 +2090,5 @@ USD, impressionEvent.should.eql(expectedImpressionEvent); }); - - }); }); From e84d3a7f3e03349215acf87652405930a0ca8648 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 20 Jul 2023 10:43:20 -0700 Subject: [PATCH 09/10] reverts changes in dist files --- dist/BrazeKit.common.js | 7 +------ dist/BrazeKit.iife.js | 7 +------ 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/dist/BrazeKit.common.js b/dist/BrazeKit.common.js index a298fa1..aec3e7c 100644 --- a/dist/BrazeKit.common.js +++ b/dist/BrazeKit.common.js @@ -9914,7 +9914,7 @@ var constructor = function () { finishBrazeInitialization(forwarderSettings); } else { if (!braze.initialize(forwarderSettings.apiKey, options)) { - return 'Failed to initialize: ' + name;corrects; + return 'Failed to initialize: ' + name;; } finishBrazeInitialization(forwarderSettings); } @@ -9929,11 +9929,6 @@ 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/dist/BrazeKit.iife.js b/dist/BrazeKit.iife.js index 692a31a..05279c8 100644 --- a/dist/BrazeKit.iife.js +++ b/dist/BrazeKit.iife.js @@ -9914,7 +9914,7 @@ var mpBrazeKitV4 = (function (exports) { finishBrazeInitialization(forwarderSettings); } else { if (!braze.initialize(forwarderSettings.apiKey, options)) { - return 'Failed to initialize: ' + name;corrects; + return 'Failed to initialize: ' + name; } finishBrazeInitialization(forwarderSettings); } @@ -9929,11 +9929,6 @@ var mpBrazeKitV4 = (function (exports) { 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); } From cd8147e2d5bbab4c10ae1f42079913708f7ad1a2 Mon Sep 17 00:00:00 2001 From: SbDove <100377552+SbDove@users.noreply.github.com> Date: Thu, 20 Jul 2023 10:45:04 -0700 Subject: [PATCH 10/10] reverts changes in dist files --- dist/BrazeKit.common.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/BrazeKit.common.js b/dist/BrazeKit.common.js index aec3e7c..ad46518 100644 --- a/dist/BrazeKit.common.js +++ b/dist/BrazeKit.common.js @@ -9914,7 +9914,7 @@ var constructor = function () { finishBrazeInitialization(forwarderSettings); } else { if (!braze.initialize(forwarderSettings.apiKey, options)) { - return 'Failed to initialize: ' + name;; + return 'Failed to initialize: ' + name; } finishBrazeInitialization(forwarderSettings); }