@mparticle/web-braze-kit-5 3.1.0 → 3.2.1

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/README.md CHANGED
@@ -1,46 +1,101 @@
1
- ![Braze Logo](https://github.com/mparticle-integrations/mparticle-javascript-integration-appboy/blob/master/braze-logo.png)
1
+ ![Braze Logo](https://github.com/mparticle-integrations/mparticle-javascript-integration-appboy/blob/master/braze-logo.png)
2
2
 
3
- ⚠️⚠️⚠️
4
- # Notice! Opt in is now available for Braze Web SDK V5 - Action Required
3
+ # mParticle Braze Kit — Braze Web SDK V5
5
4
 
6
- You can now select what version of the Braze SDK you want to use when setting up a Braze connection in the mParticle UI. Braze occasionally makes breaking changes to their SDK, so if you call `appboy` directly in your code, you will have to update your code to ensure your website performs as expected when updating versions of Braze.
5
+ This kit bundles **Braze Web SDK V5** (`@braze/web-sdk@^5.5.0`) and exposes it on the page as `window.braze`.
7
6
 
8
- Please review the [Braze Changelog](https://www.braze.com/docs/developer_guide/platform_integration_guides/web/changelog#500) and [V5 migration guide](https://github.com/braze-inc/braze-web-sdk/blob/master/UPGRADE_GUIDE.md) to learn about the differences between V4 and V5 and what changes you will need to make in your code. The most significant breaking changes are the removal of the deprecated `enableHtmlInAppMessages` initialization option (replaced by `allowUserSuppliedJavascript`), in addition to the removal and renaming of several APIs.
7
+ ---
9
8
 
10
- You can opt into the latest major version of the Braze Web SDK whether you implement mParticle's Web SDK using npm or our snippet/CDN.
11
- * Customers who self-host mParticle via npm - You should add @mparticle/web-braze-kit version 5.0.0 or greater in your package.json. You must also select `Version 5` under `Braze Web SDK Version` in the Braze connection settings.
12
- * Customers who load mParticle via snippet/CDN - You must select `Version 5` under `Braze Web SDK Version` in the Braze connection settings.
9
+ ## ⚠️ We recommend upgrading to Braze Web SDK V6
13
10
 
14
- Note that the following is only one example of migrating from V3 to V5. Everywhere you manually call `appboy` needs to be updated similar to the below. If you are using NPM, you can skip to step 3. Please be sure to test your site fully in development prior to releasing.
11
+ Braze is now on **V6**, and V6 is the version mParticle recommends for all customers. We recommend updating straight to V6 for latest support of all Braze features.
15
12
 
13
+ The `braze` global, initialization options, and the vast majority of the API are unchanged. Two areas break — the **legacy News Feed**, which V6 removes entirely, and **manual card-analytics method names**.
14
+
15
+ See the [Braze Event Integration](https://docs.mparticle.com/integrations/braze/event/) docs.
16
+
17
+ ### How to upgrade
18
+
19
+ 1. **Audit the code you own.** If you call Braze directly, find every `braze` reference and compare it with the table below and Braze's upgrade documentation.
20
+ 2. **Move to the V6 kit.**
21
+ - Self-hosting via npm with **core Web SDK v3 (latest)**: `npm install @mparticle/web-braze-kit-6`
22
+ - Self-hosting via npm with **core Web SDK v2 (legacy)**: `npm install @mparticle/web-braze-kit@^6`
23
+ - Loading mParticle via snippet/CDN: nothing to install; the kit is delivered for you.
24
+ 3. **Add defensive code** if you load mParticle via the snippet and call Braze directly. Skip this if you self-host via npm. See [Write version-tolerant code](#write-version-tolerant-code).
25
+ 4. **Select `Version 6`** under `Braze Web SDK Version` in your Braze connection settings in the mParticle UI. This step is **required for both npm and snippet/CDN** integrations — installing the package alone does not switch you over.
26
+ 5. **Update your push service worker**, if you use push. See [Push notifications](#push-notifications).
27
+
28
+ ---
29
+
30
+ ## What changed from V5 to V6
31
+
32
+ The table below is the V5 API you have today mapped to the V6 API you should use.
33
+
34
+ Primary sources: the [Braze Web SDK changelog](https://github.com/braze-inc/braze-web-sdk/blob/master/CHANGELOG.md) and the [Braze upgrade guide](https://github.com/braze-inc/braze-web-sdk/blob/master/UPGRADE_GUIDE.md).
35
+
36
+ | V5 | V6 |
37
+ | --- | --- |
38
+ | `braze.logCardClick()` | `braze.logContentCardClick()` — already exists in V5, so you can rename before you upgrade |
39
+ | `braze.logCardImpressions()` | `braze.logContentCardImpressions()` — already exists in V5 |
40
+ | Legacy News Feed: `Feed`, `destroyFeed()`, `getCachedFeed()`, `logFeedDisplayed()`, `requestFeedRefresh()`, `showFeed()`, `subscribeToFeedUpdates()`, `toggleFeed()` | **No drop-in replacement.** Migrate to Content Cards |
41
+ | `Card.created`, `Card.categories` | No replacement; these were News Feed fields |
42
+ | `ImageOnly.linkText` | No replacement; unused |
43
+ | Custom banner HTML + `logBannerClick()` / `logBannerImpressions()` | `braze.insertBanner()`, which handles rendering, impressions, and clicks |
44
+
45
+ If you call Braze directly, search your codebase for **every** `braze` reference and use Braze's changelog and upgrade guide to determine the corresponding V6 change. The table above highlights common changes but is not a substitute for reviewing your implementation.
46
+
47
+ For example, use the Content Card-specific analytics methods:
16
48
 
17
- * 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:
18
49
  ```javascript
19
- window.appboy.display.destroyFeed();
50
+ // V5
51
+ window.braze.logCardImpressions([card], true);
52
+
53
+ // V6
54
+ window.braze.logContentCardImpressions([card]);
20
55
  ```
21
56
 
22
- Step 2: Roll out code changes prior to opting in to V5
57
+ ---
58
+
59
+ ## Write version-tolerant code
60
+
61
+ Do this if you load mParticle via the snippet. After you select `Version 6`, cache busting can leave some visitors on the old kit for a while, so if you call Braze directly, ship code that works against both versions first, then flip the setting.
62
+
63
+ If you self-host via npm, you control when the kit version ships with your own deploy, so you do not need version-tolerant fallbacks — update your Braze calls and deploy them together with the V6 kit.
64
+
65
+ The `braze` global is the same in V5 and V6, so guard on the method instead. For the card-analytics renames:
66
+
23
67
  ```javascript
24
- if (window.appboy) {
25
- window.appboy.display.destroyFeed();
26
- } else if (window.braze) {
27
- window.braze.destroyFeed();
68
+ if (window.braze.logContentCardImpressions) {
69
+ window.braze.logContentCardImpressions([card]);
70
+ } else {
71
+ window.braze.logCardImpressions([card], true);
28
72
  }
29
73
  ```
30
- Step 3: Whether you are using the snippet or self hosting, you need to navigate to your Braze connection settings and select `Version 5` from the `Braze Web SDK Version` drop down.
31
74
 
32
- Step 4: After you opt in, you can simplify your code. We recommend testing and waiting at least 24 hours between opting in and removing previous instances of `appboy` and doing thorough testing of your application in a development environment to ensure everything is working:
33
- ```javascript
34
- window.braze.destroyFeed();
35
- ```
75
+ Search your codebase for every remaining direct `braze` call and apply the same pattern, using the mapping table above and Braze's changelog to find the V6 equivalent of each one.
36
76
 
37
- Step 5: Push Notifications via service-worker.js
38
- 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-5.5.0.js` instead of `https://static.mparticle.com/sdk/js/braze/service-worker-4.2.0.js`. Your `service-worker.js` file should now contain:
77
+ Once V6 is live and verified, you can delete the fallbacks and call the V6 methods directly.
78
+
79
+ ---
80
+
81
+ ## Push notifications
82
+
83
+ If you use push notifications, update your `service-worker.js` to import the V6 service worker that mParticle hosts:
39
84
 
40
85
  ```javascript
41
- self.importScripts('https://static.mparticle.com/sdk/js/braze/service-worker-5.5.0.js')
86
+ self.importScripts('https://static.mparticle.com/sdk/js/braze/service-worker-6.5.0.js');
42
87
  ```
43
88
 
89
+ mParticle hosts Braze's service worker to avoid unpredictable versioning issues — do not point at Braze's own service worker CDN.
90
+
91
+ ---
92
+
93
+ ## Reference
94
+
95
+ - [mParticle Braze integration docs](https://docs.mparticle.com/integrations/braze/event/)
96
+ - [Braze Web SDK changelog](https://github.com/braze-inc/braze-web-sdk/blob/master/CHANGELOG.md)
97
+ - [Braze Web SDK upgrade guide](https://github.com/braze-inc/braze-web-sdk/blob/master/UPGRADE_GUIDE.md)
98
+ - [Braze Web SDK API reference](https://js.appboycdn.com/web-sdk/latest/doc/modules/braze.html)
44
99
 
45
100
  # License
46
101
 
@@ -56,4 +111,4 @@ Unless required by applicable law or agreed to in writing, software
56
111
  distributed under the License is distributed on an "AS IS" BASIS,
57
112
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58
113
  See the License for the specific language governing permissions and
59
- limitations under the License.
114
+ limitations under the License.
@@ -10021,7 +10021,7 @@ window.braze = require$$0;
10021
10021
  var name = 'Appboy',
10022
10022
  suffix = 'v5',
10023
10023
  moduleId = 28,
10024
- version = '5.0.3',
10024
+ version = "3.2.1",
10025
10025
  MessageType = {
10026
10026
  PageView: 3,
10027
10027
  PageEvent: 4,
@@ -10019,7 +10019,7 @@ window.braze = require$$0;
10019
10019
  var name = 'Appboy',
10020
10020
  suffix = 'v5',
10021
10021
  moduleId = 28,
10022
- version = '5.0.3',
10022
+ version = "3.2.1",
10023
10023
  MessageType = {
10024
10024
  PageView: 3,
10025
10025
  PageEvent: 4,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-braze-kit-5",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
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",
@@ -25,6 +25,7 @@
25
25
  "devDependencies": {
26
26
  "@rollup/plugin-commonjs": "22.0.1",
27
27
  "@rollup/plugin-node-resolve": "13.3.0",
28
+ "@rollup/plugin-replace": "^6.0.3",
28
29
  "chai": "^4.2.0",
29
30
  "karma": "^5.1.0",
30
31
  "karma-chai": "^0.1.0",