@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
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
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
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 reachesflushAt (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 anonError callback to log batches that still fail:
401 from an invalid write key, call onError and then drop the batch. See Configuration & delivery.