Skip to content

feat(issues): Add copy breadcrumbs to clipboard button#105007

Merged
scttcper merged 6 commits intomasterfrom
scttcper/copy-breadcrumbs-to-clipboard
Dec 30, 2025
Merged

feat(issues): Add copy breadcrumbs to clipboard button#105007
scttcper merged 6 commits intomasterfrom
scttcper/copy-breadcrumbs-to-clipboard

Conversation

@scttcper
Copy link
Copy Markdown
Member

@scttcper scttcper commented Dec 15, 2025

adds copy as plaintext or markdown

text:

Timestamp: 2025-12-15T23:38:34.107Z
Type: error
Category: exception
Level: error
Data: {"type":"React ErrorBoundary Error","value":"The data does not contain any plottable values."}

markdown:

| Timestamp | Type | Category | Level | Message | Data |
|-----------|------|----------|-------|---------|------|
| 2025-12-15T23:38:34.107Z | error | exception | error |  | {"type":"React ErrorBoundary Error","value":"The data does not contain any plottable values."} |

markdown preview:

Timestamp Type Category Level Message Data
2025-12-15T23:38:34.107Z error exception error {"type":"React ErrorBoundary Error","value":"The data does not contain any plottable values."}

fixes #92536

picked two formats, markdown and plain text

plain text:
```
Timestamp: 2025-12-15T23:08:17.007Z
Type: error
Category: exception
Level: error
Data: {"type":"React ErrorBoundary Error","value":"The data does not contain any plottable values."}
```

markdown:
```markdown
| Timestamp | Type | Category | Level | Message | Data |
|-----------|------|----------|-------|---------|------|
| 2025-12-15T23:08:17.007Z | error | exception | error |  | {"type":"React ErrorBoundary Error","value":"The data does not contain any plottable values."} |
```
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Dec 15, 2025
@scttcper scttcper changed the title feat(issues): Add copy to clipboard button feat(issues): Add copy breadcrumbs to clipboard button Dec 15, 2025
@scttcper scttcper requested a review from a team December 15, 2025 23:40
control: 'copy',
value: 'markdown',
organization,
});
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.

Bug: Analytics event incorrectly attributes data section actions to drawer

The CopyBreadcrumbsDropdown component always uses 'breadcrumbs.drawer.action' as the analytics event name, but it's also used in breadcrumbsDataSection.tsx which is not inside a drawer. Other actions in the data section use the 'breadcrumbs.issue_details.*' prefix pattern (e.g., breadcrumbs.issue_details.change_time_display). This will cause copy actions from the main breadcrumbs section to be incorrectly attributed to the drawer in analytics data.

Additional Locations (1)

Fix in Cursor Fix in Web

value: 'markdown',
organization,
});
}, [copy, breadcrumbs, organization]);
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.

Bug: Analytics tracked before copy operation completes or succeeds

The copy function from useCopyToClipboard returns a Promise, but trackAnalytics is called synchronously immediately after invoking copy() without awaiting the result. This means analytics events are recorded even when the clipboard operation fails (e.g., due to permission denial or browser restrictions). Other components in the codebase properly chain .then() after copy() to handle success. The analytics call needs to be placed inside a .then() callback or the function made async with await.

Additional Locations (1)

Fix in Cursor Fix in Web

@roggenkemper
Copy link
Copy Markdown
Member

roggenkemper commented Dec 30, 2025

work well - not sure if just local but when i click the copy button then select text/markdown, the tooltip for the original button reappears

Screen.Recording.2025-12-30.at.1.29.54.PM.mov

Comment on lines +42 to +44
if (crumb.breadcrumb.timestamp) {
lines.push(`Timestamp: ${new Date(crumb.breadcrumb.timestamp).toISOString()}`);
}
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.

Bug: new Date(crumb.breadcrumb.timestamp) can create an invalid date if the timestamp is a malformed string. Calling .toISOString() on it will throw an exception.
Severity: CRITICAL | Confidence: High

🔍 Detailed Analysis

The breadcrumb.timestamp field is an optional string and is not guaranteed to be a valid ISO date format. The code creates a Date object from this timestamp and immediately calls .toISOString() without validation. If timestamp is a truthy but malformed string (e.g., "invalid-date"), new Date() returns an Invalid Date object. Calling .toISOString() on an Invalid Date object throws a TypeError, which will crash the copy functionality and prevent the user from copying breadcrumbs.

💡 Suggested Fix

Before calling .toISOString(), validate the Date object using the existing isValidDate() utility function. This follows the established pattern already used in breadcrumbsTimeline.tsx to handle potentially invalid timestamps.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: static/app/components/events/breadcrumbs/copyBreadcrumbs.tsx#L42-L44

Potential issue: The `breadcrumb.timestamp` field is an optional string and is not
guaranteed to be a valid ISO date format. The code creates a `Date` object from this
timestamp and immediately calls `.toISOString()` without validation. If `timestamp` is a
truthy but malformed string (e.g., "invalid-date"), `new Date()` returns an `Invalid
Date` object. Calling `.toISOString()` on an `Invalid Date` object throws a `TypeError`,
which will crash the copy functionality and prevent the user from copying breadcrumbs.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8042703

@scttcper scttcper enabled auto-merge (squash) December 30, 2025 19:26
@scttcper scttcper merged commit 8645355 into master Dec 30, 2025
61 of 63 checks passed
@scttcper scttcper deleted the scttcper/copy-breadcrumbs-to-clipboard branch December 30, 2025 19:51
@github-actions github-actions bot locked and limited conversation to collaborators Jan 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not possible to copy all event breadcrumbs from the UI

4 participants