segment v0.2.0 Segment.Http
Segment.Http
is the underlying implementation for making calls to the Segment HTTP API.
The send/2
and batch/4
methods can be used for sending events or batches of events to the API. The sending can be configured with
config :segment,
send_to_http: true
retry_attempts: 3,
retry_expiry: 10_000,
retry_start: 100
config :segment, :retry_attempts
The number of times to retry sending against the segment API. Default value is 3config :segment, :retry_expiry
The maximum time (in ms) spent retrying. Default value is 10000 (10 seconds)config :segment, :retry_start
The time (in ms) to start the first retry. Default value is 100config :segment, :send_to_http
If set tofalse
, the libray will override the Tesla Adapter implementation to only log segment calls todebug
but not make any actual API calls. This can be useful if you want to switch off Segment for test or dev. Default value is true
The retry uses a linear back-off strategy when retring the Segment API.
Additionally a different Tesla Adapter can be used if you want to use something other than Hackney.
config :segment, :tesla, :adapter
This config option allows for overriding the HTTP Adapter for Tesla (which the library defaults to Hackney).This can be useful if you prefer something else, or want to mock the adapter for testing.
Link to this section Summary
Functions
Send a list of Segment events as a batch.
Create a Tesla client with the Segment Source Write API Key
Create a Tesla client with the Segment Source Write API Key and the given Tesla adapter
Send a list of Segment events as a batch
Link to this section Types
Link to this section Functions
batch(client, events, context \\ nil, integrations \\ nil)
batch(String.t(), [Segment.segment_event()], map(), map()) :: :ok | :error
Send a list of Segment events as a batch.
The batch
function takes optional arguments for context and integrations which can
be applied to the entire batch of events. See Segment's docs
Create a Tesla client with the Segment Source Write API Key
Create a Tesla client with the Segment Source Write API Key and the given Tesla adapter
send(client, events)
send(String.t(), [Segment.segment_event()]) :: :ok | :error
send(String.t(), Segment.segment_event()) :: :ok | :error
Send a list of Segment events as a batch