зеркало из https://github.com/mozilla/gecko-dev.git
Bug 917480 - Part 5: UI telemetry for locale switching. r=mfinkle
This commit is contained in:
Родитель
dab6073463
Коммит
0d3c0b2d9c
|
@ -7,31 +7,37 @@ package org.mozilla.gecko;
|
|||
|
||||
/**
|
||||
* Holds data definitions for our UI Telemetry implementation.
|
||||
*
|
||||
* See mobile/android/base/docs/index.rst for a full dictionary.
|
||||
*/
|
||||
public interface TelemetryContract {
|
||||
|
||||
/**
|
||||
* Holds event names. Intended for use with
|
||||
* Telemetry.sendUIEvent() as the "action" parameter.
|
||||
*
|
||||
* Please keep this list sorted.
|
||||
*/
|
||||
public interface Event {
|
||||
// Outcome of data policy notification: can be true or false.
|
||||
public static final String POLICY_NOTIFICATION_SUCCESS = "policynotification.success.1:";
|
||||
// Generic action, usually for tracking menu and toolbar actions.
|
||||
public static final String ACTION = "action.1";
|
||||
|
||||
// Top site pinned.
|
||||
public static final String TOP_SITES_PIN = "pin.1";
|
||||
// Launching (opening) an external application.
|
||||
// Note: Only used in JavaScript for now, but here for completeness.
|
||||
public static final String LAUNCH = "launch.1";
|
||||
|
||||
// Top site un-pinned.
|
||||
public static final String TOP_SITES_UNPIN = "unpin.1";
|
||||
// Loading a URL.
|
||||
public static final String LOAD_URL = "loadurl.1";
|
||||
|
||||
// Top site edited.
|
||||
public static final String TOP_SITES_EDIT = "edit.1";
|
||||
public static final String LOCALE_BROWSER_RESET = "locale.browser.reset.1";
|
||||
public static final String LOCALE_BROWSER_SELECTED = "locale.browser.selected.1";
|
||||
public static final String LOCALE_BROWSER_UNSELECTED = "locale.browser.unselected.1";
|
||||
|
||||
// Set default panel.
|
||||
public static final String PANEL_SET_DEFAULT = "setdefault.1";
|
||||
|
||||
// Sharing content.
|
||||
public static final String SHARE = "share.1";
|
||||
// Outcome of data policy notification: can be true or false.
|
||||
public static final String POLICY_NOTIFICATION_SUCCESS = "policynotification.success.1:";
|
||||
|
||||
// Sanitizing private data.
|
||||
public static final String SANITIZE = "sanitize.1";
|
||||
|
@ -40,19 +46,21 @@ public interface TelemetryContract {
|
|||
// Note: Only used in JavaScript for now, but here for completeness.
|
||||
public static final String SAVE = "save.1";
|
||||
|
||||
// Sharing content.
|
||||
public static final String SHARE = "share.1";
|
||||
|
||||
// Top site edited.
|
||||
public static final String TOP_SITES_EDIT = "edit.1";
|
||||
|
||||
// Top site pinned.
|
||||
public static final String TOP_SITES_PIN = "pin.1";
|
||||
|
||||
// Top site un-pinned.
|
||||
public static final String TOP_SITES_UNPIN = "unpin.1";
|
||||
|
||||
// Stop holding a resource (reader, bookmark, etc) for viewing later.
|
||||
// Note: Only used in JavaScript for now, but here for completeness.
|
||||
public static final String UNSAVE = "unsave.1";
|
||||
|
||||
// Loading a URL.
|
||||
public static final String LOAD_URL = "loadurl.1";
|
||||
|
||||
// Generic action, usually for tracking menu and toolbar actions.
|
||||
public static final String ACTION = "action.1";
|
||||
|
||||
// Launching (opening) an external application
|
||||
// Note: Only used in JavaScript for now, but here for completeness.
|
||||
public static final String LAUNCH = "launch.1";
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -14,7 +14,7 @@ Some links:
|
|||
- `User research notes <https://wiki.mozilla.org/Mobile/User_Experience/Research>`_
|
||||
|
||||
Sessions
|
||||
--------
|
||||
========
|
||||
|
||||
**Sessions** are essentially scopes. They are meant to provide context to
|
||||
events; this allows events to be simpler and more reusable. Sessions are
|
||||
|
@ -56,7 +56,7 @@ To stop a session, call ``Telemetry.stopUISession(String sessionName, String rea
|
|||
The user left for an entirely different element.
|
||||
|
||||
Events
|
||||
------
|
||||
======
|
||||
|
||||
Events capture key occurrences. They should be brief and simple, and should not contain sensitive or excess information. Context for events should come from the session (scope). An event can be created with four fields (via ``Telemetry.sendUIEvent``): ``action``, ``method``, ``extras``, and ``timestamp``.
|
||||
|
||||
|
@ -73,14 +73,48 @@ Events capture key occurrences. They should be brief and simple, and should not
|
|||
The time at which the event occurred. If not specified, this field defaults to the current value of the realtime clock.
|
||||
|
||||
Versioning
|
||||
----------
|
||||
========
|
||||
|
||||
As a we improve on our Telemetry methods, it is foreseeable that our probes will change over time. Different versions of a probe could carry different data or have different interpretations on the server-side. To make it easier for the server to handle these changes, you should add version numbers to your event and session names. An example of a versioned session is ``homepanel.1``; this is version 1 of the ``homepanel`` session. This approach should also be applied to event names, an example being: ``panel.enable.1`` and ``panel.enable.2``.
|
||||
|
||||
|
||||
Clock
|
||||
-----
|
||||
=====
|
||||
|
||||
Times are relative to either elapsed realtime (an arbitrary monotonically increasing clock that continues to tick when the device is asleep), or elapsed uptime (which doesn't tick when the device is in deep sleep). We default to elapsed realtime.
|
||||
|
||||
See the documentation in `the source <http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/Telemetry.java>`_ for more details.
|
||||
|
||||
Dictionary
|
||||
==========
|
||||
|
||||
Events
|
||||
------
|
||||
|
||||
``policynotification.success.1:true``
|
||||
Sent when a user has accepted the data notification policy. Can be ``false``
|
||||
instead of ``true`` if an error occurs.
|
||||
|
||||
``pin.1``, ``unpin.1``
|
||||
Sent when the user pinned or unpinned a top site.
|
||||
|
||||
``edit.1``
|
||||
Sent when the user edits a top site.
|
||||
|
||||
``locale.browser.reset.1``
|
||||
When the user chooses "System default" in the browser locale picker.
|
||||
|
||||
``locale.browser.selected.1``
|
||||
When the user chooses a locale in the browser locale picker. The selected
|
||||
locale is provided as the extra.
|
||||
|
||||
``locale.browser.unselected.1``
|
||||
When the user chose a different locale in the browser locale picker, this
|
||||
event is fired with the previous locale as the extra. If the previous locale
|
||||
could not be determined, "unknown" is provided.
|
||||
|
||||
``sanitize.1``
|
||||
Sent when the user chooses to clear private data.
|
||||
|
||||
``setdefault.1``
|
||||
Sent when the user makes a choice of default home panel.
|
||||
|
|
|
@ -24,6 +24,8 @@ 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.background.announcements.AnnouncementsConstants;
|
||||
import org.mozilla.gecko.background.common.GlobalConstants;
|
||||
import org.mozilla.gecko.background.healthreport.HealthReportConstants;
|
||||
|
@ -716,7 +718,7 @@ public class GeckoPreferences
|
|||
* We handle the case of the user returning to the browser via the
|
||||
* onActivityResult mechanism: see {@link BrowserApp#onActivityResult(int, int, Intent)}.
|
||||
*/
|
||||
private boolean onLocaleSelected(final String newValue) {
|
||||
private boolean onLocaleSelected(final String currentLocale, final String newValue) {
|
||||
final Context context = getApplicationContext();
|
||||
|
||||
// LocaleManager operations need to occur on the background thread.
|
||||
|
@ -729,10 +731,14 @@ public class GeckoPreferences
|
|||
|
||||
if (newValue.equals("")) {
|
||||
BrowserLocaleManager.getInstance().resetToSystemLocale(context);
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOCALE_BROWSER_RESET);
|
||||
} else {
|
||||
if (null == localeManager.setSelectedLocale(context, newValue)) {
|
||||
localeManager.updateConfiguration(context, Locale.getDefault());
|
||||
}
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOCALE_BROWSER_UNSELECTED, null,
|
||||
currentLocale == null ? "unknown" : currentLocale);
|
||||
Telemetry.sendUIEvent(TelemetryContract.Event.LOCALE_BROWSER_SELECTED, null, newValue);
|
||||
}
|
||||
|
||||
ThreadUtils.postToUiThread(new Runnable() {
|
||||
|
@ -761,7 +767,7 @@ public class GeckoPreferences
|
|||
if (PREFS_BROWSER_LOCALE.equals(prefName)) {
|
||||
// Even though this is a list preference, we don't want to handle it
|
||||
// below, so we return here.
|
||||
return onLocaleSelected((String) newValue);
|
||||
return onLocaleSelected(BrowserLocaleManager.getLanguageTag(lastLocale), (String) newValue);
|
||||
}
|
||||
|
||||
if (PREFS_MENU_CHAR_ENCODING.equals(prefName)) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче