From 0a0e320ca8a844c8b66f5410d7469b371a8e06d9 Mon Sep 17 00:00:00 2001 From: Dmitry S Date: Tue, 13 Jul 2021 10:11:25 -0400 Subject: [PATCH] (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 --- app/client/lib/helpScout.ts | 6 +++--- app/client/ui/NotifyUI.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/client/lib/helpScout.ts b/app/client/lib/helpScout.ts index 2444bf92..fc083c56 100644 --- a/app/client/lib/helpScout.ts +++ b/app/client/lib/helpScout.ts @@ -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}); } diff --git a/app/client/ui/NotifyUI.ts b/app/client/ui/NotifyUI.ts index 33f44a50..92cce8de 100644 --- a/app/client/ui/NotifyUI.ts +++ b/app/client/ui/NotifyUI.ts @@ -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': {