diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:35:29 +0000 |
commit | 59203c63bb777a3bacec32fb8830fba33540e809 (patch) | |
tree | 58298e711c0ff0575818c30485b44a2f21bf28a0 /browser/components/newtab/lib/TelemetryFeed.sys.mjs | |
parent | Adding upstream version 126.0.1. (diff) | |
download | firefox-59203c63bb777a3bacec32fb8830fba33540e809.tar.xz firefox-59203c63bb777a3bacec32fb8830fba33540e809.zip |
Adding upstream version 127.0.upstream/127.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/newtab/lib/TelemetryFeed.sys.mjs')
-rw-r--r-- | browser/components/newtab/lib/TelemetryFeed.sys.mjs | 79 |
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? |