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

Wyświetl plik

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