(core) Fix reporting of errors to HelpScout using "Report a problem" link.

Summary:
Error notifications include a "Report a problem" link, but the inclusion of
error message and stack trace was broken.

Test Plan: Tested manually and added a test case.

Reviewers: paulfitz

Reviewed By: paulfitz

Differential Revision: https://phab.getgrist.com/D2911
This commit is contained in:
Dmitry S 2021-07-13 10:11:25 -04:00
parent 09b4aaa90e
commit 0a0e320ca8
2 changed files with 4 additions and 4 deletions

View File

@ -108,7 +108,7 @@ function _beaconOpen(userObj: IUserObj|null, options: {onOpen?: () => void, erro
// The beacon remembers its content, so reset it when switching between reporting errors and
// sending a message.
const openType = errors ? 'error' : 'message';
const openType = errors?.length ? 'error' : 'message';
if (openType !== lastOpenType) {
Beacon('reset');
lastOpenType = openType;
@ -128,7 +128,7 @@ function _beaconOpen(userObj: IUserObj|null, options: {onOpen?: () => void, erro
}
const attrs: ISessionData = {};
if (errors) {
if (errors?.length) {
// If sending errors, prefill part of the message (the user sees this and can add to it), and
// include more detailed errors with stack traces into session-data.
const messages = errors.map(({error, timestamp}) =>
@ -180,7 +180,7 @@ export function beaconOpenMessage(options: IBeaconOpenOptions) {
if (options.includeAppErrors && app) {
errors.push(...app.notifier.getFullAppErrors());
}
_beaconOpen(getBeaconUserObj(app), options);
_beaconOpen(getBeaconUserObj(app), {...options, errors});
}

View File

@ -32,7 +32,7 @@ function buildAction(action: NotifyAction, item: Notification, options: IBeaconO
{href: urlState().makeUrl({billing: 'billing'})});
case 'report-problem':
return cssToastAction('Report a problem',
return cssToastAction('Report a problem', testId('toast-report-problem'),
dom.on('click', () => beaconOpenMessage({...options, includeAppErrors: true})));
case 'ask-for-help': {