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

Port Google Analytics fixes to the develop branch (develop) #242

Merged
merged 1 commit into from
Mar 6, 2015
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
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ private void reportAnalytics() {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.APP_SETTINGS.toString(),
getString(R.string.analytics_action_configured_region), getString(R.string.analytics_label_region)
+ getCurrentRegion().getName());
} else {
} else if (Application.get().getCustomApiUrl() != null) {
String customUrl = null;
MessageDigest digest = null;
try {
Expand All @@ -261,14 +261,6 @@ private void reportAnalytics() {
getString(R.string.analytics_action_configured_region), getString(R.string.analytics_label_region)
+ customUrl);
}

if (getCurrentRegion() != null) {
Boolean showExperimentalRegions = getCurrentRegion().getExperimental();
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.APP_SETTINGS.toString(),
getString(R.string.analytics_action_configured_region), getString(R.string.analytics_label_region)
+ (showExperimentalRegions ? "YES" : "NO"));
}

Boolean experimentalRegions = getPrefs().getBoolean(getString(R.string.preference_key_experimental_regions),
Boolean.FALSE);
Boolean autoRegion = getPrefs().getBoolean(getString(R.string.preference_key_auto_select_region),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@
public class ObaAnalytics {

/**
* Users location accuracy should be less then 100m
* Users location accuracy should be less then 50f
*/
private static final float LOCATION_ACCURACY_THRESHOLD = 100f;
private static final float LOCATION_ACCURACY_THRESHOLD = 50f;

/**
* To measure the distance when the bus stop tapped.
Expand Down Expand Up @@ -227,8 +227,6 @@ private static String getObaRegionName() {
} catch (Exception e) {
regionName = Application.get().getString(R.string.analytics_label_custom_url);
}
} else {
regionName = Application.get().getString(R.string.analytics_label_custom_url);
}
return regionName;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import org.onebusaway.android.R;
import org.onebusaway.android.app.Application;
import org.onebusaway.android.io.ObaAnalytics;
import org.onebusaway.android.io.elements.ObaRegion;
import org.onebusaway.android.util.LocationHelper;
import org.onebusaway.android.util.OrientationHelper;
Expand Down Expand Up @@ -278,6 +279,11 @@ public void onClick(View v) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(stopInfoBuilder.build());
mContext.startActivity(i);
//Analytics
if (obaRegion != null && obaRegion.getName() != null)
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
mContext.getString(R.string.analytics_action_button_press),
mContext.getString(R.string.analytics_label_button_press_stopinfo) + obaRegion.getName());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,26 +602,10 @@ public void onFocusChanged(ObaStop stop, HashMap<String, ObaRoute> routes) {
// A stop on the map was just tapped, show it in the sliding panel
updateArrivalListFragment(stop.getId(), stop, routes);

ObaRegion region = Application.get().getCurrentRegion();
if (region != null && region.getName() != null) {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_stopinfo) + region.getName());
} else {
String customUrl = null;
MessageDigest digest = null;
try {
digest = MessageDigest.getInstance("SHA-1");
digest.update(Application.get().getCustomApiUrl().getBytes());
customUrl = Application.get().getString(R.string.analytics_label_custom_url) +
": " + Application.getHex(digest.digest());
} catch (Exception e) {
customUrl = Application.get().getString(R.string.analytics_label_custom_url);
}
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_stopinfo) + customUrl);
}
//Analytics
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_map_icon));
} else {
// A particular stop lost focus (e.g., user tapped on the map), so hide the panel
// and clear the currently focused stopId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,16 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
task.execute();

// Wait to change the region preference description until the task callback

//Analytics
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_experimental) + experimentalServers);
if (experimentalServers) {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_experimental_on));
} else {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_experimental_off));
}
} else if (key.equals(getString(R.string.preference_key_oba_api_url))) {
// Change the region preference description to show we're not using a region
changePreferenceSummary(key);
Expand All @@ -229,10 +234,15 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin
//Analytics
boolean autoSelect = settings
.getBoolean(getString(R.string.preference_key_auto_select_region), false);

ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_auto) + autoSelect);
if (autoSelect) {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_auto));
} else {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
getString(R.string.analytics_action_button_press),
getString(R.string.analytics_label_button_press_manual));
}
} else if (key.equalsIgnoreCase(getString(R.string.preferences_key_analytics))) {
Boolean isAnalyticsActive = settings.getBoolean(Application.get().
getString(R.string.preferences_key_analytics), Boolean.FALSE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.onebusaway.android.ui;

import org.onebusaway.android.R;
import org.onebusaway.android.io.ObaAnalytics;
import org.onebusaway.android.io.elements.ObaStop;
import org.onebusaway.android.io.request.ObaReportProblemWithStopRequest;
import org.onebusaway.android.util.LocationUtil;
Expand Down Expand Up @@ -114,6 +115,8 @@ protected void sendReport() {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mUserComment.getWindowToken(), 0);
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.SUBMIT.toString(),
getString(R.string.analytics_action_problem), getString(R.string.analytics_label_report_stop_problem));
super.sendReport();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package org.onebusaway.android.ui;

import org.onebusaway.android.R;
import org.onebusaway.android.io.ObaAnalytics;
import org.onebusaway.android.io.elements.ObaArrivalInfo;
import org.onebusaway.android.io.request.ObaReportProblemWithTripRequest;
import org.onebusaway.android.util.LocationUtil;
Expand Down Expand Up @@ -160,6 +161,8 @@ protected void sendReport() {
InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(
Context.INPUT_METHOD_SERVICE);
imm.hideSoftInputFromWindow(mUserComment.getWindowToken(), 0);
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.SUBMIT.toString(),
getString(R.string.analytics_action_problem), getString(R.string.analytics_label_report_trip_problem));
super.sendReport();
}

Expand Down
11 changes: 8 additions & 3 deletions onebusaway-android/src/main/res/values/do_not_translate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,24 @@
<string name="analytics_label_button_press_settings">Clicked Settings Link</string>
<string name="analytics_label_button_press_donate">Clicked Donate Link</string>
<string name="analytics_label_button_press_help">Clicked Help Link</string>
<string name="analytics_label_button_press_feedback">Clicked Send Feedback Link</string>
<string name="analytics_label_button_press_feedback">Clicked Email Link</string>
<string name="analytics_label_button_press_stopinfo">Loaded StopInfo from\u0020</string>
<string name="analytics_label_button_press_map_icon">Clicked MapStopIcon</string>
<string name="analytics_label_button_press_search_box">Search box selected</string>
<string name="analytics_label_button_press_search_button">Search button clicked</string>
<string name="analytics_label_button_press_location">Clicked My Location Button</string>
<string name="analytics_label_button_press_experimental">ExperimentalRegionCell:\u0020</string>
<string name="analytics_label_button_press_experimental_on">Turned on Experimental Regions</string>
<string name="analytics_label_button_press_experimental_off">Turned off Experimental Regions</string>
<string name="analytics_label_experimental">Show Experimental Regions:\u0020</string>
<string name="analytics_label_button_press_auto">Set region automatically:\u0020</string>
<string name="analytics_label_button_press_auto">Set region automatically</string>
<string name="analytics_label_button_press_manual">Set region manually</string>
<string name="analytics_label_edit_field">Edited Bookmark</string>
<string name="analytics_label_edit_field_bookmark_delete">Edited Bookmark Group Deleted</string>
<string name="analytics_label_set_region">Set Region:\u0020</string>
<string name="analytics_label_app_switch">Loaded Twitter via Web</string>
<string name="analytics_label_report_problem">Reported Problem</string>
<string name="analytics_label_report_stop_problem">Reported Stop Problem</string>
<string name="analytics_label_report_trip_problem">Reported Trip Problem</string>
<string name="analytics_label_talkback">Loaded view:\u0020</string>
<string name="analytics_label_custom_url">Custom URL</string>
<string name="analytics_label_analytic_preference">Set Send anonymous usage data:\u0020</string>
Expand Down