Mxpanel.Batcher (Mxpanel v1.0.1) View Source
Manages a pool of buffers that accumulate the events and sends them to the Mixpanel API in batches in background. It implements a registry-based routing pool with round-robing as routing strategy.
Checkout start_link/1 for all supported options.
Usage
- Add to your supervision tree:
{Mxpanel.Batcher, name: MyApp.Batcher, token: "mixpanel project token"}- Enqueue an event:
Mxpanel.track_later(MyApp.MxpanelBatcher, event)- The event will be buffered, and later sent in batch to the Mixpanel API.
Link to this section Summary
Functions
Returns a specification to start this module under a supervisor.
Synchronously drain all buffers in the batcher. Returns a list containing all the processed events.
Starts a Mxpanel.Batcher linked to the current process.
Link to this section Types
Specs
name() :: atom()
Link to this section Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
Specs
drain_buffers(name()) :: :ok
Synchronously drain all buffers in the batcher. Returns a list containing all the processed events.
Mxpanel.Batcher.drain_buffers(MyApp.Batcher)
Starts a Mxpanel.Batcher linked to the current process.
Supported options
:name- Required. Name of the batcher instance.:token- Required if active. The Mixpanel token associated with your project.:active- Configure Batcher to be active or not. Useful for disabling requests in certain environments. The default value istrue.:base_url- Mixpanel API URL. The default value is"https://api.mixpanel.com".:http_client- HTTP client used by the Batcher. The default value is{Mxpanel.HTTPClient.HackneyAdapter, []}.:pool_size- The size of the pool of event buffers. Defaults toSystem.schedulers_online().:flush_interval- Interval in milliseconds which the event buffer are processed. The default value is5000.:flush_jitter- Jitter the flush interval by a random amount. Value in milliseconds. This is primarily to avoid large write spikes. For example, aflush_jitterof 1s andflush_intervalof 1s means flushes will happen every 5-6s. The default value is1000.:retry_max_attempts- Max attempts that a batch of events should be tried before giving up. The default value is5.:retry_base_backoff- Base time in milliseconds to calculate the wait time between retry attempts. Formula:(attempt * retry_base_backoff) + random(1..retry_base_backoff). The default value is100.:import_timeout- The maximum amount of time in milliseconds each batch of events is allowed to execute for. The default value is30000.:telemetry_buffers_info_interval- Interval in milliseconds thetelemetrywith the buffers info is published. The default value is30000.:debug- Enable debug logging. The default value isfalse.