Skip to content
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

Sending Settings v2 events to Koala #389

Merged
merged 12 commits into from
Nov 29, 2018
4 changes: 4 additions & 0 deletions app/src/main/java/com/kickstarter/extensions/AnswersExt.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ import com.crashlytics.android.answers.CustomEvent
fun fabricLogCustomEvent(customEvent: String) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we kill this extension until we decide we're using Fabric officially?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Killed!

Answers.getInstance().logCustom(CustomEvent(customEvent))
}

fun fabricLogCustomEventWithAttributes(customEvent: String, key: String, attribute: String) {
Copy link
Contributor

Choose a reason for hiding this comment

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

This method sends a single attribute along with an event. My understanding was that we wanted to send all of the attributes we send to Koala to Fabric/Firebase. Which is why @justinswart was running into the limit issue. I know Justin said he's going to do some more exploration with Fabric/Firebase.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the issue was that he was sending all of the default properties along with the custom event which we don't need to do because we get that from Fabric automatically. (Device, OS, etc..)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh cool, @Rcureton please show me where to find that in Fabric, I could only see the custom attributes on the event that I was logging. Also - I'm not seeing any of that stuff appearing in Firebase yet 🤔

Copy link
Contributor Author

@Rcureton Rcureton Nov 28, 2018

Choose a reason for hiding this comment

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

@justinswart So for us to be able to see events in Firebase we'll have to use the Firebase SDK. Right now the only thing that transfers over are the crash reports. Also I thought Fabric had a set of automatically collected properties with each events but apparently Firebase has them Firebase Automatically Collected Properties. I don't think it will be a large change for us on both platforms. What do you think?

Answers.getInstance().logCustom(CustomEvent(customEvent).putCustomAttribute(key, attribute))
}
38 changes: 19 additions & 19 deletions app/src/main/java/com/kickstarter/libs/Koala.java
Original file line number Diff line number Diff line change
Expand Up @@ -299,30 +299,30 @@ public void trackSignupNewsletterToggle(final boolean sendNewsletters) {

// SETTINGS
public void trackChangedEmail() {
this.client.track(KoalaEvent.CHANGED_EMAIL);
this.client.track(KoalaEvent.CHANGED_EMAIL, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.CHANGED_EMAIL);
}

public void trackChangedPassword() {
this.client.track(KoalaEvent.CHANGED_PASSWORD);
this.client.track(KoalaEvent.CHANGED_PASSWORD, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.CHANGED_PASSWORD);
}
public void trackContactEmailClicked() {
this.client.track("Contact Email Clicked");
}

public void trackDeletePaymentMethod() {
this.client.track(KoalaEvent.DELETED_PAYMENT_METHOD);
this.client.track(KoalaEvent.DELETED_PAYMENT_METHOD, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.DELETED_PAYMENT_METHOD);
}

public void trackErroredDeletePaymentMethod() {
this.client.track(KoalaEvent.ERRORED_DELETE_PAYMENT_METHOD);
this.client.track(KoalaEvent.ERRORED_DELETE_PAYMENT_METHOD, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.ERRORED_DELETE_PAYMENT_METHOD);
}

public void trackFailedPaymentMethodCreation() {
this.client.track(KoalaEvent.FAILED_PAYMENT_METHOD_CREATION);
this.client.track(KoalaEvent.FAILED_PAYMENT_METHOD_CREATION, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.FAILED_PAYMENT_METHOD_CREATION);
}

Expand All @@ -335,62 +335,62 @@ public void trackNewsletterToggle(final boolean sendNewsletter) {
}

public void trackResentVerificationEmail() {
this.client.track(KoalaEvent.RESENT_VERIFICATION_EMAIL);
this.client.track(KoalaEvent.RESENT_VERIFICATION_EMAIL, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.RESENT_VERIFICATION_EMAIL);
}

public void trackSavedPaymentMethod() {
this.client.track(KoalaEvent.SAVED_PAYMENT_METHOD);
this.client.track(KoalaEvent.SAVED_PAYMENT_METHOD, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.SAVED_PAYMENT_METHOD);
}

public void trackSelectedChosenCurrency() {
this.client.track(KoalaEvent.SELECTED_CHOSEN_CURRENCY);
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.SELECTED_CHOSEN_CURRENCY);
public void trackSelectedChosenCurrency(String selectedCurrency) {
this.client.trackEventType(KoalaEvent.SELECTED_CHOSEN_CURRENCY, this.client.defaultProperties(), selectedCurrency);
AnswersExtKt.fabricLogCustomEventWithAttributes(KoalaEvent.SELECTED_CHOSEN_CURRENCY, "currency", selectedCurrency);
Copy link
Contributor

Choose a reason for hiding this comment

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

I thought we're not doing any more Fabric events. 👀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed!

}

public void trackSettingsView() {
this.client.track("Settings View");
this.client.track("Settings View",this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_SETTINGS);
}

public void trackViewedAccount() {
this.client.track(KoalaEvent.VIEWED_ACCOUNT);
this.client.track(KoalaEvent.VIEWED_ACCOUNT, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_ACCOUNT);
}

public void trackViewedAddNewCard() {
this.client.track(KoalaEvent.VIEWED_ADD_NEW_CARD);
this.client.track(KoalaEvent.VIEWED_ADD_NEW_CARD, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_ADD_NEW_CARD);
}

public void trackViewedChangedEmail() {
this.client.track(KoalaEvent.VIEWED_CHANGE_EMAIL);
this.client.track(KoalaEvent.VIEWED_CHANGE_EMAIL, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_CHANGE_EMAIL);
}

public void trackViewedChangedPassword() {
this.client.track(KoalaEvent.VIEWED_CHANGE_PASSWORD);
this.client.track(KoalaEvent.VIEWED_CHANGE_PASSWORD, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_CHANGE_PASSWORD);
}

public void trackViewedNotifications() {
this.client.track(KoalaEvent.VIEWED_NOTIFICATIONS);
this.client.track(KoalaEvent.VIEWED_NOTIFICATIONS, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_NOTIFICATIONS);
}

public void trackViewedNewsletter() {
this.client.track(KoalaEvent.VIEWED_NEWSLETTER);
this.client.track(KoalaEvent.VIEWED_NEWSLETTER, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_NEWSLETTER);
}

public void trackViewedPaymentMethods() {
this.client.track(KoalaEvent.VIEWED_PAYMENT_METHODS);
this.client.track(KoalaEvent.VIEWED_PAYMENT_METHODS, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_PAYMENT_METHODS);
}

public void trackViewedPrivacy() {
this.client.track(KoalaEvent.VIEWED_PRIVACY);
this.client.track(KoalaEvent.VIEWED_PRIVACY, this.client.defaultProperties());
AnswersExtKt.fabricLogCustomEvent(KoalaEvent.VIEWED_PRIVACY);
}

Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/com/kickstarter/libs/KoalaTrackingClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import android.content.Context;
import android.content.res.Configuration;
import android.os.Build;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

Expand Down Expand Up @@ -71,6 +72,15 @@ public Map<String, Object> defaultProperties() {
hashMap.put("device_fingerprint", this.mixpanel.getDistinctId());
hashMap.put("android_uuid", this.mixpanel.getDistinctId());
hashMap.put("android_pay_capable", this.androidPayCapability.isCapable());
hashMap.put("manufacturer", android.os.Build.MANUFACTURER);
hashMap.put("app_version", android.os.Build.VERSION.RELEASE);
hashMap.put("model", android.os.Build.MODEL);
hashMap.put("brand", android.os.Build.BRAND);
hashMap.put("product", android.os.Build.PRODUCT);
hashMap.put("os_version", android.os.Build.VERSION.SDK_INT);
hashMap.put("mp_lib", "kickstarter_android");
hashMap.put("koala_lib", "kickstarter_android");
hashMap.put("time", Build.TIME);

return hashMap;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

public abstract class TrackingClientType {
public abstract void track(final String eventName, final Map<String, Object> properties);
public abstract void trackEventType(final String eventName, final Map<String, Object> properties, final String eventType);

public final void track(final String eventName) {
track(eventName, new HashMap<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ interface AccountViewModel {
.subscribe {
this.chosenCurrency.onNext(it)
this.success.onNext(it)
this.koala.trackSelectedChosenCurrency()
this.koala.trackSelectedChosenCurrency(it)
}

updateCurrencyNotification
Expand Down