Skip to content

Commit

Permalink
[nan-103] talkbase fix list records error (NangoHQ#1394)
Browse files Browse the repository at this point in the history
* [nan-103] clean up error report

* [nan-103] move id into query and add metrics manager
  • Loading branch information
khaliqgant authored Dec 5, 2023
1 parent 2316793 commit 375a782
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
16 changes: 13 additions & 3 deletions packages/shared/lib/services/sync/data/records.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,6 @@ export async function getAllDataRecords(
let nextCursor = null;

const rawResult = await query.select(
'id',
db.knex.raw(`
jsonb_set(
json::jsonb,
Expand All @@ -456,7 +455,7 @@ export async function getAllDataRecords(
ELSE 'UPDATED'
END
)
) as record
) as record, id
`)
);

Expand All @@ -482,7 +481,18 @@ export async function getAllDataRecords(
} else {
return { success: true, error: null, response: { records: customerResult as CustomerFacingDataRecord[], next_cursor: nextCursor } };
}
} catch (error: any) {
} catch (e: any) {
const errorMessage = 'List records error';
await metricsManager.capture(MetricTypes.SYNC_GET_RECORDS_QUERY_TIMEOUT, errorMessage, LogActionEnum.SYNC, {
environmentId: String(environmentId),
connectionId,
providerConfigKey,
delta: String(delta),
model,
error: JSON.stringify(e)
});

const error = new Error(errorMessage);
const nangoError = new NangoError('pass_through_error', error);
return { success: false, error: nangoError, response: null };
}
Expand Down
1 change: 1 addition & 0 deletions packages/shared/lib/utils/metrics.manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export enum MetricTypes {
SYNC_GET_RECORDS_ORDER_USED = 'sync_get_records_order_used',
SYNC_GET_RECORDS_INCLUDE_METADATA_USED = 'sync_get_records_include_metadata_used',
SYNC_GET_RECORDS_DEPRECATED_METHOD_USED = 'sync_get_records_deprecated_method_used',
SYNC_GET_RECORDS_QUERY_TIMEOUT = 'sync_get_records_query_timeout',
FLOW_JOB_TIMEOUT_FAILURE = 'flow_job_failure'
}

Expand Down

0 comments on commit 375a782

Please sign in to comment.