Skip to content

Commit

Permalink
Added logs to AML webhook (#2372)
Browse files Browse the repository at this point in the history
* feat: added logs to AML webhook

* feat: added log when starting aml webhook

---------

Co-authored-by: Alon Peretz <[email protected]>
  • Loading branch information
tomer-shvadron and alonp99 authored May 16, 2024
1 parent 1aa075b commit 5a5da47
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 7 additions & 1 deletion services/workflows-service/src/webhooks/webhooks.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ export class WebhooksService {
endUserId: string;
data: IndividualAmlWebhookInput['data'];
}) {
this.logger.log('Started handling individual AML hit', { endUserId });

const { projectId, ...rest } = await this.endUserRepository.findByIdUnscoped(endUserId, {
select: {
approvalState: true,
Expand Down Expand Up @@ -85,10 +87,12 @@ export class WebhooksService {
});

if (hits.length === 0) {
this.logger.log('No AML hits found', { endUserId });

return;
}

await this.workflowService.createOrUpdateWorkflowRuntime({
const workflow = await this.workflowService.createOrUpdateWorkflowRuntime({
workflowDefinitionId,
context: {
aml: data,
Expand All @@ -105,5 +109,7 @@ export class WebhooksService {
projectIds: [projectId],
currentProjectId: projectId,
});

this.logger.log(`Created workflow for AML hits`, { workflow });
}
}
5 changes: 5 additions & 0 deletions services/workflows-service/src/workflow/workflow.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,11 @@ export class WorkflowService {
const result = ConfigSchema.safeParse(config);

if (!result.success) {
this.logger.error('Invalid workflow config', {
config,
error: result.error,
});

throw ValidationError.fromZodError(result.error);
}

Expand Down

0 comments on commit 5a5da47

Please sign in to comment.