Honeylixir.Event (honeylixir v0.2.0) View Source

Used for managing Events and holding their data. It also has a send function that really just kicks off the sending process which happens asynchronously.

Link to this section Summary

Types

An RFC3339 formatted timestamp

t()

A struct containing all the data of an event.

Functions

Add a single key/value pair to the event.

Creates an event using the current timestamp, configured values for sending, and no initial fields other than service_name if configured.

create/1 accepts either a timestamp or a set of fields to initialize the Honeylixir.Event.

Accepts both a timestamp in RFC3339 format and a map of key/values to initialize the Event struct with.

Used for acknowledging the event is ready for sending, passing it off to be sent asynchronously. Currently nothing stops a user from sending the same event twice.

Link to this section Types

Specs

rfc_timestamp() :: String.t()

An RFC3339 formatted timestamp

"2020-09-29 04:36:15Z"

Specs

t() :: %Honeylixir.Event{
  api_host: String.t(),
  dataset: String.t() | atom(),
  fields: map(),
  sample_rate: integer(),
  team_writekey: String.t(),
  timestamp: rfc_timestamp()
}

A struct containing all the data of an event.

By default, an event is constructed with the values in the configuration defined in Honeylixir. Any field can be overwritten via regular struct assigning of values.

event = Honeylixir.Event.create()
event = %{event | api_host: "something-else.com"}

Link to this section Functions

Link to this function

add_field(event, field, value)

View Source (since 0.1.0)

Specs

add_field(t(), String.t(), any()) :: t()

Add a single key/value pair to the event.

Examples

iex> event = Honeylixir.Event.create()
iex> Honeylixir.Event.add_field(event, "key", "other").fields
%{"service_name" => "honeylixir-tests", "key" => "other"}

Specs

create() :: t()

Creates an event using the current timestamp, configured values for sending, and no initial fields other than service_name if configured.

event = Honeycomb.Event.create()
Link to this function

create(fields_or_timestamp)

View Source (since 0.1.0)

Specs

create(rfc_timestamp() | map()) :: t()

create/1 accepts either a timestamp or a set of fields to initialize the Honeylixir.Event.

event = Honeylixir.Event.create("2020-09-29 04:36:15Z")
event = Honeylixir.Event.create(%{"field1" => "value1"})
Link to this function

create(timestamp, fields)

View Source (since 0.1.0)

Specs

create(rfc_timestamp(), map()) :: t()

Accepts both a timestamp in RFC3339 format and a map of key/values to initialize the Event struct with.

Specs

send(t()) :: {:ok, :processed | :sampled}

Used for acknowledging the event is ready for sending, passing it off to be sent asynchronously. Currently nothing stops a user from sending the same event twice.