Features
- Synchronous & Asynchronous Tracking: Track events with both blocking and non-blocking methods
- Flexible Configuration: Customize API URLs, HTTP clients, and worker pools
- Context Support: Full context.Context support for cancellation and timeouts
- Error Handling: Comprehensive error types for different failure scenarios
- Easy Integration: Simple integration with popular Telegram bot libraries
Installation
Quick Start
Basic Usage
With Custom Configuration
Integration Examples
With tgbotapi
With telebot
API Reference
Client Creation
Available Options
WithAPIURL(url string)
: Set custom API URLWithOrigin(origin string)
: Set custom origin stringWithHTTPClient(client HttpClient)
: Set custom HTTP clientWithUseAsync()
: Enable asynchronous processing by default (client.TrackEvent(…) will act as client.TrackEventAsync(…))WithNumWorkers(num int)
: Set number of worker goroutines to process async events
Methods
Synchronous Methods
Asynchronous Methods
Error Handling
Best Practices
- Use Async for High-Volume: Enable async processing for bots with high message volumes
- Include Context: Use context-aware methods for better control over request lifecycle
- Handle Errors: Always check for errors and handle them appropriately
- Close Client: Always call
client.Close()
when shutting down your application - Structured Events: Use telegram native updates type for better analytics