Enable SentryFeedbackForm, it works!

environments/review-main-yi2y9f/deployments/4227
Alex Gleason 2023-10-21 18:36:01 -05:00
rodzic 365cd70c9b
commit c518d82359
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 7211D1F99744FBB7
2 zmienionych plików z 18 dodań i 4 usunięć

Wyświetl plik

@ -1,7 +1,8 @@
import React, { useState } from 'react'; import React, { useState } from 'react';
import { FormattedMessage } from 'react-intl'; import { FormattedMessage } from 'react-intl';
import { Textarea, Form, Button, FormGroup, FormActions } from 'soapbox/components/ui'; import { Textarea, Form, Button, FormGroup, FormActions, Text } from 'soapbox/components/ui';
import { useOwnAccount } from 'soapbox/hooks';
import { captureSentryFeedback } from 'soapbox/sentry'; import { captureSentryFeedback } from 'soapbox/sentry';
interface ISentryFeedbackForm { interface ISentryFeedbackForm {
@ -10,8 +11,11 @@ interface ISentryFeedbackForm {
/** Accept feedback for the given Sentry event. */ /** Accept feedback for the given Sentry event. */
const SentryFeedbackForm: React.FC<ISentryFeedbackForm> = ({ eventId }) => { const SentryFeedbackForm: React.FC<ISentryFeedbackForm> = ({ eventId }) => {
const { account } = useOwnAccount();
const [feedback, setFeedback] = useState<string>(); const [feedback, setFeedback] = useState<string>();
const [isSubmitting, setIsSubmitting] = useState<boolean>(false); const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
const [isSubmitted, setIsSubmitted] = useState<boolean>(false);
const handleFeedbackChange: React.ChangeEventHandler<HTMLTextAreaElement> = (e) => { const handleFeedbackChange: React.ChangeEventHandler<HTMLTextAreaElement> = (e) => {
setFeedback(e.target.value); setFeedback(e.target.value);
@ -22,13 +26,22 @@ const SentryFeedbackForm: React.FC<ISentryFeedbackForm> = ({ eventId }) => {
setIsSubmitting(true); setIsSubmitting(true);
await captureSentryFeedback({ await captureSentryFeedback({
name: account?.acct,
event_id: eventId, event_id: eventId,
comments: feedback, comments: feedback,
}).catch(console.error); }).catch(console.error);
setFeedback(''); setIsSubmitted(true);
setIsSubmitting(false);
}; };
if (isSubmitted) {
return (
<Text align='center'>
<FormattedMessage id='alert.unexpected.thanks' defaultMessage='Thanks for your feedback!' />
</Text>
);
}
return ( return (
<Form onSubmit={handleSubmitFeedback}> <Form onSubmit={handleSubmitFeedback}>
<FormGroup> <FormGroup>

Wyświetl plik

@ -10,6 +10,7 @@ import KVStore from 'soapbox/storage/kv-store';
import sourceCode from 'soapbox/utils/code'; import sourceCode from 'soapbox/utils/code';
import { unregisterSW } from 'soapbox/utils/sw'; import { unregisterSW } from 'soapbox/utils/sw';
import SentryFeedbackForm from './sentry-feedback-form';
import SiteLogo from './site-logo'; import SiteLogo from './site-logo';
interface ISiteErrorBoundary { interface ISiteErrorBoundary {
@ -121,7 +122,7 @@ const SiteErrorBoundary: React.FC<ISiteErrorBoundary> = ({ children }) => {
<div className='mx-auto max-w-lg space-y-4 py-16'> <div className='mx-auto max-w-lg space-y-4 py-16'>
{(isProduction) ? ( {(isProduction) ? (
(sentryEnabled && sentryEventId) && ( (sentryEnabled && sentryEventId) && (
<>{/* <SentryFeedbackForm eventId={sentryEventId} /> */}</> <SentryFeedbackForm eventId={sentryEventId} />
) )
) : ( ) : (
<> <>