npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

revolt-sdk

v1.1.2

Published

Revolt JavaScript SDK

Downloads

32

Readme

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);
  1. 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.

| 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.sendEvent(event);

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.sendEvent(revolt.RevoltSDKEventBuilder.locationChangedEvent());