Created
March 1, 2023 22:21
-
-
Save quiiver/60d503badaad887c453b5692ac88b8c0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git i/browser/components/urlbar/UrlbarPrefs.sys.mjs w/browser/components/urlbar/UrlbarPrefs.sys.mjs | |
index 29df6877b0138..5b9cea35a1db8 100644 | |
--- i/browser/components/urlbar/UrlbarPrefs.sys.mjs | |
+++ w/browser/components/urlbar/UrlbarPrefs.sys.mjs | |
@@ -272,6 +272,14 @@ const PREF_URLBAR_DEFAULTS = new Map([ | |
// weather suggestions are turned on. | |
["suggest.weather", true], | |
+ // Comma-separated list of `source.providers` combinations, that are used to determine if an exposure event should be fired. | |
+ // This is a fallback for a nimbus variable and should be set from nimbus experiment configuration. | |
+ ["quicksuggest.exposureProviders", ""], | |
+ | |
+ // Comma-separated list of `source.providers` combinations, that are used to filter suggestions from being displayed. | |
+ // This is a fallback for a nimbus variable and should be set from nimbus experiment configuration. | |
+ ["quicksuggest.displayProviderFilter", ""], | |
+ | |
// JSON'ed array of blocked quick suggest URL digests. | |
["quicksuggest.blockedDigests", ""], | |
diff --git i/browser/components/urlbar/UrlbarProviderQuickSuggest.sys.mjs w/browser/components/urlbar/UrlbarProviderQuickSuggest.sys.mjs | |
index 1169cd4cd9c0a..89ce59a580df4 100644 | |
--- i/browser/components/urlbar/UrlbarProviderQuickSuggest.sys.mjs | |
+++ w/browser/components/urlbar/UrlbarProviderQuickSuggest.sys.mjs | |
@@ -169,6 +169,19 @@ class ProviderQuickSuggest extends UrlbarProvider { | |
return; | |
} | |
+ // look at the source.provider combination and determine if we should fire an experiment exposure event. | |
+ if (this._checkExposureProvider(suggestion)) { | |
+ this._triggerExposureEvent(suggestion); | |
+ } | |
+ | |
+ // Check if we've configured provider based filtering and drop the suggestion if we have. | |
+ // We don't check this in `_canAddSuggestion` because we care about suggestions that have | |
+ // already passed the scoring and filtering steps and would be shown. | |
+ if (this._checkProviderFilter(suggestion)) { | |
+ return; | |
+ } | |
+ | |
+ | |
// Replace the suggestion's template substrings, but first save the original | |
// URL before its timestamp template is replaced. | |
let originalUrl = suggestion.url; | |
@@ -708,6 +721,32 @@ class ProviderQuickSuggest extends UrlbarProvider { | |
return true; | |
} | |
+ _checkExposureProvider(suggestion) { | |
+ this.logger.debug("Checking if suggestion should trigger exposure event") | |
+ const exposureProviders = lazy.UrlbarPrefs.get("quickSuggestExposureProviders"); | |
+ if (exposureProviders) { | |
+ const providerLookup = `${suggestion.source}.${suggestion.provider}` | |
+ return exposureProviders.split(",") | |
+ .includes(providerLookup); | |
+ } | |
+ } | |
+ | |
+ _triggerExposureEvent(suggestion) { | |
+ const provider = `${suggestion.source}.${suggestion.provider}` | |
+ Glean.urlbar.exposure.record({provider}) | |
+ this.logger.debug(`Triggered exposure event for provider: ${provider}`) | |
+ } | |
+ | |
+ _checkProviderFilter(suggestion) { | |
+ this.logger.debug("Checking if suggestion should filtered from display.") | |
+ const providerFilters = lazy.UrlbarPrefs.get("quickSuggestDisplayProviderFilter"); | |
+ if (providerFilters) { | |
+ const providerLookup = `${suggestion.source}.${suggestion.provider}` | |
+ return providerFilters.split(",") | |
+ .includes(providerLookup); | |
+ } | |
+ } | |
+ | |
get _test_merino() { | |
return this.#merino; | |
} | |
diff --git i/browser/components/urlbar/metrics.yaml w/browser/components/urlbar/metrics.yaml | |
index 0588c9c8ddc44..7ec9c54085f74 100644 | |
--- i/browser/components/urlbar/metrics.yaml | |
+++ w/browser/components/urlbar/metrics.yaml | |
@@ -333,3 +333,16 @@ urlbar: | |
notification_emails: | |
- [email protected] | |
expires: never | |
+ exposure: | |
+ type: event | |
+ description: > | |
+ Recorded when client can be exposed to urlbar experiment results. | |
+ extra_keys: | |
+ provider: | |
+ description: Provider that triggered the exposure. | |
+ type: string | |
+ data_sensitivity: | |
+ - interaction | |
+ notification_emails: | |
+ - [email protected] | |
+ expires: never | |
diff --git i/browser/components/urlbar/private/RemoteSettingsClient.sys.mjs w/browser/components/urlbar/private/RemoteSettingsClient.sys.mjs | |
index d6f4cd2bd8a80..b04b46eefd88a 100644 | |
--- i/browser/components/urlbar/private/RemoteSettingsClient.sys.mjs | |
+++ w/browser/components/urlbar/private/RemoteSettingsClient.sys.mjs | |
@@ -190,6 +190,7 @@ export class RemoteSettingsClient extends BaseFeature { | |
source: "remote-settings", | |
icon: icons.shift(), | |
position: result.position, | |
+ provider: result.advertiser, | |
})); | |
} | |
diff --git i/toolkit/components/nimbus/FeatureManifest.yaml w/toolkit/components/nimbus/FeatureManifest.yaml | |
index b80e06dbf5ef0..4794220faff86 100644 | |
--- i/toolkit/components/nimbus/FeatureManifest.yaml | |
+++ w/toolkit/components/nimbus/FeatureManifest.yaml | |
@@ -139,6 +139,16 @@ urlbar: | |
type: int | |
fallbackPref: browser.urlbar.merino.timeoutMs | |
description: Timeout for Merino fetches (ms) | |
+ quickSuggestExposureProviders: | |
+ type: string | |
+ fallbackPref: browser.urlbar.quicksuggest.exposureProviders | |
+ description: >- | |
+ Comma-separated list of `source.providers` combinations, that are used to determine if an exposure event should be fired. | |
+ quickSuggestDisplayProviderFilter: | |
+ type: string | |
+ fallbackPref: browser.urlbar.quicksuggest.displayProviderFilters | |
+ description: >- | |
+ Comma-separated list of `source.providers` combinations, that are used to filter suggestions from being displayed. | |
quickSuggestAllowPositionInSuggestions: | |
type: boolean | |
fallbackPref: browser.urlbar.quicksuggest.allowPositionInSuggestions |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment