Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document new urls in MigrationFromOldJsClient.mdx #1842

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions docs/client/javascript-mono/MigrationFromOldJsClient.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The architecture and majority of the APIs in the updated SDK have been retained;

Below is a list of identified breaking changes that will require manual refactoring:

### Initialization
## Initialization

Previously, the SDK employed a single method for initialization. However, we have recognized that waiting for a method call during app startup can be impractical. Consequently, we have introduced two distinct initialization approaches: one synchronous and one asynchronous.

Expand Down Expand Up @@ -54,7 +54,7 @@ You can read more about StatsigClient initialization [here](/client/javascript-s



### getConfig is now getDynamicConfig
## getConfig is now getDynamicConfig
Make sure you update your `getConfig` callsites to call the new method, `getDynamicConfig`. In addition, `DynamicConfig` and `Layer` are no longer classes, but javascript objects. There are still convenience `get` methods, which should remain unchanged.

```js
Expand All @@ -66,8 +66,7 @@ statsigClient.getDynamicConfig('config_name');
```



### Bootstrapping
## Bootstrapping
If you are using a server SDK to bootstrap your js/react app, you will need to make some updates to how your server SDK generates values. One of the optimizations we made with this new js-client SDK was to remove the `sha256` library for hashing gate/experiment names. Instead, we use a `djb2` hash. By default, all server SDKs generate `sha256` hashes of gate/experiment names in the `getClientInitializeResponse` method. You will need to set the hash algorithm parameter to that method call to `"djb2"` instead in order to bootstrap this new client SDK. One of the benefits to this hashing algorithm is it will make the entire payload smaller as well, so its a net win on package size, speed, and payload size for the SDK.

For example, if you are bootstrapping from a nodejs app, you will need to do:
Expand All @@ -83,13 +82,7 @@ statsig.getClientInitializeResponse(
```








### Updating the User
## Updating the User

Similar to initialization, the `updateUser` method now supports both synchronous and asynchronous approaches. Each method functions in the same manner as the initialization process.

Expand Down Expand Up @@ -120,12 +113,6 @@ await Statsig.updateUser(user);









## Static Instance

In the previous SDK version, there was a top-level static interface for using Statsig. To enhance support for multiple instances,
Expand Down Expand Up @@ -163,12 +150,6 @@ You can read more about StatsigClient multi-instance support [here](/client/java









## Overrides

Previously, the client had top level methods for managing overrides for gates/configs/experiments/layers, etc. Now, this has been removed from the main SDK and is in its own package. You can implement your own overrides, or use `@statsig/js-local-overrides` and plug it in as the local override adapter in `StatsigOptions`
Expand Down Expand Up @@ -244,6 +225,18 @@ StatsigLocalStorage.disabled = false;
</Tabs>



## Endpoints
If you are migrating from v4.x.x of the js-client sdk, or v1.x.x of the react SDK, you may need to account for new default apis that the SDK will hit to initialize and log events.

- event logging endpoint: https://prodregistryv2.org/v1/rgstr
- initialize endpoint: https://featureassets.org/v1/initialize

See also: [https://docs.statsig.com/client/javascript-sdk#networkconfig-object](/client/javascript-sdk#networkconfig-object)




## Legacy StatsigOptions
The options to parameterize initialization of the SDK have changed. In some cases, the underlying features were removed or moved and can be enabled/disabled in a different way. In other scenarios, there is a new API for managing them. The following is a mapping of old options to their equivalents in the new sdk.

Expand Down
Loading