FYI.Event (FYI v1.0.2)

View Source

Represents an event in the FYI system.

An event has:

  • name - dot-separated event name (e.g., "purchase.created")
  • payload - arbitrary map of event data
  • actor - who/what triggered the event (user_id, system, etc.)
  • tags - additional metadata for filtering/routing
  • source - where the event originated
  • occurred_at - when the event happened

Summary

Functions

Creates a new event with the given name and payload.

Types

t()

@type t() :: %FYI.Event{
  actor: String.t() | nil,
  emoji: String.t() | nil,
  id: String.t() | nil,
  name: String.t(),
  occurred_at: DateTime.t(),
  payload: map(),
  source: String.t() | nil,
  tags: map()
}

Functions

new(name, payload \\ %{}, opts \\ [])

@spec new(String.t(), map(), keyword()) :: t()

Creates a new event with the given name and payload.

Options

  • :actor - who triggered the event (user_id, email, etc.)
  • :tags - additional metadata map
  • :source - where the event originated
  • :emoji - override emoji for this specific event

Examples

iex> FYI.Event.new("purchase.created", %{amount: 4900})
%FYI.Event{name: "purchase.created", payload: %{amount: 4900}, ...}

iex> FYI.Event.new("user.signup", %{email: "user@example.com"}, actor: "user_123")
%FYI.Event{name: "user.signup", actor: "user_123", ...}

iex> FYI.Event.new("error.critical", %{}, emoji: "🚨")
%FYI.Event{name: "error.critical", emoji: "🚨", ...}