Interface PostHogInterface

    • Constructor Detail

    • Method Detail

      • setup

         abstract <T extends PostHogConfig> Unit setup(T config)

        Setup the SDK

        Parameters:
        config - the SDK configuration
      • identify

         abstract Unit identify(String distinctId, Map<String, Object> userProperties, Map<String, Object> userPropertiesSetOnce)

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

        Parameters:
        distinctId - the distinctId
        userProperties - the user properties, set as a "$set" property, Docs https://posthog.
        userPropertiesSetOnce - the user properties to set only once, set as a "$set_once" property, Docs https://posthog.
      • identify

         Unit identify(String distinctId)

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

        Parameters:
        distinctId - the distinctId
      • identify

         Unit identify(String distinctId, Map<String, Object> userProperties)

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

        Parameters:
        distinctId - the distinctId
        userProperties - the user properties, set as a "$set" property, Docs https://posthog.
      • flush

         abstract Unit flush()

        Flushes all the events in the Queue right away

      • capture

         Unit capture(String distinctId, String event, PostHogCaptureOptions options)

        Captures events

        Parameters:
        distinctId - the distinctId
        event - the event name
        options - the capture options containing properties, userProperties, userPropertiesSetOnce, groups, and appendFeatureFlags
      • capture

         Unit capture(String distinctId, String event)

        Captures events

        Parameters:
        distinctId - the distinctId
        event - the event name
      • isFeatureEnabled

         abstract Boolean isFeatureEnabled(String distinctId, String key, Boolean defaultValue, Map<String, String> groups, Map<String, Object> personProperties, Map<String, Map<String, Object>> groupProperties)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
        defaultValue - the default value if not found, false if not given
      • isFeatureEnabled

         Boolean isFeatureEnabled(String distinctId, String key)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
      • isFeatureEnabled

         Boolean isFeatureEnabled(String distinctId, String key, Boolean defaultValue)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
        defaultValue - the default value if not found
      • isFeatureEnabled

         Boolean isFeatureEnabled(String distinctId, String key, PostHogFeatureFlagOptions options)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
        options - the feature flag options containing defaultValue, groups, personProperties, and groupProperties
      • getFeatureFlag

         abstract Object getFeatureFlag(String distinctId, String key, Object defaultValue, Map<String, String> groups, Map<String, Object> personProperties, Map<String, Map<String, Object>> groupProperties)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
        defaultValue - the default value if not found
      • getFeatureFlag

         Object getFeatureFlag(String distinctId, String key)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
      • getFeatureFlag

         Object getFeatureFlag(String distinctId, String key, PostHogFeatureFlagOptions options)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
        options - the feature flag options containing defaultValue, groups, personProperties, and groupProperties
      • getFeatureFlag

         Object getFeatureFlag(String distinctId, String key, Object defaultValue)

        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

        Parameters:
        distinctId - the distinctId
        key - the Key
        defaultValue - the default value if not found
      • getFeatureFlagPayload

         Object getFeatureFlagPayload(String distinctId, String key)

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

        Parameters:
        distinctId - the distinctId
        key - the Key
      • getFeatureFlagPayload

         Object getFeatureFlagPayload(String distinctId, String key, PostHogFeatureFlagOptions options)

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

        Parameters:
        distinctId - the distinctId
        key - the Key
        options - the feature flag options containing defaultValue, groups, personProperties, and groupProperties
      • getFeatureFlagPayload

         Object getFeatureFlagPayload(String distinctId, String key, Object defaultValue)

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

        Parameters:
        distinctId - the distinctId
        key - the Key
        defaultValue - the default value if not found
      • getFeatureFlagResult

         abstract FeatureFlagResult getFeatureFlagResult(String distinctId, String key, Map<String, String> groups, Map<String, Object> personProperties, Map<String, Map<String, Object>> groupProperties, Boolean sendFeatureFlagEvent)

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

        Parameters:
        distinctId - the distinctId
        key - the Key
        groups - groups for group-based flags
        personProperties - person properties for flag evaluation
        groupProperties - group properties for flag evaluation
        sendFeatureFlagEvent - whether to send the $feature_flag_called event, or null to use config default
      • getFeatureFlagResult

         FeatureFlagResult getFeatureFlagResult(String distinctId, String key)

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

        Parameters:
        distinctId - the distinctId
        key - the Key
      • getFeatureFlagResult

         FeatureFlagResult getFeatureFlagResult(String distinctId, String key, PostHogFeatureFlagResultOptions options)

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

        Parameters:
        distinctId - the distinctId
        key - the Key
        options - the feature flag result options containing groups, personProperties, groupProperties, and sendFeatureFlagEvent
      • group

         abstract Unit group(String distinctId, String type, String key, Map<String, Object> groupProperties)

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

        Parameters:
        distinctId - the distinctId
        type - the Group type
        key - the Group key
        groupProperties - the Group properties, set as a "$group_set" property, Docs https://posthog.
      • group

         Unit group(String distinctId, String type, String key)

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

        Parameters:
        distinctId - the distinctId
        type - the Group type
        key - the Group key
      • alias

         abstract Unit alias(String distinctId, String alias)

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

        Parameters:
        distinctId - the distinctId
        alias - the alias
      • reloadFeatureFlags

         abstract Unit 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

      • captureException

         abstract Unit captureException(Throwable exception, String distinctId, Map<String, Object> properties)

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

        Parameters:
        exception - the exception to capture
        distinctId - the distinctId
        properties - the exception properties to add to the event
      • captureException

         Unit captureException(Throwable exception, String distinctId)

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

        Parameters:
        exception - the exception to capture
        distinctId - the distinctId
      • captureException

         Unit captureException(Throwable exception, Map<String, Object> properties)

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

        Parameters:
        exception - the exception to capture
        properties - the exception properties to add to the event
      • captureException

         Unit captureException(Throwable exception)

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

        Parameters:
        exception - the exception to capture