InvergeDocs
JavaScriptAPI reference

Nexus (entry point)

Nexus (entry point) in the JavaScript SDK.

// access
Nexus.init({ apiKey })
SymbolKindSummary
NexusclassThe Nexus umbrella SDK — one entry point for every service, correlated to a single journey session.
NexusConfiginterfaceConfiguration for {@link Nexus.init }.

Nexus

class

The Nexus umbrella SDK — one entry point for every service, correlated to a single journey session. Isomorphic: works in every browser framework and in Node/Express.

import { Nexus } from '@inverge/nexus';
const nexus = Nexus.init({ apiKey: 'nxs_...' });
nexus.events.track('order_placed', { total: 42 });

init()

static method
static init(config: NexusConfig, opts?: { force?: boolean }): Nexus

Initialise the SDK. Idempotent: if an instance already exists it is returned as-is — a repeated call (an SSR module re-eval, an HMR reload, a second import) will NOT tear down and reconnect the live realtime socket. Pass { force: true } to deliberately dispose the current instance and start a fresh one (e.g. to switch API keys).

Parameters

Prop

Type

Returns Nexus

View source

config

property
readonly config: ResolvedConfig

sessions

property
readonly sessions: NexusSessions

events

property
readonly events: NexusEvents

logs

property
readonly logs: NexusLogs

errors

property
readonly errors: NexusErrors

flags

property
readonly flags: NexusFlags
property
readonly links: NexusLinks

realtime

property
readonly realtime: NexusRealtime

remoteConfig

property
readonly remoteConfig: NexusRemoteConfig

surveys

property
readonly surveys: NexusSurveys

replay

property
readonly replay: NexusReplay

push

property
readonly push: NexusPush

inApp

property
readonly inApp: NexusInApp

liveActivities

property
readonly liveActivities: NexusLiveActivities

instance

property
static readonly instance: Nexus

The app-wide instance. Throws if {@link init} hasn't run.

isInitialized

property
static readonly isInitialized: boolean

distinctId

property
readonly distinctId: string | null

sessionKey

property
readonly sessionKey: string

enabled()

method
enabled(service: NexusService): boolean

Whether a product is switched on — config services / NEXUS_<SERVICE>_ENABLED.

Parameters

Prop

Type

Returns boolean

View source

identify()

method
identify(distinctId: string, options?: IdentifyOptions): Promise<void>

Identify the current end-user (shorthand for sessions.identify).

Parameters

Prop

Type

View source

reset()

method
reset(): void

Forget the current user and start a fresh session (e.g. on logout).

View source

flush()

method
async flush(): Promise<void>

Flush all batched telemetry now.

View source

dispose()

method
dispose(): void
View source

NexusConfig

interface

Configuration for {@link Nexus.init }.

apiKey

property
apiKey: string

Tenant API key (nxs_...). Sent as x-api-key, and in the socket handshake.

baseUrl

property
baseUrl?: string

API origin. Partner endpoints live under /partner. Default https://services.inverge.net.

realtimeUrl

property
realtimeUrl?: string

Realtime (Socket.IO) origin. Defaults to {@link baseUrl}.

autoTrackSessions

property
autoTrackSessions?: boolean

Start/refresh a journey session automatically. Default true.

autoCaptureErrors

property
autoCaptureErrors?: boolean

Capture uncaught errors automatically (browser window/unhandledrejection, Node process). Default true.

flushOnHide

property
flushOnHide?: boolean

Flush queued telemetry on page hide / process exit. Default true.

flushIntervalMs

property
flushIntervalMs?: number

Batch flush cadence (ms) for events/logs. Default 10000.

maxBatch

property
maxBatch?: number

Max items per flush. Default 50.

logLevel

property
logLevel?: 'silent' | 'error' | 'warn' | 'info' | 'debug'

Diagnostic verbosity. Default warn.

appVersion

property
appVersion?: string

App/service version reported with telemetry.

defaultProperties

property
defaultProperties?: Record<string, unknown>

Properties merged into every event/person context.

remoteConfigEnabled

property
remoteConfigEnabled?: boolean

Fetch Remote Config at init (and on foreground). Default false.

remoteConfigRealtime

property
remoteConfigRealtime?: boolean

Re-fetch Remote Config live on publish (needs a realtime connection). Default false.

remoteConfigDefaults

property
remoteConfigDefaults?: Record<string, unknown>

In-app default Remote Config values.

replayEnabled

property
replayEnabled?: boolean

Record browser session replay (rrweb). Requires the rrweb peer dependency. Browser-only; no-op on the server. Default false.

replayMaskAllInputs

property
replayMaskAllInputs?: boolean

Redact every input value from replay. Default true.

replayBlockClass

property
replayBlockClass?: string

CSS class on elements to fully block (never captured) in replay. Default nexus-block.

replayMaskTextClass

property
replayMaskTextClass?: string

CSS class on elements whose text is masked in replay. Default nexus-mask.

replayFlushIntervalMs

property
replayFlushIntervalMs?: number

How often (ms) buffered replay events are shipped. Default 5000.

fetch

property
fetch?: typeof globalThis.fetch

Custom fetch implementation (defaults to global fetch).

services

property
services?: Partial<Record<NexusService, boolean>>

Switch products off without removing their code, e.g. { liveActivities: false }. On Node the NEXUS_<SERVICE>_ENABLED environment variables apply too — off wins. A switched-off service makes no request and never throws.

enabled

property
enabled?: boolean

false switches every service off (also NEXUS_ENABLED=false). Default true.

On this page