tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit 70319edab3551c57720e31936bda8837bbfd315f
parent 0f725335a006cb0399bfdcc50e269aedda31af3c
Author: Rolf Rando <rrando@mozilla.com>
Date:   Tue,  7 Oct 2025 23:36:08 +0000

Bug 1991806 - Add pref to log feature interactions to db when inferred feature flag is off r=thecount,home-newtab-reviewers

Add experimenter pref to allow local storage of general topic interactions with the overall inferred feature off

Two smaller tweaks:
• Also changed default inferred preference refresh to 24 hours from 8 (it was already overridden to 24 hours in nimbus prefs)
• Also added debug config to assist in PM/dev testing which allows a custom interest vector to be set/sent to Merino.
• Remove iv_unary_dp_in_request config which previously had always been set to true and was no longer connected in the rest of the code

Differential Revision: https://phabricator.services.mozilla.com/D266940

Diffstat:
Mbrowser/extensions/newtab/lib/ActivityStream.sys.mjs | 7+++++++
Mbrowser/extensions/newtab/lib/DiscoveryStreamFeed.sys.mjs | 20++++++++++++++------
Mbrowser/extensions/newtab/lib/InferredPersonalizationFeed.sys.mjs | 12+++++++++---
Mtoolkit/components/nimbus/FeatureManifest.yaml | 4----
4 files changed, 30 insertions(+), 13 deletions(-)

diff --git a/browser/extensions/newtab/lib/ActivityStream.sys.mjs b/browser/extensions/newtab/lib/ActivityStream.sys.mjs @@ -728,6 +728,13 @@ export const PREFS_CONFIG = new Map([ }, ], [ + "discoverystream.sections.personalization.inferred.interests.override", + { + title: + "Testing feature to allow specification of specific user interests", + }, + ], + [ "discoverystream.dailyBrief.enabled", { title: "Boolean flag to enable the daily brief section", diff --git a/browser/extensions/newtab/lib/DiscoveryStreamFeed.sys.mjs b/browser/extensions/newtab/lib/DiscoveryStreamFeed.sys.mjs @@ -117,6 +117,9 @@ const PREF_USER_INFERRED_PERSONALIZATION = "discoverystream.sections.personalization.inferred.user.enabled"; const PREF_SYSTEM_INFERRED_PERSONALIZATION = "discoverystream.sections.personalization.inferred.enabled"; +const PREF_INFERRED_INTERESTS_OVERRIDE = + "discoverystream.sections.personalization.inferred.interests.override"; + const PREF_MERINO_OHTTP = "discoverystream.merino-provider.ohttp.enabled"; const PREF_BILLBOARD_ENABLED = "newtabAdSize.billboard"; const PREF_LEADERBOARD_ENABLED = "newtabAdSize.leaderboard"; @@ -2123,13 +2126,18 @@ export class DiscoveryStreamFeed { let inferredInterests = null; if (inferredPersonalization && merinoOhttpEnabled) { - const useLaplace = - !prefs.inferredPersonalizationConfig?.iv_unary_dp_in_request; inferredInterests = - (useLaplace - ? this.store.getState().InferredPersonalization.inferredInterests - : this.store.getState().InferredPersonalization - .coarsePrivateInferredInterests) || {}; + this.store.getState().InferredPersonalization + ?.coarsePrivateInferredInterests || {}; + if (prefs[PREF_INFERRED_INTERESTS_OVERRIDE]) { + try { + inferredInterests = JSON.parse( + prefs[PREF_INFERRED_INTERESTS_OVERRIDE] + ); + } catch (ex) { + console.error("Invalid format json for inferred interest override."); + } + } } const requestMetadata = { diff --git a/browser/extensions/newtab/lib/InferredPersonalizationFeed.sys.mjs b/browser/extensions/newtab/lib/InferredPersonalizationFeed.sys.mjs @@ -26,7 +26,7 @@ import { MODEL_TYPE } from "./InferredModel/InferredConstants.sys.mjs"; const CACHE_KEY = "inferred_personalization_feed"; const DISCOVERY_STREAM_CACHE_KEY = "discovery_stream"; -const INTEREST_VECTOR_UPDATE_HOURS = 8; +const INTEREST_VECTOR_UPDATE_HOURS = 24; const HOURS_TO_MS = 60 * 60 * 1000; const PREF_USER_INFERRED_PERSONALIZATION = @@ -75,6 +75,11 @@ export class InferredPersonalizationFeed { ); } + isStoreData() { + return !!this.store.getState().Prefs.values?.trainhopConfig + ?.newTabSectionsExperiment?.personalizationStoreFeaturesEnabled; + } + async init() { await this.loadInterestVector(true /* isStartup */); } @@ -431,12 +436,13 @@ export class InferredPersonalizationFeed { await this.clearOldData(0); break; case at.DISCOVERY_STREAM_IMPRESSION_STATS: - if (this.loaded && this.isEnabled()) { + // We have the ability to collect feature impressions when the feature is off + if (this.isEnabled() || this.isStoreData()) { await this.handleDiscoveryStreamImpressionStats(action); } break; case at.DISCOVERY_STREAM_USER_EVENT: - if (this.loaded && this.isEnabled()) { + if (this.isEnabled() || this.isStoreData()) { await this.handleDiscoveryStreamUserEvent(action); } break; diff --git a/toolkit/components/nimbus/FeatureManifest.yaml b/toolkit/components/nimbus/FeatureManifest.yaml @@ -1424,10 +1424,6 @@ newtabInferredPersonalization: type: int description: >- Time to refresh interest vector in hours - iv_unary_dp_in_request: - type: boolean - description: >- - Whether to use Unary encoding with differential privacy in the interest vector. If false or not set, we default to laplace noise with real values history_cull_days: type: int description: >-