Segmentry.Http (segmentry v0.3.0)

Copy Markdown View Source

Underlying implementation for making calls to the Segment HTTP API, built on Req.

Configuration

config :segmentry,
  send_to_http: true,
  retry_attempts: 3,
  retry_expiry: 10_000,
  retry_start: 100
  • :retry_attempts — number of times to retry against the Segment API. Default 3.
  • :retry_expiry — maximum delay (ms) between retries. Default 10_000.
  • :retry_start — base delay (ms) for the first retry. Default 100.
  • :send_to_http — if false, swaps in a no-op adapter that logs at :debug and replies 200. Default true.
  • :req_options — keyword list merged into every Req client. Useful for :plug (see Req.Test) or to override :receive_timeout.

Summary

Functions

Send a list of Segment events as a batch.

Build a Req client for the given Segment write key.

Build a Req client and merge in the supplied Req options (used to inject test stubs).

Send a single Segment event (or a list of events as a batch).

Types

client()

@type client() :: Req.Request.t()

Functions

batch(client, events, context \\ nil, integrations \\ nil)

@spec batch(client(), [Segmentry.segment_event()], map() | nil, map() | nil) ::
  :ok | :error

Send a list of Segment events as a batch.

Optional context and integrations maps are applied to the entire batch — see Segment's docs.

client(api_key)

@spec client(String.t()) :: client()

Build a Req client for the given Segment write key.

client(api_key, req_options)

@spec client(
  String.t(),
  keyword()
) :: client()

Build a Req client and merge in the supplied Req options (used to inject test stubs).

send(client, events)

@spec send(client(), [Segmentry.segment_event()]) :: :ok | :error
@spec send(client(), Segmentry.segment_event()) :: :ok | :error

Send a single Segment event (or a list of events as a batch).