commit de5f8a258fdb0ccec090e36be3737704221612ff
parent 7f7988f472ba2fc94968b79413bdafe44f454f6d
Author: Mike Conley <mconley@mozilla.com>
Date: Mon, 20 Oct 2025 16:27:30 +0000
Bug 1992486 - Make ./mach newtab channel-metrics-diff diff against the local versions of metrics.yaml and pings.yaml. r=pdahiya,home-newtab-reviewers,thecount
This way, we can add new metrics and pings, and update the runtime registration files
all in one shot, rather than waiting for the metrics and pings to merge to main.
Differential Revision: https://phabricator.services.mozilla.com/D267484
Diffstat:
1 file changed, 12 insertions(+), 27 deletions(-)
diff --git a/browser/extensions/newtab/mach_commands.py b/browser/extensions/newtab/mach_commands.py
@@ -469,19 +469,19 @@ def display_report(report, details=None):
@SubCommand(
"newtab",
"channel-metrics-diff",
- description="Compares and produces a JSON diff between NewTab Nightly metrics and pings, using the specified channel.",
+ description="Compares and produces a JSON diff between local NewTab metrics and pings, and the specified channel.",
virtualenv_name="newtab",
)
@CommandArgument(
"--channel",
- default="local",
- choices=["beta", "release", "local"],
+ default="release",
+ choices=["beta", "release"],
help="Which channel should be used to compare NewTab metrics and pings YAML",
)
def channel_metrics_diff(command_context, channel):
"""
Fetch main and a comparison branch (beta or release) metrics.yaml, compute only the new metrics,
- and process as before. To run use: ./mach newtab channel-metrics-diff --channel [beta|release|local]
+ and process as before. To run use: ./mach newtab channel-metrics-diff --channel [beta|release]
This will print YAML-formatted output to stdout, showing the differences in newtab metrics and pings.
"""
METRICS_LOCAL_YAML_PATH = Path("browser", "components", "newtab", "metrics.yaml")
@@ -509,29 +509,14 @@ def channel_metrics_diff(command_context, channel):
# Base URL for fetching YAML files from GitHub
GITHUB_URL_TEMPLATE = "https://raw.githubusercontent.com/mozilla-firefox/firefox/refs/heads/{branch}/browser/components/newtab/{yaml}"
- # 1. Fetch both main and comparison metrics and pings YAMLs and determine which branch to compare against
- if channel == "local":
- main_metrics_yaml = yaml.safe_load(open(METRICS_LOCAL_YAML_PATH))
- compare_metrics_yaml = fetch_yaml(
- GITHUB_URL_TEMPLATE.format(branch="main", yaml="metrics.yaml")
- )
- main_pings_yaml = yaml.safe_load(open(PINGS_LOCAL_YAML_PATH))
- compare_pings_yaml = fetch_yaml(
- GITHUB_URL_TEMPLATE.format(branch="main", yaml="pings.yaml")
- )
- else:
- main_metrics_yaml = fetch_yaml(
- GITHUB_URL_TEMPLATE.format(branch="main", yaml="metrics.yaml")
- )
- compare_metrics_yaml = fetch_yaml(
- GITHUB_URL_TEMPLATE.format(branch=channel, yaml="metrics.yaml")
- )
- main_pings_yaml = fetch_yaml(
- GITHUB_URL_TEMPLATE.format(branch="main", yaml="pings.yaml")
- )
- compare_pings_yaml = fetch_yaml(
- GITHUB_URL_TEMPLATE.format(branch=channel, yaml="pings.yaml")
- )
+ main_metrics_yaml = yaml.safe_load(open(METRICS_LOCAL_YAML_PATH))
+ compare_metrics_yaml = fetch_yaml(
+ GITHUB_URL_TEMPLATE.format(branch=channel, yaml="metrics.yaml")
+ )
+ main_pings_yaml = yaml.safe_load(open(PINGS_LOCAL_YAML_PATH))
+ compare_pings_yaml = fetch_yaml(
+ GITHUB_URL_TEMPLATE.format(branch=channel, yaml="pings.yaml")
+ )
with tempfile.TemporaryDirectory() as temp_dir:
temp_dir_path = Path(temp_dir)