@mparticle/web-braze-kit 3.0.3 → 3.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +44 -25
- package/dist/BrazeKit.common.js +31 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
--
|
|
4
4
|
|
|
5
|
+
#### 3.0.5 - 2022-10-20
|
|
6
|
+
- docs: Update README to alert developers about v4 kit upgrade date, add console warning to current CDN users (#15)
|
|
7
|
+
|
|
8
|
+
#### 3.0.4 - 2022-09-06
|
|
9
|
+
- fix: Add Transaction Id to Purchase Commerce Events
|
|
10
|
+
|
|
5
11
|
#### 3.0.3 - 2022-08-24
|
|
6
12
|
- feat: Add logging for debugging
|
|
7
13
|
|
package/README.md
CHANGED
|
@@ -1,50 +1,69 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
3
|
⚠️⚠️⚠️
|
|
4
|
-
# Notice! Timeline for Breaking Changes for mParticle Web Braze Kit-
|
|
5
|
-
|
|
4
|
+
# Notice! Timeline for Breaking Changes for mParticle Web Braze Kit- 10/15/2022 - 2/15/2023
|
|
5
|
+
Customers who use mParticle and Braze on their websites may require some code changes due to an update we are making to the mParticle Braze web kit. The web kit, which previously used v3.5.0 of the Braze web SDK, will use Braze SDK 4.2.1 starting on 2/15/2023 on our CDN.
|
|
6
6
|
|
|
7
|
-
Braze has breaking changes
|
|
7
|
+
* <b>The Braze web SDK has several breaking changes and if you load mParticle via snippet/CDN, you should <a href="#update-to-braze-sdk-version-4-from-version-3---10152022---2152023">follow these instructions to ensure your code continues to work when our changes go live to the CDN on 2/15/2023</a>. If you self-host mParticle and the Braze Web Kit via npm, you can update sooner. Follow the instructions below whether you self-host or load mParticle via snippet/CDN.</b>.
|
|
8
|
+
* <b>Note that if you are here looking at source code, the `master` branch will continue to contain Braze Web Kit version 3.X until 2/15/2023. The `braze-v4-npm-master` branch currently contains the source code for v4.X, and this will be merged to `master` on 2/15/2023 to be available via CDN. </b>
|
|
9
|
+
* If you are using version 2 of the @mparticle/web-appboy-kit, you will need to <a href="#transition-from-mparticleweb-appboy-kit-to-mparticleweb-braze-kit">transition to @mparticle/web-braze-kit per the instructions here</a> before following the below instructions as well.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## Braze Web Kit Citical Updates and Timelines
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
Braze occasionally makes breaking changes to their SDK, so if you call Braze directly in your code, you may have to update your code to ensure your website performs as expected after mParticle updates to the latest Braze SDKs. This section communicates migration steps for customers to make to their codebase to ensure compatibility.
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
* The `appboy.ab` namespace has been removed and everything lives under the `appboy` namespace now.
|
|
15
|
-
* `InAppMessage.Button` has been renamed to `InAppMessageButton`
|
|
15
|
+
Customers who implement mParticle via NPM and self-host our SDK can choose when they want to update their code and [@mParticle/web-braze-kit version](https://www.npmjs.com/package/@mparticle/web-braze-kit), but customers who implement mParticle via our snippet/CDN must pay close attention to the following timelines and instructions.
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
| mParticle Braze Web Kit Version | Braze SDK Version Supported | Deadline/Date of CDN Release | Link to Description |
|
|
18
|
+
| ---|---|---|---|
|
|
19
|
+
| v4.0.0 | v4.2.1 | 2/15/2023 | [Link](#update-to-braze-sdk-version-4-from-version-3---10152022---2152023) |
|
|
20
|
+
| v3.0.4 | v3.5.0 | NA | [Link](#transition-from-mparticleweb-appboy-kit-to-mparticleweb-braze-kit) |
|
|
18
21
|
|
|
19
|
-
|
|
22
|
+
### Update to Braze SDK Version 4 from Version 3 - 10/15/2022 - 2/15/2023
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
Please review [Braze’s Changelog notes](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/changelog#400) as well as Braze’s [migration guide](https://github.com/braze-inc/braze-web-sdk/blob/master/UPGRADE_GUIDE.md) between version 3 and 4 to understand these changes and what code updates are needed from your side. The largest change is the move from class name `appboy` to `braze`. Braze also removed and renamed some APIs. As a result, we are also updating our mParticle Braze web kit from 3.0.X to 4.0.X in order to support Braze’s Web SDK version 4.2.1.
|
|
25
|
+
|
|
26
|
+
We plan to release the updated mParticle Braze Kit on two different time frames depending on how you load mParticle:
|
|
27
|
+
* Customers who self-host mParticle via npm - You will be able to update manually from npm on 10/15/2022
|
|
28
|
+
* Customers who load mParticle via snippet/CDN - We will push an update to the CDN on 2/15/2023 to make it automatically available.
|
|
29
|
+
|
|
30
|
+
We want to allow our customers to take advantage of the latest from Braze, so we are releasing the kit update via npm earlier. However, due to the sensitive nature of the breaking changes in Braze’s latest version, we want to give ample notice to all of our customers who are on the CDN since these customers will get the update automatically. We want to respect the end-of-year code freezes that a lot of our customers have and allow plenty of time to make the required code changes. Striking this balance is important for us, so if you are on the CDN but need the update sooner, you can [switch to self-hosting on npm](https://docs.mparticle.com/developers/sdk/web/self-hosting/).
|
|
31
|
+
|
|
32
|
+
If you load mParticle via snippet/CDN, you will have to make changes to your codebase before February 15, 2023 to be compatible with both version 3 and version 4 of the Braze SDK to ensure your code continues to work. We recommend a three-step approach. Here are some code samples of what this code could look like today (step 1), preparing for the update (step 2) and after the change is live (step 3).
|
|
33
|
+
|
|
34
|
+
The following recommendations apply only to customers who load mParticle via snippet. Customers who self-host via npm can ignore step 1 and jump straight to step 3 after updating their mParticle Braze kit. Note that this is only one example. Everywhere you manually call `appboy` needs to be updated similar to the below, and please refer to the Braze Changelog and migration guide as referenced earlier:
|
|
35
|
+
|
|
36
|
+
* Step 1: Legacy code sample. Find all the places where your code references the `appboy.display` namespace. Braze has removed all instances of the `display` namespace:
|
|
22
37
|
```javascript
|
|
23
|
-
|
|
38
|
+
window.appboy.display.destroyFeed();
|
|
24
39
|
```
|
|
25
40
|
|
|
26
|
-
Step 2:
|
|
41
|
+
Step 2: Roll out code changes to be used before February 15, 2023:
|
|
27
42
|
```javascript
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
banner = new appboy.Banner(‘test’);
|
|
43
|
+
if (window.appboy) {
|
|
44
|
+
window.appboy.display.destroyFeed();
|
|
45
|
+
} else if (window.braze) {
|
|
46
|
+
window.braze.destroyFeed();
|
|
33
47
|
}
|
|
34
48
|
```
|
|
35
|
-
Step 3: After
|
|
49
|
+
Step 3: After February 1, 2023, you can simplify your code after the mParticle Braze Web kit, which includes Braze SDK V4, has been released to our CDN:
|
|
36
50
|
```javascript
|
|
37
|
-
|
|
51
|
+
window.braze.destroyFeed();
|
|
38
52
|
```
|
|
39
53
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
Additionally, if you are using Push Notifications, we have updated the “service-worker.js” file. In our testing, Braze’s push notifications work as expected regardless of what version of the service-worker is used, but we recommend updating this to ensure future compatibility. In your `service-worker.js` file, update the code to reference `https://static.mparticle.com/sdk/js/braze/service-worker-3.5.0.js` instead of `https://static.mparticle.com/sdk/js/braze/service-worker.js`, ie:
|
|
54
|
+
Step 4: Push Notifications via service-worker.js
|
|
55
|
+
If you use Push Notifications, we have updated the `service-worker.js` file. In our testing, Braze’s push notifications work as expected regardless of what version of the service-worker is used, but we recommend updating this file to ensure future compatibility. In your `service-worker.js` file, update the code to reference `https://static.mparticle.com/sdk/js/braze/service-worker-4.2.0.js` instead of `https://static.mparticle.com/sdk/js/braze/service-worker-3.5.0.js`. Your `service-worker.js` file should now contain:
|
|
43
56
|
|
|
44
57
|
```javascript
|
|
45
|
-
self.
|
|
58
|
+
self.imports('https://static.mparticle.com/sdk/js/braze/service-worker-4.2.0.js')
|
|
46
59
|
```
|
|
47
60
|
|
|
61
|
+
### Transition from @mparticle/web-appboy-kit to @mparticle/web-braze-kit
|
|
62
|
+
|
|
63
|
+
The legacy @mparticle/web-appboy-kit from npm includes version 2 of the Braze Web SDK. As part of this update, we've created a new [Braze web kit repo](https://github.com/mparticle-integrations/mparticle-javascript-integration-braze) to replace our deprecated [Appboy web kit repo](https://github.com/mparticle-integrations/mparticle-javascript-integration-appboy). If you are still using `@mparticle/web-appboy-kit`, you will need to consider the breaking changes Braze made between V2 and V3 of the Braze SDK (found [here](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/changelog/#300)) as well as the instructions above to get from V2 to V4 of the Braze SDK.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
|
|
48
67
|
# License
|
|
49
68
|
|
|
50
69
|
Copyright 2022 mParticle, Inc.
|
|
@@ -59,4 +78,4 @@ Unless required by applicable law or agreed to in writing, software
|
|
|
59
78
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
60
79
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
61
80
|
See the License for the specific language governing permissions and
|
|
62
|
-
limitations under the License.
|
|
81
|
+
limitations under the License.
|
package/dist/BrazeKit.common.js
CHANGED
|
@@ -305,7 +305,7 @@ window.appboy = appboy_min;
|
|
|
305
305
|
|
|
306
306
|
var name = 'Appboy',
|
|
307
307
|
moduleId = 28,
|
|
308
|
-
version = '3.0.
|
|
308
|
+
version = '3.0.5',
|
|
309
309
|
MessageType = {
|
|
310
310
|
PageView: 3,
|
|
311
311
|
PageEvent: 4,
|
|
@@ -324,7 +324,7 @@ var clusterMapping = {
|
|
|
324
324
|
EU02: 'sdk.fra-02.braze.eu',
|
|
325
325
|
};
|
|
326
326
|
|
|
327
|
-
var constructor = function() {
|
|
327
|
+
var constructor = function () {
|
|
328
328
|
var self = this,
|
|
329
329
|
forwarderSettings,
|
|
330
330
|
options = {},
|
|
@@ -358,7 +358,7 @@ var constructor = function() {
|
|
|
358
358
|
function logPurchaseEvent(event) {
|
|
359
359
|
var reportEvent = false;
|
|
360
360
|
if (event.ProductAction.ProductList) {
|
|
361
|
-
event.ProductAction.ProductList.forEach(function(product) {
|
|
361
|
+
event.ProductAction.ProductList.forEach(function (product) {
|
|
362
362
|
if (product.Attributes == null) {
|
|
363
363
|
product.Attributes = {};
|
|
364
364
|
}
|
|
@@ -375,9 +375,12 @@ var constructor = function() {
|
|
|
375
375
|
);
|
|
376
376
|
}
|
|
377
377
|
|
|
378
|
-
var
|
|
379
|
-
|
|
380
|
-
);
|
|
378
|
+
var productAttributes = mergeObjects(product.Attributes, {
|
|
379
|
+
'Transaction Id': event.ProductAction.TransactionId,
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
var sanitizedProperties =
|
|
383
|
+
getSanitizedCustomProperties(productAttributes);
|
|
381
384
|
|
|
382
385
|
if (sanitizedProperties == null) {
|
|
383
386
|
return (
|
|
@@ -537,9 +540,8 @@ var constructor = function() {
|
|
|
537
540
|
) {
|
|
538
541
|
reportEvent = logPurchaseEvent(event);
|
|
539
542
|
} else if (event.EventDataType == MessageType.Commerce) {
|
|
540
|
-
var listOfPageEvents =
|
|
541
|
-
event
|
|
542
|
-
);
|
|
543
|
+
var listOfPageEvents =
|
|
544
|
+
mParticle.eCommerce.expandCommerceEvent(event);
|
|
543
545
|
if (listOfPageEvents != null) {
|
|
544
546
|
for (var i = 0; i < listOfPageEvents.length; i++) {
|
|
545
547
|
// finalLoopResult keeps track of if any logAppBoyEvent in this loop returns true or not
|
|
@@ -663,7 +665,7 @@ var constructor = function() {
|
|
|
663
665
|
// The following code block is based on Braze's best practice for implementing
|
|
664
666
|
// their push primer. We only modify it to include pushPrimer and register_inapp settings.
|
|
665
667
|
// https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration/#soft-push-prompts
|
|
666
|
-
appboy.subscribeToInAppMessage(function(inAppMessage) {
|
|
668
|
+
appboy.subscribeToInAppMessage(function (inAppMessage) {
|
|
667
669
|
var shouldDisplay = true;
|
|
668
670
|
var pushPrimer = false;
|
|
669
671
|
if (inAppMessage instanceof appboy.InAppMessage) {
|
|
@@ -685,7 +687,7 @@ var constructor = function() {
|
|
|
685
687
|
if (inAppMessage.buttons[0] != null) {
|
|
686
688
|
// Prompt the user when the first button is clicked
|
|
687
689
|
inAppMessage.buttons[0].subscribeToClickedEvent(
|
|
688
|
-
function() {
|
|
690
|
+
function () {
|
|
689
691
|
appboy.registerAppboyPushMessages();
|
|
690
692
|
}
|
|
691
693
|
);
|
|
@@ -726,11 +728,14 @@ var constructor = function() {
|
|
|
726
728
|
appName,
|
|
727
729
|
customFlags
|
|
728
730
|
) {
|
|
731
|
+
console.warn(
|
|
732
|
+
'mParticle is upgrading the Braze web kit and Braze SDK that you are currently using from V3 to V4 on 2/15/2023. You will AUTOMATICALLY receive this update if you see this message. There are many breaking changes if you invoke deprecated Braze SDK methods in your code. Please see https://docs.mparticle.com/integrations/braze/event for more information and necessary upgrade steps to take to ensure code compatibility on 2/15/2023.'
|
|
733
|
+
);
|
|
729
734
|
// check to see if there is a logger for backwards compatibility, and if not, mock one to avoid errors
|
|
730
735
|
if (!self.logger) {
|
|
731
736
|
// create a logger
|
|
732
737
|
self.logger = {
|
|
733
|
-
verbose: function() {},
|
|
738
|
+
verbose: function () {},
|
|
734
739
|
};
|
|
735
740
|
}
|
|
736
741
|
// eslint-disable-line no-unused-vars
|
|
@@ -903,7 +908,7 @@ var constructor = function() {
|
|
|
903
908
|
var nonMethodArguments = Array.prototype.slice.call(arguments, 1);
|
|
904
909
|
msg += '\n' + method + ':\n';
|
|
905
910
|
|
|
906
|
-
nonMethodArguments.forEach(function(arg) {
|
|
911
|
+
nonMethodArguments.forEach(function (arg) {
|
|
907
912
|
if (isObject(arg) || Array.isArray(arg)) {
|
|
908
913
|
msg += JSON.stringify(arg);
|
|
909
914
|
} else {
|
|
@@ -958,6 +963,18 @@ if (window && window.mParticle && window.mParticle.addForwarder) {
|
|
|
958
963
|
});
|
|
959
964
|
}
|
|
960
965
|
|
|
966
|
+
function mergeObjects() {
|
|
967
|
+
var resObj = {};
|
|
968
|
+
for (var i = 0; i < arguments.length; i += 1) {
|
|
969
|
+
var obj = arguments[i],
|
|
970
|
+
keys = Object.keys(obj);
|
|
971
|
+
for (var j = 0; j < keys.length; j += 1) {
|
|
972
|
+
resObj[keys[j]] = obj[keys[j]];
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
return resObj;
|
|
976
|
+
}
|
|
977
|
+
|
|
961
978
|
function isObject(val) {
|
|
962
979
|
return (
|
|
963
980
|
val != null && typeof val === 'object' && Array.isArray(val) === false
|
|
@@ -966,7 +983,7 @@ function isObject(val) {
|
|
|
966
983
|
|
|
967
984
|
var BrazeKitDev = {
|
|
968
985
|
register: register,
|
|
969
|
-
getVersion: function() {
|
|
986
|
+
getVersion: function () {
|
|
970
987
|
return version;
|
|
971
988
|
},
|
|
972
989
|
};
|
package/package.json
CHANGED