Bug 1241810 -
Bug 1251317 - Add telemetry for content notifications. r=mcomella,mfinkle
MozReview-Commit-ID: Hlh1sW0kHFg
--- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
+++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java
@@ -21,16 +21,17 @@ import org.mozilla.gecko.db.BrowserContr
import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.db.SuggestedSites;
import org.mozilla.gecko.distribution.Distribution;
import org.mozilla.gecko.dlc.DownloadContentService;
import org.mozilla.gecko.favicons.Favicons;
import org.mozilla.gecko.favicons.OnFaviconLoadedListener;
import org.mozilla.gecko.favicons.decoders.IconDirectoryEntry;
import org.mozilla.gecko.feeds.FeedService;
+import org.mozilla.gecko.feeds.action.CheckAction;
import org.mozilla.gecko.firstrun.FirstrunAnimationContainer;
import org.mozilla.gecko.gfx.DynamicToolbarAnimator;
import org.mozilla.gecko.gfx.DynamicToolbarAnimator.PinReason;
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.home.BrowserSearch;
import org.mozilla.gecko.home.HomeBanner;
import org.mozilla.gecko.home.HomeConfig;
@@ -3735,16 +3736,21 @@ public class BrowserApp extends GeckoApp
}
// Custom intent action for opening multiple URLs at once
if (isViewMultipleAction) {
List<String> urls = intent.getStringArrayListExtra("urls");
if (urls != null) {
openUrls(urls);
}
+
+ // Launched from a "content notification"
+ if (intent.hasExtra(CheckAction.EXTRA_CONTENT_NOTIFICATION)) {
+ Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.NOTIFICATION, "content_update");
+ }
}
if (!mInitialized || !Intent.ACTION_MAIN.equals(action)) {
return;
}
// Check to see how many times the app has been launched.
final String keyName = getPackageName() + ".feedback_launch_count";
--- a/mobile/android/base/java/org/mozilla/gecko/TelemetryContract.java
+++ b/mobile/android/base/java/org/mozilla/gecko/TelemetryContract.java
@@ -177,16 +177,19 @@ public interface TelemetryContract {
// Action triggered from a pageaction in the URLBar.
// Note: Only used in JavaScript for now, but here for completeness.
PAGEACTION("pageaction"),
// Action triggered from one of a series of views, such as ViewPager.
PANEL("panel"),
+ // Action triggered by a background service / automatic system making a decision.
+ SERVICE("service"),
+
// Action triggered from a settings screen.
SETTINGS("settings"),
// Actions triggered from the share overlay.
SHARE_OVERLAY("shareoverlay"),
// Action triggered from a suggestion provided to the user.
SUGGESTION("suggestion"),
--- a/mobile/android/base/java/org/mozilla/gecko/feeds/action/CheckAction.java
+++ b/mobile/android/base/java/org/mozilla/gecko/feeds/action/CheckAction.java
@@ -19,16 +19,18 @@ import android.support.v4.content.Contex
import android.text.format.DateFormat;
import android.util.Log;
import org.json.JSONException;
import org.mozilla.gecko.AppConstants;
import org.mozilla.gecko.BrowserApp;
import org.mozilla.gecko.GeckoApp;
import org.mozilla.gecko.R;
+import org.mozilla.gecko.Telemetry;
+import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.db.UrlAnnotations;
import org.mozilla.gecko.feeds.FeedFetcher;
import org.mozilla.gecko.feeds.parser.Feed;
import org.mozilla.gecko.feeds.subscriptions.FeedSubscription;
import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.util.StringUtils;
@@ -103,22 +105,27 @@ public class CheckAction implements Base
}
return null;
}
private void notify(List<Feed> updatedFeeds) {
final int feedCount = updatedFeeds.size();
+ if (feedCount == 0) {
+ return;
+ }
if (feedCount == 1) {
notifySingle(updatedFeeds.get(0));
- } else if (feedCount > 1) {
+ } else {
notifyMultiple(updatedFeeds);
}
+
+ Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.NOTIFICATION, "content_update");
}
private void notifySingle(Feed feed) {
final String date = DateFormat.getMediumDateFormat(context).format(new Date(feed.getLastItem().getTimestamp()));
NotificationCompat.BigTextStyle style = new NotificationCompat.BigTextStyle()
.bigText(feed.getLastItem().getTitle())
.setBigContentTitle(feed.getTitle())
--- a/mobile/android/base/java/org/mozilla/gecko/feeds/action/SubscribeAction.java
+++ b/mobile/android/base/java/org/mozilla/gecko/feeds/action/SubscribeAction.java
@@ -5,16 +5,18 @@
package org.mozilla.gecko.feeds.action;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
+import org.mozilla.gecko.Telemetry;
+import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.db.BrowserDB;
import org.mozilla.gecko.db.UrlAnnotations;
import org.mozilla.gecko.feeds.FeedFetcher;
import org.mozilla.gecko.feeds.subscriptions.FeedSubscription;
/**
* SubscribeAction: Try to fetch a feed and create a subscription if successful.
*/
@@ -64,10 +66,12 @@ public class SubscribeAction implements
}
Log.d(LOGTAG, "Subscribing to feed: " + response.feed.getTitle());
Log.d(LOGTAG, " Last item: " + response.feed.getLastItem().getTitle());
final FeedSubscription subscription = FeedSubscription.create(feedUrl, response);
urlAnnotations.insertFeedSubscription(context.getContentResolver(), subscription);
+
+ Telemetry.sendUIEvent(TelemetryContract.Event.SAVE, TelemetryContract.Method.SERVICE, "content_update");
}
}
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -27,16 +27,17 @@ import org.mozilla.gecko.R;
import org.mozilla.gecko.Restrictions;
import org.mozilla.gecko.SnackbarHelper;
import org.mozilla.gecko.Telemetry;
import org.mozilla.gecko.TelemetryContract;
import org.mozilla.gecko.TelemetryContract.Method;
import org.mozilla.gecko.background.common.GlobalConstants;
import org.mozilla.gecko.db.BrowserContract.SuggestedSites;
import org.mozilla.gecko.feeds.FeedService;
+import org.mozilla.gecko.feeds.action.CheckAction;
import org.mozilla.gecko.permissions.Permissions;
import org.mozilla.gecko.restrictions.Restrictable;
import org.mozilla.gecko.tabqueue.TabQueueHelper;
import org.mozilla.gecko.tabqueue.TabQueuePrompt;
import org.mozilla.gecko.updater.UpdateService;
import org.mozilla.gecko.updater.UpdateServiceHelper;
import org.mozilla.gecko.util.EventCallback;
import org.mozilla.gecko.util.Experiments;
@@ -380,16 +381,21 @@ OnSharedPreferenceChangeListener
// capture EXTRA_SHOW_FRAGMENT_TITLE from the intent and store the title ID.
// If launched from notification, explicitly cancel the notification.
if (intentExtras != null && intentExtras.containsKey(DataReportingNotification.ALERT_NAME_DATAREPORTING_NOTIFICATION)) {
Telemetry.sendUIEvent(TelemetryContract.Event.LAUNCH, Method.NOTIFICATION, "settings-data-choices");
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancel(DataReportingNotification.ALERT_NAME_DATAREPORTING_NOTIFICATION.hashCode());
}
+
+ // Launched from "Notifications settings" action button in a notification.
+ if (intentExtras != null && intentExtras.containsKey(CheckAction.EXTRA_CONTENT_NOTIFICATION)) {
+ Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, Method.BUTTON, "notification-settings");
+ }
}
/**
* Initializes the action bar configuration in code.
*
* Declaring these attributes in XML does not work on some devices for an unknown reason
* (e.g. the back button stops working or the logo disappears; see bug 1152314) so we
* duplicate those attributes in code here. Note: the order of these calls matters.
--- a/mobile/android/docs/uitelemetry.rst
+++ b/mobile/android/docs/uitelemetry.rst
@@ -219,16 +219,19 @@ Methods
Action triggered from the main menu.
``notification``
Action triggered from a system notification.
``pageaction``
Action triggered from a pageaction, displayed in the URL bar.
+``service``
+ Action triggered from an automatic system making a decision.
+
``settings``
Action triggered from a content page.
``shareoverlay``
Action triggered from a content page.
``suggestion``
Action triggered from a suggested result, like those from search engines or default tiles.