Skip to content

fix(clipboard): report a failed copy to Sentry once, not twice - #2916

Merged
innolope-dev merged 1 commit into
devfrom
fix/21690-clipboard-sentry-once
Sep 2, 2026
Merged

innolope-dev merged 1 commit into
devfrom
fix/21690-clipboard-sentry-once

Conversation

@innolope-dev

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #2911. copyTextToClipboard logged the failure map with console.error right before captureException. captureConsoleIntegration is on for the error level and promotes a non-Error console argument into its own stackless message event, so every copy that failed every path produced two Sentry issues instead of the one the PR intended, and re-created the stackless-message class #2810 cleaned up.

  • Drop the console.error; keep the explicit captureException, which carries the extra.failed context.
  • Pin it: the existing failure test now asserts console.error was never called, which the old test could not catch because it only counted captureException.

Task

TASK-21690 — https://app.notion.com/p/3c283811757981758696de3bc36cc022

Risks / breaking changes

None. No behaviour change for the user; one fewer Sentry event per failed copy.

QA

Unit: src/utils/__tests__/clipboard.utils.test.ts (12 passing locally).

Screenshots: N/A — no UI change.

captureConsoleIntegration promotes every console.error into its own event,
and a non-Error argument arrives as a stackless message. Logging the failure
map right before captureException therefore produced two Sentry issues per
failed copy. Keep the explicit capture, which carries the failed-methods
context, and pin the single event with a console assertion.
@coderabbitai

coderabbitai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Essentials

Run ID: 6b07a16d-bf5c-496f-a717-99f65c778c89

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@vercel

vercel Bot commented Sep 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
peanut-wallet Ready Ready Preview Sep 1, 2026 8:55pm UTC

Request Review

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Code-analysis diff

Painscore total: 7088.8 → 7088.85 (+0.05)
Findings: 0 net (+4 new, -4 resolved)

🆕 New findings (4)

  • medium complexity — src/utils/clipboard.utils.ts — CC 25, MI 64.94, SLOC 98
  • low high-mdd — src/utils/clipboard.utils.ts:20 — copyTextToClipboard: MDD 17.5 (uses across many lines from declarations)
  • low high-dlt — src/utils/clipboard.utils.ts:20 — copyTextToClipboard: DLT 16 (calls 16 distinct functions — high context load)
  • low high-mdd — src/utils/clipboard.utils.ts:96 — beginClipboardCopy: MDD 10.8 (uses across many lines from declarations)

✅ Resolved (4)

  • src/utils/clipboard.utils.ts — CC 25, MI 64.76, SLOC 99
  • src/utils/clipboard.utils.ts:20 — copyTextToClipboard: MDD 18.9 (uses across many lines from declarations)
  • src/utils/clipboard.utils.ts:20 — copyTextToClipboard: DLT 17 (calls 17 distinct functions — high context load)
  • src/utils/clipboard.utils.ts:97 — beginClipboardCopy: MDD 10.8 (uses across many lines from declarations)

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

🧪 UI test report — ✅ all green

Suites

  • ✅ unit: 5066 ran, 0 failed, 0 skipped, 1.7m

📊 Coverage (unit)

metric %
statements 74.5%
branches 60.4%
functions 66.8%
lines 75.6%
⏱ 10 slowest test cases
time test
3.8s src/components/Card/share-asset/__tests__/shareAssetLayout.test.ts › never places two stickers in heavy overlap (broad seed sweep)
1.9s src/components/Profile/views/__tests__/ResidenceChangeModal.test.tsx › saves the declared residence, refetches, and closes
1.9s src/components/Profile/views/__tests__/ResidenceChangeModal.test.tsx › swaps from the server value with no device mirror at all
1.4s src/components/Profile/views/__tests__/ResidenceChangeModal.test.tsx › the change cooldown shows its date and blocks changing to another country, not re-saving
1.3s src/components/Profile/views/__tests__/ResidenceChangeModal.test.tsx › prefers the server value over a stale device mirror
1.2s src/components/Profile/views/__tests__/ResidenceChangeModal.test.tsx › moving to a country in neither slot leaves the second document alone
1.1s src/components/Profile/views/__tests__/ResidenceChangeModal.test.tsx › promoting the second document country swaps the pair instead of dropping one
1.1s src/components/Setup/Views/__tests__/Residence.test.tsx › disables Continue until a country is chosen
1.1s src/app/receipt/[entryId]/pdf/__tests__/receipt-pdf-render.test.ts › produces a real, non-trivial PDF document
1.0s src/components/Setup/Views/__tests__/Residence.test.tsx › reveals the second selector via the multi-doc link
📍 Inline annotations are in the **Unit test report** check above. Coverage artifact: `coverage-unit`. Generated by `.github/workflows/tests.yml`.

@chip-peanut-bot chip-peanut-bot 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.

Chip review — no blocking findings — this is not an approval

The duplicate Sentry event is removed without changing clipboard behavior or losing the structured failure report.

Checked clean

  • Verified the detached HEAD, trusted author, dev base SHA, exact head SHA, and merge base against the supplied inputs.
  • Reviewed all changed lines and surrounding clipboard failure paths: the explicit captureException and failed-method context remain, while the console.error captured by Sentry is removed.
  • Confirmed the new regression assertion covers the removed console event and the browser Sentry configuration captures console error and warn levels.
  • Reviewed correctness, security, adversarial failure scenarios, and slop; copied text remains excluded from telemetry and no user-facing clipboard result changes.
  • CI unit, typecheck, eslint, format, analyze, and policy gates succeeded at the exact head; the focused local Jest run was unavailable because the detached worktree has no node_modules.

Second opinion by moonshotai/kimi-k3: 0 finding(s), marked with the model name. It reads the diff only, so treat its findings as advice.

Third opinion by claude-opus: 0 finding(s), marked with the model name. It answers only product truth, missing tests and the cross-repo contract, so treat its findings as advice.

Exact head: 58225f5ce540 · Context: repo · Took 6m

@innolope-dev
innolope-dev merged commit 43bfe7b into dev Sep 2, 2026
22 of 23 checks passed

This branch was successfully deployed

1 active deployment
Preview — 58225f5c Deployed Sep 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant