diff --git a/packages/wrangler/src/__tests__/metrics.test.ts b/packages/wrangler/src/__tests__/metrics.test.ts index 5d867d24a5ca..ffccf2e75a9a 100644 --- a/packages/wrangler/src/__tests__/metrics.test.ts +++ b/packages/wrangler/src/__tests__/metrics.test.ts @@ -359,6 +359,20 @@ describe("metrics", () => { expect(std.debug).toContain('isWorkersCI":true'); }); + it("should not send arguments with wrangler login", async () => { + const requests = mockMetricRequest(); + + await expect( + runWrangler("login username password") + ).rejects.toThrowErrorMatchingInlineSnapshot( + `[Error: Unknown arguments: username, password]` + ); + + expect(requests.count).toBe(2); + expect(std.debug).toContain('"argsCombination":""'); + expect(std.debug).toContain('"command":"wrangler login"'); + }); + it("should include args provided by the user", async () => { const requests = mockMetricRequest(); diff --git a/packages/wrangler/src/__tests__/vitest.setup.ts b/packages/wrangler/src/__tests__/vitest.setup.ts index 19ba6cceefd2..a5edb90b087a 100644 --- a/packages/wrangler/src/__tests__/vitest.setup.ts +++ b/packages/wrangler/src/__tests__/vitest.setup.ts @@ -135,8 +135,9 @@ vi.mock("../user/generate-auth-url", () => { }; }); -vi.mock("../is-ci", () => { - return { CI: { isCI: vi.fn().mockImplementation(() => false) } }; +vi.mock("../is-ci", async (importOriginal) => { + const original = await importOriginal(); + return { ...original, CI: { isCI: vi.fn().mockImplementation(() => false) } }; }); vi.mock("../user/generate-random-state", () => { diff --git a/packages/wrangler/src/metrics/metrics-dispatcher.ts b/packages/wrangler/src/metrics/metrics-dispatcher.ts index be06f4326da6..53f2e32b3a00 100644 --- a/packages/wrangler/src/metrics/metrics-dispatcher.ts +++ b/packages/wrangler/src/metrics/metrics-dispatcher.ts @@ -77,6 +77,9 @@ export function getMetricsDispatcher(options: MetricsConfigOptions) { argv?: string[] ) { try { + if (properties.command?.startsWith("wrangler login")) { + properties.command = "wrangler login"; + } if ( properties.command === "wrangler telemetry disable" || properties.command === "wrangler metrics disable"