From 9e1c65650669f0226b991058ff0d52b9f1d0fbc0 Mon Sep 17 00:00:00 2001 From: Hongbo Wu Date: Wed, 6 Dec 2023 14:16:44 +0800 Subject: [PATCH] add debugging logs --- packages/integration-handler/src/index.ts | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/packages/integration-handler/src/index.ts b/packages/integration-handler/src/index.ts index 7fb805682..fb53aa4f3 100644 --- a/packages/integration-handler/src/index.ts +++ b/packages/integration-handler/src/index.ts @@ -101,12 +101,18 @@ export const exporter = Sentry.GCPFunction.wrapHttpFunction( let hasMore = true let after = '0' while (hasMore) { - console.log('searching for items...') + const updatedSince = new Date(syncAt) + console.log('searching for items...', { + userId: claims.uid, + first, + after, + updatedSince, + }) const response = await search( REST_BACKEND_ENDPOINT, systemToken, client.highlightOnly, - new Date(syncAt), + updatedSince, first, after ) @@ -125,7 +131,10 @@ export const exporter = Sentry.GCPFunction.wrapHttpFunction( break } - console.log('exporting items...') + console.log('exporting items...', { + userId: claims.uid, + total: items.length, + }) const synced = await client.export(claims.token, items) if (!synced) { console.error('failed to export item', { @@ -134,7 +143,11 @@ export const exporter = Sentry.GCPFunction.wrapHttpFunction( return res.status(400).send('Failed to sync') } - console.log('updating integration...') + console.log('updating integration...', { + userId: claims.uid, + integrationId, + syncedAt: items[items.length - 1].updatedAt, + }) // update integration syncedAt if successful const updated = await updateIntegration( REST_BACKEND_ENDPOINT,