Skip to content

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

@vicb

Description

@vicb

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

Labels

wranglerRelating to the Wrangler CLI tool

Type

No type

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions