Skill 77 · Instrument Feature Flags
Subchapter 77.8
references/elixir.mdMarkdown1 KBView on GitHub
AI agents: this is one page from PostHog’s docs. Full index of Markdown docs for LLMs: https://posthog.com/llms.txt (opens in a new tab)
This library was built by the community but it’s being maintained by the PostHog core team since v1.0.0. Thank you to Nick Kezhaya (opens in a new tab) for building it originally. Thank you to Alex Martsinovich (opens in a new tab) for contributing v2.0.0.
The package can be installed by adding posthog to your list of dependencies in mix.exs:
Elixir
def deps do
[
{:posthog, "~> 2.0"}
]
endconfig/config.exs
config :posthog,
enable: true,
api_host: "https://us.i.posthog.com",
api_key: "<ph_project_token>",
in_app_otp_apps: [:my_app]You can see all the available configuration options in the PostHog.Config (opens in a new tab) module.
Optionally, you might want to enable the Plug integration (opens in a new tab) to attach request metadata and tracing context in Plug-based applications including Phoenix. You still need to capture events explicitly with PostHog.capture/2 or PostHog.capture/3.
For a test environment, you can pass in test_mode: true value to the config. This causes events to be dropped instead of sent to PostHog.
Ask PostHog AI
HelpfulCould be better