@mparticle/web-braze-kit 3.0.1 → 3.0.2

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 CHANGED
@@ -2,6 +2,9 @@
2
2
 
3
3
  --
4
4
 
5
+ #### 3.0.2 - 2022-06-16
6
+ - fix: add register_inapp and pushPrimer variables
7
+
5
8
  #### 3.0.1 - 2022-05-18
6
9
 
7
10
  - consume initOptions customFlags - this allows a customer to pass a callback to include additional options that mParticle doesn't support in the UI
package/README.md CHANGED
@@ -1,29 +1,29 @@
1
1
  ![Braze Logo](https://github.com/mparticle-integrations/mparticle-javascript-integration-appboy/blob/master/braze-logo.png)
2
2
 
3
3
  ⚠️⚠️⚠️
4
- # Notice! Timeline for Breaking Changes for mParticle Web Braze Kit- 3/28/2022 - 6/8/2022
4
+ # Notice! Timeline for Breaking Changes for mParticle Web Braze Kit- 3/28/2022 - 6/14/2022
5
5
  This repository renames and replaces our [mParticle Appboy Web Kit](https://github.com/mparticle-integrations/mparticle-javascript-integration-appboy), which will be archived in the future.
6
6
 
7
- Braze has breaking changes between version 2.5.2 and 3.5.0 of their SDK. As a result, we too are updating our [mParticle Braze web kit](https://github.com/mparticle-integrations/mparticle-javascript-integration-appboy) to support Braze’s Web SDK version 3.5.0. The updated mParticle Braze Web kit will be available via CDN on June 8, 2022 and is currently available on NPM as [@mparticle/web-braze-kit](https://www.npmjs.com/package/@mparticle/web-braze-kit) v3.0.0.
7
+ Braze has breaking changes between version 2.5.2 and 3.5.0 of their SDK. As a result, we too are updating our [mParticle Braze web kit](https://github.com/mparticle-integrations/mparticle-javascript-integration-appboy) to support Braze’s Web SDK version 3.5.0. The updated mParticle Braze Web kit will be available via CDN on June 14, 2022 and is currently available on NPM as [@mparticle/web-braze-kit](https://www.npmjs.com/package/@mparticle/web-braze-kit) v3.0.1.
8
8
 
9
9
  **How do you know if your code is affected?**
10
10
 
11
- You may notice errors on your site if you load mParticle [via snippet](https://docs.mparticle.com/developers/sdk/web/getting-started/#add-the-sdk-snippet) (as most of our clients do), and you reference any deprecated Braze APIs starting 6/8/2022.
11
+ You may notice errors on your site if you load mParticle [via snippet](https://docs.mparticle.com/developers/sdk/web/getting-started/#add-the-sdk-snippet) (as most of our clients do), and you reference any deprecated Braze APIs starting 6/14/2022.
12
12
 
13
13
  We highly recommend that you review the changes between version 2 and 3 of the Braze Web SDK to understand these changes, which can be found [here](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/changelog/#300). To summarize:
14
14
  * The `appboy.ab` namespace has been removed and everything lives under the `appboy` namespace now.
15
15
  * `InAppMessage.Button` has been renamed to `InAppMessageButton`
16
16
 
17
- If you reference any of the above deprecations, you will have to makes changes to your codebase before June 8, 2022 to be compatible with both version 2 and version 3 of the Braze SDK to ensure your code continues to work. We recommend a 3 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).
17
+ If you reference any of the above deprecations, you will have to makes changes to your codebase before June 14, 2022 to be compatible with both version 2 and version 3 of the Braze SDK to ensure your code continues to work. We recommend a 3 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).
18
18
 
19
- The below recommendations apply only to customers who load mParticle [via snippet](https://docs.mparticle.com/developers/sdk/web/getting-started/#add-the-sdk-snippet). Customers who [self host via NPM](https://docs.mparticle.com/developers/sdk/web/self-hosting/) can ignore step 1 and jump straight to step 3 after updating their mParticle Braze kit to v3.0.0.
19
+ The below recommendations apply only to customers who load mParticle [via snippet](https://docs.mparticle.com/developers/sdk/web/getting-started/#add-the-sdk-snippet). Customers who [self host via NPM](https://docs.mparticle.com/developers/sdk/web/self-hosting/) can ignore step 1 and jump straight to step 3 after updating their mParticle Braze kit to v3.0.1.
20
20
 
21
21
  Step 1: Legacy code sample. If your code references the `ab` namespace (like below) or `InAppMessage.Button`, you should change it following Step 2’s example:
22
22
  ```javascript
23
23
  let banner = new appboy.ab.Banner(‘test’);
24
24
  ```
25
25
 
26
- Step 2: Rollout code sample to be used before June 8, 2022:
26
+ Step 2: Rollout code sample to be used before June 14, 2022:
27
27
  ```javascript
28
28
  let banner;
29
29
  if (appboy.hasOwnProperty(‘ab’)) {
@@ -32,7 +32,7 @@ if (appboy.hasOwnProperty(‘ab’)) {
32
32
  banner = new appboy.Banner(‘test’);
33
33
  }
34
34
  ```
35
- Step 3: After June 8, 2022, you can simplify your code to the following once the mParticle Braze Web kit has been released to our CDN:
35
+ Step 3: After June 14, 2022, you can simplify your code to the following once the mParticle Braze Web kit has been released to our CDN:
36
36
  ```javascript
37
37
  let banner = new appboy.Banner(‘test’);
38
38
  ```
@@ -602,18 +602,19 @@ var constructor = function() {
602
602
  }
603
603
 
604
604
  function primeAppBoyWebPush() {
605
- // The following code block is Braze's best practice for implementing
606
- // their push primer. It should not be changed unless Braze updates it
605
+ // The following code block is based on Braze's best practice for implementing
606
+ // their push primer. We only modify it to include pushPrimer and register_inapp settings.
607
607
  // https://www.braze.com/docs/developer_guide/platform_integration_guides/web/push_notifications/integration/#soft-push-prompts
608
608
  appboy.subscribeToInAppMessage(function(inAppMessage) {
609
609
  var shouldDisplay = true;
610
-
610
+ var pushPrimer = false;
611
611
  if (inAppMessage instanceof appboy.InAppMessage) {
612
612
  // Read the key-value pair for msg-id
613
613
  var msgId = inAppMessage.extras['msg-id'];
614
614
 
615
615
  // If this is our push primer message
616
616
  if (msgId == 'push-primer') {
617
+ pushPrimer = true;
617
618
  // We don't want to display the soft push prompt to users on browsers that don't support push, or if the user
618
619
  // has already granted/blocked permission
619
620
  if (
@@ -634,8 +635,11 @@ var constructor = function() {
634
635
  }
635
636
  }
636
637
 
637
- // Display the message
638
- if (shouldDisplay) {
638
+ // Display the message if it's a push primer message and shouldDisplay is true
639
+ if (
640
+ (pushPrimer && shouldDisplay) ||
641
+ (!pushPrimer && forwarderSettings.register_inapp === 'True')
642
+ ) {
639
643
  appboy.display.showInAppMessage(inAppMessage);
640
644
  }
641
645
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-braze-kit",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "author": "mParticle Developers <developers@mparticle.com> (https://www.mparticle.com)",
5
5
  "description": "mParticle integration sdk for Braze",
6
6
  "main": "dist/BrazeKit.common.js",