Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(replay): Web Vital Breadcrumb Design #76320

Merged
merged 19 commits into from
Sep 3, 2024
Merged

Conversation

c298lee
Copy link
Member

@c298lee c298lee commented Aug 16, 2024

Implements the newest web vital breadcrumbs design: https://www.figma.com/design/bZIT1O93bdxTNbNWDUvCyQ/Specs%3A-Breadcrumbs-%26-Web-Vitals?node-id=277-336&node-type=CANVAS&t=ccSNvPkjFTZWWpDY-0

For web vitals, nodeId was changed to nodeIds, which means there could be multiple elements associated with a breadcrumb item. Highlighting and code snippet extraction were updated to accept multiple nodeIds. When hovering over a web vital breadcrumb, all the associated elements will be highlighted, and when hovering over a selector, only that associated element would be highlighted.

Since the SDK changes have not been merged and released yet, the CLS web vital is currently using web vitals to show what they would look like.

Screen.Recording.2024-08-28.at.7.01.44.PM.mov

Closes #69881

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Aug 16, 2024
Copy link

codecov bot commented Aug 16, 2024

Codecov Report

Attention: Patch coverage is 10.93750% with 114 lines in your changes missing coverage. Please review.

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
.../components/replays/breadcrumbs/breadcrumbItem.tsx 22.00% 39 Missing ⚠️
static/app/utils/replays/highlightNode.tsx 6.45% 29 Missing ⚠️
static/app/utils/replays/extractHtml.tsx 0.00% 23 Missing ⚠️
static/app/utils/replays/replayReader.tsx 7.14% 13 Missing ⚠️
...tatic/app/utils/replays/hooks/useCrumbHandlers.tsx 0.00% 7 Missing ⚠️
static/app/utils/replays/types.tsx 0.00% 1 Missing ⚠️
...views/replays/detail/breadcrumbs/breadcrumbRow.tsx 0.00% 1 Missing ⚠️
...p/views/replays/detail/useVirtualizedInspector.tsx 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master   #76320      +/-   ##
==========================================
+ Coverage   78.15%   78.22%   +0.07%     
==========================================
  Files        6910     6895      -15     
  Lines      307183   306364     -819     
  Branches    50351    50225     -126     
==========================================
- Hits       240073   239655     -418     
+ Misses      60755    60323     -432     
- Partials     6355     6386      +31     

Comment on lines 230 to 243
// TODO: remove test CLS data once SDK is merged and updated
const clsFrame = {
...frame,
data: {
value: frame.data.value,
size: frame.data.size,
rating: frame.data.rating,
nodeIds: [frame.data.nodeIds, 333, 870],
attributes: [
{value: 0.0123, nodeIds: frame.data.nodeIds ?? [93]},
{value: 0.0345, nodeIds: [333, 870]},
],
},
};
Copy link
Member Author

Choose a reason for hiding this comment

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

to be removed once the sdk is updated

Copy link
Member

Choose a reason for hiding this comment

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

Are older sdk versions sending data in this format? if so we'd need to continue to support it as there are customers out there on that older version

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, the older format is supported too! This is just to demo what it would look like with the newer format since we don't have that yet, with the older format, it'll look more similar to the other web vitals (eg. no layout shifts, only element and value).

@c298lee c298lee marked this pull request as ready for review August 28, 2024 23:09
@c298lee c298lee requested a review from a team as a code owner August 28, 2024 23:09
@c298lee c298lee requested a review from Jesse-Box August 28, 2024 23:35

type RemoveHighlightParams =
| {
nodeId: number;
nodeIds: number[];
Copy link
Member

Choose a reason for hiding this comment

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

Will the new sdk version break the UI in self hosted sentry sending data on this old version/format?

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this method isn't called directly with data from the sdk, instead something like static/app/utils/replays/hooks/useCrumbHandlers.tsx is fixing the data first with code like this, so we should be good.:

  if ('nodeId' in data) {
    return {nodeIds: [data.nodeId], annotation: record.data.label};
  }
  if ('nodeIds' in data) {
    return {nodeIds: data.nodeIds, annotation: record.data.label};
  }

Copy link
Member

Choose a reason for hiding this comment

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

a better example is: getNodeIds in static/app/utils/replays/types.tsx

@@ -38,7 +33,6 @@ export default function useVirtualizedInspector({cache, listRef, expandPathsRef}
}
expandPathsRef.current?.set(index, rowState);
handleDimensionChange(index);
event.stopPropagation();
Copy link
Member

Choose a reason for hiding this comment

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

Does this line need to move up into the onClick callbacks themselves? it should be moved somewhere i think

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated into onClick!

Comment on lines +523 to +535
const SelectorButton = styled(Button)`
background: none;
border: none;
padding: 0 2px;
border-radius: 2px;
font-weight: ${p => p.theme.fontWeightNormal};
box-shadow: none;
font-size: ${p => p.theme.fontSizeSmall};
color: ${p => p.theme.subText};
margin: 0 ${space(0.5)};
height: auto;
min-height: auto;
`;
Copy link
Member

Choose a reason for hiding this comment

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

might be able to get away with something like <Button size="zero" borderless>...</Button> instead of having to write so much new css

Copy link
Member Author

Choose a reason for hiding this comment

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

we could do that! would look like this instead:
image

Copy link
Member

Choose a reason for hiding this comment

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

either way i don't mind!

Co-authored-by: Ryan Albrecht <ryan.albrecht@sentry.io>
Copy link
Member

@ryan953 ryan953 left a comment

Choose a reason for hiding this comment

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

some nits, but nothing important or urgent.

Copy link

codecov bot commented Sep 3, 2024

Bundle Report

Changes will increase total bundle size by 4.65kB ⬆️

Bundle name Size Change
app-webpack-bundle-array-push 30.1MB 4.65kB ⬆️

@c298lee c298lee requested a review from billyvg September 3, 2024 19:36

const renderCodeSnippet = useCallback(() => {
return (
(!isSpanFrame(frame) || (isSpanFrame(frame) && !isWebVitalFrame(frame))) &&
Copy link
Member

Choose a reason for hiding this comment

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

nit: Isn't the second isSpanFrame() check redundant? e.g. not a OR (a AND b) == not A OR b

Copy link
Member Author

Choose a reason for hiding this comment

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

great catch! boolean logic hurts my brain :(

@c298lee c298lee merged commit ab2945b into master Sep 3, 2024
42 of 43 checks passed
@c298lee c298lee deleted the cl/web-vital-breadcrumb branch September 3, 2024 21:26
@github-actions github-actions bot locked and limited conversation to collaborators Sep 19, 2024
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.

[Epic] Replay x Web Vitals
5 participants