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 - a Hedgex.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

Link to this function

batch(batch, opts \\ [])

View Source
@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
Link to this function

capture(event, opts \\ [])

View Source
@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
Link to this function

decide(distinct_id, opts \\ [])

View Source
@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}}}
Link to this function

map_req_response(response, success_fun)

View Source