зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1599711 - Add TP blocked events by category to targeting attributes r=k88hudson
Differential Revision: https://phabricator.services.mozilla.com/D54913 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
652ecd936e
Коммит
7605d414b5
|
@ -45,6 +45,7 @@ Please note that some targeting attributes require stricter controls on the tele
|
|||
* [personalizedCfrScores](#personalizedcfrscores)
|
||||
* [personalizedCfrThreshold](#personalizedcfrthreshold)
|
||||
* [messageImpressions](#messageimpressions)
|
||||
* [blockedCountByType](#blockedcountbytype)
|
||||
|
||||
## Detailed usage
|
||||
|
||||
|
@ -636,3 +637,25 @@ Badge impressions should not be used for targeting.
|
|||
```
|
||||
declare const messageImpressions: { [key: string]: Array<UnixEpochNumber> };
|
||||
```
|
||||
|
||||
### `blockedCountByType`
|
||||
|
||||
Returns a breakdown by category of all blocked resources in the past 42 days.
|
||||
|
||||
#### Definition
|
||||
|
||||
```
|
||||
declare const messageImpressions: { [key: string]: number };
|
||||
```
|
||||
|
||||
#### Examples
|
||||
|
||||
```javascript
|
||||
Object {
|
||||
trackerCount: 0,
|
||||
cookieCount: 34,
|
||||
cryptominerCount: 0,
|
||||
fingerprinterCount: 3,
|
||||
socialCount: 2
|
||||
}
|
||||
```
|
||||
|
|
|
@ -482,6 +482,33 @@ const TargetingGetters = {
|
|||
get totalBlockedCount() {
|
||||
return TrackingDBService.sumAllEvents();
|
||||
},
|
||||
get blockedCountByType() {
|
||||
const idToTextMap = new Map([
|
||||
[Ci.nsITrackingDBService.TRACKERS_ID, "trackerCount"],
|
||||
[Ci.nsITrackingDBService.TRACKING_COOKIES_ID, "cookieCount"],
|
||||
[Ci.nsITrackingDBService.CRYPTOMINERS_ID, "cryptominerCount"],
|
||||
[Ci.nsITrackingDBService.FINGERPRINTERS_ID, "fingerprinterCount"],
|
||||
[Ci.nsITrackingDBService.SOCIAL_ID, "socialCount"],
|
||||
]);
|
||||
|
||||
const dateTo = new Date();
|
||||
const dateFrom = new Date(dateTo.getTime() - 42 * 24 * 60 * 60 * 1000);
|
||||
return TrackingDBService.getEventsByDateRange(dateFrom, dateTo).then(
|
||||
eventsByDate => {
|
||||
let totalEvents = {};
|
||||
for (let blockedType of idToTextMap.values()) {
|
||||
totalEvents[blockedType] = 0;
|
||||
}
|
||||
|
||||
return eventsByDate.reduce((acc, day) => {
|
||||
const type = day.getResultByName("type");
|
||||
const count = day.getResultByName("count");
|
||||
acc[idToTextMap.get(type)] = acc[idToTextMap.get(type)] + count;
|
||||
return acc;
|
||||
}, totalEvents);
|
||||
}
|
||||
);
|
||||
},
|
||||
get attachedFxAOAuthClients() {
|
||||
// Explicitly catch error objects e.g. NO_ACCOUNT triggered when
|
||||
// setting FXA_USERNAME_PREF from tests
|
||||
|
|
|
@ -908,6 +908,20 @@ add_task(async function checkCFRAddonsUserPref() {
|
|||
);
|
||||
});
|
||||
|
||||
add_task(async function check_blockedCountByType() {
|
||||
const message = {
|
||||
id: "foo",
|
||||
targeting:
|
||||
"blockedCountByType.cryptominerCount == 0 && blockedCountByType.socialCount == 0",
|
||||
};
|
||||
|
||||
is(
|
||||
await ASRouterTargeting.findMatchingMessage({ messages: [message] }),
|
||||
message,
|
||||
"should select correct item"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(async function checkCFRPinnedTabsTargetting() {
|
||||
const now = Date.now();
|
||||
const timeMinutesAgo = numMinutes => now - numMinutes * 60 * 1000;
|
||||
|
|
Загрузка…
Ссылка в новой задаче