Installation
Basic usage
Basic setup
Create a client instance to start tracking events:client.ts
The client provides methods to send events individually or in batches, with
automatic retries and error handling built-in.
Sending events
Send a single event
Send a complete event in one call:Send a batch of events
Send multiple events at once for better performance:Start and complete events
For long-running requests or when you want to track the start and completion separately:Start/complete tracking is useful for asynchronous operations or when you need
to track events that span multiple function calls or processes.
Tracking steps
Track sub-operations within a request to monitor database queries, external API calls, and other operations:Configuration
The SDK automatically reads configuration from environment variables. You can also pass options directly when creating the client.string
required
Your Sentinel API key. Can be provided via
SENTINEL_API_KEY environment
variable or passed directly to createClient().API reference
createClient(config: SentinelConfig): SentinelClient
Creates a new Sentinel client instance.
client.sendEvent(event: Event): Promise<{ success: boolean; queued: number; projectId: string }>
Sends a single event to Sentinel.
client.sendBatch(events: Event[]): Promise<{ success: boolean; queued: number; projectId: string }>
Sends a batch of events to Sentinel in a single API call.
client.startEvent(eventStart: EventStart): Promise<{ success: boolean; requestId: string; projectId: string }>
Starts tracking an event. The event will be stored partially until completed.
client.completeEvent(eventComplete: EventComplete): Promise<{ success: boolean; requestId: string; projectId: string }>
Completes an event that was previously started. The start and complete data will be merged and sent.
Helper functions
string
Generates a unique request ID for tracking events.
string
Gets the current timestamp in ISO 8601 format.
number
Calculates the size of a request or response body in bytes.