From 127dec5b4c12ce831248306042158f58f5d294ce Mon Sep 17 00:00:00 2001 From: First Name Date: Thu, 31 Jul 2025 22:42:53 +0000 Subject: [PATCH 1/3] Adds thorough logging to Google sheets action Adds info logs for the different stages of sheets action. Includes the sheet verwrite check, the file search within the overwrite, spreadsheet metadata fetch if the file is found, and the beginning of the request.stream process. --- lib/actions/google/drive/sheets/google_sheets.js | 6 ++++++ src/actions/google/drive/sheets/google_sheets.ts | 11 +++++++++++ src/actions/google/drive/sheets/test_google_sheets.ts | 4 ++++ 3 files changed, 21 insertions(+) diff --git a/lib/actions/google/drive/sheets/google_sheets.js b/lib/actions/google/drive/sheets/google_sheets.js index fcc1f40af..b2a5a2cce 100644 --- a/lib/actions/google/drive/sheets/google_sheets.js +++ b/lib/actions/google/drive/sheets/google_sheets.js @@ -137,6 +137,8 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { return url.toString(); } async sendOverwriteData(filename, request, drive, sheet) { + var _a; + winston.info(`${LOG_PREFIX} Beginning sendOverwriteData`, { webhookId: request.webhookId }); let folder; if (request.formParams.folderid) { winston.info("Using manual folder id"); @@ -171,12 +173,14 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { else { options.corpora = "user"; } + winston.info(`${LOG_PREFIX} Searching for existing file with options: ${JSON.stringify(options)}`, { webhookId: request.webhookId }); const files = await this.retriableFileList(drive, options, 0, request.webhookId) .catch((e) => { this.sanitizeGaxiosError(e); winston.warn(`Error listing drives. Error ${e.toString()}`, { webhookId: request.webhookId }); throw e; }); + winston.info(`${LOG_PREFIX} File list call complete. Found ${(_a = files.data.files) === null || _a === void 0 ? void 0 : _a.length} files.`, { webhookId: request.webhookId }); if (files.data.files === undefined || files.data.files.length === 0) { winston.debug(`New file: ${filename}`, { webhookId: request.webhookId }); return this.sendData(filename, request, drive); @@ -191,6 +195,7 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { winston.debug(`Error retrieving spreadsheet. Error ${e.toString()}`, { webhookId: request.webhookId }); throw e; }); + winston.info(`${LOG_PREFIX} Spreadsheet get call complete.`, { webhookId: request.webhookId }); if (!sheets.data.sheets || sheets.data.sheets[0].properties === undefined || sheets.data.sheets[0].properties.gridProperties === undefined) { throw "Now sheet data available"; @@ -203,6 +208,7 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { const requestBody = { requests: [] }; let rowCount = 0; let finished = false; + winston.info(`${LOG_PREFIX} Beginning stream processing.`, { webhookId: request.webhookId }); return request.stream(async (readable) => { return new Promise(async (resolve, reject) => { try { diff --git a/src/actions/google/drive/sheets/google_sheets.ts b/src/actions/google/drive/sheets/google_sheets.ts index 987e5df93..6e089e579 100644 --- a/src/actions/google/drive/sheets/google_sheets.ts +++ b/src/actions/google/drive/sheets/google_sheets.ts @@ -156,6 +156,7 @@ export class GoogleSheetsAction extends GoogleDriveAction { } async sendOverwriteData(filename: string, request: Hub.ActionRequest, drive: Drive, sheet: Sheet) { + winston.info(`${LOG_PREFIX} Beginning sendOverwriteData`, {webhookId: request.webhookId}) let folder: string | undefined if (request.formParams.folderid) { winston.info("Using manual folder id") @@ -189,6 +190,9 @@ export class GoogleSheetsAction extends GoogleDriveAction { options.corpora = "user" } + winston.info(`${LOG_PREFIX} Searching for existing file with options: ${JSON.stringify(options)}`, + {webhookId: request.webhookId}, + ) const files = await this.retriableFileList(drive, options, 0, request.webhookId!) .catch((e: any) => { this.sanitizeGaxiosError(e) @@ -196,6 +200,10 @@ export class GoogleSheetsAction extends GoogleDriveAction { {webhookId: request.webhookId}) throw e }) + winston.info(`${LOG_PREFIX} File list call complete. Found ${files.data.files?.length} files.`, + {webhookId: request.webhookId}, + ) + if (files.data.files === undefined || files.data.files.length === 0) { winston.debug(`New file: ${filename}`, {webhookId: request.webhookId}) @@ -214,6 +222,8 @@ export class GoogleSheetsAction extends GoogleDriveAction { {webhookId: request.webhookId}) throw e }) + winston.info(`${LOG_PREFIX} Spreadsheet get call complete.`, {webhookId: request.webhookId}) + if (!sheets.data.sheets || sheets.data.sheets[0].properties === undefined || sheets.data.sheets[0].properties.gridProperties === undefined) { throw "Now sheet data available" @@ -227,6 +237,7 @@ export class GoogleSheetsAction extends GoogleDriveAction { let rowCount = 0 let finished = false + winston.info(`${LOG_PREFIX} Beginning stream processing.`, {webhookId: request.webhookId}) return request.stream(async (readable) => { return new Promise(async (resolve, reject) => { try { diff --git a/src/actions/google/drive/sheets/test_google_sheets.ts b/src/actions/google/drive/sheets/test_google_sheets.ts index e806d9dd7..58f47c617 100644 --- a/src/actions/google/drive/sheets/test_google_sheets.ts +++ b/src/actions/google/drive/sheets/test_google_sheets.ts @@ -6,6 +6,7 @@ import concatStream = require("concat-stream") import * as Hub from "../../../../hub" +import * as winston from "winston" import { ActionCrypto } from "../../../../hub" import { GoogleSheetsAction } from "./google_sheets" @@ -96,6 +97,7 @@ describe(`${action.constructor.name} unit tests`, () => { }), }, }) + const winstonSpy = sinon.spy(winston, "info") const flushSpy = sinon.spy(async (buffer: any, _sheet: any, _spreadsheetId: number) => { chai.expect(buffer).to.deep.equal({ requests: [ @@ -174,10 +176,12 @@ describe(`${action.constructor.name} unit tests`, () => { } chai.expect(action.validateAndExecute(request)).to.eventually.be.fulfilled.then( () => { chai.expect(flushSpy).to.have.been.calledOnce + chai.expect(winstonSpy).to.have.been.calledWith("[GOOGLE_SHEETS] Beginning sendOverwriteData") stubDriveClient.restore() stubSheetClient.restore() stubFlush.restore() stubRetriableResize.restore() + winstonSpy.restore() done() }) From a8a2ada0070d66b3500466f97c0f4b8e6882fcba Mon Sep 17 00:00:00 2001 From: First Name Date: Thu, 31 Jul 2025 22:42:53 +0000 Subject: [PATCH 2/3] Adds thorough logging to Google sheets action Adds info logs for the different stages of sheets action. Includes the sheet verwrite check, the file search within the overwrite, spreadsheet metadata fetch if the file is found, and the beginning of the request.stream process. --- lib/actions/google/drive/sheets/google_sheets.js | 8 ++++++++ src/actions/google/drive/sheets/google_sheets.ts | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/lib/actions/google/drive/sheets/google_sheets.js b/lib/actions/google/drive/sheets/google_sheets.js index b2a5a2cce..2af8abcc6 100644 --- a/lib/actions/google/drive/sheets/google_sheets.js +++ b/lib/actions/google/drive/sheets/google_sheets.js @@ -137,7 +137,11 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { return url.toString(); } async sendOverwriteData(filename, request, drive, sheet) { +<<<<<<< HEAD var _a; +======= + var _a, _b; +>>>>>>> 0b0cfbf8 (Adds thorough logging to Google sheets action) winston.info(`${LOG_PREFIX} Beginning sendOverwriteData`, { webhookId: request.webhookId }); let folder; if (request.formParams.folderid) { @@ -180,7 +184,11 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { winston.warn(`Error listing drives. Error ${e.toString()}`, { webhookId: request.webhookId }); throw e; }); +<<<<<<< HEAD winston.info(`${LOG_PREFIX} File list call complete. Found ${(_a = files.data.files) === null || _a === void 0 ? void 0 : _a.length} files.`, { webhookId: request.webhookId }); +======= + winston.info(`${LOG_PREFIX} File list call complete. Found ${(_b = (_a = files.data.files) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0} files.`, { webhookId: request.webhookId }); +>>>>>>> 0b0cfbf8 (Adds thorough logging to Google sheets action) if (files.data.files === undefined || files.data.files.length === 0) { winston.debug(`New file: ${filename}`, { webhookId: request.webhookId }); return this.sendData(filename, request, drive); diff --git a/src/actions/google/drive/sheets/google_sheets.ts b/src/actions/google/drive/sheets/google_sheets.ts index 6e089e579..1a1b87f9b 100644 --- a/src/actions/google/drive/sheets/google_sheets.ts +++ b/src/actions/google/drive/sheets/google_sheets.ts @@ -200,7 +200,11 @@ export class GoogleSheetsAction extends GoogleDriveAction { {webhookId: request.webhookId}) throw e }) +<<<<<<< HEAD winston.info(`${LOG_PREFIX} File list call complete. Found ${files.data.files?.length} files.`, +======= + winston.info(`${LOG_PREFIX} File list call complete. Found ${files.data.files?.length ?? 0} files.`, +>>>>>>> 0b0cfbf8 (Adds thorough logging to Google sheets action) {webhookId: request.webhookId}, ) From 82051760bf216f59cf592be59d2cd01c41fedf28 Mon Sep 17 00:00:00 2001 From: First Name Date: Thu, 31 Jul 2025 22:42:53 +0000 Subject: [PATCH 3/3] Adds thorough logging to Google sheets action Adds info logs for the different stages of sheets action. Includes the sheet verwrite check, the file search within the overwrite, spreadsheet metadata fetch if the file is found, and the beginning of the request.stream process. --- lib/actions/google/drive/sheets/google_sheets.js | 8 -------- src/actions/google/drive/sheets/google_sheets.ts | 4 ---- 2 files changed, 12 deletions(-) diff --git a/lib/actions/google/drive/sheets/google_sheets.js b/lib/actions/google/drive/sheets/google_sheets.js index 2af8abcc6..9678c4c41 100644 --- a/lib/actions/google/drive/sheets/google_sheets.js +++ b/lib/actions/google/drive/sheets/google_sheets.js @@ -137,11 +137,7 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { return url.toString(); } async sendOverwriteData(filename, request, drive, sheet) { -<<<<<<< HEAD - var _a; -======= var _a, _b; ->>>>>>> 0b0cfbf8 (Adds thorough logging to Google sheets action) winston.info(`${LOG_PREFIX} Beginning sendOverwriteData`, { webhookId: request.webhookId }); let folder; if (request.formParams.folderid) { @@ -184,11 +180,7 @@ class GoogleSheetsAction extends google_drive_1.GoogleDriveAction { winston.warn(`Error listing drives. Error ${e.toString()}`, { webhookId: request.webhookId }); throw e; }); -<<<<<<< HEAD - winston.info(`${LOG_PREFIX} File list call complete. Found ${(_a = files.data.files) === null || _a === void 0 ? void 0 : _a.length} files.`, { webhookId: request.webhookId }); -======= winston.info(`${LOG_PREFIX} File list call complete. Found ${(_b = (_a = files.data.files) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0} files.`, { webhookId: request.webhookId }); ->>>>>>> 0b0cfbf8 (Adds thorough logging to Google sheets action) if (files.data.files === undefined || files.data.files.length === 0) { winston.debug(`New file: ${filename}`, { webhookId: request.webhookId }); return this.sendData(filename, request, drive); diff --git a/src/actions/google/drive/sheets/google_sheets.ts b/src/actions/google/drive/sheets/google_sheets.ts index 1a1b87f9b..476d3b1a5 100644 --- a/src/actions/google/drive/sheets/google_sheets.ts +++ b/src/actions/google/drive/sheets/google_sheets.ts @@ -200,11 +200,7 @@ export class GoogleSheetsAction extends GoogleDriveAction { {webhookId: request.webhookId}) throw e }) -<<<<<<< HEAD - winston.info(`${LOG_PREFIX} File list call complete. Found ${files.data.files?.length} files.`, -======= winston.info(`${LOG_PREFIX} File list call complete. Found ${files.data.files?.length ?? 0} files.`, ->>>>>>> 0b0cfbf8 (Adds thorough logging to Google sheets action) {webhookId: request.webhookId}, )