commit 45400a1060cccb320da95bd77fc5000fb3169039
parent 5133ef8effde727ac7afb1d26e36d63b13809945
Author: Mark Banner <standard8@mozilla.com>
Date: Thu, 30 Oct 2025 08:44:44 +0000
Bug 1997161 - Stop saving the telemetry ID in search engine settings files. r=mcheang
The telemetry ID is only used for configuration based search engines, but they have a toJSON which skips saving it.
Differential Revision: https://phabricator.services.mozilla.com/D270570
Diffstat:
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/toolkit/components/search/ConfigSearchEngine.sys.mjs b/toolkit/components/search/ConfigSearchEngine.sys.mjs
@@ -434,6 +434,14 @@ export class ConfigSearchEngine extends SearchEngine {
#partnerCode = "";
/**
+ * The telemetry id to use for this engine for legacy telemetry. This is
+ * deprecated and should not be used for new telemetry.
+ *
+ * @type {string}
+ */
+ #telemetryId;
+
+ /**
* @param {object} options
* The options for this search engine.
* @param {SearchEngineDefinition} options.config
@@ -552,6 +560,26 @@ export class ConfigSearchEngine extends SearchEngine {
}
/**
+ * Returns the appropriate identifier to use for telemetry. It is based on
+ * the following order:
+ *
+ * - telemetryId: The telemetry id from the configuration, or derived from
+ * the WebExtension name.
+ * - other-<name>: The engine name prefixed by `other-` for non-config-engines.
+ *
+ * @returns {string}
+ * @deprecated This should not be used for new telemetry. It is a combined
+ * field that contains multiple values. Report separate
+ * id/partner_code/other fields instead.
+ */
+ get telemetryId() {
+ if (this.getAttr("overriddenBy")) {
+ return this.#telemetryId + "-addon";
+ }
+ return this.#telemetryId;
+ }
+
+ /**
* Returns the icon URL for the search engine closest to the preferred width.
*
* @param {number} preferredWidth
@@ -653,7 +681,7 @@ export class ConfigSearchEngine extends SearchEngine {
*/
#init(engineConfig) {
this._orderHint = engineConfig.orderHint;
- this._telemetryId = engineConfig.identifier;
+ this.#telemetryId = engineConfig.identifier;
this.#isGeneralPurposeSearchEngine =
engineConfig.classification == lazy.SearchEngineClassification.GENERAL;
@@ -662,7 +690,7 @@ export class ConfigSearchEngine extends SearchEngine {
}
if (engineConfig.telemetrySuffix) {
- this._telemetryId += `-${engineConfig.telemetrySuffix}`;
+ this.#telemetryId += `-${engineConfig.telemetrySuffix}`;
}
if (engineConfig.clickUrl) {
diff --git a/toolkit/components/search/SearchEngine.sys.mjs b/toolkit/components/search/SearchEngine.sys.mjs
@@ -569,8 +569,6 @@ export class SearchEngine {
_queryCharset = null;
// The order hint from the configuration (if any).
_orderHint = null;
- // The telemetry id from the configuration (if any).
- _telemetryId = null;
// Set to true once the engine has been added to the store, and the initial
// notification sent. This allows to skip sending notifications during
// initialization.
@@ -1081,7 +1079,6 @@ export class SearchEngine {
"_metaData",
"_urls",
"_orderHint",
- "_telemetryId",
"_filePath",
"_definedAliases",
];
@@ -1202,11 +1199,7 @@ export class SearchEngine {
* id/partner_code/other fields instead.
*/
get telemetryId() {
- let telemetryId = this._telemetryId || `other-${this.name}`;
- if (this.getAttr("overriddenBy")) {
- return telemetryId + "-addon";
- }
- return telemetryId;
+ return `other-${this.name}`;
}
get hidden() {