Bug 996753 - Telemetry probes for settings pages. r=liuche

This commit is contained in:
Margaret Leibovic 2014-08-25 15:28:10 -07:00
parent daaa053e20
commit 42184a6334
3 changed files with 31 additions and 1 deletions

View File

@ -158,6 +158,9 @@ public interface TelemetryContract {
// Note: Only used in JavaScript for now, but here for completeness.
PAGEACTION("pageaction"),
// Action triggered from a settings screen.
SETTINGS("settings"),
// Action triggered from a suggestion provided to the user.
SUGGESTION("suggestion"),
@ -209,6 +212,9 @@ public interface TelemetryContract {
// Started when the search activity launches.
SEARCH_ACTIVITY("searchactivity.1"),
// Settings activity is active.
SETTINGS("settings.1"),
// VALUES BELOW THIS LINE ARE EXCLUSIVE TO TESTING.
_TEST_STARTED_TWICE("_test_session_started_twice.1"),
_TEST_STOPPED_TWICE("_test_session_stopped_twice.1"),

View File

@ -13,6 +13,9 @@ import org.mozilla.gecko.GeckoSharedPrefs;
import org.mozilla.gecko.LocaleManager;
import org.mozilla.gecko.PrefsHelper;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.TelemetryContract.Method;
import android.app.ActionBar;
import android.app.Activity;
@ -59,6 +62,12 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
getPreferenceManager().setSharedPreferencesName(GeckoSharedPrefs.APP_PREFS_NAME);
int res = getResource();
if (res == R.xml.preferences) {
Telemetry.startUISession(TelemetryContract.Session.SETTINGS);
} else {
final String resourceName = getArguments().getString("resource");
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, Method.SETTINGS, resourceName);
}
// Display a menu for Search preferences.
if (res == R.xml.preferences_search) {
@ -195,5 +204,10 @@ public class GeckoPreferenceFragment extends PreferenceFragment {
if (mPrefsRequestId > 0) {
PrefsHelper.removeObserver(mPrefsRequestId);
}
final int res = getResource();
if (res == R.xml.preferences) {
Telemetry.stopUISession(TelemetryContract.Session.SETTINGS);
}
}
}

View File

@ -338,7 +338,9 @@ OnSharedPreferenceChangeListener
int res = 0;
if (intentExtras != null && intentExtras.containsKey(INTENT_EXTRA_RESOURCES)) {
// Fetch resource id from intent.
String resourceName = intentExtras.getString(INTENT_EXTRA_RESOURCES);
final String resourceName = intentExtras.getString(INTENT_EXTRA_RESOURCES);
Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, Method.SETTINGS, resourceName);
if (resourceName != null) {
res = getResources().getIdentifier(resourceName, "xml", getPackageName());
if (res == 0) {
@ -350,6 +352,7 @@ OnSharedPreferenceChangeListener
// No resource specified, or the resource was invalid; use the default preferences screen.
Log.e(LOGTAG, "Displaying default settings.");
res = R.xml.preferences;
Telemetry.startUISession(TelemetryContract.Session.SETTINGS);
}
// We don't include a title in the XML, so set it here, in a locale-aware fashion.
@ -476,6 +479,13 @@ OnSharedPreferenceChangeListener
if (mPrefsRequestId > 0) {
PrefsHelper.removeObserver(mPrefsRequestId);
}
// The intent extras will be null if this is the top-level settings
// activity. In that case, we want to end the SETTINGS telmetry session.
// For HC+ versions of Android this is handled in GeckoPreferenceFragment.
if (Versions.preHC && getIntent().getExtras() == null) {
Telemetry.stopUISession(TelemetryContract.Session.SETTINGS);
}
}
@Override