1.2.4 โข Published 1 year ago
@rella-so/sdk v1.2.4
Rella
This is the Rella javascript SDK, allowing you to easily track what's happening in your React/Node.js/Vue/etc. application.
Installation
To install:
yarn add @rella/sdk
or
npm install @rella/sdk
Useage
Setup
// index.ts
const rella = Rella({
enabled: proccess.env.NODE_ENV === "production",
apiKey: "<your-api-key>", // from Rella dashboard
});
Tracking events
// inside things you want to track:
import { rella } from "./";
const userRegistered = (params) => {
//....
rella.track({
type: "user-registered",
icon: "๐",
color: "#A6F4C5",
title: "User registered",
msg: user.name + " has registered",
tags: {
userID: user.id,
email: user.email,
orgID: user.organization.id,
},
});
};
// You can also at any time add default tags that will be included in every request.
// Which is really handy if you want to always associate all events with a user.
rella.setDefaults({ "user-id": "1234" });
// If for a particular track event you want to ignore these default tags, just pass `includeDefault` option to track as false
rella.track(
{
type: "database-usage-high",
icon: "๐ฅ",
color: "#A6F4C5",
title: "Database CPU spike",
},
{ includeDefault: false }
);
Identify users
// inside things you want to track:
import { rella } from "./";
const userSignIn = (user: User) => {
//....
rella.identify({
user: {
id: user.id,
name: user.name,
image: user.imageUrl,
email: user.emailAddress,
active: true,
created: user.createdAt.toIS08601()
},
org: {
id: user.team.id,
name: user.team.name,
plan: user.team.plan,
active: true,
created: user.team.createdAt.toIS08601()
}
};
Send metrics
// inside things you want to track:
import { rella } from "./";
const downReport = (user: User) => {
//....
rella.metric({
name: "Report downloaded",
incr_by: 1,
icon: "๐งพ",
});
};
You can also use the event builder located here to quickly prototype new events.