Node.js SDK

Access the Experience API within Node.js.

The Node.js SDK enables you to interact easily format and send events to Experience API endpoints in Node.js run times.

The Node.js SDK exposes the sendTrackEvent and sendIdentifyEvent functions. These SDK methods automatically generate the event payloads necessary for the Experience API batch upsert endpoint as track and identify events, respectively.

This SDK is deigned for sending location-agnostic track and identify events server-side, typically as part of bulk import processes or within serverless functions. The batch endpoint is used because it does not attempt to resolve the request's location.

A page function is purposely not exposed. For ESR/SSR use cases where page events may need to be sent and/or request location may need to be resolved, consider using the Shared SDK.

import { NinetailedAPIClient } from "@ninetailed/experience.js-node";

const apiClient = new NinetailedAPIClient({
  clientId: "YOUR_API_KEY"
  environment: "YOUR_NINETAILED_ENV"
})

apiClient.sendTrackEvent(
    id: string,
    event: name, 
    properties?: JsonObject, // A JSON object of arbitrary key:value pairs
    options?: {
        anonymousId?: string,
        timestamp?: number,
        timeout?: number | undefined // Default: 5000
    }
)

apiClient.sendIdentifyEvent(
    id: string,
    traits: Traits, // A JSON object of arbitrary key:value pairs
    options?: {
        anonymousId?: string,
        timestamp?: number,
        timeout?: number | undefined // Default: 5000
    }
)

apiClient.getProfile(
    id: string,
    options?: {
        timeout?: number | undefined // Default: 5000
    }
)

Last updated