Skip to content

Commit

Permalink
Fix #234 report stop info - Fix # 237 custom url reporting disabled f…
Browse files Browse the repository at this point in the history
…or develop branch
  • Loading branch information
cagryInside committed Mar 5, 2015
1 parent c4ab35e commit 1cb77f8
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 43 deletions.
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
7 changes: 5 additions & 2 deletions onebusaway-android/src/main/res/values/do_not_translate.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,15 @@
<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_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>
Expand Down

0 comments on commit 1cb77f8

Please sign in to comment.