summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/lib/TelemetryFeed.sys.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'browser/components/newtab/lib/TelemetryFeed.sys.mjs')
-rw-r--r--browser/components/newtab/lib/TelemetryFeed.sys.mjs79
1 files changed, 79 insertions, 0 deletions
diff --git a/browser/components/newtab/lib/TelemetryFeed.sys.mjs b/browser/components/newtab/lib/TelemetryFeed.sys.mjs
index 6cf4dba4ab..2643337674 100644
--- a/browser/components/newtab/lib/TelemetryFeed.sys.mjs
+++ b/browser/components/newtab/lib/TelemetryFeed.sys.mjs
@@ -114,6 +114,7 @@ const NEWTAB_PING_PREFS = {
"feeds.section.topstories": Glean.pocket.enabled,
showSponsored: Glean.pocket.sponsoredStoriesEnabled,
topSitesRows: Glean.topsites.rows,
+ showWeather: Glean.newtab.weatherEnabled,
};
const TOP_SITES_BLOCKED_SPONSORS_PREF = "browser.topsites.blockedSponsors";
@@ -932,9 +933,87 @@ export class TelemetryFeed {
case at.BLOCK_URL:
this.handleBlockUrl(action);
break;
+ case at.WALLPAPER_CLICK:
+ this.handleWallpaperUserEvent(action);
+ break;
+ case at.SET_PREF:
+ this.handleSetPref(action);
+ break;
+ case at.WEATHER_IMPRESSION:
+ this.handleWeatherUserEvent(action);
+ break;
+ case at.WEATHER_LOAD_ERROR:
+ this.handleWeatherUserEvent(action);
+ break;
+ case at.WEATHER_OPEN_PROVIDER_URL:
+ this.handleWeatherUserEvent(action);
+ break;
+ }
+ }
+
+ handleSetPref(action) {
+ const prefName = action.data.name;
+
+ // TODO: Migrate this event to handleWeatherUserEvent()
+ if (prefName === "weather.display") {
+ const session = this.sessions.get(au.getPortIdOfSender(action));
+
+ if (!session) {
+ return;
+ }
+
+ Glean.newtab.weatherChangeDisplay.record({
+ newtab_visit_id: session.session_id,
+ weather_display_mode: action.data.value,
+ });
+ }
+ }
+
+ handleWeatherUserEvent(action) {
+ const session = this.sessions.get(au.getPortIdOfSender(action));
+
+ if (!session) {
+ return;
+ }
+
+ // Weather specific telemtry events can be added and parsed here.
+ switch (action.type) {
+ case "WEATHER_IMPRESSION":
+ Glean.newtab.weatherImpression.record({
+ newtab_visit_id: session.session_id,
+ });
+ break;
+ case "WEATHER_LOAD_ERROR":
+ Glean.newtab.weatherLoadError.record({
+ newtab_visit_id: session.session_id,
+ });
+ break;
+ case "WEATHER_OPEN_PROVIDER_URL":
+ Glean.newtab.weatherOpenProviderUrl.record({
+ newtab_visit_id: session.session_id,
+ });
+ break;
+ default:
+ break;
}
}
+ handleWallpaperUserEvent(action) {
+ const session = this.sessions.get(au.getPortIdOfSender(action));
+
+ if (!session) {
+ return;
+ }
+ const { data } = action;
+ const { selected_wallpaper, hadPreviousWallpaper } = data;
+ // if either of the wallpaper prefs are truthy, they had a previous wallpaper
+ Glean.newtab.wallpaperClick.record({
+ newtab_visit_id: session.session_id,
+ selected_wallpaper,
+ hadPreviousWallpaper,
+ });
+ }
+
handleBlockUrl(action) {
const session = this.sessions.get(au.getPortIdOfSender(action));
// TODO: Do we want to not send this unless there's a newtab_visit_id?