UNPKG

@tranthor/sdk-node

Version:

Tranthor's node sdk for customer engagement.

62 lines (51 loc) 1.57 kB
# tranthor Tranthor node SDK. Use it to send events to Tranthor, an open source customer engagement platform, from your node application. ## Installation ```bash # Using Yarn yarn add tranthor # Using NPM npm install --save tranthor ``` ## Usage ```typescript 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(); ```