Class PostHogConfig
-
- All Implemented Interfaces:
public class PostHogConfigThe SDK Config
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public final classPostHogConfig.Builder
-
Field Summary
-
Constructor Summary
Constructors Constructor Description PostHogConfig(String apiKey, String host, Boolean debug, Boolean sendFeatureFlagEvent, Boolean preloadFeatureFlags, Boolean remoteConfig, Integer flushAt, Integer maxQueueSize, Integer maxBatchSize, Integer flushIntervalSeconds, PostHogEncryption encryption, PostHogOnFeatureFlags onFeatureFlags, Proxy proxy, Integer featureFlagCacheSize, Integer featureFlagCacheMaxAgeMs, Integer featureFlagCalledCacheSize, Boolean localEvaluation, String personalApiKey, Integer pollIntervalSeconds, List<String> evaluationContexts)
-
Method Summary
Modifier and Type Method Description final StringgetApiKey()The PostHog API Key final StringgetHost()The PostHog Host Defaults to https://us.i.posthog.com EU Host: https://eu.i.posthog. final BooleangetDebug()Logs the debug logs to the logger if enabled Defaults to false final UnitsetDebug(Boolean debug)Logs the debug logs to the logger if enabled Defaults to false final BooleangetSendFeatureFlagEvent()Send a $feature_flag_called event when a feature flag is used automatically Used by experimentsDefaults to true final UnitsetSendFeatureFlagEvent(Boolean sendFeatureFlagEvent)Send a $feature_flag_called event when a feature flag is used automatically Used by experimentsDefaults to true final BooleangetPreloadFeatureFlags()Preload feature flags automatically Docs https://posthog.com/docs/feature-flags and https://posthog. final UnitsetPreloadFeatureFlags(Boolean preloadFeatureFlags)Preload feature flags automatically Docs https://posthog.com/docs/feature-flags and https://posthog. final BooleangetRemoteConfig()Preload PostHog remote config automatically Defaults to true final UnitsetRemoteConfig(@Deprecated(message = "Remote config is now always enabled. This option is a no-op and will be removed in a future version.", level = DeprecationLevel.WARNING) Boolean remoteConfig)Preload PostHog remote config automatically Defaults to true final IntegergetFlushAt()Number of minimum events before they are sent over the wire Defaults to 20 final UnitsetFlushAt(Integer flushAt)Number of minimum events before they are sent over the wire Defaults to 20 final IntegergetMaxQueueSize()Number of maximum events in memory and disk, when the maximum is exceed, the oldest event is deleted and the new one takes place Defaults to 1000 final UnitsetMaxQueueSize(Integer maxQueueSize)Number of maximum events in memory and disk, when the maximum is exceed, the oldest event is deleted and the new one takes place Defaults to 1000 final IntegergetMaxBatchSize()Number of maximum events in a batch call Defaults to 50 final UnitsetMaxBatchSize(Integer maxBatchSize)Number of maximum events in a batch call Defaults to 50 final IntegergetFlushIntervalSeconds()Interval in seconds for sending events over the wire The lower the number, most likely more battery is used Defaults to 30s final UnitsetFlushIntervalSeconds(Integer flushIntervalSeconds)Interval in seconds for sending events over the wire The lower the number, most likely more battery is used Defaults to 30s final PostHogEncryptiongetEncryption()Hook for encrypt and decrypt events Devices are sandbox so likely not needed Defaults to no encryption final UnitsetEncryption(PostHogEncryption encryption)Hook for encrypt and decrypt events Devices are sandbox so likely not needed Defaults to no encryption final PostHogOnFeatureFlagsgetOnFeatureFlags()Hook that is called when feature flag definitions are loaded. final UnitsetOnFeatureFlags(PostHogOnFeatureFlags onFeatureFlags)Hook that is called when feature flag definitions are loaded. final ProxygetProxy()Hook that allows to sanitize the event properties The hook is called before the event is cached or sent over the wire final UnitsetProxy(Proxy proxy)Hook that allows to sanitize the event properties The hook is called before the event is cached or sent over the wire final IntegergetFeatureFlagCacheSize()The maximum size of the feature flag cache in memory Defaults to 1000 final UnitsetFeatureFlagCacheSize(Integer featureFlagCacheSize)The maximum size of the feature flag cache in memory Defaults to 1000 final IntegergetFeatureFlagCacheMaxAgeMs()The maximum age of a feature flag cache record in memory in milliseconds Defaults to 5 minutes final UnitsetFeatureFlagCacheMaxAgeMs(Integer featureFlagCacheMaxAgeMs)The maximum age of a feature flag cache record in memory in milliseconds Defaults to 5 minutes final IntegergetFeatureFlagCalledCacheSize()The maximum size of the feature flag called cache in memory. final UnitsetFeatureFlagCalledCacheSize(Integer featureFlagCalledCacheSize)The maximum size of the feature flag called cache in memory. final BooleangetLocalEvaluation()Enable local evaluation of feature flags When enabled, the SDK periodically fetches flag definitions and evaluates flags locally without making API calls for each flag check. final UnitsetLocalEvaluation(Boolean localEvaluation)Enable local evaluation of feature flags When enabled, the SDK periodically fetches flag definitions and evaluates flags locally without making API calls for each flag check. final StringgetPersonalApiKey()Personal API key for local evaluation Required when localEvaluation is true. final UnitsetPersonalApiKey(String personalApiKey)Personal API key for local evaluation Required when localEvaluation is true. final IntegergetPollIntervalSeconds()Interval in seconds for polling feature flag definitions for local evaluation Defaults to 30 seconds final UnitsetPollIntervalSeconds(Integer pollIntervalSeconds)Interval in seconds for polling feature flag definitions for local evaluation Defaults to 30 seconds final List<String>getEvaluationContexts()Evaluation contexts for feature flags List of contexts (e.g., "web", "mobile", "checkout") used to filter feature flag evaluations on the server side. final UnitsetEvaluationContexts(List<String> evaluationContexts)Evaluation contexts for feature flags List of contexts (e.g., "web", "mobile", "checkout") used to filter feature flag evaluations on the server side. final UnitaddBeforeSend(PostHogBeforeSend beforeSend)final UnitremoveBeforeSend(PostHogBeforeSend beforeSend)final UnitaddIntegration(PostHogIntegration integration)final static PostHogConfig.Builderbuilder(String apiKey)-
-
Constructor Detail
-
PostHogConfig
PostHogConfig(String apiKey, String host, Boolean debug, Boolean sendFeatureFlagEvent, Boolean preloadFeatureFlags, Boolean remoteConfig, Integer flushAt, Integer maxQueueSize, Integer maxBatchSize, Integer flushIntervalSeconds, PostHogEncryption encryption, PostHogOnFeatureFlags onFeatureFlags, Proxy proxy, Integer featureFlagCacheSize, Integer featureFlagCacheMaxAgeMs, Integer featureFlagCalledCacheSize, Boolean localEvaluation, String personalApiKey, Integer pollIntervalSeconds, List<String> evaluationContexts)
-
-
Method Detail
-
getHost
final String getHost()
The PostHog Host Defaults to https://us.i.posthog.com EU Host: https://eu.i.posthog.com
-
setDebug
final Unit setDebug(Boolean debug)
Logs the debug logs to the logger if enabled Defaults to false
-
getSendFeatureFlagEvent
final Boolean getSendFeatureFlagEvent()
Send a $feature_flag_called event when a feature flag is used automatically Used by experiments
Defaults to true
-
setSendFeatureFlagEvent
final Unit setSendFeatureFlagEvent(Boolean sendFeatureFlagEvent)
Send a $feature_flag_called event when a feature flag is used automatically Used by experiments
Defaults to true
-
getPreloadFeatureFlags
final Boolean getPreloadFeatureFlags()
Preload feature flags automatically Docs https://posthog.com/docs/feature-flags and https://posthog.com/docs/experiments Defaults to true
-
setPreloadFeatureFlags
final Unit setPreloadFeatureFlags(Boolean preloadFeatureFlags)
Preload feature flags automatically Docs https://posthog.com/docs/feature-flags and https://posthog.com/docs/experiments Defaults to true
-
getRemoteConfig
final Boolean getRemoteConfig()
Preload PostHog remote config automatically Defaults to true
-
setRemoteConfig
final Unit setRemoteConfig(@Deprecated(message = "Remote config is now always enabled. This option is a no-op and will be removed in a future version.", level = DeprecationLevel.WARNING) Boolean remoteConfig)
Preload PostHog remote config automatically Defaults to true
-
getFlushAt
final Integer getFlushAt()
Number of minimum events before they are sent over the wire Defaults to 20
-
setFlushAt
final Unit setFlushAt(Integer flushAt)
Number of minimum events before they are sent over the wire Defaults to 20
-
getMaxQueueSize
final Integer getMaxQueueSize()
Number of maximum events in memory and disk, when the maximum is exceed, the oldest event is deleted and the new one takes place Defaults to 1000
-
setMaxQueueSize
final Unit setMaxQueueSize(Integer maxQueueSize)
Number of maximum events in memory and disk, when the maximum is exceed, the oldest event is deleted and the new one takes place Defaults to 1000
-
getMaxBatchSize
final Integer getMaxBatchSize()
Number of maximum events in a batch call Defaults to 50
-
setMaxBatchSize
final Unit setMaxBatchSize(Integer maxBatchSize)
Number of maximum events in a batch call Defaults to 50
-
getFlushIntervalSeconds
final Integer getFlushIntervalSeconds()
Interval in seconds for sending events over the wire The lower the number, most likely more battery is used Defaults to 30s
-
setFlushIntervalSeconds
final Unit setFlushIntervalSeconds(Integer flushIntervalSeconds)
Interval in seconds for sending events over the wire The lower the number, most likely more battery is used Defaults to 30s
-
getEncryption
final PostHogEncryption getEncryption()
Hook for encrypt and decrypt events Devices are sandbox so likely not needed Defaults to no encryption
-
setEncryption
final Unit setEncryption(PostHogEncryption encryption)
Hook for encrypt and decrypt events Devices are sandbox so likely not needed Defaults to no encryption
-
getOnFeatureFlags
final PostHogOnFeatureFlags getOnFeatureFlags()
Hook that is called when feature flag definitions are loaded. This is called immediately if local evaluation is not enabled. Defaults to no callback
-
setOnFeatureFlags
final Unit setOnFeatureFlags(PostHogOnFeatureFlags onFeatureFlags)
Hook that is called when feature flag definitions are loaded. This is called immediately if local evaluation is not enabled. Defaults to no callback
-
getProxy
final Proxy getProxy()
Hook that allows to sanitize the event properties The hook is called before the event is cached or sent over the wire
-
setProxy
final Unit setProxy(Proxy proxy)
Hook that allows to sanitize the event properties The hook is called before the event is cached or sent over the wire
-
getFeatureFlagCacheSize
final Integer getFeatureFlagCacheSize()
The maximum size of the feature flag cache in memory Defaults to 1000
-
setFeatureFlagCacheSize
final Unit setFeatureFlagCacheSize(Integer featureFlagCacheSize)
The maximum size of the feature flag cache in memory Defaults to 1000
-
getFeatureFlagCacheMaxAgeMs
final Integer getFeatureFlagCacheMaxAgeMs()
The maximum age of a feature flag cache record in memory in milliseconds Defaults to 5 minutes
-
setFeatureFlagCacheMaxAgeMs
final Unit setFeatureFlagCacheMaxAgeMs(Integer featureFlagCacheMaxAgeMs)
The maximum age of a feature flag cache record in memory in milliseconds Defaults to 5 minutes
-
getFeatureFlagCalledCacheSize
final Integer getFeatureFlagCalledCacheSize()
The maximum size of the feature flag called cache in memory. This cache prevents duplicate $feature_flag_called events from being sent by keeping track of per-user feature flag usage. Defaults to 1000
-
setFeatureFlagCalledCacheSize
final Unit setFeatureFlagCalledCacheSize(Integer featureFlagCalledCacheSize)
The maximum size of the feature flag called cache in memory. This cache prevents duplicate $feature_flag_called events from being sent by keeping track of per-user feature flag usage. Defaults to 1000
-
getLocalEvaluation
final Boolean getLocalEvaluation()
Enable local evaluation of feature flags When enabled, the SDK periodically fetches flag definitions and evaluates flags locally without making API calls for each flag check. Falls back to API if evaluation is inconclusive. Requires personalApiKey to be set. Defaults to false
-
setLocalEvaluation
final Unit setLocalEvaluation(Boolean localEvaluation)
Enable local evaluation of feature flags When enabled, the SDK periodically fetches flag definitions and evaluates flags locally without making API calls for each flag check. Falls back to API if evaluation is inconclusive. Requires personalApiKey to be set. Defaults to false
-
getPersonalApiKey
final String getPersonalApiKey()
Personal API key for local evaluation Required when localEvaluation is true. Defaults to null
-
setPersonalApiKey
final Unit setPersonalApiKey(String personalApiKey)
Personal API key for local evaluation Required when localEvaluation is true. Defaults to null
-
getPollIntervalSeconds
final Integer getPollIntervalSeconds()
Interval in seconds for polling feature flag definitions for local evaluation Defaults to 30 seconds
-
setPollIntervalSeconds
final Unit setPollIntervalSeconds(Integer pollIntervalSeconds)
Interval in seconds for polling feature flag definitions for local evaluation Defaults to 30 seconds
-
getEvaluationContexts
final List<String> getEvaluationContexts()
Evaluation contexts for feature flags List of contexts (e.g., "web", "mobile", "checkout") used to filter feature flag evaluations on the server side. Defaults to null
-
setEvaluationContexts
final Unit setEvaluationContexts(List<String> evaluationContexts)
Evaluation contexts for feature flags List of contexts (e.g., "web", "mobile", "checkout") used to filter feature flag evaluations on the server side. Defaults to null
-
addBeforeSend
final Unit addBeforeSend(PostHogBeforeSend beforeSend)
-
removeBeforeSend
final Unit removeBeforeSend(PostHogBeforeSend beforeSend)
-
addIntegration
final Unit addIntegration(PostHogIntegration integration)
-
builder
final static PostHogConfig.Builder builder(String apiKey)
-
-
-
-