Bug 1243387 - Add telemetry probe to understand how often users load reading list items when offline. r=mfinkle

This commit is contained in:
Margaret Leibovic 2016-02-05 09:37:15 -05:00
parent 653e06ab02
commit e9ba3ecf54
5 changed files with 44 additions and 1 deletions

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko.home;
import java.util.EnumSet;
import android.util.Log;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
@ -21,6 +22,7 @@ import android.view.View;
import android.widget.AdapterView;
import android.widget.HeaderViewListAdapter;
import android.widget.ListAdapter;
import org.mozilla.gecko.util.NetworkUtils;
/**
* A ListView of bookmarks.
@ -93,6 +95,7 @@ public class BookmarksListView extends HomeListView
final String url = cursor.getString(cursor.getColumnIndexOrThrow(Bookmarks.URL));
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM, "bookmarks");
Telemetry.addToHistogram("FENNEC_LOAD_SAVED_PAGE", NetworkUtils.isConnected(getContext()) ? 2 : 3);
// This item is a TwoLinePageRow, so we allow switch-to-tab.
getOnUrlOpenListener().onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB));

View File

@ -7,6 +7,7 @@ package org.mozilla.gecko.home;
import java.util.EnumSet;
import android.util.Log;
import org.mozilla.gecko.GeckoProfile;
import org.mozilla.gecko.R;
import org.mozilla.gecko.ReaderModeUtils;
@ -34,6 +35,7 @@ import android.view.ViewStub;
import android.widget.AdapterView;
import android.widget.ImageView;
import android.widget.TextView;
import org.mozilla.gecko.util.NetworkUtils;
/**
* Fragment that displays reading list contents in a ListView.
@ -92,6 +94,7 @@ public class ReadingListPanel extends HomeFragment {
url = ReaderModeUtils.getAboutReaderForUrl(url);
Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.LIST_ITEM, "reading_list");
Telemetry.addToHistogram("FENNEC_LOAD_SAVED_PAGE", NetworkUtils.isConnected(context) ? 0 : 1);
// This item is a TwoLinePageRow, so we allow switch-to-tab.
mUrlOpenListener.onUrlOpen(url, EnumSet.of(OnUrlOpenListener.Flags.ALLOW_SWITCH_TO_TAB));

View File

@ -0,0 +1,28 @@
/* -*- Mode: Java; c-basic-offset: 4; tab-width: 20; indent-tabs-mode: nil; -*-
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.gecko.util;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
public class NetworkUtils {
/**
* Indicates whether network connectivity exists and it is possible to establish connections and pass data.
*/
public static boolean isConnected(Context context) {
final ConnectivityManager connectivity = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
if (connectivity == null) {
return false;
}
final NetworkInfo networkInfo = connectivity.getActiveNetworkInfo();
if (networkInfo == null) {
return false;
}
return networkInfo.isConnected();
}
}

View File

@ -116,6 +116,7 @@ gujar.sources += ['java/org/mozilla/gecko/' + x for x in [
'util/NativeEventListener.java',
'util/NativeJSContainer.java',
'util/NativeJSObject.java',
'util/NetworkUtils.java',
'util/NonEvictingLruCache.java',
'util/PrefUtils.java',
'util/ProxySelector.java',

View File

@ -9018,11 +9018,19 @@
},
"FENNEC_READER_VIEW_BUTTON" : {
"expires_in_version": "50",
"alert_emails": ["mleibovic@mozilla.com"],
"alert_emails": ["mobile-frontend@mozilla.com"],
"kind": "enumerated",
"n_values": 10,
"description": "Bug 1219240: Measures user interaction with the reader view button (0=Button hidden, 1=Button shown, 2=Tap to enter reader view, 3=Tap to exit reader view, 4=Long tap)"
},
"FENNEC_LOAD_SAVED_PAGE": {
"expires_in_version": "50",
"alert_emails": ["mobile-frontend@mozilla.com"],
"kind": "enumerated",
"n_values": 10,
"description": "How often users load saved items when online/offline (0=RL online, 1=RL offline, 2=BM online, 3=BM offline)",
"bug_numbers": [1243387]
},
"PERMISSIONS_SQL_CORRUPTED": {
"expires_in_version": "never",
"kind": "count",