View Source Hedgex.Api (hedgex v0.3.4)
Low-level operations for the Posthog API. This module is meant to be 1:1 with Posthog endpoints: https://posthog.com/docs/api
Options
Common options
:hedgex
- aHedgex.Env
containing API configuration. Defaults to a context constructed by application config.
Summary
Functions
Send a batch of events to Posthog. See https://posthog.com/docs/api/capture#batch-events for more details
Send a single event to Posthog. See https://posthog.com/docs/api/capture#single-event for more details
Call the public decide
endpoint used to evaluate feature flag state for a given user. See
https://posthog.com/docs/api/decide for more details.
Functions
@spec batch(batch :: [Hedgex.event()], opts :: Keyword.t()) :: :ok | {:error, Exception.t()}
Send a batch of events to Posthog. See https://posthog.com/docs/api/capture#batch-events for more details
Options
:historical_migration
- defaults to false
Examples
iex> Hedgex.Api.batch([%{event: "foo_created", distinct_id: "user_12345", properties: %{}}])
:ok
@spec capture(event :: Hedgex.event(), opts :: Keyword.t()) :: :ok | {:error, Exception.t()}
Send a single event to Posthog. See https://posthog.com/docs/api/capture#single-event for more details
Examples
iex> Hedgex.Api.capture(%{event: "foo_created", distinct_id: "user_12345", properties: %{}})
:ok
@spec decide(distinct_id :: any(), opts :: Keyword.t()) :: {:ok, map()} | {:error, Exception.t()}
Call the public decide
endpoint used to evaluate feature flag state for a given user. See
https://posthog.com/docs/api/decide for more details.
Options
:groups
- (optional) Group config used to evaluate the feature flag
Examples
iex> Hedgex.Api.decide("user_12345", groups: %{company: "Acme, Inc."}}])
{:ok, %{"featureFlags" => %{"my-awesome-flag" => true}}}