Skip to main content
@glyphhq/browser sends events from a web app. It queues messages in memory, sends them in batches, and attempts a flush when the tab is hidden or the connection returns.

Install

The script tag build exposes init, profile, track, group, page, flush, and reset on window.Glyph. The npm package additionally exports the GlyphBrowser class and singleton helpers such as getClient. 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.
Browser write keys are public credentials. They can ingest events but cannot read data. Use a glyph_test_... key during development so test events stay separate from live customer data.

Initialize

Create a client directly, or use init to share a singleton across the app:
Calling init() again disposes the previous singleton and discards its queued messages. reset() disposes it without creating a replacement; call it on logout. See Configuration & delivery for all constructor options. The browser client adds one of its own:

Identify customers with profile

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

Record actions with track

Properties are optional JSON. See What to capture for event selection and naming guidance.

Record page views with page

The browser SDK exposes page for client-side page views:
The name is optional; properties default to {}.

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), on the flushIntervalMs timer (default 5 s), or when autoFlush fires on tab hide or reconnect. You can also force it:
The queue is not persisted to local storage. A tab close, crash, blocked request, or failed unload can lose messages. Capture payments, subscription changes, and other critical events with a server SDK.

Known customers only

Every method takes userId as its first argument. Glyph does not support anonymous identities; begin tracking after signup or another point where the customer is known.