From 4cf8cd20f33d9e084d1ba987ad5ba7c94fb73545 Mon Sep 17 00:00:00 2001 From: maryia-matskevich-deriv Date: Tue, 4 Jun 2024 14:38:00 +0300 Subject: [PATCH 1/2] fix: TrackJS BBot: There was an error listing files from Google Drive - Error: {} --- src/utilities/integrations/GoogleDrive.js | 29 ++++++++++++++++------ src/utilities/integrations/trackJSTrack.js | 1 + 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/utilities/integrations/GoogleDrive.js b/src/utilities/integrations/GoogleDrive.js index 71b90a8de..b0a585756 100644 --- a/src/utilities/integrations/GoogleDrive.js +++ b/src/utilities/integrations/GoogleDrive.js @@ -148,16 +148,31 @@ class GoogleDriveUtil { const picker = document.getElementsByClassName('picker-dialog-content')[0]; picker.parentNode.removeChild(picker); }, 500); + this.client.requestAccessToken({ prompt: '' }); - } + const { + result: { + error: { + errors: [{ message, reason }], + code, + status, + }, + }, + } = err; + const errorObject = { + error: { + error: { + message: `${message}, status: ${status}, code: ${code} `, + code: reason, + }, + }, + }; + trackJSTrack(errorObject); + } else { + errLogger(JSON.stringify(err, ['message', 'arguments', 'type', 'name'])); + } const error = translate('There was an error listing files from Google Drive'); - - errLogger( - JSON.stringify(err, ['message', 'arguments', 'type', 'name']), - translate('There was an error listing files from Google Drive') - ); - globalObserver.emit('Error', error); } }; diff --git a/src/utilities/integrations/trackJSTrack.js b/src/utilities/integrations/trackJSTrack.js index 22ddb3744..7bfc16b9c 100644 --- a/src/utilities/integrations/trackJSTrack.js +++ b/src/utilities/integrations/trackJSTrack.js @@ -8,6 +8,7 @@ export const default_errors_to_ignore = [ 'RateLimit', 'DisconnectError', 'MarketIsClosed', + 'authError', // Invalid Credentials, access token's been expired, show pop-up modal to sign in ]; export function trackJSTrack(error) { From 5ebe81561fd8ee92ae01480038fb82756c6774f4 Mon Sep 17 00:00:00 2001 From: maryia-matskevich-deriv Date: Wed, 5 Jun 2024 12:22:19 +0300 Subject: [PATCH 2/2] refactor: make double safety trackJS error --- src/utilities/integrations/GoogleDrive.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/utilities/integrations/GoogleDrive.js b/src/utilities/integrations/GoogleDrive.js index b0a585756..c418ccbfc 100644 --- a/src/utilities/integrations/GoogleDrive.js +++ b/src/utilities/integrations/GoogleDrive.js @@ -151,15 +151,11 @@ class GoogleDriveUtil { this.client.requestAccessToken({ prompt: '' }); - const { - result: { - error: { - errors: [{ message, reason }], - code, - status, - }, - }, - } = err; + const message = err?.result?.error?.errors[0]?.message; + const reason = err?.result?.error?.errors[0]?.reason; + const code = err?.result?.error?.code; + const status = err?.result?.error?.status; + const errorObject = { error: { error: {