Migrating from v1

Migrating from v1 to v2 has breaking changes, as we have made some architectural level changes. Following are changes in detail:

Authentication Changes

In v1, workspace key and workspace secret are used to authenticate requests made to SuprSend which is not so secure.

In v2 we have changed authentication to use public API Key and Signed User Token.

const suprSendClient = new SuprSend(publicApiKey);

suprSendClient.idenitfy(distinctId, userToken);
suprsend.init(workspace_key, workspace_secret);

Initializing SDK

v1 used init method to initialize SDK and suprsend instance was provided by SDK itself.

In v2 we have provided SuprSend class and its clients responsibility to export the class instance and use it in other places to call library methods.

export const suprSendClient = new SuprSend(publicApiKey);

suprSendClient.track("test")
suprsend.init(workspace_key, workspace_secret);

suprsend.track("test")

Synchronous methods

In v1 all methods used to be asynchronous and have returned void. In background SDK used to batch requests and make api calls.

In v2 we have made all requests synchronous so you could access response of api immediately depending of status of api call. Almost all methods including preference methods return response type of APIResponse.

const trackResponse = await suprSendClient.track("test")

console.log(trackResponse.status) // success or error
const resp = suprsend.track("test") // resp will be null

Renamed methods and arguments to camelCase

In v1, all library methods and method parameters are in snake_case which has been changed to camelCase in v2.

// examples
suprSendClient.user.addEmail();
suprSendClient.user.preferences.getPreferences({tenantId: "test"});
// examples
suprsend.user.add_email();
suprsend.user.preferences.get_preferences({tenant_id: "test"});

Removed purchase_made method

In v2 purchase_mademethod has been removed. If you are using this method in v1 you can directly call track method with event type: $purchase_made.

suprSendClient.track("$purchase_made", {item: "ps5"});
suprsend.purchase_made({item: "ps5"});

Removed set_super_properties

In v2 set_super_properties method has been removed. If you are using this method in v1 you could directly pass all these super properties as individual event properties.


After migrating please test all library methods to see if they everything is working properly. If you face any issue in migration process please reach out to us on our slack community or drop an email to us on [email protected]