index/classes/EventsBatcherService.md
Service for batching and flushing events to the backend
Usage:
const batcher = new EventsBatcherService(httpClient, {
batchSize: 20,
flushIntervalMs: 3000
});
batcher.track('token_buy', { tokenName: 'PEPE', amount: '100' });
await batcher.flush(); // Manual flush
Constructors
Constructor
new EventsBatcherService(
httpClient,config?):EventsBatcherService
Parameters
| Parameter | Type |
|---|---|
httpClient | HttpClient |
config? | EventsConfig |
Returns
EventsBatcherService
http client events batcher service config
Methods
configure()
configure(
options):void
Configure batching options
Parameters
| Parameter | Type |
|---|---|
options | Partial<EventsConfig> |
Returns
void
events config
flush()
flush():
Promise<void>
Manually flush all buffered events
Returns
Promise<void>
getStats()
getStats():
EventsBatcherStats
Get current statistics
Returns
get stats events batcher
shutdown()
shutdown(
timeoutMs?):Promise<void>
Graceful shutdown - flush remaining events
Parameters
| Parameter | Type | Description |
|---|---|---|
timeoutMs? | number | Max time to wait for flush (default: 5000) |
Returns
Promise<void>
timeout ms
track()
track(
eventType,payload,options?):void
Track an event
Parameters
| Parameter | Type | Description |
|---|---|---|
eventType | string | Type of event |
payload | Record<string, unknown> | Event payload data |
options? | { immediate?: boolean; sessionId?: string; tokenName?: string; userAddress?: string; } | Optional tracking options |
options.immediate? | boolean | - |
options.sessionId? | string | - |
options.tokenName? | string | - |
options.userAddress? | string | - |
Returns
void
event type session id token name user address