View Source Hedgex (hedgex v0.1.0)
General methods for the Posthog 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.
Types
@type event_body() :: %{ :event => String.t(), :distinct_id => any(), optional(:properties) => map(), optional(:timestamp) => DateTime.t() }
Functions
@spec batch(batch :: [event_body()], 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.batch([%{event: "foo_created", distinct_id: "user_12345", properties: %{}}])
:ok
@spec capture(event :: event_body(), 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.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.decide("user_12345", groups: %{company: "Acme, Inc."}}])
{:ok, %{"featureFlags" => %{"my-awesome-flag" => true}}}