Skip to content

Configuration

Call once at application startup before any observe() calls.

import { initPulse } from "@pulse/sdk";
initPulse({
apiKey: "pulse_sk_...",
apiUrl: "https://pulse.yourcompany.com",
batchSize: 20,
flushInterval: 10000,
enabled: process.env.NODE_ENV === "production",
});
OptionTypeRequiredDescription
apiKeystringYesYour Pulse API key. Must start with pulse_sk_.
apiUrlstringNoPulse server URL. Default: http://localhost:3000
batchSizenumberNoNumber of traces to buffer before flushing. Range: 1-100. Default: 10
flushIntervalnumberNoMilliseconds between periodic flushes. Minimum: 1000. Default: 5000
enabledbooleanNoEnable or disable tracing. Default: true

Traces are buffered in memory and sent to the server in two situations:

  • Buffer reaches batchSize and flushes immediately.
  • The flushInterval timer fires and flushes what is buffered.

On process exit (beforeExit, SIGINT, SIGTERM), the SDK flushes all remaining traces before shutdown.

initPulse() validates values at startup:

  • apiKey must be a non-empty string starting with pulse_sk_.
  • batchSize must be an integer between 1 and 100.
  • flushInterval must be at least 1000ms.

Invalid values throw immediately so misconfiguration is caught early.

Set enabled: false to turn off all tracing. observe() still returns a working client but skips trace capture.

initPulse({
apiKey: "pulse_sk_...",
enabled: false,
});