summaryrefslogtreecommitdiffstats
path: root/toolkit/components/normandy/lib/Uptake.sys.mjs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:47:29 +0000
commit0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch)
treea31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /toolkit/components/normandy/lib/Uptake.sys.mjs
parentInitial commit. (diff)
downloadfirefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz
firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/normandy/lib/Uptake.sys.mjs')
-rw-r--r--toolkit/components/normandy/lib/Uptake.sys.mjs67
1 files changed, 67 insertions, 0 deletions
diff --git a/toolkit/components/normandy/lib/Uptake.sys.mjs b/toolkit/components/normandy/lib/Uptake.sys.mjs
new file mode 100644
index 0000000000..73f3eb2068
--- /dev/null
+++ b/toolkit/components/normandy/lib/Uptake.sys.mjs
@@ -0,0 +1,67 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { UptakeTelemetry } from "resource://services-common/uptake-telemetry.sys.mjs";
+
+const COMPONENT = "normandy";
+
+export var Uptake = {
+ // Action uptake
+ ACTION_NETWORK_ERROR: UptakeTelemetry.STATUS.NETWORK_ERROR,
+ ACTION_PRE_EXECUTION_ERROR: UptakeTelemetry.STATUS.CUSTOM_1_ERROR,
+ ACTION_POST_EXECUTION_ERROR: UptakeTelemetry.STATUS.CUSTOM_2_ERROR,
+ ACTION_SERVER_ERROR: UptakeTelemetry.STATUS.SERVER_ERROR,
+ ACTION_SUCCESS: UptakeTelemetry.STATUS.SUCCESS,
+
+ // Per-recipe uptake
+ RECIPE_ACTION_DISABLED: UptakeTelemetry.STATUS.CUSTOM_1_ERROR,
+ RECIPE_DIDNT_MATCH_FILTER: UptakeTelemetry.STATUS.BACKOFF,
+ RECIPE_INCOMPATIBLE_CAPABILITIES: UptakeTelemetry.STATUS.BACKOFF,
+ RECIPE_EXECUTION_ERROR: UptakeTelemetry.STATUS.APPLY_ERROR,
+ RECIPE_FILTER_BROKEN: UptakeTelemetry.STATUS.CONTENT_ERROR,
+ RECIPE_ARGUMENTS_INVALID: UptakeTelemetry.STATUS.CONTENT_ERROR,
+ RECIPE_INVALID_ACTION: UptakeTelemetry.STATUS.DOWNLOAD_ERROR,
+ RECIPE_SUCCESS: UptakeTelemetry.STATUS.SUCCESS,
+ RECIPE_INVALID_SIGNATURE: UptakeTelemetry.STATUS.SIGNATURE_ERROR,
+
+ // Uptake for the runner as a whole
+ RUNNER_NETWORK_ERROR: UptakeTelemetry.STATUS.NETWORK_ERROR,
+ RUNNER_SERVER_ERROR: UptakeTelemetry.STATUS.SERVER_ERROR,
+ RUNNER_SUCCESS: UptakeTelemetry.STATUS.SUCCESS,
+
+ async _report(status, source) {
+ // Telemetry doesn't help us much with error detection, so do some here.
+ if (!status) {
+ throw new Error(
+ `Uptake status is required (got "${JSON.stringify(status)}"`
+ );
+ }
+ if (!source) {
+ throw new Error(
+ `Uptake source is required (got "${JSON.stringify(status)}`
+ );
+ }
+ await UptakeTelemetry.report(COMPONENT, status, {
+ source: `${COMPONENT}/${source}`,
+ });
+ },
+
+ async reportRunner(status) {
+ await Uptake._report(status, "runner");
+ },
+
+ async reportRecipe(recipe, status) {
+ await Uptake._report(status, `recipe/${recipe.id}`);
+ const revisionId = parseInt(recipe.revision_id, 10);
+ Services.telemetry.keyedScalarSet(
+ "normandy.recipe_freshness",
+ recipe.id,
+ revisionId
+ );
+ },
+
+ async reportAction(actionName, status) {
+ await Uptake._report(status, `action/${actionName}`);
+ },
+};