From 4690264be5fc3f649eb970e287ac0d31ec1d6e70 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Mon, 11 Apr 2016 11:25:39 +0200 Subject: [PATCH] Bug 1261830 - Content notifications: Stamp telemetry events with experiment session. r=margaret MozReview-Commit-ID: 8Nsdfbe6x74 --HG-- extra : rebase_source : d59f567531b3abc873a2ef519785a1970bb2a19d --- .../base/java/org/mozilla/gecko/BrowserApp.java | 4 ++++ .../java/org/mozilla/gecko/feeds/FeedService.java | 14 ++++++++++++++ .../gecko/feeds/action/CheckForUpdatesAction.java | 3 +++ .../gecko/feeds/action/SubscribeToFeedAction.java | 3 +++ .../feeds/action/WithdrawSubscriptionsAction.java | 3 +++ .../gecko/preferences/GeckoPreferences.java | 2 ++ 6 files changed, 29 insertions(+) diff --git a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java index 70d829d8e8c8..391103e2a0f5 100644 --- a/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java +++ b/mobile/android/base/java/org/mozilla/gecko/BrowserApp.java @@ -3720,8 +3720,12 @@ public class BrowserApp extends GeckoApp // Launched from a "content notification" if (intent.hasExtra(CheckForUpdatesAction.EXTRA_CONTENT_NOTIFICATION)) { + Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(this)); + Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, TelemetryContract.Method.NOTIFICATION, "content_update"); Telemetry.sendUIEvent(TelemetryContract.Event.LOAD_URL, TelemetryContract.Method.INTENT, "content_update"); + + Telemetry.stopUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(this)); } } diff --git a/mobile/android/base/java/org/mozilla/gecko/feeds/FeedService.java b/mobile/android/base/java/org/mozilla/gecko/feeds/FeedService.java index 53454e3f8333..6f3c1273de33 100644 --- a/mobile/android/base/java/org/mozilla/gecko/feeds/FeedService.java +++ b/mobile/android/base/java/org/mozilla/gecko/feeds/FeedService.java @@ -148,6 +148,20 @@ public class FeedService extends IntentService { SwitchBoard.isInExperiment(context, Experiments.CONTENT_NOTIFICATIONS_8AM); } + public static String getEnabledExperiment(Context context) { + String experiment = null; + + if (SwitchBoard.isInExperiment(context, Experiments.CONTENT_NOTIFICATIONS_12HRS)) { + experiment = Experiments.CONTENT_NOTIFICATIONS_12HRS; + } else if (SwitchBoard.isInExperiment(context, Experiments.CONTENT_NOTIFICATIONS_8AM)) { + experiment = Experiments.CONTENT_NOTIFICATIONS_8AM; + } else if (SwitchBoard.isInExperiment(context, Experiments.CONTENT_NOTIFICATIONS_5PM)) { + experiment = Experiments.CONTENT_NOTIFICATIONS_5PM; + } + + return experiment; + } + private boolean isPreferenceEnabled() { return GeckoSharedPrefs.forApp(this).getBoolean(GeckoPreferences.PREFS_NOTIFICATIONS_CONTENT, true); } diff --git a/mobile/android/base/java/org/mozilla/gecko/feeds/action/CheckForUpdatesAction.java b/mobile/android/base/java/org/mozilla/gecko/feeds/action/CheckForUpdatesAction.java index a90e3372cf36..68ef54542279 100644 --- a/mobile/android/base/java/org/mozilla/gecko/feeds/action/CheckForUpdatesAction.java +++ b/mobile/android/base/java/org/mozilla/gecko/feeds/action/CheckForUpdatesAction.java @@ -28,6 +28,7 @@ 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.FeedService; import org.mozilla.gecko.feeds.parser.Feed; import org.mozilla.gecko.feeds.subscriptions.FeedSubscription; import org.mozilla.gecko.preferences.GeckoPreferences; @@ -119,7 +120,9 @@ public class CheckForUpdatesAction extends FeedAction { showNotificationForMultipleUpdates(updatedFeeds); } + Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(context)); Telemetry.sendUIEvent(TelemetryContract.Event.SHOW, TelemetryContract.Method.NOTIFICATION, "content_update"); + Telemetry.stopUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(context)); } private void showNotificationForSingleUpdate(Feed feed) { diff --git a/mobile/android/base/java/org/mozilla/gecko/feeds/action/SubscribeToFeedAction.java b/mobile/android/base/java/org/mozilla/gecko/feeds/action/SubscribeToFeedAction.java index 335fb8d572d6..fbfce1af2fa4 100644 --- a/mobile/android/base/java/org/mozilla/gecko/feeds/action/SubscribeToFeedAction.java +++ b/mobile/android/base/java/org/mozilla/gecko/feeds/action/SubscribeToFeedAction.java @@ -14,6 +14,7 @@ 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.FeedService; import org.mozilla.gecko.feeds.subscriptions.FeedSubscription; /** @@ -71,6 +72,8 @@ public class SubscribeToFeedAction extends FeedAction { urlAnnotations.insertFeedSubscription(context.getContentResolver(), subscription); + Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(context)); Telemetry.sendUIEvent(TelemetryContract.Event.SAVE, TelemetryContract.Method.SERVICE, "content_update"); + Telemetry.stopUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(context)); } } diff --git a/mobile/android/base/java/org/mozilla/gecko/feeds/action/WithdrawSubscriptionsAction.java b/mobile/android/base/java/org/mozilla/gecko/feeds/action/WithdrawSubscriptionsAction.java index 3103e7a95092..6f955c185710 100644 --- a/mobile/android/base/java/org/mozilla/gecko/feeds/action/WithdrawSubscriptionsAction.java +++ b/mobile/android/base/java/org/mozilla/gecko/feeds/action/WithdrawSubscriptionsAction.java @@ -16,6 +16,7 @@ import org.mozilla.gecko.TelemetryContract; import org.mozilla.gecko.db.BrowserContract; import org.mozilla.gecko.db.BrowserDB; import org.mozilla.gecko.db.UrlAnnotations; +import org.mozilla.gecko.feeds.FeedService; import org.mozilla.gecko.feeds.subscriptions.FeedSubscription; /** @@ -84,7 +85,9 @@ public class WithdrawSubscriptionsAction extends FeedAction { urlAnnotations.deleteFeedSubscription(resolver, subscription); + Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(context)); Telemetry.sendUIEvent(TelemetryContract.Event.UNSAVE, TelemetryContract.Method.SERVICE, "content_update"); + Telemetry.stopUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(context)); } } } catch (JSONException e) { diff --git a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java index 8a123f9ed780..998e5616a32e 100644 --- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java +++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java @@ -387,7 +387,9 @@ OnSharedPreferenceChangeListener // Launched from "Notifications settings" action button in a notification. if (intentExtras != null && intentExtras.containsKey(CheckForUpdatesAction.EXTRA_CONTENT_NOTIFICATION)) { + Telemetry.startUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(this)); Telemetry.sendUIEvent(TelemetryContract.Event.ACTION, Method.BUTTON, "notification-settings"); + Telemetry.stopUISession(TelemetryContract.Session.EXPERIMENT, FeedService.getEnabledExperiment(this)); } }