Skip to content

Commit

Permalink
normalise all args
Browse files Browse the repository at this point in the history
  • Loading branch information
emily-shen committed Nov 29, 2024
1 parent 6df3c69 commit f2b0b40
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
13 changes: 5 additions & 8 deletions packages/wrangler/src/__tests__/metrics.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,15 +207,10 @@ describe("metrics", () => {
argsCombination: "j, search, xGradualRollouts, xJsonConfig, xVersions",
command: "wrangler docs",
args: {
"experimental-json-config": true,
xJsonConfig: true,
j: true,
experimentalJsonConfig: true,
"experimental-versions": true,
"x-versions": true,
"experimental-gradual-rollouts": true,
xVersions: true,
experimentalGradualRollouts: true,
experimentalVersions: true,
xGradualRollouts: true,
search: ["<REDACTED>"],
},
};
Expand Down Expand Up @@ -448,13 +443,15 @@ describe("metrics", () => {
default: false,
array: ["beep", "boop"],
secretArray: ["beep", "boop"],
// Note how
"secret-array": ["beep", "boop"],
number: 42,
string: "secret",
secretString: "secret",
};

const redacted = redactArgValues(args, ["string", "array"]);
expect(redacted).toMatchObject({
expect(redacted).toEqual({
default: false,
array: ["beep", "boop"],
secretArray: ["<REDACTED>", "<REDACTED>"],
Expand Down
3 changes: 2 additions & 1 deletion packages/wrangler/src/metrics/metrics-dispatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ export const redactArgValues = (
) => {
const result: Record<string, unknown> = {};

for (const [key, value] of Object.entries(args)) {
for (const [k, value] of Object.entries(args)) {
const key = normalise(k);
if (exclude.has(key)) {
continue;
}
Expand Down

0 comments on commit f2b0b40

Please sign in to comment.