|
| 1 | +# Migrating to JavaScript SDK v11 |
| 2 | + |
| 3 | +JavaScript SDK v11.0.0 has a few breaking changes that you should consider when migrating from version 10.x.x. |
| 4 | + |
| 5 | +## Changes that affect server-side API (Node.js) |
| 6 | + |
| 7 | +While JavaScript SDK previously supported Node.js v6 and above, the SDK now requires Node.js v14 or above. |
| 8 | + |
| 9 | +## Changes that affect client-side API (Browser) |
| 10 | + |
| 11 | +Below you will find a list of the changes: |
| 12 | + |
| 13 | +- **Removed the `core.trafficType` configuration option (`SplitIO.IBrowserSettings['core']['trafficType]`) and the `trafficType` parameter from the SDK `client()` method in Browser (`SplitIO.IBrowserSDK['client']`). As a result, traffic types can no longer be bound to SDK clients, and the traffic type must be provided in the `track` method.** |
| 14 | + |
| 15 | +This change was made to align the SDK with the client-side APIs of the [Browser SDK](https://help.split.io/hc/en-us/articles/360058730852-Browser-SDK) and [React Native SDK](https://help.split.io/hc/en-us/articles/4406066357901-React-Native-SDK). |
| 16 | + |
| 17 | +SDK clients cannot be bound to a traffic type anymore, and so the traffic type must be provided when calling the `client.track` method. For example: |
| 18 | + |
| 19 | +```javascript |
| 20 | +// JS SDK v10.x.x |
| 21 | +const factory = SplitFactory({ |
| 22 | + core: { |
| 23 | + authorizationKey: '...', |
| 24 | + key: USER_KEY, |
| 25 | + trafficType: 'user' |
| 26 | + } |
| 27 | +}); |
| 28 | + |
| 29 | +const client = factory.client(); |
| 30 | +const accountClient = factory.client(ACCOUNT_ID, 'account'); |
| 31 | + |
| 32 | +client.track('my_event'); |
| 33 | +accountClient.track('my_event'); |
| 34 | +``` |
| 35 | + |
| 36 | +should be replaced with: |
| 37 | + |
| 38 | +```javascript |
| 39 | +// JS SDK v11.0.0 |
| 40 | +const factory = SplitFactory({ |
| 41 | + core: { |
| 42 | + authorizationKey: '...', |
| 43 | + key: USER_KEY |
| 44 | + } |
| 45 | +}); |
| 46 | + |
| 47 | +const client = factory.client(); |
| 48 | +const accountClient = factory.client(ACCOUNT_ID); |
| 49 | + |
| 50 | +client.track('usuer', 'my_event'); |
| 51 | +accountClient.track('account', 'my_event'); |
| 52 | +``` |
| 53 | + |
| 54 | +- **Removed the deprecated `GOOGLE_ANALYTICS_TO_SPLIT` and `SPLIT_TO_GOOGLE_ANALYTICS` integrations. The `integrations` configuration option has been removed from the SDK factory configuration, along with the associated interfaces in the TypeScript definitions.** |
| 55 | + |
| 56 | +The Google Analytics integrations were removed since they integrate with the *Google Universal Analytics* library, which was shut down on July 1, 2024, and [replaced by *Google Analytics 4*](https://support.google.com/analytics/answer/11583528?hl=en). Go to Split's [Google Analytics integration guide](https://help.split.io/hc/en-us/articles/360040838752-Google-Analytics) for more information on how to integrate Split with Google Analytics 4. |
| 57 | + |
| 58 | +The integrations have stopped being used and maintained, and were removed from the SDK, together with the `integrations` configuration option. If you were using the `integrations` option, you should remove it from your SDK configuration object. |
| 59 | + |
| 60 | +- **Removed internal polyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers.** |
| 61 | + |
| 62 | +The SDK no longer ships with internal implementations for the `Map` and `Set` global objects, which were used to support old browsers like IE. |
| 63 | + |
| 64 | +If you need to target environments that do not support these features natively, you should provide a polyfill for them. For example, [es6-map](https://github.com/medikoo/es6-map) for `Map`, and [es6-set](https://github.com/medikoo/es6-set) for `Set`. |
| 65 | + |
| 66 | +In addition, the Split SDK depends on support for ES6 promises. Since v10.2.0, the SDK does not pollute any global variable to add the ES6 promise polyfill. If your environment does not support ES6 promises, you can [polyfill](https:/github.com/stefanpenner/es6-promise). |
| 67 | + |
| 68 | +- **Dropped support for Split Proxy below version 5.9.0, when using in the browser (client-side API). The SDK now requires Split Proxy 5.9.0 or above.** |
| 69 | + |
| 70 | +If using the Split Proxy with the SDK in the browser, make sure to update it to version 5.9.0 or above. This is required due to the introduction of Large Segments matchers in the SDK on client-side, which uses a new HTTP endpoint to retrieve the segments data and is only supported by Split Proxy 5.9.0. |
0 commit comments