|
| 1 | +# Migrating to JavaScript Browser SDK v1 |
| 2 | + |
| 3 | +JavaScript Browser SDK v1.0.0 has a few breaking changes that you should consider when migrating from version 0.x.x. |
| 4 | + |
| 5 | +## Renamed some TypeScript definitions in the `SplitIO` namespace to avoid conflicts with other Split packages |
| 6 | + |
| 7 | +The renamed types are: |
| 8 | +- `SplitIO.IBrowserSettings` -> `SplitIO.IClientSideSettings` |
| 9 | +- `SplitIO.IBrowserAsyncSettings` -> `SplitIO.IClientSideAsyncSettings` |
| 10 | +- `SplitIO.ISDK` -> `SplitIO.IBrowserSDK` |
| 11 | +- `SplitIO.IAsyncSDK` -> `SplitIO.IBrowserAsyncSDK` |
| 12 | +- `SplitIO.IClient` -> `SplitIO.IBrowserClient` |
| 13 | +- `SplitIO.IAsyncClient` -> `SplitIO.IBrowserAsyncClient` |
| 14 | + |
| 15 | +For example, you should replace: |
| 16 | + |
| 17 | +```ts |
| 18 | +import { SplitFactory } from '@splitsoftware/splitio-browserjs'; |
| 19 | + |
| 20 | +const config: SplitIO.IBrowserSettings = { ... }; |
| 21 | +const factory: SplitIO.ISDK = SplitFactory(config); |
| 22 | +``` |
| 23 | + |
| 24 | +with: |
| 25 | + |
| 26 | +```ts |
| 27 | +import { SplitFactory } from '@splitsoftware/splitio-browserjs'; |
| 28 | + |
| 29 | +const config: SplitIO.IClientSideSettings = { ... }; |
| 30 | +const factory: SplitIO.IBrowserSDK = SplitFactory(config); |
| 31 | +``` |
| 32 | + |
| 33 | + |
| 34 | +## Removed the `LocalhostFromObject` export from the default import |
| 35 | + |
| 36 | +In order to simplify the SDK API, the `LocalhostFromObject` export was removed from the default import (`import { LocalhostFromObject } from '@splitsoftware/splitio-browserjs'`), and it is no longer necessary to manually pass it to the `sync.localhostMode` configuration option to enable localhost mode. |
| 37 | + |
| 38 | +If you were using the `LocalhostFromObject` export, you should remove it from your code. For example, replace: |
| 39 | + |
| 40 | +```js |
| 41 | +import { SplitFactory, LocalhostFromObject } from '@splitsoftware/splitio-browserjs'; |
| 42 | + |
| 43 | +const factory = SplitFactory({ |
| 44 | + core: { |
| 45 | + authorizationKey: 'localhost', |
| 46 | + key: SOME_KEY |
| 47 | + }, |
| 48 | + features: { |
| 49 | + 'feature1': 'on' |
| 50 | + }, |
| 51 | + sync: { |
| 52 | + localhostMode: LocalhostFromObject() |
| 53 | + } |
| 54 | +}); |
| 55 | +``` |
| 56 | + |
| 57 | +with: |
| 58 | + |
| 59 | +```js |
| 60 | +import { SplitFactory } from '@splitsoftware/splitio-browserjs'; |
| 61 | + |
| 62 | +const factory = SplitFactory({ |
| 63 | + core: { |
| 64 | + authorizationKey: 'localhost', |
| 65 | + key: SOME_KEY |
| 66 | + }, |
| 67 | + features: { |
| 68 | + 'feature1': 'on' |
| 69 | + } |
| 70 | +}); |
| 71 | +``` |
| 72 | + |
| 73 | +## Removed the deprecated `GoogleAnalyticsToSplit` and `SplitToGoogleAnalytics` pluggable integration modules, along with the related interfaces in the TypeScript definitions |
| 74 | + |
| 75 | +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). Check [this docs](https://help.split.io/hc/en-us/articles/360040838752-Google-Analytics#google-analytics-4-ga4) for more information on how to integrate Split with Google Analytics 4. |
| 76 | + |
| 77 | +## Removed internal polyfills for the `Map` and `Set` global objects, dropping support for IE and other outdated browsers |
| 78 | + |
| 79 | +The SDK no longer ships with internal implementations for the `Map` and `Set` global objects, which were used to support old browsers like IE. |
| 80 | + |
| 81 | +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`. |
| 82 | + |
| 83 | +## Dropped support for Split Proxy below version 5.9.0. The SDK now requires Split Proxy 5.9.0 or above |
| 84 | + |
| 85 | +If using the Split Proxy with the SDK, 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, which uses a new HTTP endpoint to retrieve the segments data and is only supported by Split Proxy 5.9.0. |
0 commit comments