1.2.4 โ€ข Published 1 year ago

@rella-so/sdk v1.2.4

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

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.

1.2.4

1 year ago

1.2.3

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago