Node — Configuration
Configure the Node client withcreateSignalNode(options). Required: apiKey. Optional: endpoint (defaults to https://api.trysignal.ai/).
createSignalNode options
| Option | Type | Default | Description |
|---|---|---|---|
endpoint | string | https://api.trysignal.ai/ | API endpoint for sending events |
apiKey | string | required | API key for authentication |
projectId | string | 'default' | Project ID |
debug | boolean | false | Enable debug logging |
flushBatchSize | number | 20 | Flush when this many events are queued |
flushInterval | number | 10000 | Flush interval in ms |
timeout | number | 30000 | Request timeout in ms |
compression | boolean | true | Enable gzip compression |
personalApiKey | string | '' | Personal API key (e.g. for feature flags) |
fetch | typeof fetch | globalThis.fetch | Custom fetch implementation |
Available methods
After creating a client withcreateSignalNode(), you can call these methods on the instance. All methods are synchronous (return immediately) except flush() and shutdown() which are async.
capture(options)
Track custom events from the server. PasssessionId and windowId from request headers to correlate with client sessions.
| Option | Type | Required | Description |
|---|---|---|---|
distinctId | string | yes | User identifier |
event | string | yes | Event name |
properties | Record<string, JsonType> | no | Event properties |
timestamp | Date | no | When the event occurred (default: now) |
groups | Record<string, string> | no | Groups the user belongs to (e.g. { company: 'acme' }) |
sessionId | string | no | From x-signal-session-id header for client correlation |
windowId | string | no | From x-signal-window-id header for client correlation |
order_created, payment_processed, user_action). Events are queued and sent in batches.
identify(options)
Identify a user and set their properties. Sends an$identify event.
| Option | Type | Required | Description |
|---|---|---|---|
distinctId | string | yes | User identifier |
properties | UserTraits | no | User properties to set (e.g. email, name, plan) |
sessionId | string | no | From header for client correlation |
windowId | string | no | From header for client correlation |
setPersonProperties(distinctId, properties, sessionId?, windowId?)
Set or update user properties (overwrites existing). Sends$set event.
When to use: Update user properties without sending an $identify event (e.g. when properties change after initial identification).
setPersonPropertiesOnce(distinctId, properties, sessionId?, windowId?)
Set user properties only if not already set. Sends$set_once event.
When to use: One-time attributes that shouldn’t be overwritten (e.g. signupSource, firstPurchaseDate).
group(distinctId, groupType, groupKey, properties?, sessionId?, windowId?)
Associate a user with a group (e.g. company, organization). Sends$group_assign event. If properties are provided, also calls groupIdentify() to set group properties.
When to use: When a user joins or is associated with a group (e.g. company, team, organization).
groupIdentify(options, sessionId?, windowId?)
Set or update group properties. Sends$groupidentify event.
| Option | Type | Required | Description |
|---|---|---|---|
groupType | string | yes | e.g. 'company', 'organization' |
groupKey | string | yes | Group identifier |
properties | Record<string, JsonType> | no | Group properties to set |
alias(distinctId, alias, sessionId?, windowId?)
Link an alias (e.g. anonymous ID) to a user. Sends$create_alias event.
When to use: After login to merge anonymous events (from before login) with the identified user.
flush()
Flush all queued events to the server immediately. Returns a Promise. When to use: Before a response in serverless functions, after critical paths, or when you need to ensure events are sent immediately.shutdown()
Stop the flush timer and flush remaining events. Returns a Promise. Call before process exit for graceful shutdown. When to use: In cleanup handlers (e.g.process.on('SIGTERM', ...)) to ensure no events are lost when the process exits.
Client-side: tracing headers
For session correlation, the client must send tracing headers. Use @signal-js/browser (or React/Next.js/Vue) and setaddTracingHeaders: true (or an array of hostnames). See Vue or React for client options.
See also
- Initialization — Setup
- Flush and shutdown — flush(), shutdown()
