1.1.1 • Published 7 months ago

usertrail-js v1.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Installation

npm install usertrail-js

Usage

Import UserTrail

import UserTrail from "usertrail-js";

Create a new UserTrail client

const usertrail = new UserTrail({
  key: <Your API key>
    });

Track event

usertrail.track({
  eventName: "User subscribed", 
  userId: "user-123-456"
});

Identify user

You can set the user id on the client level. It will be sent with all events.

// set user id once
usertrail.identify({
  userId: "user-123-456"
});

// send events, user id can be omitted from track()
usertrail.track({
  eventName: "Event 1",
});

usertrail.track({
  eventName: "Event 2",
});

or you can set the user id on the event level. It will be sent only with this event.

usertrail.track({
  eventName: "User subscribed", 
  userId: "user-123-456" // will override the client user id if exists
});

Updating user id

You can assign a new user id to an existing user. This will update the user data and events from the old user id to the new user id. Useful when a user signs up, and you want to keep the events from the anonymous user.

await usertrail.updateIdentity({
  userId: "user-id-1",
  newUserId: "user-id-2"
});
1.1.1

7 months ago

1.1.0

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago