Browse Source

feat(nocodb): insert hook log based on NC_AUTOMATION_LOG_LEVEL

pull/5349/head
Wing-Kam Wong 2 years ago
parent
commit
c850074d73
  1. 8
      packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts
  2. 3
      packages/nocodb/src/lib/models/HookLog.ts

8
packages/nocodb/src/lib/meta/helpers/webhookHelpers.ts

@ -301,6 +301,7 @@ export async function invokeWebhook(
subject: parseBody(notification?.payload?.subject, newData),
html: parseBody(notification?.payload?.body, newData),
});
if (process.env.NC_AUTOMATION_LOG_LEVEL === 'ALL') {
hookLog = {
...hook,
fk_hook_id: hook.id,
@ -310,6 +311,7 @@ export async function invokeWebhook(
triggered_by: user?.email,
};
}
}
break;
case 'URL':
{
@ -323,6 +325,7 @@ export async function invokeWebhook(
newData
);
if (process.env.NC_AUTOMATION_LOG_LEVEL === 'ALL') {
hookLog = {
...hook,
fk_hook_id: hook.id,
@ -343,6 +346,7 @@ export async function invokeWebhook(
triggered_by: user?.email,
};
}
}
break;
default:
{
@ -357,6 +361,7 @@ export async function invokeWebhook(
})
);
if (process.env.NC_AUTOMATION_LOG_LEVEL === 'ALL') {
hookLog = {
...hook,
fk_hook_id: hook.id,
@ -366,10 +371,12 @@ export async function invokeWebhook(
triggered_by: user?.email,
};
}
}
break;
}
} catch (e) {
console.log(e);
if (['ERROR', 'ALL'].includes(process.env.NC_AUTOMATION_LOG_LEVEL)) {
hookLog = {
...hook,
type: notification.type,
@ -380,6 +387,7 @@ export async function invokeWebhook(
error: JSON.stringify(e),
triggered_by: user?.email,
};
}
if (throwErrorOnFailure) throw e;
} finally {
if (hookLog) {

3
packages/nocodb/src/lib/models/HookLog.ts

@ -63,6 +63,9 @@ export default class HookLog implements HookLogType {
}
public static async insert(hookLog: Partial<HookLog>, ncMeta = Noco.ncMeta) {
if (process.env.NC_AUTOMATION_LOG_LEVEL === 'OFF') {
return;
}
const insertObj: any = extractProps(hookLog, [
'base_id',
'project_id',

Loading…
Cancel
Save