@logsnag/node
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published
LogSnag

@logsnag/node

Clear, Simple, Effective Product Analytics for SaaS.

NPM Version Discord Documentation

Installation

Using npm

npm install @logsnag/node

Using yarn

yarn add @logsnag/node

Using pnpm

pnpm add @logsnag/node

Usage

import { LogSnag } from '@logsnag/node';

const logsnag = new LogSnag({
  token: '<TOKEN>',
  project: '<PROJECT_NAME>'
});

// Track an event
await logsnag.track({
  channel: "payments",
  event: "New Subscription",
  user_id: "user-123",
  icon: "💰",
  notify: true,
  tags: {
    plan: "premium",
    cycle: "monthly",
    trial: false
  }
});

// Identify user traits (e.g. name, email, plan, etc.)
await logsnag.identify({
  user_id: "user-123",
  properties: {
    name: "John Doe",
    email: "john@doe.com",
    plan: "premium",
  }
});

// Track an insight
await logsnag.insight.track({
  title: "User Count",
  value: "100",
  icon: "👨",
});

// Increment an insight value
await logsnag.insight.increment({
  title: "User Count",
  value: 1,
  icon: "👨",
});

Disabling Tracking

You can disable tracking for development purposes by using the disableTracking method:

logsnag.disableTracking();

And enable it back with:

logsnag.enableTracking();

You can check if tracking is disabled with:

logsnag.isTrackingDisabled();

Methods

  • track(options: TrackOptions): Promise<boolean>: Track custom events.
  • identify(options: IdentifyOptions): Promise<boolean>: Identify user traits.
  • group(options: GroupOptions): Promise<boolean>: Group users.
  • insightTrack(options: InsightTrackOptions): Promise<boolean>: Track insights.
  • insightIncrement(options: InsightIncrementOptions): Promise<boolean>: Increment insight values.

API Documentation

For more information about the LogSnag API, see: docs.logsnag.com

Support

If you encounter any problems or issues, please contact us at shayan@logsnag.com

Package Sidebar

Install

npm i @logsnag/node

Homepage

logsnag.com

Weekly Downloads

814

Version

1.0.1

License

MIT

Unpacked Size

21.4 kB

Total Files

6

Last publish

Collaborators

  • sh4yy