commit 9b4be3fbfac08d4a974aaabdc8f7de66e3d4b667
parent 5308d85d1342b4ce4721100a319bec1cd2d03ef0
Author: Beth Rennie <beth@brennie.ca>
Date: Wed, 29 Oct 2025 19:56:39 +0000
Bug 1997164 - Add targeting for number of profiles in a group r=nimbus-reviewers,omc-reviewers,emcminn
Differential Revision: https://phabricator.services.mozilla.com/D270582
Diffstat:
3 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/browser/components/asrouter/docs/targeting-attributes.md b/browser/components/asrouter/docs/targeting-attributes.md
@@ -29,6 +29,7 @@ Please note that some targeting attributes require stricter controls on the tele
* [currentTabGroups](#currenttabgroups)
* [currentTabInstalledAsWebApp](#currenttabinstalledaswebapp)
* [currentProfileId](#currentprofileid)
+* [profileGroupProfileCount](#profileGroupProfileCount)
* [defaultPDFHandler](#defaultpdfhandler)
* [devToolsOpenedCount](#devtoolsopenedcount)
* [distributionId](#distributionid)
@@ -1168,6 +1169,11 @@ Returns the stable profile group ID used for data reporting.
The integer-valued identifier of the current selectable profile, as reported by `SelectableProfileService`, converted to a string.
+### `profileGroupProfileCount`
+
+The number of profiles in the current profile group or zero if either the
+feature is not enabled or the user has not created any profiles.
+
### `backupsInfo`
Provides information about the backups a user has in the default directory.
diff --git a/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs b/browser/components/asrouter/modules/ASRouterTargeting.sys.mjs
@@ -427,6 +427,23 @@ export const QueryCache = {
FRECENT_SITES_UPDATE_INTERVAL,
ClientID
),
+ profileGroupProfileCount: new CachedTargetingGetter(
+ "getProfileGroupProfileCount",
+ null,
+ FRECENT_SITES_UPDATE_INTERVAL,
+ {
+ getProfileGroupProfileCount() {
+ if (
+ !Services.prefs.getBoolPref("browser.profiles.enabled", false) ||
+ !Services.prefs.getBoolPref("browser.profiles.created", false)
+ ) {
+ return 0;
+ }
+
+ return lazy.SelectableProfileService.getProfileCount();
+ },
+ }
+ ),
backupsInfo: new CachedTargetingGetter(
"findBackupsInWellKnownLocations",
null,
@@ -1318,6 +1335,10 @@ const TargetingGetters = {
return lazy.SelectableProfileService.currentProfile.id.toString();
},
+ get profileGroupProfileCount() {
+ return QueryCache.getters.profileGroupProfileCount.get();
+ },
+
get buildId() {
return parseInt(AppConstants.MOZ_BUILDID, 10);
},
diff --git a/toolkit/components/nimbus/metrics.yaml b/toolkit/components/nimbus/metrics.yaml
@@ -32,6 +32,7 @@ nimbus_targeting_environment:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1971552
- https://bugzilla.mozilla.org/show_bug.cgi?id=1967328
- https://bugzilla.mozilla.org/show_bug.cgi?id=1983122
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1997164
data_reviews: &targeting_context_data_reviews
- https://bugzilla.mozilla.org/show_bug.cgi?id=1928107
- https://bugzilla.mozilla.org/show_bug.cgi?id=1937207
@@ -42,6 +43,7 @@ nimbus_targeting_environment:
- https://bugzilla.mozilla.org/show_bug.cgi?id=1971552
- https://bugzilla.mozilla.org/show_bug.cgi?id=1967328
- https://bugzilla.mozilla.org/show_bug.cgi?id=1983122
+ - https://bugzilla.mozilla.org/show_bug.cgi?id=1997164
notification_emails: &targeting_context_notification_emails
- beth@mozilla.com
- project-nimbus@mozilla.com
@@ -94,6 +96,7 @@ nimbus_targeting_environment:
- "nimbus.qa.pref-1"
- "nimbus.qa.pref-2"
- "security.sandbox.content.level"
+ - "toolkit.profile.created"
- "trailhead.firstrun.didSeeAboutWelcome"
attr_eval_errors:
@@ -136,6 +139,7 @@ nimbus_targeting_environment:
- "os"
- "primaryResolution"
- "profileAgeCreated"
+ - "profileGroupProfileCount"
- "region"
- "totalBookmarksCount"
- "userMonthlyActivity"
@@ -212,6 +216,8 @@ nimbus_targeting_environment:
type: number
security__sandbox__content__level:
type: number
+ toolkit__profile__created:
+ type: boolean
trailhead__firstrun__didSeeAboutWelcome:
type: boolean
@@ -646,6 +652,20 @@ nimbus_targeting_context:
type: quantity
unit: seconds since UNIX epoch
+ profile_group_profile_count:
+ bugs: *targeting_context_bugs
+ data_reviews: *targeting_context_data_reviews
+ expires: *targeting_context_expiry
+ notification_emails: *targeting_context_notification_emails
+ send_in_pings: *targeting_context_pings
+ description: >
+ The number of profiles in the current profile group or zero if either the
+ feature is not enabled or the user has not created any profiles.
+ data_sensitivity:
+ - interaction
+ type: quantity
+ unit: profiles
+
region:
bugs: *targeting_context_bugs
data_reviews: *targeting_context_data_reviews