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
30 changes: 4 additions & 26 deletions core-api/src/jmh/java/com/optimizely/ab/OptimizelyBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,49 +157,27 @@ public Variation measureActivateForGroupExperimentWithForcedVariation() {
}

@Benchmark
public void measureTrackWithNoAttributesAndNoRevenue() {
public void measureTrackWithNoAttributes() {
optimizely.track("testEventWithMultipleExperiments", "optimizely_user" + random.nextInt());
}

@Benchmark
public void measureTrackWithNoAttributesAndRevenue() {
optimizely.track("testEventWithMultipleExperiments", "optimizely_user" + random.nextInt(), 50000);
}

@Benchmark
public void measureTrackWithAttributesAndNoRevenue() {
public void measureTrackWithAttributes() {
optimizely.track("testEventWithMultipleExperiments", "optimizely_user" + random.nextInt(),
Collections.singletonMap("browser_type", "firefox"));
}

@Benchmark
public void measureTrackWithAttributesAndRevenue() {
optimizely.track("testEventWithMultipleExperiments", "optimizely_user" + random.nextInt(),
Collections.singletonMap("browser_type", "firefox"), 50000);
}

@Benchmark
public void measureTrackWithGroupExperimentsNoAttributesNoRevenue() {
public void measureTrackWithGroupExperimentsNoAttributes() {
optimizely.track("testEventWithMultipleExperiments", trackGroupExperimentUserId);
}

@Benchmark
public void measureTrackWithGroupExperimentsNoAttributesAndRevenue() {
optimizely.track("testEventWithMultipleExperiments", trackGroupExperimentUserId, 50000);
}

@Benchmark
public void measureTrackWithGroupExperimentsNoRevenueAndAttributes() {
public void measureTrackWithGroupExperimentsAndAttributes() {
optimizely.track("testEventWithMultipleExperiments", trackGroupExperimentAttributesUserId,
Collections.singletonMap("browser_type", "chrome"));
}

@Benchmark
public void measureTrackWithGroupExperimentsAndAttributesAndRevenue() {
optimizely.track("testEventWithMultipleExperiments", trackGroupExperimentAttributesUserId,
Collections.singletonMap("browser_type", "chrome"), 50000);
}

@Benchmark
public void measureTrackWithGroupExperimentsAndForcedVariation() {
optimizely.track("testEventWithMultipleExperiments", "user_a");
Expand Down
20 changes: 0 additions & 20 deletions core-api/src/main/java/com/optimizely/ab/Optimizely.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,26 +213,6 @@ public void track(@Nonnull String eventName,
track(eventName, userId, attributes, Collections.<String, String>emptyMap());
}

/**
* @deprecated see {@link #track(String, String, Map)} and pass in the revenue value as an event tag instead.
*/
public void track(@Nonnull String eventName,
@Nonnull String userId,
long eventValue) throws UnknownEventTypeException {
track(eventName, userId, Collections.<String, String>emptyMap(), Collections.singletonMap(
ReservedEventKey.REVENUE.toString(), eventValue));
}

/**
* @deprecated see {@link #track(String, String, Map, long)} and pass in the revenue value as an event tag instead.
*/
public void track(@Nonnull String eventName,
@Nonnull String userId,
@Nonnull Map<String, String> attributes,
long eventValue) throws UnknownEventTypeException {
track(eventName, userId, attributes, Collections.singletonMap(ReservedEventKey.REVENUE.toString(), eventValue));
}

public void track(@Nonnull String eventName,
@Nonnull String userId,
@Nonnull Map<String, String> attributes,
Expand Down
61 changes: 0 additions & 61 deletions core-api/src/test/java/com/optimizely/ab/OptimizelyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -1140,67 +1140,6 @@ public void trackEventWithUnknownAttribute() throws Exception {
verify(mockEventHandler).dispatchEvent(logEventToDispatch);
}

/**
* Verify that {@link Optimizely#track(String, String, long)} passes through revenue.
*/
@Test
public void trackEventWithRevenue() throws Exception {
EventType eventType = validProjectConfig.getEventTypes().get(0);
long revenue = 1234L;

// setup a mock event builder to return expected conversion params
EventBuilder mockEventBuilder = mock(EventBuilder.class);

Optimizely optimizely = Optimizely.builder(validDatafile, mockEventHandler)
.withBucketing(mockBucketer)
.withEventBuilder(mockEventBuilder)
.withConfig(validProjectConfig)
.withErrorHandler(mockErrorHandler)
.build();

Map<String, String> testParams = new HashMap<String, String>();
testParams.put("test", "params");
Map<String, Object> eventTags= new HashMap<String, Object>();
eventTags.put(ReservedEventKey.REVENUE.toString(), revenue);
Map<Experiment, Variation> experimentVariationMap = createExperimentVariationMap(
validProjectConfig,
mockBucketer,
eventType.getKey(),
genericUserId,
Collections.<String, String>emptyMap());
LogEvent logEventToDispatch = new LogEvent(RequestMethod.GET, "test_url", testParams, "");
when(mockEventBuilder.createConversionEvent(
eq(validProjectConfig),
eq(experimentVariationMap),
eq(genericUserId),
eq(eventType.getId()),
eq(eventType.getKey()),
eq(Collections.<String, String>emptyMap()),
eq(eventTags)))
.thenReturn(logEventToDispatch);

// call track
optimizely.track(eventType.getKey(), genericUserId, revenue);

// setup the event tag map captor (so we can verify its content)
ArgumentCaptor<Map> eventTagCaptor = ArgumentCaptor.forClass(Map.class);

// verify that the event builder was called with the expected revenue
verify(mockEventBuilder).createConversionEvent(
eq(validProjectConfig),
eq(experimentVariationMap),
eq(genericUserId),
eq(eventType.getId()),
eq(eventType.getKey()),
eq(Collections.<String, String>emptyMap()),
eventTagCaptor.capture());

Long actualValue = (Long)eventTagCaptor.getValue().get(ReservedEventKey.REVENUE.toString());
assertThat(actualValue, is(revenue));

verify(mockEventHandler).dispatchEvent(logEventToDispatch);
}

/**
* Verify that {@link Optimizely#track(String, String, Map, Map)} passes event features to
* {@link EventBuilder#createConversionEvent(ProjectConfig, Map, String, String, String, Map, Map)}
Expand Down