Page cover

Quick Start

Getting started with Telemetry is straightforward! Once installed, you can immediately use its powerful features with just a few lines of code. Below, you'll find step-by-step instructions and code examples to help you integrate and leverage the package effectively in your project.

import { YofiTelemetry, LogLevel, AvailableSensors} from '@yofi-ai/telemetry-web-sdk'

const publicToken = 'YOUR-PUBLIC-TOKEN';

YofiTelemetry.initialize({
    publicToken: publicToken, 
    // journeyIdSalt used to generate journey id. If you have different websites, you can use different Salts.
    journeyIdSalt: 'yofiscakes.myshopify.com'
});

// Initial labels if any
const initLabels = {
    'some-label': 'some-value'
};

const session = YofiTelemetry.startSession({
    duration: 900 * 1000, // 15mins
    labels: initLabels,   // Optional
    networkTelemetryConfig: {
        ip: true
    }
});

For single page application(SPA), please use this to stopAllSessions to terminate all existing sessions and initiate a new one when route changes, set the stopAllSessions parameter of startSession to true.

Starting a New Journey

To start a new journey, follow the steps below. You can set labels and other configuration options via yourSessionConfig.

Note: Before calling startNewJourney, make sure you have already called YofiTelemetry.initialize.

Session Labels

You can add labels to a session, the value of each label must be string.

You can wait for the result of addLabels using the following approachs.

Connect Your User to Journey

To connect your user to Yofi Journey, you can simply add a userId label

Default bundleGenerationInterval is 2s

client_id, journey_id and __page_url are labels reserved by the SDK, please do not use them.

Last updated

Was this helpful?