import { TranthorSdk } from '@tranthor/sdk-web';
// Initialize the sdk with a writeKey, which is used to identify your
// workspace. This key can be found at
// https://app.tranthor.com/dashboard/settings
await TranthorSdk.init({
writeKey: "Basic trn_abcdefg...",
});
// Lets you tie a user to their actions and record traits about them. It
// includes a unique User ID and any optional traits you know about the
// user, like their email, name, and more.
TranthorSdk.identify({
userId: "user-123",
traits: {
email: "[email protected]",
name: "Alex Smith",
phone: "+1234567890"
},
});
// The track call is how you record any actions your users perform, along
// with any properties that describe the action.
TranthorSdk.track({
userId: "user-123",
event: "Completed Order",
properties: {
orderId: "ORD-789",
revenue: 99.99
},
});
// Lets you record whenever a user sees a screen, the mobile equivalent of
// page, in your mobile app, along with any properties about the screen.
TranthorSdk.screen({
userId: "user-123",
name: "Product Page",
properties: {
category: "Electronics",
priceRange: "500-1000"
},
});
// Ensures that asynchronously submitted events are flushed synchronously
// to Tranthor's API.
await TranthorSdk.flush();