8000 [🧽🐨] NT-926 Koala clean up by eoji · Pull Request #759 · kickstarter/android-oss · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[🧽🐨] NT-926 Koala clean up #759

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 2 commits into from clean-up-koala
Feb 25, 2020
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
86 changes: 3 additions & 83 deletions app/src/main/java/com/kickstarter/libs/Koala.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,9 @@ public void trackEditorialCardClicked(final @NonNull Editorial editorial) {
* @param cookieRefTag (nullable) The ref tag extracted from the cookie store upon viewing the project.
*/
public void trackProjectShow(final @NonNull Project project, final @Nullable RefTag intentRefTag, final @Nullable RefTag cookieRefTag) {

final Map<String, Object> properties = KoalaUtils.projectProperties(project, this.client.loggedInUser());

if (intentRefTag != null) {
properties.put("session_ref_tag", intentRefTag.tag());
}

if (cookieRefTag != null) {
properties.put("session_referrer_credit", cookieRefTag.tag());
}
properties.putAll(KoalaUtils.refTagProperties(intentRefTag, cookieRefTag));

this.client.track(KoalaEvent.PROJECT_PAGE, properties);
}
Expand Down Expand Up @@ -320,10 +313,6 @@ public void trackFacebookConfirmation() {
this.client.track(KoalaEvent.FACEBOOK_CONFIRM);
}

public void trackFacebookLoginSuccess() {
this.client.track("Facebook Login");
}

public void trackFacebookLoginError() {
this.client.track("Errored Facebook Login");
}
Expand Down Expand Up @@ -433,25 +422,10 @@ public void trackViewedPrivacy() {
}

// CHECKOUT
public void trackCheckoutNext() { // rewards webview and top nav
this.client.track("Checkout Next");
}
public void trackCheckoutCancel() {
this.client.track("Checkout Cancel");
}

public void trackCheckoutLoadFailed() {
// TODO: set up error props
}

public void trackCheckoutShowShareSheet() {
this.client.track("Checkout Show Share Sheet");
}

public void trackCheckoutCancelShareSheet() {
this.client.track("Checkout Cancel Share Sheet");
}

public void trackCheckoutShowFacebookShareView() {
this.client.track("Checkout Show Share", new HashMap<String, Object>() {
{
Expand All @@ -468,10 +442,6 @@ public void trackCheckoutShowTwitterShareView() {
});
}

public void trackCheckoutShareFinished() {
this.client.track("Checkout Share Finished");
}

public void trackCheckoutFinishJumpToDiscovery() {
this.client.track("Checkout Finished Discover More");
}
Expand Down Expand Up @@ -539,42 +509,6 @@ public void trackShowProjectShareSheet(final @NonNull Project project) {
this.client.track(KoalaEvent.SHOWED_SHARE_SHEET, props);
}

public void trackCancelProjectShareSheet() {
this.client.track("Project Cancel Share Sheet");
}

public void trackShowProjectFacebookShareView() {
this.client.track("Project Show Share", new HashMap<String, Object>() {
{
put("share_type", "facebook");
}
});
}

public void trackShowProjectTwitterShareView() {
this.client.track("Project Show Share", new HashMap<String, Object>() {
{
put("share_type", "twitter");
}
});
}

public void trackProjectFacebookShare() {
this.client.track("Project Share", new HashMap<String, Object>() {
{
put("share_type", "facebook");
}
});
}

public void trackProjectTwitterShare() {
this.client.track("Project Share", new HashMap<String, Object>() {
{
put("share_type", "twitter");
}
});
}

// MESSAGES
public void trackSentMessage(final @NonNull Project project, final @NonNull KoalaContext.Message context) {
final Map<String, Object> props = KoalaUtils.projectProperties(project, this.client.loggedInUser());
Expand Down Expand Up @@ -725,14 +659,7 @@ public void trackHamburgerMenuClicked(final @NonNull DiscoveryParams discoveryPa

public void trackProjectPageViewed(final @NonNull Project project, final @Nullable RefTag intentRefTag, final @Nullable RefTag cookieRefTag) {
final Map<String, Object> props = KoalaUtils.projectProperties(project, this.client.loggedInUser());

if (intentRefTag != null) {
props.put("session_ref_tag", intentRefTag.tag());
}

if (cookieRefTag != null) {
props.put("session_referrer_credit", cookieRefTag.tag());
}
props.putAll(KoalaUtils.refTagProperties(intentRefTag, cookieRefTag));

this.client.track(LakeEvent.PROJECT_PAGE_VIEWED, props);
}
Expand Down Expand Up @@ -769,14 +696,7 @@ public void trackPledgeSubmitButtonClicked(final @NonNull CheckoutData checkoutD

public void trackProjectPagePledgeButtonClicked(final @NonNull Project project, final @Nullable RefTag intentRefTag, final @Nullable RefTag cookieRefTag) {
final Map<String, Object> props = KoalaUtils.projectProperties(project, this.client.loggedInUser());
< 10000 span class='blob-code-inner blob-code-marker js-skip-tagsearch' data-code-marker="-">
if (intentRefTag != null) {
props.put("session_ref_tag", intentRefTag.tag());
}

if (cookieRefTag != null) {
props.put("session_referrer_credit", cookieRefTag.tag());
}
props.putAll(KoalaUtils.refTagProperties(intentRefTag, cookieRefTag));

this.client.track(LakeEvent.PROJECT_PAGE_PLEDGE_BUTTON_CLICKED, props);
}
Expand Down
24 changes: 15 additions & 9 deletions app/src/main/java/com/kickstarter/libs/utils/KoalaUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,7 @@ private KoalaUtils() {}
final Map<String, Object> props = KoalaUtils.projectProperties(projectData.project(), loggedInUser);
props.putAll(KoalaUtils.pledgeProperties(pledgeData.reward()));

final RefTag intentRefTag = projectData.refTagFromIntent();
if (intentRefTag != null) {
props.put("session_ref_tag", intentRefTag.tag());
}

final RefTag cookieRefTag = projectData.refTagFromCookie();
if (cookieRefTag != null) {
props.put("session_referrer_credit", cookieRefTag.tag());
}
props.putAll(refTagProperties(projectData.refTagFromIntent(), projectData.refTagFromCookie()));

props.put("context_pledge_flow", pledgeData.pledgeFlowContext().getTrackingString());
return props;
Expand Down Expand Up @@ -226,6 +218,20 @@ private KoalaUtils() {}
return MapUtils.prefixKeys(properties, prefix);
}

public static @NonNull Map<String, Object> refTagProperties(final @Nullable RefTag intentRefTag, final @Nullable RefTag cookieRefTag) {
return new HashMap<String, Object>() {
{
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you need this extra bracket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes! It's the init block of the HashMap

if (intentRefTag != null) {
put("session_ref_tag", intentRefTag.tag());
}

if (cookieRefTag != null) {
put("session_referrer_credit", cookieRefTag.tag());
}
}
};
}

public static @NonNull Map<String, Object> activityProperties(final @NonNull Activity activity, final @Nullable User loggedInUser) {
return activityProperties(activity, loggedInUser, "activity_");
}
Expand Down
0