PostHog.Config (posthog v2.8.3)
View SourcePostHog configuration
Configuration Schema
Application Configuration
These are convenience options that only affect how PostHog's own application behaves.
:enable(boolean/0) - Automatically start PostHog? The default value istrue.:enable_error_tracking(boolean/0) - Automatically start the logger handler for error tracking? The default value istrue.:test_mode(boolean/0) - Test mode keeps captured events in memory for assertions instead of sending them to PostHog. The default value isfalse.
Supervisor Configuration
This is the main options block that configures each supervision tree instance.
:api_host(String.t/0) -https://us.i.posthog.comfor US cloud orhttps://eu.i.posthog.comfor EU cloud The default value is"https://us.i.posthog.com".:api_key(String.t/0) - Required. Your PostHog Project API key. Find it in your project's settings under the Project ID section.:api_client_module(atom/0) - API client to use The default value isPostHog.API.Client.:supervisor_name(atom/0) - Name of the supervisor process running PostHog The default value isPostHog.:metadata- List of Logger metadata keys to include in event properties. Set to:allto include all metadata. This only affects Error Tracking events. The default value is[].:capture_level- Minimum level for logs that should be captured as errors. Errors withcrash_reasonare always captured. The default value is:error.:global_properties(map/0) - Map of properties that should be added to all events The default value is%{}.:in_app_otp_apps(list ofatom/0) - List of OTP app names of your applications. Stacktrace entries that belong to these apps will be marked as "in_app". The default value is[].:enable_source_code_context(boolean/0) - Enable source code context in error tracking stack frames. Requires source code to be available at runtime or packaged viamix posthog.package_source_code. The default value isfalse.:root_source_code_paths(list ofString.t/0) - List of root paths to scan for source files. Used by the source context feature andmix posthog.package_source_code. The default value is[].:source_code_path_pattern(String.t/0) - Glob pattern for source files to include in source context. The default value is"**/*.ex".:source_code_exclude_patterns(list of struct of typeRegex) - List of regex patterns to exclude from source context. Defaults to excluding_build/,priv/, andtest/directories. The default value is[~r/^_build\//, ~r/^priv\//, ~r/^test\//].:context_lines(non_neg_integer/0) - Number of source lines to include before and after the error line in stack frames. The default value is5.:source_code_map_path(String.t/0) - Custom path to a packaged source map file. Defaults topriv/posthog_source.mapin the:posthogapplication directory.:test_mode(boolean/0) - Test mode keeps captured events in memory for assertions instead of sending them to PostHog. The default value isfalse.
Summary
Types
Map containing validated configuration for a PostHog supervision tree.
Keyword options accepted by validate/1 and validate!/1.
Types
@opaque config()
Map containing validated configuration for a PostHog supervision tree.
It mostly follows options/0, but also includes runtime values such as the
initialized API client, resolved in-app modules, and system global properties.
The internal structure should not be relied upon outside of starting
PostHog.Supervisor or reading values through PostHog.config/1.
@type options() :: {:api_host, binary()} | {:api_key, binary()} | {:api_client_module, atom()} | {:supervisor_name, atom()} | {:metadata, [atom()] | term()} | {:capture_level, term() | nil} | {:global_properties, map()} | {:in_app_otp_apps, [atom()]} | {:enable_source_code_context, boolean()} | {:root_source_code_paths, [binary()]} | {:source_code_path_pattern, binary()} | {:source_code_exclude_patterns, [struct()]} | {:context_lines, non_neg_integer()} | {:source_code_map_path, binary()} | {:test_mode, boolean()}
Keyword options accepted by validate/1 and validate!/1.
See the module documentation for the full schema, defaults, and remarks for each configuration option.
Functions
@spec validate(options()) :: {:ok, config()} | {:error, NimbleOptions.ValidationError.t()}
Validates configuration against the supervisor schema.
Parameters
options- keyword list matchingoptions/0.
Returns
Returns {:ok, config} with a normalized config/0 on success, or
{:error, %NimbleOptions.ValidationError{}} when the options are invalid.
Remarks
String :api_key and :api_host values are trimmed before validation. A blank
:api_host falls back to the default PostHog US ingestion host.
Validates configuration and returns a config/0, raising if validation fails.
See validate/1 for the accepted options and return shape.