mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-26 04:09:50 +00:00
Bug 1921326 - Separate unified ads API enabled pref into independent prefs for tiles and spocs r=home-newtab-reviewers,places-reviewers,thecount,adw
Differential Revision: https://phabricator.services.mozilla.com/D223848
This commit is contained in:
parent
433339fc5e
commit
d16ad42be9
@ -1737,7 +1737,8 @@ pref("browser.partnerlink.campaign.topsites", "amzn_2020_a1");
|
||||
pref("browser.newtab.preload", true);
|
||||
|
||||
// Mozilla Ad Routing Service (MARS) unified ads service
|
||||
pref("browser.newtabpage.activity-stream.unifiedAds.enabled", false);
|
||||
pref("browser.newtabpage.activity-stream.unifiedAds.tiles.enabled", false);
|
||||
pref("browser.newtabpage.activity-stream.unifiedAds.spocs.enabled", false);
|
||||
pref("browser.newtabpage.activity-stream.unifiedAds.endpoint", "https://ads.mozilla.org/");
|
||||
|
||||
// Weather widget for newtab
|
||||
|
@ -237,9 +237,18 @@ export const PREFS_CONFIG = new Map([
|
||||
},
|
||||
],
|
||||
[
|
||||
"unifiedAds.enabled",
|
||||
"unifiedAds.tiles.enabled",
|
||||
{
|
||||
title: "Use Mozilla Ad Routing Service (MARS) unified ads API",
|
||||
title:
|
||||
"Use Mozilla Ad Routing Service (MARS) unified ads API for sponsored top sites tiles",
|
||||
value: false,
|
||||
},
|
||||
],
|
||||
[
|
||||
"unifiedAds.spocs.enabled",
|
||||
{
|
||||
title:
|
||||
"Use Mozilla Ad Routing Service (MARS) unified ads API for sponsored content in Recommend Stories",
|
||||
value: false,
|
||||
},
|
||||
],
|
||||
|
@ -78,7 +78,7 @@ const PREF_USER_TOPSTORIES = "feeds.section.topstories";
|
||||
const PREF_SYSTEM_TOPSTORIES = "feeds.system.topstories";
|
||||
const PREF_SYSTEM_TOPSITES = "feeds.system.topsites";
|
||||
const PREF_UNIFIED_ADS_BLOCKED_LIST = "unifiedAds.blockedAds";
|
||||
const PREF_UNIFIED_ADS_ENABLED = "unifiedAds.enabled";
|
||||
const PREF_UNIFIED_ADS_SPOCS_ENABLED = "unifiedAds.spocs.enabled";
|
||||
const PREF_UNIFIED_ADS_ENDPOINT = "unifiedAds.endpoint";
|
||||
const PREF_USER_TOPSITES = "feeds.topsites";
|
||||
const PREF_SPOCS_CLEAR_ENDPOINT = "discoverystream.endpointSpocsClear";
|
||||
@ -988,7 +988,7 @@ export class DiscoveryStreamFeed {
|
||||
// so we can change as little as possible. Once we commit to one, we can remove all this.
|
||||
normalizeSpocsItems(spocs) {
|
||||
const unifiedAdsEnabled =
|
||||
this.store.getState().Prefs.values[PREF_UNIFIED_ADS_ENABLED];
|
||||
this.store.getState().Prefs.values[PREF_UNIFIED_ADS_SPOCS_ENABLED];
|
||||
if (unifiedAdsEnabled) {
|
||||
return {
|
||||
items: spocs.map(spoc => ({
|
||||
@ -1051,7 +1051,7 @@ export class DiscoveryStreamFeed {
|
||||
async loadSpocs(sendUpdate, isStartup) {
|
||||
const cachedData = (await this.cache.get()) || {};
|
||||
const unifiedAdsEnabled =
|
||||
this.store.getState().Prefs.values[PREF_UNIFIED_ADS_ENABLED];
|
||||
this.store.getState().Prefs.values[PREF_UNIFIED_ADS_SPOCS_ENABLED];
|
||||
let spocsState = cachedData.spocs;
|
||||
let placements = this.getPlacements();
|
||||
|
||||
@ -1270,7 +1270,8 @@ export class DiscoveryStreamFeed {
|
||||
const state = this.store.getState();
|
||||
let endpoint = state.Prefs.values[PREF_SPOCS_CLEAR_ENDPOINT];
|
||||
|
||||
const unifiedAdsEnabled = state.Prefs.values[PREF_UNIFIED_ADS_ENABLED];
|
||||
const unifiedAdsEnabled =
|
||||
state.Prefs.values[PREF_UNIFIED_ADS_SPOCS_ENABLED];
|
||||
|
||||
let body = {
|
||||
pocket_id: this._impressionId,
|
||||
@ -1965,7 +1966,7 @@ export class DiscoveryStreamFeed {
|
||||
|
||||
recordBlockFlightId(flightId) {
|
||||
const unifiedAdsEnabled =
|
||||
this.store.getState().Prefs.values[PREF_UNIFIED_ADS_ENABLED];
|
||||
this.store.getState().Prefs.values[PREF_UNIFIED_ADS_SPOCS_ENABLED];
|
||||
|
||||
const flights = this.readDataPref(PREF_FLIGHT_BLOCKS);
|
||||
if (!flights[flightId]) {
|
||||
@ -2107,7 +2108,7 @@ export class DiscoveryStreamFeed {
|
||||
case PREF_LAYOUT_EXPERIMENT_A:
|
||||
case PREF_LAYOUT_EXPERIMENT_B:
|
||||
case PREF_SPOC_POSITIONS:
|
||||
case PREF_UNIFIED_ADS_ENABLED:
|
||||
case PREF_UNIFIED_ADS_SPOCS_ENABLED:
|
||||
case PREF_CONTEXTUAL_CONTENT_ENABLED:
|
||||
// This is a config reset directly related to Discovery Stream pref.
|
||||
this.configReset();
|
||||
|
@ -42,8 +42,8 @@ const PLACES_LINKS_CHANGED_DELAY_TIME = 1000; // time in ms to delay timer for p
|
||||
// blocked sponsors.
|
||||
const TOP_SITES_BLOCKED_SPONSORS_PREF = "browser.topsites.blockedSponsors";
|
||||
|
||||
const PREF_UNIFIED_ADS_ENABLED =
|
||||
"browser.newtabpage.activity-stream.unifiedAds.enabled";
|
||||
const PREF_UNIFIED_ADS_TILES_ENABLED =
|
||||
"browser.newtabpage.activity-stream.unifiedAds.tiles.enabled";
|
||||
|
||||
const PREF_UNIFIED_ADS_BLOCKED_LIST =
|
||||
"browser.newtabpage.activity-stream.unifiedAds.blockedAds";
|
||||
@ -530,8 +530,8 @@ export class PlacesFeed {
|
||||
}
|
||||
|
||||
onAction(action) {
|
||||
const unifiedAdsEnabled = Services.prefs.getBoolPref(
|
||||
PREF_UNIFIED_ADS_ENABLED,
|
||||
const unifiedAdsTilesEnabled = Services.prefs.getBoolPref(
|
||||
PREF_UNIFIED_ADS_TILES_ENABLED,
|
||||
false
|
||||
);
|
||||
|
||||
@ -563,7 +563,7 @@ export class PlacesFeed {
|
||||
sponsoredTopSites.push({ url });
|
||||
|
||||
// Add block keys if available
|
||||
if (unifiedAdsEnabled) {
|
||||
if (unifiedAdsTilesEnabled) {
|
||||
sponsoredBlockKeys.push(block_key);
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,8 @@ export const USER_PREFS_ENCODING = {
|
||||
export const PREF_IMPRESSION_ID = "impressionId";
|
||||
export const TELEMETRY_PREF = "telemetry";
|
||||
export const EVENTS_TELEMETRY_PREF = "telemetry.ut.events";
|
||||
export const PREF_UNIFIED_ADS_ENABLED = "unifiedAds.enabled";
|
||||
export const PREF_UNIFIED_ADS_SPOCS_ENABLED = "unifiedAds.spocs.enabled";
|
||||
export const PREF_UNIFIED_ADS_TILES_ENABLED = "unifiedAds.spocs.enabled";
|
||||
const PREF_UPLOAD_ENABLED = "datareporting.healthreport.uploadEnabled";
|
||||
|
||||
// Used as the missing value for timestamps in the session ping
|
||||
@ -139,8 +140,10 @@ export class TelemetryFeed {
|
||||
return this._prefs.get(EVENTS_TELEMETRY_PREF);
|
||||
}
|
||||
|
||||
get canSendUnifiedAdsCallbacks() {
|
||||
const unifiedAdsEnabled = this._prefs.get(PREF_UNIFIED_ADS_ENABLED);
|
||||
get canSendUnifiedAdsSpocCallbacks() {
|
||||
const unifiedAdsSpocsEnabled = this._prefs.get(
|
||||
PREF_UNIFIED_ADS_SPOCS_ENABLED
|
||||
);
|
||||
|
||||
// Check PREF_UPLOAD_ENABLED if data reporting is allowed
|
||||
const uploadEnabled = Services.prefs.getBoolPref(
|
||||
@ -148,7 +151,21 @@ export class TelemetryFeed {
|
||||
false
|
||||
);
|
||||
|
||||
return unifiedAdsEnabled && uploadEnabled;
|
||||
return unifiedAdsSpocsEnabled && uploadEnabled;
|
||||
}
|
||||
|
||||
get canSendUnifiedAdsTilesCallbacks() {
|
||||
const unifiedAdsTilesEnabled = this._prefs.get(
|
||||
PREF_UNIFIED_ADS_TILES_ENABLED
|
||||
);
|
||||
|
||||
// Check PREF_UPLOAD_ENABLED if data reporting is allowed
|
||||
const uploadEnabled = Services.prefs.getBoolPref(
|
||||
PREF_UPLOAD_ENABLED,
|
||||
false
|
||||
);
|
||||
|
||||
return unifiedAdsTilesEnabled && uploadEnabled;
|
||||
}
|
||||
|
||||
get telemetryClientId() {
|
||||
@ -629,7 +646,9 @@ export class TelemetryFeed {
|
||||
// Legacy telemetry expects 1-based tile positions.
|
||||
const legacyTelemetryPosition = position + 1;
|
||||
|
||||
const unifiedAdsEnabled = this._prefs.get(PREF_UNIFIED_ADS_ENABLED);
|
||||
const unifiedAdsTilesEnabled = this._prefs.get(
|
||||
PREF_UNIFIED_ADS_TILES_ENABLED
|
||||
);
|
||||
|
||||
let pingType;
|
||||
|
||||
@ -675,14 +694,14 @@ export class TelemetryFeed {
|
||||
Glean.topSites.position.set(legacyTelemetryPosition);
|
||||
Glean.topSites.source.set(source);
|
||||
Glean.topSites.tileId.set(tile_id);
|
||||
if (data.reporting_url && !unifiedAdsEnabled) {
|
||||
if (data.reporting_url && !unifiedAdsTilesEnabled) {
|
||||
Glean.topSites.reportingUrl.set(data.reporting_url);
|
||||
}
|
||||
Glean.topSites.advertiser.set(advertiser_name);
|
||||
Glean.topSites.contextId.set(lazy.contextId);
|
||||
GleanPings.topSites.submit();
|
||||
|
||||
if (data.reporting_url && this.canSendUnifiedAdsCallbacks) {
|
||||
if (data.reporting_url && this.canSendUnifiedAdsTilesCallbacks) {
|
||||
// Send callback events to MARS unified ads api
|
||||
this.sendUnifiedAdsCallbackEvent({
|
||||
url: data.reporting_url,
|
||||
@ -790,7 +809,7 @@ export class TelemetryFeed {
|
||||
}),
|
||||
});
|
||||
if (shim) {
|
||||
if (this.canSendUnifiedAdsCallbacks) {
|
||||
if (this.canSendUnifiedAdsSpocCallbacks) {
|
||||
// Send unified ads callback event
|
||||
this.sendUnifiedAdsCallbackEvent({
|
||||
url: shim,
|
||||
@ -1297,7 +1316,7 @@ export class TelemetryFeed {
|
||||
}),
|
||||
});
|
||||
if (tile.shim) {
|
||||
if (this.canSendUnifiedAdsCallbacks) {
|
||||
if (this.canSendUnifiedAdsSpocCallbacks) {
|
||||
// Send unified ads callback event
|
||||
this.sendUnifiedAdsCallbackEvent({
|
||||
url: tile.shim,
|
||||
|
@ -90,7 +90,7 @@ const NIMBUS_VARIABLE_CONTILE_SOV_ENABLED = "topSitesContileSovEnabled";
|
||||
// The default will be `CONTILE_MAX_NUM_SPONSORED` if variable is unspecified.
|
||||
const NIMBUS_VARIABLE_CONTILE_MAX_NUM_SPONSORED = "topSitesContileMaxSponsored";
|
||||
|
||||
const PREF_UNIFIED_ADS_ENABLED = "unifiedAds.enabled";
|
||||
const PREF_UNIFIED_ADS_TILES_ENABLED = "unifiedAds.tiles.enabled";
|
||||
const PREF_UNIFIED_ADS_ENDPOINT = "unifiedAds.endpoint";
|
||||
const PREF_UNIFIED_ADS_PLACEMENTS = "discoverystream.placements.tiles";
|
||||
const PREF_UNIFIED_ADS_COUNTS = "discoverystream.placements.tiles.counts";
|
||||
@ -390,13 +390,13 @@ export class ContileIntegration {
|
||||
* string value of the Contile resposne cache-control header
|
||||
*/
|
||||
_extractCacheValidFor(cacheHeader) {
|
||||
const unifiedAdsEnabled =
|
||||
const unifiedAdsTilesEnabled =
|
||||
this._topSitesFeed.store.getState().Prefs.values[
|
||||
PREF_UNIFIED_ADS_ENABLED
|
||||
PREF_UNIFIED_ADS_TILES_ENABLED
|
||||
];
|
||||
|
||||
// Note: Cache-control only applies to direct Contile API calls
|
||||
if (!cacheHeader && !unifiedAdsEnabled) {
|
||||
if (!cacheHeader && !unifiedAdsTilesEnabled) {
|
||||
lazy.log.warn("Contile response cache control header is empty");
|
||||
return 0;
|
||||
}
|
||||
@ -499,13 +499,14 @@ export class ContileIntegration {
|
||||
let response;
|
||||
const state = this._topSitesFeed.store.getState();
|
||||
|
||||
const unifiedAdsEnabled = state.Prefs.values[PREF_UNIFIED_ADS_ENABLED];
|
||||
const unifiedAdsTilesEnabled =
|
||||
state.Prefs.values[PREF_UNIFIED_ADS_TILES_ENABLED];
|
||||
|
||||
const serviceName = unifiedAdsEnabled ? "MARS" : "Contile";
|
||||
const serviceName = unifiedAdsTilesEnabled ? "MARS" : "Contile";
|
||||
|
||||
try {
|
||||
// Fetch tiles via MARS unified ads service
|
||||
if (unifiedAdsEnabled) {
|
||||
if (unifiedAdsTilesEnabled) {
|
||||
const headers = new Headers();
|
||||
headers.append("content-type", "application/json");
|
||||
|
||||
@ -586,7 +587,7 @@ export class ContileIntegration {
|
||||
}
|
||||
let body = await response.json();
|
||||
|
||||
if (unifiedAdsEnabled) {
|
||||
if (unifiedAdsTilesEnabled) {
|
||||
// Converts response into normalized tiles[] array
|
||||
body = this._normalizeTileData(body);
|
||||
}
|
||||
@ -630,7 +631,7 @@ export class ContileIntegration {
|
||||
JSON.stringify(this._sites)
|
||||
);
|
||||
|
||||
if (!unifiedAdsEnabled) {
|
||||
if (!unifiedAdsTilesEnabled) {
|
||||
Services.prefs.setIntPref(
|
||||
CONTILE_CACHE_VALID_FOR_PREF,
|
||||
this._extractCacheValidFor(
|
||||
|
Loading…
x
Reference in New Issue
Block a user