Skip to content

feat(track): Introducing easier event tracking #250

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Jan 15, 2019
Merged

Conversation

aliabbasrizvi
Copy link
Contributor

Summary

This change updates track to always send an event without doing experiment/variation lookup.

Test plan

  • Updated unit tests.
  • (Pending) Manual tests confirming that even with decisions, conversions are recorded fine.
  • (Pending) SDK compatibility tests.

Copy link
Contributor

@loganlinn loganlinn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM; just some minor comments.


decisions.add(decision);
}
ArrayList<Decision> decisions = new ArrayList<Decision>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like it's only being used below once. We can skip instantiating this list if we:

       Snapshot snapshot = new Snapshot.Builder()
-              .setDecisions(decisions)
+              .setDecisions(Collections.emptyList())
               .setEvents(Collections.singletonList((conversionEvent)))
               .build();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will update.

@@ -104,28 +104,13 @@ public LogEvent createImpressionEvent(@Nonnull ProjectConfig projectConfig,
}

public LogEvent createConversionEvent(@Nonnull ProjectConfig projectConfig,
@Nonnull Map<Experiment, Variation> experimentVariationMap,
Copy link
Contributor

@loganlinn loganlinn Jan 2, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if we want to avoid breaking API changes in this PR, but if we do, we may want to overload this method rather than removing argument since this is technically public even though we probably don't encourage direct.

Edit: disregard. I was going off of this method+class being public, but it lives in internal package, which is good-enough warning of being a non-stable API in my opinion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

testParams + " and payload \"{}\"");

optimizely.track(eventType.getKey(), genericUserId, attributes);
verify(mockEventHandler).dispatchEvent(eq(logEventToDispatch));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: since we are mocking the event factory (for better or worse), maybe consider sameInstance() instead of eq() for a little more stringency. also can consider using verifyNoMoreInteractions(mockEventFactory) if that's what we expect. if you decide to incorporate, could probably do in a helper method on this test class, as this isn't the only test it could be applied to.

@mikeproeng37
Copy link
Contributor

@aliabbasrizvi can you resolve the conflicts please

@aliabbasrizvi
Copy link
Contributor Author

@mikeng13 will do that when I respond to feedback.

@aliabbasrizvi
Copy link
Contributor Author

All conflicts resolved and made changes as per discussion with @loganlinn and @mjc1283

@mikeproeng37
Copy link
Contributor

I am running this PR against tests from Matt's PR to test EET in compat suite: https://github.com/optimizely/fullstack-sdk-compatibility-suite/pull/199/files

I created a branch that enables it for the Java SDK: mng/enable-eet-tests

Test Run:
https://travis-ci.com/optimizely/fullstack-sdk-compatibility-suite/builds/96688120

.setDecisions(decisions)
.setEvents(Collections.singletonList((conversionEvent)))
.build();
.setEvents(Collections.singletonList((conversionEvent)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extra set of parenthesis

@coveralls
Copy link

coveralls commented Jan 15, 2019

Pull Request Test Coverage Report for Build 835

  • 13 of 15 (86.67%) changed or added relevant lines in 5 files are covered.
  • 2 unchanged lines in 2 files lost coverage.
  • Overall coverage decreased (-0.2%) to 89.616%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core-api/src/main/java/com/optimizely/ab/event/internal/payload/Snapshot.java 3 5 60.0%
Files with Coverage Reduction New Missed Lines %
core-api/src/main/java/com/optimizely/ab/config/audience/UserAttribute.java 1 81.58%
core-api/src/main/java/com/optimizely/ab/config/Experiment.java 1 97.67%
Totals Coverage Status
Change from base Build 823: -0.2%
Covered Lines: 2684
Relevant Lines: 2995

💛 - Coveralls

@aliabbasrizvi
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants