Skip to content

Commit

Permalink
Merge pull request #241 from cagryInside/master
Browse files Browse the repository at this point in the history
Fix #237 - If custom url reporting disabled when it is null.
  • Loading branch information
barbeau committed Mar 5, 2015
2 parents 2bd3efe + dbe704c commit fb8df7e
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 42 deletions.
Original file line number Diff line number Diff line change
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 @@ -254,7 +254,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 @@ -270,13 +270,6 @@ private void reportAnalytics() {
+ 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 @@ -216,9 +216,15 @@ public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, Strin

// 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,9 +235,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 @@ -26,14 +26,11 @@
import com.google.android.maps.MapView;
import com.google.android.maps.OverlayItem;
import com.joulespersecond.oba.ObaAnalytics;
import com.joulespersecond.oba.elements.ObaRegion;
import com.joulespersecond.oba.elements.ObaStop;
import com.joulespersecond.seattlebusbot.Application;
import com.joulespersecond.seattlebusbot.ArrivalsListActivity;
import com.joulespersecond.seattlebusbot.R;
import com.joulespersecond.seattlebusbot.util.LocationHelp;

import java.security.MessageDigest;
import java.util.List;

public class StopOverlay extends ItemizedOverlay<OverlayItem> {
Expand Down Expand Up @@ -214,28 +211,11 @@ protected boolean onTap(int index) {

//Track analytics
Location myLocation = LocationHelp.getLocation2(mActivity, null);
ObaRegion region = Application.get().getCurrentRegion();
ObaStop stop = mStops.get(index);
Location stopLocation = stop.getLocation();
if (region != null && region.getName() != null) {
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
mActivity.getString(R.string.analytics_action_button_press),
mActivity.getString(R.string.analytics_label_button_press_map_icon) + 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(),
mActivity.getString(R.string.analytics_action_button_press),
mActivity.getString(R.string.analytics_label_button_press_map_icon) + customUrl);
}
ObaAnalytics.reportEventWithCategory(ObaAnalytics.ObaEventCategory.UI_ACTION.toString(),
mActivity.getString(R.string.analytics_action_button_press),
mActivity.getString(R.string.analytics_label_button_press_map_icon));
ObaAnalytics.trackBusStopDistance(stop.getId(), myLocation, stopLocation);
}
return true;
Expand Down
8 changes: 5 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 @@ -55,13 +55,15 @@
<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_map_icon">Clicked MapStopIcon 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 fb8df7e

Please sign in to comment.