Bug 1963183 - Add buildId to ASRouterTargeting and Nimbus targeting context r=omc-reviewers,nimbus-reviewers,emcminn
Differential Revision: https://phabricator.services.mozilla.com/D246994
This commit is contained in:
committed by
brennie@mozilla.com
parent
ea73afd884
commit
25f1aa8bdb
@@ -19,6 +19,7 @@ Please note that some targeting attributes require stricter controls on the tele
|
|||||||
* [blockedCountByType](#blockedcountbytype)
|
* [blockedCountByType](#blockedcountbytype)
|
||||||
* [browserIsSelected](#browserisselected)
|
* [browserIsSelected](#browserisselected)
|
||||||
* [browserSettings](#browsersettings)
|
* [browserSettings](#browsersettings)
|
||||||
|
* [buildId](#buildId)
|
||||||
* [canCreateSelectableProfiles](#cancreateselectableprofiles)
|
* [canCreateSelectableProfiles](#cancreateselectableprofiles)
|
||||||
* [creditCardsSaved](#creditcardssaved)
|
* [creditCardsSaved](#creditcardssaved)
|
||||||
* [currentDate](#currentdate)
|
* [currentDate](#currentdate)
|
||||||
@@ -205,6 +206,24 @@ declare const browserSettings: {
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### `buildId`
|
||||||
|
|
||||||
|
The build ID (`MOZ_BUILDID`) parsed as a number to allow for comparisons.
|
||||||
|
|
||||||
|
#### Examples
|
||||||
|
|
||||||
|
* Is the build from at least Jan 01 2025
|
||||||
|
|
||||||
|
```java
|
||||||
|
buildId >= 202501010000
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Definition
|
||||||
|
|
||||||
|
```ts
|
||||||
|
declare const buildId: number;
|
||||||
|
```
|
||||||
|
|
||||||
### `currentDate`
|
### `currentDate`
|
||||||
|
|
||||||
The current date at the moment message targeting is checked.
|
The current date at the moment message targeting is checked.
|
||||||
|
|||||||
@@ -1199,6 +1199,10 @@ const TargetingGetters = {
|
|||||||
get profileGroupId() {
|
get profileGroupId() {
|
||||||
return QueryCache.getters.profileGroupId.get();
|
return QueryCache.getters.profileGroupId.get();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
get buildId() {
|
||||||
|
return parseInt(AppConstants.MOZ_BUILDID, 10);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const ASRouterTargeting = {
|
export const ASRouterTargeting = {
|
||||||
|
|||||||
@@ -2031,3 +2031,22 @@ add_task(async function check_profileGroupIdTargeting() {
|
|||||||
"should select correct item by profile group id"
|
"should select correct item by profile group id"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
add_task(async function test_buildId() {
|
||||||
|
is(
|
||||||
|
typeof ASRouterTargeting.Environment.buildId,
|
||||||
|
"number",
|
||||||
|
"Should return a number"
|
||||||
|
);
|
||||||
|
|
||||||
|
const message = {
|
||||||
|
id: "foo",
|
||||||
|
// Later than January 2025
|
||||||
|
targeting: `buildId >= 20251010000`,
|
||||||
|
};
|
||||||
|
is(
|
||||||
|
await ASRouterTargeting.findMatchingMessage({ messages: [message] }),
|
||||||
|
message,
|
||||||
|
"should select correct item when filtering by build ID"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|||||||
@@ -99,6 +99,8 @@ function assertType(expectedType, attribute) {
|
|||||||
* type.
|
* type.
|
||||||
*/
|
*/
|
||||||
const typeAssertions = {
|
const typeAssertions = {
|
||||||
|
integer: attribute =>
|
||||||
|
assertType("number", attribute) && Number.isSafeInteger(attribute),
|
||||||
string: attribute => assertType("string", attribute),
|
string: attribute => assertType("string", attribute),
|
||||||
boolean: attribute => assertType("boolean", attribute),
|
boolean: attribute => assertType("boolean", attribute),
|
||||||
quantity: attribute => Math.floor(assertType("number", attribute)),
|
quantity: attribute => Math.floor(assertType("number", attribute)),
|
||||||
@@ -133,6 +135,7 @@ export const ATTRIBUTE_TRANSFORMS = Object.freeze({
|
|||||||
browserSettings: pickWith({
|
browserSettings: pickWith({
|
||||||
update: pick("channel"),
|
update: pick("channel"),
|
||||||
}),
|
}),
|
||||||
|
buildId: typeAssertions.integer,
|
||||||
currentDate: typeAssertions.date,
|
currentDate: typeAssertions.date,
|
||||||
defaultPDFHandler: pick("knownBrowser", "registered"),
|
defaultPDFHandler: pick("knownBrowser", "registered"),
|
||||||
distributionId: typeAssertions.string,
|
distributionId: typeAssertions.string,
|
||||||
|
|||||||
@@ -28,12 +28,14 @@ nimbus_targeting_environment:
|
|||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1898394
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1898394
|
||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1949813
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1949813
|
||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1963160
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1963160
|
||||||
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1963183
|
||||||
data_reviews: &targeting_context_data_reviews
|
data_reviews: &targeting_context_data_reviews
|
||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1928107
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1928107
|
||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1937207
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1937207
|
||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1898394
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1898394
|
||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1949813
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1949813
|
||||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1963160
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1963160
|
||||||
|
- https://bugzilla.mozilla.org/show_bug.cgi?id=1963183
|
||||||
notification_emails: &targeting_context_notification_emails
|
notification_emails: &targeting_context_notification_emails
|
||||||
- beth@mozilla.com
|
- beth@mozilla.com
|
||||||
- project-nimbus@mozilla.com
|
- project-nimbus@mozilla.com
|
||||||
@@ -107,6 +109,7 @@ nimbus_targeting_environment:
|
|||||||
- "archBits"
|
- "archBits"
|
||||||
- "attributionData"
|
- "attributionData"
|
||||||
- "browserSettings"
|
- "browserSettings"
|
||||||
|
- "buildId"
|
||||||
- "currentDate"
|
- "currentDate"
|
||||||
- "defaultPDFHandler"
|
- "defaultPDFHandler"
|
||||||
- "distributionId"
|
- "distributionId"
|
||||||
@@ -335,6 +338,18 @@ nimbus_targeting_context:
|
|||||||
channel:
|
channel:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
|
build_id:
|
||||||
|
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 Build ID.
|
||||||
|
data_sensitivity:
|
||||||
|
- technical
|
||||||
|
type: quantity
|
||||||
|
unit: build ID
|
||||||
|
|
||||||
current_date:
|
current_date:
|
||||||
bugs: *targeting_context_bugs
|
bugs: *targeting_context_bugs
|
||||||
data_reviews: *targeting_context_data_reviews
|
data_reviews: *targeting_context_data_reviews
|
||||||
|
|||||||
Reference in New Issue
Block a user