Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/origin/experiment' into next-re…
Browse files Browse the repository at this point in the history
…lease
  • Loading branch information
gwhelanLD committed Sep 23, 2019
2 parents d26e006 + 4e76a48 commit 3ac167f
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ public void testUserObjectRemovedFromCustomEvent() {

LDUser user = builder.build();

final CustomEvent event = new CustomEvent("key1", user.getKey(), null);
final CustomEvent event = new CustomEvent("key1", user.getKey(), null, null);

assertNull(event.user);
assertEquals(user.getKey(), event.userKey);
Expand All @@ -246,7 +246,7 @@ public void testFullUserObjectIncludedInCustomEvent() {

LDUser user = builder.build();

final CustomEvent event = new CustomEvent("key1", user, null);
final CustomEvent event = new CustomEvent("key1", user, null, null);

assertEquals(user, event.user);
assertNull(event.userKey);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ class IdentifyEvent extends GenericEvent {
class CustomEvent extends GenericEvent {
@Expose
private final JsonElement data;
@Expose
private final Double metricValue;

CustomEvent(String key, LDUser user, JsonElement data) {
CustomEvent(String key, LDUser user, JsonElement data, Double metricValue) {
super("custom", key, user);
this.data = data;
this.metricValue = metricValue;
}

CustomEvent(String key, String userKey, JsonElement data) {
CustomEvent(String key, String userKey, JsonElement data, Double metricValue) {
super("custom", key, null);
this.data = data;
this.userKey = userKey;
this.metricValue = metricValue;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,19 @@ protected LDClient(final Application application, @NonNull final LDConfig config
}

@Override
public void track(String eventName, JsonElement data) {
public void track(String eventName, JsonElement data, Double metricValue) {
if (config.inlineUsersInEvents()) {
sendEvent(new CustomEvent(eventName, userManager.getCurrentUser(), data));
sendEvent(new CustomEvent(eventName, userManager.getCurrentUser(), data, metricValue));
} else {
sendEvent(new CustomEvent(eventName, userManager.getCurrentUser().getKey(), data));
sendEvent(new CustomEvent(eventName, userManager.getCurrentUser().getKey(), data, metricValue));
}
}

@Override
public void track(String eventName, JsonElement data) {
track(eventName, data, null);
}

@Override
public void track(String eventName) {
track(eventName, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ public interface LDClientInterface extends Closeable {
*/
void setOnline();

/**
* Tracks that a user performed an event.
*
* @param eventName the name of the event
* @param data a JSON object containing additional data associated with the event
* @param metricValue A numeric value used by the LaunchDarkly experimentation feature in
* numeric custom metrics. Can be omitted if this event is used by only
* non-numeric metrics. This field will also be returned as part of the
* custom event for Data Export. (Optional)
*/
void track(String eventName, JsonElement data, Double metricValue);

/**
* Tracks that a user performed an event.
*
Expand Down

0 comments on commit 3ac167f

Please sign in to comment.