GoodAnalytics.Core.Events.Recorder (GoodAnalytics v0.1.1)

Copy Markdown View Source

Records events into the unified event stream.

Populates promoted columns from source classification at ingest time, generates UUIDv7 IDs, broadcasts workspace event notifications, and fires appropriate hooks after insert.

The JS client may include an event_id idempotency key for host-app ingest layers. The recorder deliberately ignores that value for ga_events.id: the event stream primary key is (id, inserted_at) on a partitioned table, so idempotency must happen before this recorder runs.

Summary

Functions

Backfills fingerprint on a previously recorded link click by click_id.

Records a link click event.

Records a lead event.

Records a pageview event.

Records a sale event.

Functions

record(visitor, event_type, attrs \\ %{})

Records a generic event.

Parameters

  • visitor - the visitor struct (must have :id and :workspace_id)
  • event_type - one of the valid event types
  • attrs - additional event attributes

Returns {:ok, event} or {:error, changeset}.

Important: Hooks are dispatched immediately after insert. Connector planning uses a durable post-commit handoff when available so caller-owned transactions do not leak dispatches on rollback.

record_click(visitor, link, attrs)

Records a link click event.

record_custom(visitor, event_name, attrs)

Records a custom event.

record_lead(visitor, attrs)

Records a lead event.

record_pageview(visitor, attrs)

Records a pageview event.

record_sale(visitor, attrs)

Records a sale event.