PostHog

class PostHog : PostHogStateless, PostHogInterface

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override 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 override fun aliasStateless(distinctId: String, alias: String)
Link copied to clipboard
open override fun capture(distinctId: String, event: String, properties: Map<String, Any>?, userProperties: Map<String, Any>?, userPropertiesSetOnce: Map<String, Any>?, groups: Map<String, String>?, timestamp: Date?, appendFeatureFlags: Boolean)
open fun capture(distinctId: String, event: String)
open fun capture(distinctId: String, event: String, options: PostHogCaptureOptions)

Captures events

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

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

Link copied to clipboard
open override fun captureExceptionStateless(throwable: Throwable, distinctId: String?, properties: Map<String, Any>?)
Link copied to clipboard
open override fun captureStateless(event: String, distinctId: String, properties: Map<String, Any>?, userProperties: Map<String, Any>?, userPropertiesSetOnce: Map<String, Any>?, groups: Map<String, String>?, timestamp: Date?)
Link copied to clipboard
open override fun close()

Closes the SDK

Link copied to clipboard
open override fun debug(enable: Boolean)

Enables or disables the debug mode

Link copied to clipboard
open override fun flush()

Flushes all the events in the Queue right away

Link copied to clipboard
open override fun getFeatureFlag(distinctId: String, key: String, defaultValue: Any?, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?): Any?
open fun getFeatureFlag(distinctId: String, key: String): Any?
open fun getFeatureFlag(distinctId: String, key: String, options: PostHogFeatureFlagOptions): 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 override fun getFeatureFlagPayload(distinctId: String, key: String, defaultValue: Any?, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?): Any?
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?

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

Link copied to clipboard
open override fun getFeatureFlagPayloadStateless(distinctId: String, key: String, defaultValue: Any?, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?): Any?
Link copied to clipboard
open override fun getFeatureFlagResult(distinctId: String, key: String, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?, sendFeatureFlagEvent: Boolean?): FeatureFlagResult?
open fun getFeatureFlagResult(distinctId: String, key: String): FeatureFlagResult?
open fun getFeatureFlagResult(distinctId: String, key: String, options: PostHogFeatureFlagResultOptions): 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 override fun getFeatureFlagResultStateless(distinctId: String, key: String, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?, sendFeatureFlagEvent: Boolean?): FeatureFlagResult?
Link copied to clipboard
open override fun getFeatureFlagStateless(distinctId: String, key: String, defaultValue: Any?, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?): Any?
Link copied to clipboard
open override fun group(distinctId: String, type: String, key: String, groupProperties: Map<String, Any>?)
open fun group(distinctId: String, type: String, key: String)

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

Link copied to clipboard
open override fun groupStateless(distinctId: String, type: String, key: String, groupProperties: Map<String, Any>?)
Link copied to clipboard
open override fun identify(distinctId: String, userProperties: Map<String, Any>?, userPropertiesSetOnce: Map<String, Any>?)
open fun identify(distinctId: String)
open fun identify(distinctId: String, userProperties: Map<String, Any>? = null)

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

Link copied to clipboard
open override fun isFeatureEnabled(distinctId: String, key: String, defaultValue: Boolean, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?): Boolean
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

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 override fun isFeatureEnabledStateless(distinctId: String, key: String, defaultValue: Boolean, groups: Map<String, String>?, personProperties: Map<String, Any?>?, groupProperties: Map<String, Map<String, Any?>>?): Boolean
Link copied to clipboard
open override fun isOptOut(): Boolean
Link copied to clipboard
open override fun optIn()
Link copied to clipboard
open override fun optOut()
Link copied to clipboard
open override 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
open override fun <T : PostHogConfig> setup(config: T)

open override fun <T : PostHogConfig> setup(config: T)

Setup the SDK