The Events SDK provides PostHog-style event capture with automatic session context, person identification, and batched transport. Events are sent to
/ingest/e (single) and /ingest/batch (batch) endpoints.Overview
The Composite SDK events system allows you to:- Capture custom events with arbitrary properties
- Identify users and merge anonymous activity
- Set person properties for user profiles
- Filter events with beforeSend hooks
- Automatic batching for efficient transport
Quick Start
Events are enabled by default. Start capturing immediately after initialization:Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
captureEvents | boolean | true | Enable/disable event capture |
beforeSend | BeforeSendFn | BeforeSendFn[] | undefined | Hook(s) to modify or reject events |
processPersonProfile | boolean | true | Whether to process person profiles |
Disabling Event Capture
Use session recording only without sending events:When
captureEvents: false:capture()calls are ignoredsetPersonProperties()/setPersonPropertiesOnce()are ignoredcreateAlias()is ignoredidentify()still updates local identity but doesn’t send an event- Session recording continues normally
Capturing Events
Basic Event Capture
Event with Person Properties
Set person properties along with the event using the third argument:Capture Options
| Option | Type | Description |
|---|---|---|
$set | Record<string, unknown> | Person properties to set (overwrites existing) |
$set_once | Record<string, unknown> | Person properties to set only if not already set |
timestamp | string | Override event timestamp (ISO 8601) |
sys_uuid | string | Override auto-generated idempotency key |
_url | string | Per-event endpoint override |
Return Value
capture() returns the processed event or undefined if rejected:
Person Identification
Identifying Users
When a user signs up or logs in, identify them to merge their anonymous activity:sys_identify event that:
- Links the anonymous ID to the identified user
- Sets the provided properties on the person profile
- Enables attribution of past anonymous events
Identify with Options
Getting Identity Info
Reset Identity (Logout)
Person Properties
Set Properties (Overwrite)
Always overwrites existing values:Set Properties Once (First-Touch)
Only sets if the property doesn’t already exist:Create Alias
Link another identifier to the current person:beforeSend Hook
Modify or reject events before they’re sent.Single Hook
Multiple Hooks (Chained)
Hooks are executed in order. Returnnull from any hook to reject the event:
Hook Signature
- Return the event (modified or unchanged) to send it
- Return
nullto reject the event
Event Schema
CompositeEvent Structure
Events sent to the backend follow this schema:Special Event Types
| Event | Description |
|---|---|
sys_identify | User identification with merge |
sys_set | Explicit person property update |
sys_create_alias | Link identifier to person |
Complete Example
API Reference
Methods
| Method | Description |
|---|---|
capture(event, properties?, options?) | Capture a custom event |
identify(distinctId, properties?, options?) | Identify user and merge anonymous data |
setPersonProperties(properties) | Set person properties (overwrite) |
setPersonPropertiesOnce(properties) | Set person properties (first-touch) |
createAlias(alias) | Link identifier to current person |
reset() | Reset identity and session |
getDistinctId() | Get current user ID |
getAnonymousId() | Get anonymous ID |
getSessionId() | Get current session ID |
Types
Troubleshooting
Events not appearing in dashboard
Events not appearing in dashboard
Check:
captureEventsis not set tofalse- API key is correct and has event permissions
- No JavaScript errors in console
- Network tab shows requests to
/ingest/eor/ingest/batch beforeSendhook is not returningnull
User identity not merging
User identity not merging
Ensure:
- You call
identify()after the user logs in - The
distinct_idis consistent across sessions - You’re not calling
reset()immediately afteridentify()
Person properties not updating
Person properties not updating
Check:
captureEventsis enabled (person updates are ignored when disabled)- For
setPersonPropertiesOnce, the property may already exist - Verify the properties object contains valid values
beforeSend hook issues
beforeSend hook issues
Debug:Ensure your hook always returns the event or explicitly returns
null.Best Practices
Use Descriptive Names
Name events clearly:
subscription_started not sub1Set Properties Early
Use
setPersonPropertiesOnce for attribution data on first visitIdentify Promptly
Call
identify() as soon as the user logs in or signs upSanitize Data
Use
beforeSend to strip sensitive data before sending