Package net.hollowcube.posthog
Interface PostHogClient
- All Known Implementing Classes:
PostHogClientImpl
Represents the available API surface for PostHog. Used internally by the global
PostHog.
Multiple clients may be created and managed independently.
Methods are non-blocking unless otherwise specified.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptiondefault voidAlias the given distinct ID to the given alias.default voidCapture an event with the given name for the given distinct ID with no properties.voidCapture an event with the given name for the given ID with properties from the given object.default voidCapture an event with the given name for the given distinct ID with the provided properties.default voidcaptureException(@NotNull Throwable throwable) default voidcaptureException(@NotNull Throwable throwable, @NotNull String distinctId) default voidcaptureException(@NotNull Throwable throwable, @NotNull String distinctId, @NotNull Map<String, Object> properties) voidcaptureException(@NotNull Throwable throwable, @Nullable String distinctId, @Nullable Object properties) voidflush()Queue an immediate flush of the pending event queue.default @NotNull FeatureFlagStatesgetAllFeatureFlags(@NotNull String distinctId) Get all feature flags for the given distinct ID.@NotNull FeatureFlagStatesgetAllFeatureFlags(@NotNull String distinctId, @Nullable FeatureFlagContext context) Get all feature flags for the given distinct ID with extra context.default @NotNull FeatureFlagStategetFeatureFlag(@NotNull String key, @NotNull String distinctId) Get the feature flag state for the given distinct ID.@NotNull FeatureFlagStategetFeatureFlag(@NotNull String key, @NotNull String distinctId, @Nullable FeatureFlagContext context) Get the feature flag state for the given distinct ID with extra context.default @Nullable StringgetFeatureFlagPayload(@NotNull String key, @NotNull String distinctId) Get the feature flag payload for the given distinct ID.default @Nullable StringgetFeatureFlagPayload(@NotNull String key, @NotNull String distinctId, @Nullable FeatureFlagContext context) Get the feature flag payload for the given distinct ID.default voidgroupIdentify(@NotNull String type, @NotNull String key, @NotNull Object properties) Assign the given properties to the given group (type & key).default voidAssign the given properties to the given group (type & key).default voidLink the given properties with the person profile of the user (distinct id).default voididentify(@NotNull String distinctId, @Nullable Object properties, @Nullable Object propertiesSetOnce) Link the given properties with the person profile of the user (distinct id).default voidLink the given properties with the person profile of the user (distinct id).default voididentify(@NotNull String distinctId, @Nullable Map<String, Object> properties, @Nullable Map<String, Object> propertiesSetOnce) Link the given properties with the person profile of the user (distinct id).default booleanisFeatureEnabled(@NotNull String key, @NotNull String distinctId) Check if the given feature flag is enabled for the given distinct ID.default booleanisFeatureEnabled(@NotNull String key, @NotNull String distinctId, @Nullable FeatureFlagContext context) Check if the given feature flag is enabled for the given distinct ID with extra context.static @NotNull PostHogClient.BuildernewBuilder(@NotNull String projectApiKey) static @NotNull PostHogClientnewPostHogClient(@NotNull String projectApiKey) static @NotNull PostHogClientvoidTriggers a full reload of all local feature flags from the remote server.default voidSet the given properties with the person profile of the user (distinct id).default voidSet the given properties with the person profile of the user (distinct id).default voidSet the given properties with the person profile of the user (distinct id).default voidset(@NotNull String distinctId, @Nullable Map<String, Object> properties, @Nullable Map<String, Object> propertiesSetOnce) Set the given properties with the person profile of the user (distinct id).void
-
Method Details
-
noopPostHogClient
-
newPostHogClient
-
newBuilder
-
shutdown
-
capture
Capture an event with the given name for the given distinct ID with no properties.- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.event- Name of the event. May not be empty.
-
capture
default void capture(@NotNull @NotNull String distinctId, @NotNull @NotNull String event, @NotNull @NotNull Map<String, Object> properties) Capture an event with the given name for the given distinct ID with the provided properties.- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.event- Name of the event. May not be empty.properties- Event properties
-
capture
void capture(@NotNull @NotNull String distinctId, @NotNull @NotNull String event, @NotNull @NotNull Object properties) Capture an event with the given name for the given ID with properties from the given object.The object must be serializable to a JSON object via Gson (not primitive or array)
- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.event- Name of the event. May not be empty.properties- Event object data
-
identify
default void identify(@NotNull @NotNull String distinctId, @Nullable @Nullable Map<String, Object> properties, @Nullable @Nullable Map<String, Object> propertiesSetOnce) Link the given properties with the person profile of the user (distinct id).- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profilepropertiesSetOnce- Properties to set only if missing on the person profile
-
identify
default void identify(@NotNull @NotNull String distinctId, @Nullable @Nullable Object properties, @Nullable @Nullable Object propertiesSetOnce) Link the given properties with the person profile of the user (distinct id).The objects must be serializable to a JSON object via Gson (not primitive or array)
- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profilepropertiesSetOnce- Properties to set only if missing on the person profile
-
identify
default void identify(@NotNull @NotNull String distinctId, @Nullable @Nullable Map<String, Object> properties) Link the given properties with the person profile of the user (distinct id).- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profile
-
identify
Link the given properties with the person profile of the user (distinct id).The object must be serializable to a JSON object via Gson (not primitive or array)
- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profile
-
set
default void set(@NotNull @NotNull String distinctId, @Nullable @Nullable Map<String, Object> properties, @Nullable @Nullable Map<String, Object> propertiesSetOnce) Set the given properties with the person profile of the user (distinct id).- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profilepropertiesSetOnce- Properties to set only if missing on the person profile
-
set
default void set(@NotNull @NotNull String distinctId, @Nullable @Nullable Object properties, @Nullable @Nullable Object propertiesSetOnce) Set the given properties with the person profile of the user (distinct id).The objects must be serializable to a JSON object via Gson (not primitive or array)
- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profilepropertiesSetOnce- Properties to set only if missing on the person profile
-
set
default void set(@NotNull @NotNull String distinctId, @Nullable @Nullable Map<String, Object> properties) Set the given properties with the person profile of the user (distinct id).- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profile
-
set
Set the given properties with the person profile of the user (distinct id).The object must be serializable to a JSON object via Gson (not primitive or array)
- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.properties- Properties to set (including overwriting previous values) on the person profile
-
alias
Alias the given distinct ID to the given alias.- Parameters:
distinctId- Unique ID of the target in your database. May not be empty.alias- Alias to set for the distinct ID. May not be empty.
-
groupIdentify
default void groupIdentify(@NotNull @NotNull String type, @NotNull @NotNull String key, @NotNull @NotNull Map<String, Object> properties) Assign the given properties to the given group (type & key).- Parameters:
type- Group type. Must not be emptykey- Group key. Must not be emptyproperties- Properties to set (including overwriting previous values) on the group
-
groupIdentify
default void groupIdentify(@NotNull @NotNull String type, @NotNull @NotNull String key, @NotNull @NotNull Object properties) Assign the given properties to the given group (type & key).The object must be serializable to a JSON object via Gson (not primitive or array)
- Parameters:
type- Group type. Must not be emptykey- Group key. Must not be emptyproperties- Properties to set (including overwriting previous values) on the group
-
flush
void flush()Queue an immediate flush of the pending event queue. This call does not block on the flush to be completed. -
isFeatureEnabled
Check if the given feature flag is enabled for the given distinct ID.- Parameters:
key- Feature flag keydistinctId- Unique ID of the target in your database. May not be empty- Returns:
- True if the feature flag is enabled for the given distinct ID, false otherwise
-
isFeatureEnabled
default boolean isFeatureEnabled(@NotNull @NotNull String key, @NotNull @NotNull String distinctId, @Nullable @Nullable FeatureFlagContext context) Check if the given feature flag is enabled for the given distinct ID with extra context.- Parameters:
key- Feature flag keydistinctId- Unique ID of the target in your database. May not be emptycontext- Extra context to pass to the feature flag evaluation- Returns:
- True if the feature flag is enabled for the given distinct ID, false otherwise
-
getFeatureFlag
@NotNull default @NotNull FeatureFlagState getFeatureFlag(@NotNull @NotNull String key, @NotNull @NotNull String distinctId) Get the feature flag state for the given distinct ID.- Parameters:
key- Feature flag keydistinctId- Unique ID of the target in your database. May not be empty- Returns:
- Feature flag state
-
getFeatureFlag
@NotNull @NotNull FeatureFlagState getFeatureFlag(@NotNull @NotNull String key, @NotNull @NotNull String distinctId, @Nullable @Nullable FeatureFlagContext context) Get the feature flag state for the given distinct ID with extra context.- Parameters:
key- Feature flag keydistinctId- Unique ID of the target in your database. May not be emptycontext- Extra context to pass to the feature flag evaluation- Returns:
- Feature flag state
-
getFeatureFlagPayload
@Nullable default @Nullable String getFeatureFlagPayload(@NotNull @NotNull String key, @NotNull @NotNull String distinctId) Get the feature flag payload for the given distinct ID.- Parameters:
key- Feature flag keydistinctId- Unique ID of the target in your database. May not be empty- Returns:
- Feature flag payload, or null if the feature flag is disabled or has no payload configured.
-
getFeatureFlagPayload
@Nullable default @Nullable String getFeatureFlagPayload(@NotNull @NotNull String key, @NotNull @NotNull String distinctId, @Nullable @Nullable FeatureFlagContext context) Get the feature flag payload for the given distinct ID.- Parameters:
key- Feature flag keydistinctId- Unique ID of the target in your database. May not be emptycontext- Extra context to pass to the feature flag evaluation- Returns:
- Feature flag payload, or null if the feature flag is disabled or has no payload configured.
-
getAllFeatureFlags
Get all feature flags for the given distinct ID.- Parameters:
distinctId- Unique ID of the target in your database. May not be empty- Returns:
- Feature flag states
-
getAllFeatureFlags
@NotNull @NotNull FeatureFlagStates getAllFeatureFlags(@NotNull @NotNull String distinctId, @Nullable @Nullable FeatureFlagContext context) Get all feature flags for the given distinct ID with extra context.- Parameters:
distinctId- Unique ID of the target in your database. May not be emptycontext- Extra context to pass to the feature flag evaluation- Returns:
- Feature flag states
-
reloadFeatureFlags
void reloadFeatureFlags()Triggers a full reload of all local feature flags from the remote server. Only valid when local evaluation is enabled. This call does not block on the flush to be completed.- Throws:
IllegalStateException- if local feature flag evaluation is not enabled.
-
captureException
-
captureException
-
captureException
-
captureException
-