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): Use SDK value for LCP #44868

Merged
merged 6 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions static/app/components/replays/breadcrumbs/utils.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import {Tooltip} from 'sentry/components/tooltip';
import {IconWarning} from 'sentry/icons';
import {t} from 'sentry/locale';
import {BreadcrumbType, Crumb} from 'sentry/types/breadcrumbs';

/**
* Generate breadcrumb descriptions based on type
*/
export function getDescription(crumb: Crumb, startTimestampMs?: number) {
export function getDescription(crumb: Crumb) {
if (typeof crumb.data === 'object' && crumb.data !== null && 'action' in crumb.data) {
switch (crumb.data.action) {
case 'largest-contentful-paint':
if (crumb.timestamp && startTimestampMs) {
return `${new Date(crumb.timestamp).getTime() - startTimestampMs}ms`;
if (crumb.data?.value !== undefined) {
return `${Math.round(crumb.data.value)}ms`;
Copy link
Member Author

Choose a reason for hiding this comment

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

just float things

}
if (crumb.data?.duration !== undefined) {
// this means user is using an old SDK where LCP values are not
// always correct. Prompt them to upgrade
return (
<Tooltip
title={t(
'This replay uses a SDK version that is subject to inaccurate LCP values. Please upgrade to the latest version for best results if you have not already done so.'
)}
>
<IconWarning />
</Tooltip>
);
Comment on lines +16 to +27
Copy link
Member Author

Choose a reason for hiding this comment

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

This is new since last PR -- ss in PR desc.

}
break;
default:
Expand Down Expand Up @@ -50,6 +66,6 @@ export function getTitle(crumb: Crumb) {
/**
* Generate breadcrumb title + descriptions
*/
export function getDetails(crumb: Crumb, startTimestampMs?: number) {
return {title: getTitle(crumb), description: getDescription(crumb, startTimestampMs)};
export function getDetails(crumb: Crumb) {
return {title: getTitle(crumb), description: getDescription(crumb)};
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import styled from '@emotion/styled';
import BreadcrumbIcon from 'sentry/components/events/interfaces/breadcrumbs/breadcrumb/type/icon';
import {PanelItem} from 'sentry/components/panels';
import {getDetails} from 'sentry/components/replays/breadcrumbs/utils';
import {Tooltip} from 'sentry/components/tooltip';
import {SVGIconProps} from 'sentry/icons/svgIcon';
import {space} from 'sentry/styles/space';
import type {Crumb} from 'sentry/types/breadcrumbs';
Expand Down Expand Up @@ -32,7 +33,7 @@ function BreadcrumbItem({
onMouseLeave,
onClick,
}: Props) {
const {title, description} = getDetails(crumb, startTimestampMs);
const {title, description} = getDetails(crumb);

const handleMouseEnter = useCallback(
(e: React.MouseEvent<HTMLElement>) => onMouseEnter && onMouseEnter(crumb, e),
Expand Down Expand Up @@ -74,7 +75,9 @@ function BreadcrumbItem({
) : null}
</TitleContainer>

<Description title={description}>{description}</Description>
<Tooltip title={description} showOnlyOnOverflow>
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously it was expecting a string, now it uses <Tooltip> so that we can also hide the native tooltip when it is not overflowing.

<Description>{description}</Description>
</Tooltip>
</CrumbDetails>
</CrumbItem>
);
Expand Down