Skip to content

Commit dd97280

Browse files
authored
fix(investigation-rule): capture exception instead of error toast (#86017)
1 parent 7af686b commit dd97280

File tree

2 files changed

+29
-23
lines changed

2 files changed

+29
-23
lines changed

static/app/components/dynamicSampling/investigationRule.spec.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ describe('InvestigationRule', function () {
164164
expect(getRule).toHaveBeenCalledTimes(0);
165165
});
166166

167-
it('does not render when there is an unknown error but shows an error', async function () {
167+
it('does not render when there is an unknown error', async function () {
168168
initComponentEnvironment({hasRule: false});
169169
const getRule = MockApiClient.addMockResponse({
170170
url: '/organizations/org-slug/dynamic-sampling/custom-rules/',
@@ -178,7 +178,7 @@ describe('InvestigationRule', function () {
178178
);
179179
await expectNotToRender();
180180

181-
expect(addErrorMessage).toHaveBeenCalledTimes(1);
181+
expect(addErrorMessage).toHaveBeenCalledTimes(0);
182182
// check we did call the endpoint to check if a rule exists
183183
expect(getRule).toHaveBeenCalledTimes(1);
184184
});

static/app/components/dynamicSampling/investigationRule.tsx

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import {useEffect} from 'react';
22
import styled from '@emotion/styled';
3+
import * as Sentry from '@sentry/react';
34
import moment from 'moment-timezone';
45

56
import {addErrorMessage, addSuccessMessage} from 'sentry/actionCreators/indicator';
@@ -216,9 +217,12 @@ function InvestigationRuleCreationInternal(props: PropsInternal) {
216217
if (isBreakingRequestError) {
217218
const msg = t('Unable to fetch investigation rule');
218219
handleXhrErrorResponse(msg, error);
219-
addErrorMessage(msg);
220+
Sentry.withScope(scope => {
221+
scope.setExtra('query', query);
222+
Sentry.captureException(error);
223+
});
220224
}
221-
}, [isBreakingRequestError, error]);
225+
}, [isBreakingRequestError, error, query]);
222226

223227
if (isLoading || isBreakingRequestError) {
224228
return null;
@@ -256,30 +260,32 @@ function InvestigationRuleCreationInternal(props: PropsInternal) {
256260
<Tooltip
257261
isHoverable
258262
title={
259-
isTransactionQueryMissing
260-
? tct(
261-
'If you filter by [code:event.type:transaction] we can adjust your sampling priorities, increasing the odds of getting matching events. [link:Learn more.]',
262-
{
263-
code: <code />,
264-
link: (
265-
<ExternalLink href="https://docs.sentry.io/product/performance/retention-priorities/#investigation-mode" />
266-
),
267-
}
268-
)
269-
: tct(
270-
'We can find more events that match your search query by adjusting your sampling priorities for an hour, increasing the odds of getting matching events. [link:Learn more.]',
271-
{
272-
link: (
273-
<ExternalLink href="https://docs.sentry.io/product/performance/retention-priorities/#investigation-mode" />
274-
),
275-
}
276-
)
263+
isBreakingRequestError
264+
? t('Search query unsupported.')
265+
: isTransactionQueryMissing
266+
? tct(
267+
'If you filter by [code:event.type:transaction] we can adjust your sampling priorities, increasing the odds of getting matching events. [link:Learn more.]',
268+
{
269+
code: <code />,
270+
link: (
271+
<ExternalLink href="https://docs.sentry.io/product/performance/retention-priorities/#investigation-mode" />
272+
),
273+
}
274+
)
275+
: tct(
276+
'We can find more events that match your search query by adjusting your sampling priorities for an hour, increasing the odds of getting matching events. [link:Learn more.]',
277+
{
278+
link: (
279+
<ExternalLink href="https://docs.sentry.io/product/performance/retention-priorities/#investigation-mode" />
280+
),
281+
}
282+
)
277283
}
278284
>
279285
<Button
280286
{...props.buttonProps}
281287
priority={isLikelyMoreNeeded ? 'primary' : 'default'}
282-
disabled={isTransactionQueryMissing}
288+
disabled={isTransactionQueryMissing || isBreakingRequestError}
283289
onClick={() => createInvestigationRule({organization, projects, query})}
284290
icon={<IconStack />}
285291
>

0 commit comments

Comments
 (0)