Skip to content

refactor: getMetricsDispatcher#sendCommandEvent should not rely on command names #12029

@vicb

Description

@vicb

Should probably be tackled with others related issues, see #12197

We have this code:

if (properties.command?.startsWith("wrangler login")) {
properties.command = "wrangler login";
}
if (
properties.command === "wrangler telemetry disable" ||
properties.command === "wrangler metrics disable"
) {
return;
}
if (
properties.command === "wrangler deploy" ||
properties.command === "wrangler dev" ||
// for testing purposes
properties.command === "wrangler docs"
) {
printMetricsBanner();
}

It is inconsistent and brittle (i.e. what if "wrangler" changes or commands change ?

Commands behavior should be defined in... command#behaviour instead

behaviour: {
printBanner: (args) => !args.json,
},
args: {

/cc @MattieTK

Metadata

Metadata

Assignees

Labels

wranglerRelating to the Wrangler CLI tool

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions