JSPM

@tranthor/sdk-node

0.1.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 6
  • Score
    100M100P100Q40813F
  • License MIT

Tranthor's node sdk for customer engagement.

Package Exports

  • @tranthor/sdk-node
  • @tranthor/sdk-node/dist/cjs/index.js
  • @tranthor/sdk-node/dist/ejs/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@tranthor/sdk-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

tranthor

Tranthor node SDK. Use it to send events to Tranthor, an open source customer engagement platform, from your node application.

Installation

# Using Yarn
yarn add tranthor

# Using NPM
npm install --save tranthor

Usage

import { TranthorSdk } from 'tranthor';

// Initialize with workspace credentials
await TranthorSdk.init({
  writeKey: 'Basic your-write-key-here',
  host: 'https://app.tranthor.com' // Optional custom endpoint
});

// Identify user with events and record attributes about them. Save user id and an identify user and add attributes about them. 
// This is how you can add optional attributes like email, name, etc.
TranthorSdk.identify({
  userId: 'user_123',
  traits: {
    email: 'marc@legend.com',
    firstName: 'Marc',
    lastName: 'Legend',
    plan: 'premium'
  }
});
  
// Track custom events with properties where you record actions your users perform and any properties about the action.
TranthorSdk.track({
  userId: 'user_123',
  event: 'purchase_completed',
  properties: {
    amount: 49.99,
    currency: 'USD'
  }
});

// Here you can record specific screen engagement on the mobile devices. 
// along with any properties about the screen.
TranthorSdk.screen({
  userId: 'user_123',
  name: 'restaurant_screen',
  properties: {
    order_id: '1234567890',
    restaurant_name: 'The best restaurant',
    items: ['burger', 'fries', 'soda']
  }
});

 // Flush pending events to Tranthor. This is important for async events to ensure they are sent synchronously.
 await TranthorSdk.flush();