Revolt JavaScript SDK
This guide shows how to add Revolt JS SDK to your Web Application to track user behavior and the context around that behavior.
Installation
- You can to add Revolt SDK Script (from dist folder) on your website.
Then, in your javascript file
var revolt = options;
- You can install via node
npm install revolt-sdk
Then, in your javascript file
var revolt = options;
Where options is an object literal that defines the settings to use for the Revolt SDK. All available option settings are shown in the tables below.
Setting | Required | Default | Description |
---|---|---|---|
trackingId | true | n/a | String. Identifier of customer or application. It is set up by service owner. |
key | true | n/a | String. Used to verify an application during the authentication process. |
version | true | n/a | String. Version of yours application. |
code | true | n/a | String. Code of application. Example: com.miquido.revolt. |
maxBatchSize | false | 20 | Number. The max size of events batch in one request. |
eventDelayMillis | false | 5000 | Number [ms]. Delay in sending events in millisecond. |
firstRetryTimeSeconds | false | 5 | Number [s]. First time interval in seconds to retry sending the events when any error occurs. |
maxRetryTimeSeconds | false | 300 | Number [s]. Number [s]. Max interval between retries in seconds. |
disable | false | false | Boolean. You can turn off SDK |
apiUrl | false | true | String |
apiVersion | false | true | String |
If you don't have trackingId
or key
, please contact Revolt Team for assistance.
API
RevoltSDK instance has following methods:
sendEvent({ type: ‘eventType’, data: ‘eventData’ })
- It registers an event to send.sendEventImmediately({ type: ‘eventType’, data: ‘eventData’ })
- It sends an event immediately.willBeRemoved()
- It informs the SDK that the User is leaving applications.
Setting | Required | Default | Description |
---|---|---|---|
type | true | n/a | String (max. 32). Type of an event. It determines structure of event data. Example: ‘ play ’. |
data | true | n/a | Object. Data of an event. The complex structure of the data object is allowed (sub-objects, arrays). Example: { name: ‘SongName’, duration: 1500, tracks : [ ‘firstSong’, ‘secondSong’ ] }. |
Example
The following method sends an event to Revolt indicating that the song was played.
var event = type: 'play' data: trackName: 'Friday' artist: 'Rebecca Black' ; revolt;
Creating Events
RevoltSDK instance provides a few methods that allow you to build events objects.
userSignedIn(appUserId)
userSignedOut(appUserId)
userProfile(userData)
locationChanged()
Setting | Required | Default | Description |
---|---|---|---|
appUserId | true | n/a | String. Identifier of user used internally by application. In specific case it can be email or login. |
userData | true | n/a | Object. Example: { appUserId: 'appUserId', birthYear: 1990, country: 'PL', ... } |
Example
revolt;