PostHogInterface

Inheritors

Functions

Link copied to clipboard
abstract fun alias(distinctId: String, alias: String)

Creates an alias for the user Docs https://posthog.com/docs/product-analytics/identify#alias-assigning-multiple-distinct-ids-to-the-same-user

Link copied to clipboard
open fun capture(distinctId: String, event: String)
open fun capture(distinctId: String, event: String, options: PostHogCaptureOptions)
abstract fun capture(distinctId: String, event: String, properties: Map<String, Any>? = null, userProperties: Map<String, Any>? = null, userPropertiesSetOnce: Map<String, Any>? = null, groups: Map<String, String>? = null, timestamp: Date? = null, appendFeatureFlags: Boolean = false)

Captures events

Link copied to clipboard
open fun captureException(exception: Throwable)
open fun captureException(exception: Throwable, distinctId: String?)
open fun captureException(exception: Throwable, properties: Map<String, Any>)
abstract fun captureException(exception: Throwable, distinctId: String? = null, properties: Map<String, Any>? = null)

Captures an exception Docs https://posthog.com/docs/error-tracking

Link copied to clipboard
abstract fun close()

Closes the SDK

Link copied to clipboard
abstract fun debug(enable: Boolean = true)

Enables or disables the debug mode

Link copied to clipboard
abstract fun flush()

Flushes all the events in the Queue right away

Link copied to clipboard
open fun getFeatureFlag(distinctId: String, key: String): Any?
open fun getFeatureFlag(distinctId: String, key: String, options: PostHogFeatureFlagOptions): Any?
abstract fun getFeatureFlag(distinctId: String, key: String, defaultValue: Any? = null, groups: Map<String, String>? = null, personProperties: Map<String, Any?>? = null, groupProperties: Map<String, Map<String, Any?>>? = null): Any?

Returns the feature flags variant if multi-variant, otherwise whether it is enabled or not Docs https://posthog.com/docs/feature-flags and https://posthog.com/docs/experiments

open fun getFeatureFlag(distinctId: String, key: String, defaultValue: Any?): Any?

Returns if a feature flag is enabled, the feature flag must be a Boolean Docs https://posthog.com/docs/feature-flags and https://posthog.com/docs/experiments

Link copied to clipboard
open fun getFeatureFlagPayload(distinctId: String, key: String): Any?
open fun getFeatureFlagPayload(distinctId: String, key: String, options: PostHogFeatureFlagOptions): Any?
open fun getFeatureFlagPayload(distinctId: String, key: String, defaultValue: Any?): Any?
abstract fun getFeatureFlagPayload(distinctId: String, key: String, defaultValue: Any? = null, groups: Map<String, String>? = null, personProperties: Map<String, Any?>? = null, groupProperties: Map<String, Map<String, Any?>>? = null): Any?

Returns the feature flag payload Docs https://posthog.com/docs/feature-flags and https://posthog.com/docs/experiments

Link copied to clipboard
open fun getFeatureFlagResult(distinctId: String, key: String): FeatureFlagResult?
open fun getFeatureFlagResult(distinctId: String, key: String, options: PostHogFeatureFlagResultOptions): FeatureFlagResult?
abstract fun getFeatureFlagResult(distinctId: String, key: String, groups: Map<String, String>? = null, personProperties: Map<String, Any?>? = null, groupProperties: Map<String, Map<String, Any?>>? = null, sendFeatureFlagEvent: Boolean? = null): FeatureFlagResult?

Returns the feature flag result containing both value and payload. Docs https://posthog.com/docs/feature-flags and https://posthog.com/docs/experiments

Link copied to clipboard
open fun group(distinctId: String, type: String, key: String)
abstract fun group(distinctId: String, type: String, key: String, groupProperties: Map<String, Any>? = null)

Creates a group Docs https://posthog.com/docs/product-analytics/group-analytics

Link copied to clipboard
open fun identify(distinctId: String)
open fun identify(distinctId: String, userProperties: Map<String, Any>? = null)
abstract fun identify(distinctId: String, userProperties: Map<String, Any>? = null, userPropertiesSetOnce: Map<String, Any>? = null)

Identifies the user Docs https://posthog.com/docs/product-analytics/identify

Link copied to clipboard
open fun isFeatureEnabled(distinctId: String, key: String): Boolean
open fun isFeatureEnabled(distinctId: String, key: String, options: PostHogFeatureFlagOptions): Boolean
open fun isFeatureEnabled(distinctId: String, key: String, defaultValue: Boolean): Boolean
abstract fun isFeatureEnabled(distinctId: String, key: String, defaultValue: Boolean = false, groups: Map<String, String>? = null, personProperties: Map<String, Any?>? = null, groupProperties: Map<String, Map<String, Any?>>? = null): Boolean

Returns if a feature flag is enabled, the feature flag must be a Boolean Docs https://posthog.com/docs/feature-flags and https://posthog.com/docs/experiments

Link copied to clipboard
abstract fun reloadFeatureFlags()

Reloads feature flag definitions from the server for use with local evaluation. Note that feature flag definitions are automatically fetched on initialization and periodically refreshed, so this method only needs to be called if you want to force an immediate refresh. Docs https://posthog.com/docs/feature-flags/local-evaluation

Link copied to clipboard
abstract fun <T : PostHogConfig> setup(config: T)

Setup the SDK