From 617dc396036e69bc7ea6b9947acc5d5b96aa2ce5 Mon Sep 17 00:00:00 2001 From: Michael Matloka Date: Thu, 28 Mar 2024 17:36:58 +0100 Subject: [PATCH] fix(insights): Don't allow annotations overlay to crash insight (#21217) --- frontend/src/layout/ErrorBoundary/ErrorBoundary.tsx | 4 ++-- .../AnnotationsOverlay/useAnnotationsPositioning.ts | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/layout/ErrorBoundary/ErrorBoundary.tsx b/frontend/src/layout/ErrorBoundary/ErrorBoundary.tsx index 8e395b7a00f24..6ebefbbffa167 100644 --- a/frontend/src/layout/ErrorBoundary/ErrorBoundary.tsx +++ b/frontend/src/layout/ErrorBoundary/ErrorBoundary.tsx @@ -25,9 +25,9 @@ export function ErrorBoundary({ children }: { children: React.ReactElement }): J )} - {isSentryInitialized + {isSentryInitialized && eventId?.match(/[^0]/) ? `We've registered this event for analysis (ID ${eventId}), but feel free to contact us directly too.` - : 'Please send over a screenshot of this message, so that we can resolve the issue.'} + : 'Please help us resolve the issue by sending a screenshot of this message.'} }> diff --git a/frontend/src/lib/components/AnnotationsOverlay/useAnnotationsPositioning.ts b/frontend/src/lib/components/AnnotationsOverlay/useAnnotationsPositioning.ts index ab9510ab35d17..a65a0d6947997 100644 --- a/frontend/src/lib/components/AnnotationsOverlay/useAnnotationsPositioning.ts +++ b/frontend/src/lib/components/AnnotationsOverlay/useAnnotationsPositioning.ts @@ -24,8 +24,9 @@ export function useAnnotationsPositioning( const points = chart._metasets[0].data as Point[] const firstTickPointIndex = chart.scales.x.ticks[0].value const lastTickPointIndex = chart.scales.x.ticks[tickCount - 1].value - const firstTickLeftPx = points[firstTickPointIndex].x - const lastTickLeftPx = points[lastTickPointIndex].x + // Fall back to zero for resiliency against temporary chart inconsistencies during loading + const firstTickLeftPx = points[firstTickPointIndex]?.x ?? 0 + const lastTickLeftPx = points[lastTickPointIndex]?.x ?? 0 return { tickIntervalPx: (lastTickLeftPx - firstTickLeftPx) / (tickCount - 1), firstTickLeftPx,