JS SDK Update Guide

Existing Feature Updates

1) Method Renames

The following methods have been renamed:

  • identify -> setUserAttributes
  • track -> logEvent
  • init -> start
  • runningExperiments -> getRunningExperimentsAndVariations
  • runningFeatureFlags -> getRunningFeatureFlags
  • reset -> resetUser
  • propertiesLoadedCallback -> waitForLoaded (see below)

2) Methods Removed

The following methods have been removed

  • page

3) Launch Parameters Removed

The following launch parameters have been removed

  • auto_page_view

4) Sync Mode removed

The sync mode for requiring the SDK on the page has been removed. The only supported method is now to include the SDK via npm or script tag and call Taplytics.start() with your project token.

If you would like to block the load of your page, we would recommend having the render of the DOM wait on Taplytics by using the waitForLoaded() method to wait on the Taplytics.start() method to run; this will cause the initial render of the page to be blocked until the SDK is initialized, preventing any content flickering from occurring.

5) Async methods return promises

All async methods in the SDK now return promises. Callbacks are no longer supported. Code usages of these methods should be updated, eg:

Taplytics.runningExperiments((experimentVars) => {})


const experimentVars = await Taplytics.getRunningExperimentsAndVariations()

Additionally, the following methods now return promises which did not previously support callbacks.

  • start
  • setUserAttributes
  • resetUser
  • startNewSession

Awaiting these methods allows you to wait for their respective operations to fully complete before proceeding.

6) propertiesLoadedCallback is now waitForLoaded

The propertiesLoadedCallback method has been renamed to waitForLoaded.

The method now returns a promise which can be awaited to wait for the SDK to finish initializing and receiving its initial experiment configuration. Any subsequent calls to this method after the SDK has already initialized will resolve immediately.

7) Email field should not be used as an identifier

Previously, we would consider a user "identified" if either the user_id or email field were set during an identify (now setUserAttributes) call. Going forward, only the user_id field will be considered an identifier, and if that field is not set, the user will be treated as ananonymous user.

If your project does not use the user_id field but does set email, then we recommend setting the user_id field to the same value as email whenever the email is set.

New Features

1) New Session Callback

It is now possible to set a callback to be executed whenever a new session is started (and a corresponding experiment configuration has been retrieved). This can be done as follows:

Taplytics.on('newSession', () => {
    console.log('New session started!')

This can be useful if your application requires some logic to be run whenever a new Taplytics configuration is
received. For example, you may want to re-render a portion of your page using the new set of variable values.