Skip to content

[wrangler] Send login user metric when --scopes is provided#14299

Merged
petebacondarwin merged 3 commits into
mainfrom
pbacondarwin/wrangler-login-scopes-metrics
Jun 15, 2026
Merged

[wrangler] Send login user metric when --scopes is provided#14299
petebacondarwin merged 3 commits into
mainfrom
pbacondarwin/wrangler-login-scopes-metrics

Conversation

@petebacondarwin

@petebacondarwin petebacondarwin commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Wrangler's login command was already reporting the login user telemetry event when run without --scopes, but the scoped login path returned early before the event could be sent. Both paths now share a single login(...) call site and a single sendMetricsEvent(...) call, so successful scoped logins are counted alongside unscoped ones.

This was spotted by an automated review on #14064 as a pre-existing gap, and split out into its own PR.


  • Tests
    • Tests included/updated
  • Public documentation
    • Documentation not necessary because: internal telemetry-only change with no user-facing behaviour change.

Open in Devin Review

`wrangler login` was already reporting the `login user` event when called
without `--scopes`, but the scoped login path returned early before the
event could be sent. Both paths now share a single `login(...)` and
metrics call site, so successful scoped logins are counted alongside
unscoped ones.

Adds a regression test that spies on the metrics module and asserts that
`sendMetricsEvent("login user", ...)` is invoked after a successful
`wrangler login --scopes account:read`.
@changeset-bot

changeset-bot Bot commented Jun 15, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 14eae06

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Jun 15, 2026
@workers-devprod workers-devprod requested review from a team and NuroDev and removed request for a team June 15, 2026 08:08
@workers-devprod

workers-devprod commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@ask-bonk

ask-bonk Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

This confirms the refactor is behaviorally equivalent. When scopes is undefined, withDefaultScopes falls back to DefaultScopeKeys — identical to the previous unscoped path which passed no scopes key. The scoped path passes args.scopes as before. The metrics event is now sent for both paths.

Let me verify the login() return value isn't being relied upon (it returns a boolean indicating success). Previously the scoped path early-returned regardless of the boolean too, so no behavior change there.

Let me also check whether login() can return false (failure) — in which case sending the metric "alongside successful logins" might be inaccurate. But this matches existing unscoped behavior, so it's not a regression introduced by this PR.

Now let me double-check the test assertion sendMetrics: undefined. The handler passes config.send_metrics. In the test, no config sets send_metrics, so it's undefined. That's consistent.

The change is correct, minimal, behaviorally equivalent for the unscoped path, fixes the gap for the scoped path, includes a regression test and a changeset. No logic bugs, security issues, or backward-compat violations.

LGTM

github run

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

@pkg-pr-new

pkg-pr-new Bot commented Jun 15, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14299

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14299

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14299

miniflare

npm i https://pkg.pr.new/miniflare@14299

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14299

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14299

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14299

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14299

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14299

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14299

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14299

wrangler

npm i https://pkg.pr.new/wrangler@14299

commit: 14eae06

devin-ai-integration[bot]

This comment was marked as resolved.

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk Jun 15, 2026
@petebacondarwin petebacondarwin merged commit 035917f into main Jun 15, 2026
64 checks passed
@petebacondarwin petebacondarwin deleted the pbacondarwin/wrangler-login-scopes-metrics branch June 15, 2026 12:30
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk Jun 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants