Loading browser/components/search/SearchSERPTelemetry.sys.mjs +88 −2 Original line number Original line Diff line number Diff line Loading @@ -87,6 +87,87 @@ const AD_COMPONENTS = [ SearchSERPTelemetryUtils.COMPONENTS.AD_UNCATEGORIZED, SearchSERPTelemetryUtils.COMPONENTS.AD_UNCATEGORIZED, ]; ]; /** * @typedef {object} FollowOnCookies * * @property {string} codeParamName * The parameter name within the cookie. * @property {string} extraCodeParamName * The query parameter name in the URL that indicates this might be a * follow-on search. * @property {string[]} extraCodePrefixes * Possible values for the query parameter in the URL that indicates this * might be a follow-on search. * @property {string} host * The hostname on which the cookie is stored. * @property {string} name * The name of the cookie to check. */ /** * @typedef {object} SignedInCookies * * @property {string} host * The host associated with a given cookie. * @property {string} name * The name associated with a given cookie. */ /** * @typedef {object} ShoppingTab * * @property {boolean} inspectRegexpInSERP * Whether the regexp should be used against hrefs the selector matches * against. * @property {RegExp} regexp * The regular expression to match against a possible shopping tab. Must be * provided if using this feature. * @property {string} selector * The elements on the page to inspect for the shopping tab. Should be anchor * elements. */ /** * @typedef {object} ProviderInfo * * @property {string} codeParamName * The name of the query parameter for the partner code. * @property {object[]} components * An array of components that could be on the SERP. * @property {{key:string, value: string}} defaultPageQueryParam * Default page query parameter. * @property {string[]} expectedOrganicCodes * An array of partner codes to match against the parameters in the url. * Matching these codes will report the SERP as organic:none which means the * user has done a search through the search engine's website rather than * through a SAP. * @property {RegExp[]} extraAdServersRegexps * An array of regular expressions that match URLs of potential ad servers. * @property {FollowOnCookies[]} followOnCookies * An array of cookie details that are used to identify follow-on searches. * @property {string[]} followOnParamNames * An array of query parameter names that are used when a follow-on search * occurs. * @property {boolean} isSPA * Whether the provider is a single page app. * @property {string[]} organicCodes * An array of partner codes to match against the parameters in the url. * Matching these codes will report the SERP as organic:<partner code>, which * means the search was performed organically rather than through a SAP. * @property {string[]} queryParamNames * An array of query parameters that may be used for the user's search string. * @property {SignedInCookies[]} signedInCookies * An array of cookie details that are used to determine whether a client is * signed in to a provider's account. * @property {ShoppingTab} shoppingTab * Shopping page parameter. * @property {string[]} taggedCodes * An array of partner codes to match against the parameters in the url. * Matching one of these codes will report the SERP as tagged. * @property {string} telemetryId * The telemetry identifier for the provider. */ /** /** * TelemetryHandler is the main class handling Search Engine Result Page (SERP) * TelemetryHandler is the main class handling Search Engine Result Page (SERP) * telemetry. It primarily deals with tracking of what pages are loaded into tabs. * telemetry. It primarily deals with tracking of what pages are loaded into tabs. Loading Loading @@ -888,8 +969,10 @@ class TelemetryHandler { /** /** * Searches for provider information for a given url. * Searches for provider information for a given url. * * * @param {string} url The url to match for a provider. * @param {string} url * @returns {Array | null} Returns an array of provider name and the provider information. * The url to match for a provider. * @returns {?ProviderInfo} * Returns a provider or undefined if no provider was found for the url. */ */ _getProviderInfoForURL(url) { _getProviderInfoForURL(url) { return this._searchProviderInfo.find(info => return this._searchProviderInfo.find(info => Loading Loading @@ -1140,6 +1223,9 @@ class TelemetryHandler { * when ads detected and when they are selected. * when ads detected and when they are selected. */ */ class ContentHandler { class ContentHandler { /** @type {ProviderInfo[]} */ _searchProviderInfo = null; /** /** * Constructor. * Constructor. * * Loading Loading
browser/components/search/SearchSERPTelemetry.sys.mjs +88 −2 Original line number Original line Diff line number Diff line Loading @@ -87,6 +87,87 @@ const AD_COMPONENTS = [ SearchSERPTelemetryUtils.COMPONENTS.AD_UNCATEGORIZED, SearchSERPTelemetryUtils.COMPONENTS.AD_UNCATEGORIZED, ]; ]; /** * @typedef {object} FollowOnCookies * * @property {string} codeParamName * The parameter name within the cookie. * @property {string} extraCodeParamName * The query parameter name in the URL that indicates this might be a * follow-on search. * @property {string[]} extraCodePrefixes * Possible values for the query parameter in the URL that indicates this * might be a follow-on search. * @property {string} host * The hostname on which the cookie is stored. * @property {string} name * The name of the cookie to check. */ /** * @typedef {object} SignedInCookies * * @property {string} host * The host associated with a given cookie. * @property {string} name * The name associated with a given cookie. */ /** * @typedef {object} ShoppingTab * * @property {boolean} inspectRegexpInSERP * Whether the regexp should be used against hrefs the selector matches * against. * @property {RegExp} regexp * The regular expression to match against a possible shopping tab. Must be * provided if using this feature. * @property {string} selector * The elements on the page to inspect for the shopping tab. Should be anchor * elements. */ /** * @typedef {object} ProviderInfo * * @property {string} codeParamName * The name of the query parameter for the partner code. * @property {object[]} components * An array of components that could be on the SERP. * @property {{key:string, value: string}} defaultPageQueryParam * Default page query parameter. * @property {string[]} expectedOrganicCodes * An array of partner codes to match against the parameters in the url. * Matching these codes will report the SERP as organic:none which means the * user has done a search through the search engine's website rather than * through a SAP. * @property {RegExp[]} extraAdServersRegexps * An array of regular expressions that match URLs of potential ad servers. * @property {FollowOnCookies[]} followOnCookies * An array of cookie details that are used to identify follow-on searches. * @property {string[]} followOnParamNames * An array of query parameter names that are used when a follow-on search * occurs. * @property {boolean} isSPA * Whether the provider is a single page app. * @property {string[]} organicCodes * An array of partner codes to match against the parameters in the url. * Matching these codes will report the SERP as organic:<partner code>, which * means the search was performed organically rather than through a SAP. * @property {string[]} queryParamNames * An array of query parameters that may be used for the user's search string. * @property {SignedInCookies[]} signedInCookies * An array of cookie details that are used to determine whether a client is * signed in to a provider's account. * @property {ShoppingTab} shoppingTab * Shopping page parameter. * @property {string[]} taggedCodes * An array of partner codes to match against the parameters in the url. * Matching one of these codes will report the SERP as tagged. * @property {string} telemetryId * The telemetry identifier for the provider. */ /** /** * TelemetryHandler is the main class handling Search Engine Result Page (SERP) * TelemetryHandler is the main class handling Search Engine Result Page (SERP) * telemetry. It primarily deals with tracking of what pages are loaded into tabs. * telemetry. It primarily deals with tracking of what pages are loaded into tabs. Loading Loading @@ -888,8 +969,10 @@ class TelemetryHandler { /** /** * Searches for provider information for a given url. * Searches for provider information for a given url. * * * @param {string} url The url to match for a provider. * @param {string} url * @returns {Array | null} Returns an array of provider name and the provider information. * The url to match for a provider. * @returns {?ProviderInfo} * Returns a provider or undefined if no provider was found for the url. */ */ _getProviderInfoForURL(url) { _getProviderInfoForURL(url) { return this._searchProviderInfo.find(info => return this._searchProviderInfo.find(info => Loading Loading @@ -1140,6 +1223,9 @@ class TelemetryHandler { * when ads detected and when they are selected. * when ads detected and when they are selected. */ */ class ContentHandler { class ContentHandler { /** @type {ProviderInfo[]} */ _searchProviderInfo = null; /** /** * Constructor. * Constructor. * * Loading