PostHogOptions
Properties
| Name | Type |
|---|---|
disableGeoip | boolean |
Whether to disable GeoIP lookups | |
host | string |
PostHog API host, usually 'https://us.i.posthog.com' or 'https://eu.i.posthog.com' | |
flushAt | number |
The number of events to queue before sending to PostHog (flushing) | |
maxBatchSize | number |
The maximum number of queued messages to be flushed as part of a single batch (must be higher than | |
disabled | boolean |
If set to true the SDK is essentially disabled (useful for local environments where you don't want to track anything) | |
defaultOptIn | boolean |
If set to false the SDK will not track until the | |
disable_capture_url_hashes | boolean |
Whether to strip URL fragments (
If your SPA relies on hash-based routes for analytics, enabling this is a breaking behavior change.
If you want to capture hashes selectively, leave this as | |
sendFeatureFlagEvent | boolean |
Whether to track that | |
preloadFeatureFlags | boolean |
Whether to load feature flags when initialized or not | |
disableRemoteFeatureFlags | boolean |
Advanced: whether to disable fetching and evaluating feature flags from PostHog entirely. When set to true, Note: surveys gated on feature flags will not evaluate unless the survey targeting
flags are also provided via | |
disableRemoteConfig | boolean |
Whether to load remote config when initialized or not Deprecated: Remote config is now always loaded and this option is a no-op. It will be removed in a future version. | |
disableSurveys | boolean |
Whether to load surveys when initialized or not
Requires the | |
bootstrap | { distinctId?: string; isIdentifiedId?: boolean; featureFlags?: Record<string, FeatureFlagValue>; featureFlagPayloads?: Record<string, JsonType>; } |
Option to bootstrap the library with given distinctId and feature flags | |
fetchRetryCount | number |
How many times we will retry HTTP requests | |
fetchRetryDelay | number |
The delay between HTTP request retries in milliseconds | |
requestTimeout | number |
Timeout in milliseconds for any calls | |
featureFlagsRequestTimeoutMs | number |
Timeout in milliseconds for feature flag calls | |
featureFlagsRequestMaxRetries | number |
How many times feature flag requests retry after a transient network error. Set to 0 to disable feature flag request retries. | |
remoteConfigRequestTimeoutMs | number |
Timeout in milliseconds for remote config calls | |
sessionExpirationTimeSeconds | number |
For Session Analysis how long before we expire a session in seconds | |
disableCompression | boolean |
Whether to disable GZIP compression | |
historicalMigration | boolean |
Special flag to indicate ingested data is for a historical migration | |
evaluationContexts | readonly string[] |
Evaluation contexts for feature flags. When set, only feature flags that have at least one matching evaluation tag will be evaluated for this SDK instance. Feature flags with no evaluation tags will always be evaluated. Examples: ['production', 'web', 'mobile'] Evaluation contexts for feature flags. When set, only feature flags that have at least one matching evaluation tag will be evaluated for this SDK instance. Feature flags with no evaluation tags will always be evaluated. Examples: ['production', 'backend', 'api'] | |
evaluationEnvironments | readonly string[] |
Evaluation environments for feature flags. Deprecated: Use evaluationContexts instead. This property will be removed in a future version. | |
personProfiles | "always" | "identified_only" | "never" |
Determines when to create Person Profiles for users.
| |
addTracingHeaders | string[] |
A list of hostnames for which to inject PostHog tracing headers
(X-POSTHOG-DISTINCT-ID, X-POSTHOG-SESSION-ID) on outgoing Use this to link requests made from your app to session replays and LLM traces
in PostHog. When set, the global Requires the SDK to wire up | |
persistence | "memory" |
flushInterval | number |
The interval in milliseconds between periodic flushes | |
maxQueueSize | number |
The maximum number of cached messages either in memory or on the local storage (must be higher than | |
metrics | MetricsConfig |
Configuration for the | |
secretKey | string |
Credential that enables local feature flag evaluation and remote config. Accepts either a Personal API Key ( | |
personalApiKey | string |
Deprecated: Use | |
privacyMode | boolean |
enableExceptionAutocapture | boolean |
featureFlagsPollingInterval | number |
maxCacheSize | number |
fetch | (url: string, options: PostHogFetchOptions) => Promise<PostHogFetchResponse> |
enableLocalEvaluation | boolean |
flagDefinitionCacheProvider | FlagDefinitionCacheProvider |
Optional cache provider for feature flag definitions. Allows custom caching strategies (Redis, database, etc.) for flag definitions in multi-worker environments. If not provided, defaults to in-memory cache. This enables distributed coordination where only one worker fetches flags while others use cached data, reducing API calls and improving performance. | |
before_send | BeforeSendFn | BeforeSendFn[] |
Allows modification or dropping of events before they're sent to PostHog. If an array is provided, the functions are run in order. If a function returns null, the event will be dropped. | |
custom_blocked_useragents | string[] |
Additional user agent strings to block from being tracked. These are combined with the default list of blocked user agents. | |
strictLocalEvaluation | boolean |
When enabled, all feature flag evaluations will use local evaluation only, never falling back to server-side evaluation. This prevents unexpected server requests and associated costs when using local evaluation. Flags that cannot be evaluated locally (e.g., those with experience continuity)
will return | |
featureFlagsLogWarnings | boolean |
Controls whether | |
waitUntil | (promise: Promise<unknown>) => void |
Provides the API to extend the lifetime of a serverless invocation until background work (like flushing analytics events) completes after the response is sent. | |
waitUntilDebounceMs | number |
Debounce interval in milliseconds for the | |
waitUntilMaxWaitMs | number |
Maximum time in milliseconds to debounce before forcing a flush. Prevents starvation from rapid concurrent captures. | |
isServer | boolean |
Whether to attach the | |
exceptionRateLimiterRefillRate | number |
ADVANCED: alters the refill rate for the error tracking rate limiter's token bucket. Normally only altered alongside PostHog support guidance. Accepts values between 0 and 100. | |
exceptionRateLimiterBucketSize | number |
ADVANCED: alters the bucket size for the error tracking rate limiter's token bucket. Normally only altered alongside PostHog support guidance. Accepts values between 0 and 100. | |