Send user text as context
This commit is contained in:
parent
c6202bf653
commit
ba1618812c
3 changed files with 24 additions and 22 deletions
|
@ -29,7 +29,7 @@ import BaseDialog from "./BaseDialog";
|
||||||
import Field from '../elements/Field';
|
import Field from '../elements/Field';
|
||||||
import Spinner from "../elements/Spinner";
|
import Spinner from "../elements/Spinner";
|
||||||
import DialogButtons from "../elements/DialogButtons";
|
import DialogButtons from "../elements/DialogButtons";
|
||||||
import {sendSentryReport} from "../../../sentry";
|
import { sendSentryReport } from "../../../sentry";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
onFinished: (success: boolean) => void;
|
onFinished: (success: boolean) => void;
|
||||||
|
@ -116,11 +116,7 @@ export default class BugReportDialog extends React.Component<IProps, IState> {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Send a Sentry report if the user agreed to send logs and if there's an error object (Sentry won't be very
|
sendSentryReport(userText, this.state.issueUrl, this.props.error);
|
||||||
// useful for grouping errors without exception information to aggregate with)
|
|
||||||
if (sendLogs) {
|
|
||||||
sendSentryReport(userText, this.props.label, this.props.error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private onDownload = async (): Promise<void> => {
|
private onDownload = async (): Promise<void> => {
|
||||||
|
|
|
@ -51,6 +51,7 @@ export default class TileErrorBoundary extends React.Component<IProps, IState> {
|
||||||
private onBugReport = (): void => {
|
private onBugReport = (): void => {
|
||||||
Modal.createTrackedDialog('Bug Report Dialog', '', BugReportDialog, {
|
Modal.createTrackedDialog('Bug Report Dialog', '', BugReportDialog, {
|
||||||
label: 'react-soft-crash-tile',
|
label: 'react-soft-crash-tile',
|
||||||
|
error: this.state.error,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -98,30 +98,35 @@ function getDeviceContext(client: MatrixClient): Record<String, String> {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getContext() {
|
async function getContexts() {
|
||||||
const client = MatrixClientPeg.get();
|
const client = MatrixClientPeg.get();
|
||||||
return {
|
return {
|
||||||
"contexts": {
|
|
||||||
"user": getUserContext(client),
|
"user": getUserContext(client),
|
||||||
"crypto": await getCryptoContext(client),
|
"crypto": await getCryptoContext(client),
|
||||||
"device": getDeviceContext(client),
|
"device": getDeviceContext(client),
|
||||||
"storage": await getStorageOptions(),
|
"storage": await getStorageOptions(),
|
||||||
},
|
|
||||||
"extra": {
|
|
||||||
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function sendSentryReport(userText: string, label: string, error: Error): void {
|
export async function sendSentryReport(userText: string, issueUrl: string, error: Error): void {
|
||||||
if (!SdkConfig.get()["sentry"]) return;
|
const sentryConfig = SdkConfig.get()["sentry"];
|
||||||
|
if (!sentryConfig) return;
|
||||||
|
|
||||||
// Ignore reports without errors, as they're not useful in sentry and can't easily be aggregated
|
const captureContext = {
|
||||||
|
"contexts": await getContexts(),
|
||||||
|
"extra": {
|
||||||
|
"userText": userText,
|
||||||
|
"issue_url": issueUrl,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// If there's no error and no issueUrl, the report will just produce non-grouped noise in Sentry, so don't
|
||||||
|
// upload it
|
||||||
if (error) {
|
if (error) {
|
||||||
Sentry.captureException(error, await getContext());
|
Sentry.captureException(error, captureContext);
|
||||||
|
} else if (issueUrl) {
|
||||||
|
Sentry.captureMessage(`Issue: ${issueUrl}`, captureContext);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: use https://docs.sentry.io/api/projects/submit-user-feedback/ to submit userText
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ISentryConfig {
|
interface ISentryConfig {
|
||||||
|
|
Loading…
Reference in a new issue