Skip to main content
@glyphhq/node sends events from API routes, webhooks, and background jobs. Use server-side tracking for payments, subscription changes, and other events that must not depend on a browser session.

Install

The package ships ESM and CJS builds with TypeScript types. Node.js 18+ is required (the SDK uses the built-in fetch). The SDK reports its package name and version with each request. Glyph stores this as diagnostic metadata alongside the write key used for ingestion. It is not added to event properties.

Initialize

Keep the write key in an environment variable. Use a glyph_pk_... key in production and a glyph_test_... key while testing the integration. Configuration & delivery lists the shared constructor options. The Node client adds one option:

Identify customers with profile

Call profile when a customer signs up or when a profile trait changes. userId is the stable identity key, and every profile must include email.

Record actions with track

Methods resolve once the message is queued. If a call reaches the flushAt threshold, its promise waits for that flush attempt. To backfill an event, pass its original timestamp as the fourth argument:

Record account context with group

group records a group/account event on the customer’s timeline. Glyph does not currently create a separate account record or provide group-level analytics.

Flushing

Messages queue locally and flush when the queue reaches flushAt (default 20) or on the flushIntervalMs timer (default 5 s). In short-lived processes, flush explicitly before exiting:

Serverless and API routes

Serverless runtimes can freeze or terminate as soon as a response is sent, taking your queue with them. Flush before responding:

Handle delivery failures

The SDK retries transient delivery failures. Add an onError callback to log batches that still fail:
Retryable failures leave the batch queued for a later flush. Non-retryable failures, such as a 401 from an invalid write key, call onError and then drop the batch. See Configuration & delivery.