Skip to content

Commit

Permalink
feat(replay): Use SDK value for LCP
Browse files Browse the repository at this point in the history
Changes LCP breadcrumb rendering to use `data.value` instead of trying to calculate the value (which ends up resulting in incorrect values as it uses the replay start timestamp, so LCP from a refresh will be wrong).

Related getsentry/sentry-javascript#7225
  • Loading branch information
billyvg committed Feb 18, 2023
1 parent cc93289 commit 229345e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions static/app/components/replays/breadcrumbs/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ 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 `${crumb.data.value}ms`;
}
break;
default:
Expand Down Expand Up @@ -50,6 +50,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 @@ -32,7 +32,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

0 comments on commit 229345e

Please sign in to comment.