diff --git a/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx b/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx index ef80f90378bd3d..1c9f4250e485a6 100644 --- a/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx +++ b/static/app/components/events/attachmentViewers/previewAttachmentTypes.tsx @@ -1,5 +1,3 @@ -import * as Sentry from '@sentry/react'; - import ImageViewer from 'sentry/components/events/attachmentViewers/imageViewer'; import JsonViewer from 'sentry/components/events/attachmentViewers/jsonViewer'; import LogFileViewer from 'sentry/components/events/attachmentViewers/logFileViewer'; @@ -61,12 +59,6 @@ export const getInlineAttachmentRenderer = ( return WebMViewer; } - Sentry.withScope(scope => { - scope.setExtra('mimetype', attachment.mimetype); - scope.setExtra('attachmentName', attachment.name); - scope.setFingerprint(['no-inline-attachment-renderer']); - scope.captureException(new Error('No inline attachment renderer found')); - }); return undefined; }; diff --git a/static/app/components/events/eventTagsAndScreenshot/screenshot/modal.tsx b/static/app/components/events/eventTagsAndScreenshot/screenshot/modal.tsx index 909f73bfda58b1..ac12244a9b209d 100644 --- a/static/app/components/events/eventTagsAndScreenshot/screenshot/modal.tsx +++ b/static/app/components/events/eventTagsAndScreenshot/screenshot/modal.tsx @@ -1,7 +1,8 @@ import type {ComponentProps} from 'react'; -import {Fragment, useCallback, useMemo, useState} from 'react'; +import {Fragment, useCallback, useEffect, useMemo, useState} from 'react'; import {css} from '@emotion/react'; import styled from '@emotion/styled'; +import * as Sentry from '@sentry/react'; import type {ModalRenderProps} from 'sentry/actionCreators/modal'; import Confirm from 'sentry/components/confirm'; @@ -107,6 +108,17 @@ export default function ScreenshotModal({ const AttachmentComponent = getInlineAttachmentRenderer(currentEventAttachment)!; + useEffect(() => { + if (currentEventAttachment && !AttachmentComponent) { + Sentry.withScope(scope => { + scope.setExtra('mimetype', currentEventAttachment.mimetype); + scope.setExtra('attachmentName', currentEventAttachment.name); + scope.setFingerprint(['no-inline-attachment-renderer']); + scope.captureException(new Error('No screenshot attachment renderer found')); + }); + } + }, [currentEventAttachment, AttachmentComponent]); + return (