Skip to content

Commit c7fd4c6

Browse files
authored
feat(feedback): Change "Report a problem" link to open feedback modal (#7878)
Changes the "Report a problem" link to open feedback modal (when Sentry SDK is loaded). Otherwise will preserve previous behavior of opening link to GH issue.
1 parent c44485b commit c7fd4c6

File tree

2 files changed

+27
-6
lines changed

2 files changed

+27
-6
lines changed

src/components/githubCta.tsx

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import React from 'react';
1+
import React, {Fragment} from 'react';
22

3+
import {FeedbackModal} from './feedback/feedbackModal';
34
import {SmartLink} from './smartLink';
45

56
type GitHubCTAProps = {
@@ -27,9 +28,28 @@ export function GitHubCTA({sourceInstanceName, relativePath}: GitHubCTAProps) {
2728
Contribute to Docs
2829
</SmartLink>{' '}
2930
&nbsp;&nbsp;|&nbsp;&nbsp;
30-
<SmartLink to="https://github.com/getsentry/sentry-docs/issues/new/choose">
31-
Report a problem
32-
</SmartLink>{' '}
31+
<FeedbackModal title="Report a Problem">
32+
{({showModal}) => (
33+
<Fragment>
34+
<SmartLink
35+
to="https://github.com/getsentry/sentry-docs/issues/new/choose"
36+
onClick={e => {
37+
if (!window.Sentry?.getCurrentHub?.()) {
38+
return true;
39+
}
40+
41+
// Only Stop event propagation if Sentry SDK is loaded
42+
// (i.e. feedback is supported), otherwise will send you to github
43+
e.preventDefault();
44+
showModal();
45+
return false;
46+
}}
47+
>
48+
Report a problem
49+
</SmartLink>{' '}
50+
</Fragment>
51+
)}
52+
</FeedbackModal>
3353
</div>
3454
</small>
3555
</div>

src/components/smartLink.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ import {marketingUrlParams} from 'sentry-docs/utils';
55

66
import {ExternalLink} from './externalLink';
77

8-
type Props = {
8+
interface Props {
99
activeClassName?: string;
1010
children?: React.ReactNode;
1111
className?: string;
1212
href?: string;
1313
isActive?: boolean;
14+
onClick?: (e: React.MouseEvent) => void;
1415
remote?: boolean;
1516
target?: string;
1617
title?: string;
1718
to?: string;
18-
};
19+
}
1920

2021
export function SmartLink({
2122
to,

0 commit comments

Comments
 (0)