commit 792e03692e8f676c087ae4881d5a7c753c82db0f
parent 83ce0f20261e56e178598a403efdc3d269b7f79f
Author: Beth Rennie <beth@brennie.ca>
Date: Thu, 30 Oct 2025 13:01:22 +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:
4 files changed, 49 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/lib/TargetingContextRecorder.sys.mjs b/toolkit/components/nimbus/lib/TargetingContextRecorder.sys.mjs
@@ -159,6 +159,7 @@ export const ATTRIBUTE_TRANSFORMS = Object.freeze({
),
primaryResolution: pick("height", "width"),
profileAgeCreated: typeAssertions.quantity,
+ profileGroupProfileCount: typeAssertions.quantity,
region: typeAssertions.string,
totalBookmarksCount: typeAssertions.quantity,
userMonthlyActivity: userMonthlyActivity =>
@@ -221,6 +222,7 @@ export const PREFS = Object.freeze({
"browser.newtabpage.activity-stream.showSearch": PREF_BOOL,
"browser.newtabpage.activity-stream.showSponsoredTopSites": PREF_BOOL,
"browser.newtabpage.enabled": PREF_BOOL,
+ "browser.profiles.created": PREF_BOOL,
"browser.startup.page": PREF_INT,
"browser.toolbars.bookmarks.visibility": PREF_STRING,
"browser.urlbar.lastUrlbarSearchSeconds": PREF_INT,
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
@@ -80,6 +82,7 @@ nimbus_targeting_environment:
- "browser.newtabpage.activity-stream.showSearch"
- "browser.newtabpage.activity-stream.showSponsoredTopSites"
- "browser.newtabpage.enabled"
+ - "browser.profiles.created"
- "browser.startup.page"
- "browser.toolbars.bookmarks.visibility"
- "browser.urlbar.lastUrlbarSearchSeconds"
@@ -136,6 +139,7 @@ nimbus_targeting_environment:
- "os"
- "primaryResolution"
- "profileAgeCreated"
+ - "profileGroupProfileCount"
- "region"
- "totalBookmarksCount"
- "userMonthlyActivity"
@@ -188,6 +192,8 @@ nimbus_targeting_environment:
type: boolean
browser__newtabpage__enabled:
type: boolean
+ browser__profiles__created:
+ type: boolean
browser__startup__page:
type: number
browser__toolbars__bookmarks__visibility:
@@ -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