commit 8b1c49542ae15990283f8d8ceebb32c5cb8bb7d5
parent 70159186c21a3c0cfed2087e17bd64713a3b6e23
Author: Reem H <42309026+reemhamz@users.noreply.github.com>
Date: Wed, 1 Oct 2025 22:43:24 +0000
Bug 1989875 - Add telemetry to weather opt-in. r=home-newtab-reviewers,npypchenko,maxx
Differential Revision: https://phabricator.services.mozilla.com/D266575
Diffstat:
5 files changed, 62 insertions(+), 4 deletions(-)
diff --git a/browser/components/newtab/metrics.yaml b/browser/components/newtab/metrics.yaml
@@ -534,6 +534,28 @@ newtab:
send_in_pings:
- newtab
+ weather_opt_in_selection:
+ type: event
+ description: >
+ Recorded when a user answers the location opt-in prompt
+ bugs:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1989875
+ data_reviews:
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1989875
+ data_sensitivity:
+ - interaction
+ notification_emails:
+ - rhamoui@mozilla.com
+ expires: never
+ extra_keys:
+ user_selection:
+ description: >
+ User's selection when interacting with weather opt-in.
+ type: string
+ newtab_visit_id: *newtab_visit_id
+ send_in_pings:
+ - newtab
+
fakespot_dismiss:
type: event
description: >
diff --git a/browser/extensions/newtab/common/Actions.mjs b/browser/extensions/newtab/common/Actions.mjs
@@ -220,6 +220,7 @@ for (const type of [
"WEATHER_LOCATION_SEARCH_UPDATE",
"WEATHER_LOCATION_SUGGESTIONS_UPDATE",
"WEATHER_OPEN_PROVIDER_URL",
+ "WEATHER_OPT_IN_PROMPT_SELECTION",
"WEATHER_QUERY_UPDATE",
"WEATHER_SEARCH_ACTIVE",
"WEATHER_UPDATE",
diff --git a/browser/extensions/newtab/content-src/components/Weather/Weather.jsx b/browser/extensions/newtab/content-src/components/Weather/Weather.jsx
@@ -212,19 +212,36 @@ export class _Weather extends React.PureComponent {
}
handleRejectOptIn = () => {
- this.props.dispatch(ac.SetPref("weather.optInAccepted", false));
- this.props.dispatch(ac.SetPref("weather.optInDisplayed", false));
+ batch(() => {
+ this.props.dispatch(ac.SetPref("weather.optInAccepted", false));
+ this.props.dispatch(ac.SetPref("weather.optInDisplayed", false));
+
+ this.props.dispatch(
+ ac.AlsoToMain({
+ type: at.WEATHER_OPT_IN_PROMPT_SELECTION,
+ data: "rejected opt-in",
+ })
+ );
+ });
};
handleAcceptOptIn = () => {
batch(() => {
this.props.dispatch(ac.SetPref("weather.optInAccepted", true));
this.props.dispatch(ac.SetPref("weather.optInDisplayed", false));
+
this.props.dispatch(
ac.AlsoToMain({
type: at.WEATHER_USER_OPT_IN_LOCATION,
})
);
+
+ this.props.dispatch(
+ ac.AlsoToMain({
+ type: at.WEATHER_OPT_IN_PROMPT_SELECTION,
+ data: "accepted opt-in",
+ })
+ );
});
};
diff --git a/browser/extensions/newtab/data/content/activity-stream.bundle.js b/browser/extensions/newtab/data/content/activity-stream.bundle.js
@@ -293,6 +293,7 @@ for (const type of [
"WEATHER_LOCATION_SEARCH_UPDATE",
"WEATHER_LOCATION_SUGGESTIONS_UPDATE",
"WEATHER_OPEN_PROVIDER_URL",
+ "WEATHER_OPT_IN_PROMPT_SELECTION",
"WEATHER_QUERY_UPDATE",
"WEATHER_SEARCH_ACTIVE",
"WEATHER_UPDATE",
@@ -11814,8 +11815,14 @@ class _Weather extends (external_React_default()).PureComponent {
}));
}
handleRejectOptIn = () => {
- this.props.dispatch(actionCreators.SetPref("weather.optInAccepted", false));
- this.props.dispatch(actionCreators.SetPref("weather.optInDisplayed", false));
+ (0,external_ReactRedux_namespaceObject.batch)(() => {
+ this.props.dispatch(actionCreators.SetPref("weather.optInAccepted", false));
+ this.props.dispatch(actionCreators.SetPref("weather.optInDisplayed", false));
+ this.props.dispatch(actionCreators.AlsoToMain({
+ type: actionTypes.WEATHER_OPT_IN_PROMPT_SELECTION,
+ data: "rejected opt-in"
+ }));
+ });
};
handleAcceptOptIn = () => {
(0,external_ReactRedux_namespaceObject.batch)(() => {
@@ -11824,6 +11831,10 @@ class _Weather extends (external_React_default()).PureComponent {
this.props.dispatch(actionCreators.AlsoToMain({
type: actionTypes.WEATHER_USER_OPT_IN_LOCATION
}));
+ this.props.dispatch(actionCreators.AlsoToMain({
+ type: actionTypes.WEATHER_OPT_IN_PROMPT_SELECTION,
+ data: "accepted opt-in"
+ }));
});
};
render() {
diff --git a/browser/extensions/newtab/lib/TelemetryFeed.sys.mjs b/browser/extensions/newtab/lib/TelemetryFeed.sys.mjs
@@ -1272,6 +1272,7 @@ export class TelemetryFeed {
case at.WEATHER_LOAD_ERROR:
case at.WEATHER_OPEN_PROVIDER_URL:
case at.WEATHER_LOCATION_DATA_UPDATE:
+ case at.WEATHER_OPT_IN_PROMPT_SELECTION:
this.handleWeatherUserEvent(action);
break;
case at.TOPIC_SELECTION_USER_OPEN:
@@ -1726,6 +1727,12 @@ export class TelemetryFeed {
newtab_visit_id: session.session_id,
});
break;
+ case "WEATHER_OPT_IN_PROMPT_SELECTION":
+ Glean.newtab.weatherOptInSelection.record({
+ newtab_visit_id: session.session_id,
+ user_selection: action.data,
+ });
+ break;
default:
break;
}