Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions src/main/java/net/hollowcube/posthog/PostHog.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,52 @@ public static void identify(@NotNull String distinctId, @Nullable Object propert
getClient().identify(distinctId, properties);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
* @param propertiesSetOnce Properties to set only if missing on the person profile
*/
public static void set(@NotNull String distinctId, @Nullable Map<String, Object> properties, @Nullable Map<String, Object> propertiesSetOnce) {
getClient().set(distinctId, properties, propertiesSetOnce);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* <p>The objects must be serializable to a JSON object via Gson (not primitive or array)</p>
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
* @param propertiesSetOnce Properties to set only if missing on the person profile
*/
public static void set(@NotNull String distinctId, @Nullable Object properties, @Nullable Object propertiesSetOnce) {
getClient().set(distinctId, properties, propertiesSetOnce);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
*/
public static void set(@NotNull String distinctId, @Nullable Map<String, Object> properties) {
getClient().set(distinctId, properties);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* <p>The object must be serializable to a JSON object via Gson (not primitive or array)</p>
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
*/
public static void set(@NotNull String distinctId, @Nullable Object properties) {
getClient().set(distinctId, properties);
}

/**
* Alias the given distinct ID to the given alias.
*
Expand Down
56 changes: 56 additions & 0 deletions src/main/java/net/hollowcube/posthog/PostHogClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,62 @@ default void identify(@NotNull String distinctId, @Nullable Object properties) {
capture(distinctId, IDENTIFY, eventProps);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
* @param propertiesSetOnce Properties to set only if missing on the person profile
*/
default void set(@NotNull String distinctId, @Nullable Map<String, Object> properties, @Nullable Map<String, Object> propertiesSetOnce) {
Map<String, Object> eventProps = new HashMap<>();
if (properties != null) eventProps.put(SET, properties);
if (propertiesSetOnce != null) eventProps.put(SET_ONCE, propertiesSetOnce);
capture(distinctId, SET, eventProps);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* <p>The objects must be serializable to a JSON object via Gson (not primitive or array)</p>
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
* @param propertiesSetOnce Properties to set only if missing on the person profile
*/
default void set(@NotNull String distinctId, @Nullable Object properties, @Nullable Object propertiesSetOnce) {
Map<String, Object> eventProps = new HashMap<>();
if (properties != null) eventProps.put(SET, properties);
if (propertiesSetOnce != null) eventProps.put(SET_ONCE, propertiesSetOnce);
capture(distinctId, SET, eventProps);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
*/
default void set(@NotNull String distinctId, @Nullable Map<String, Object> properties) {
Map<String, Object> eventProps = new HashMap<>();
if (properties != null) eventProps.put(SET, properties);
capture(distinctId, SET, eventProps);
}

/**
* Set the given properties with the person profile of the user (distinct id).
*
* <p>The object must be serializable to a JSON object via Gson (not primitive or array)</p>
*
* @param distinctId Unique ID of the target in your database. May not be empty.
* @param properties Properties to set (including overwriting previous values) on the person profile
*/
default void set(@NotNull String distinctId, @Nullable Object properties) {
Map<String, Object> eventProps = new HashMap<>();
if (properties != null) eventProps.put(SET, properties);
capture(distinctId, SET, eventProps);
}

/**
* Alias the given distinct ID to the given alias.
*
Expand Down
Loading