feat(issues): Add copy breadcrumbs to clipboard button#105007
feat(issues): Add copy breadcrumbs to clipboard button#105007
Conversation
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."} |
```
| control: 'copy', | ||
| value: 'markdown', | ||
| organization, | ||
| }); |
There was a problem hiding this comment.
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)
| value: 'markdown', | ||
| organization, | ||
| }); | ||
| }, [copy, breadcrumbs, organization]); |
There was a problem hiding this comment.
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)
|
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 |
| if (crumb.breadcrumb.timestamp) { | ||
| lines.push(`Timestamp: ${new Date(crumb.breadcrumb.timestamp).toISOString()}`); | ||
| } |
There was a problem hiding this comment.
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
adds copy as plaintext or markdown
text:
markdown:
markdown preview:
fixes #92536