1.1.2 • Published 5 years ago

revolt-sdk v1.1.2

Weekly downloads
1
License
Apache-2.0
Repository
bitbucket
Last release
5 years ago

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

1) You can to add Revolt SDK Script (from dist folder) on your website.

<body>
    <script type="text/javascript" src="revolt.min.js"></script>
</body>

Then, in your javascript file

var revolt = new RevoltSDK(options);

2) You can install via node

npm install revolt-sdk

Then, in your javascript file

import 'revolt-sdk'

var revolt = new RevoltSDK(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.

SettingRequiredDefaultDescription
trackingIdtruen/aString. Identifier of customer or application. It is set up by service owner.
keytruen/aString. Used to verify an application during the authentication process.
versiontruen/aString. Version of yours application.
codetruen/aString. Code of application. Example: com.miquido.revolt.
maxBatchSizefalse20Number. The max size of events batch in one request.
eventDelayMillisfalse5000Number ms. Delay in sending events in millisecond.
firstRetryTimeSecondsfalse5Number s. First time interval in seconds to retry sending the events when any error occurs.
maxRetryTimeSecondsfalse300Number s. Number s. Max interval between retries in seconds.
disablefalsefalseBoolean. You can turn off SDK
apiUrlfalsetrueString
apiVersionfalsetrueString

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.
SettingRequiredDefaultDescription
typetruen/aString (max. 32). Type of an event. It determines structure of event data. Example: ‘ play ’.
datatruen/aObject. 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.sendEvent(event);

Creating Events

RevoltSDK instance provides a few methods that allow you to build events objects.

  • userSignedIn(appUserId)
  • userSignedOut(appUserId)
  • userProfile(userData)
  • locationChanged()
SettingRequiredDefaultDescription
appUserIdtruen/aString. Identifier of user used internally by application. In specific case it can be email or login.
userDatatruen/aObject. Example: { appUserId: 'appUserId', birthYear: 1990, country: 'PL', ... }

Example

    revolt.sendEvent(revolt.RevoltSDKEventBuilder.locationChangedEvent());
1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.8

5 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago