mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-07 07:15:45 +00:00
feat(freight-api): enrich canonical request log line
Emit the request line as raw JSON on stdout (level/time/logger as fields) instead of through Nest's console logger, whose prefix made it unparsable. Collect data points via logCtx at the flow chokepoints: BaseRepository writes (status changes, creates, deletes), invoice transitions, payment intent lifecycle + outbound payment-service calls, booking/contract entry state, review-note reasons, signatures and OTP verify outcomes.
This commit is contained in:
@@ -9,7 +9,7 @@ import { InjectDataSource } from '@nestjs/typeorm';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import { Readable } from 'stream';
|
||||
import { insertWithGeneratedReference } from '@edr/api-common';
|
||||
import { insertWithGeneratedReference, logCtx } from '@edr/api-common';
|
||||
import type { TCurrentUser } from '@tria-plc/api-common/modules/auth/types/current-user.type';
|
||||
|
||||
import { ContractDocumentViewModelBuilder } from '../../contracts/contract-document-view-model.builder';
|
||||
@@ -1084,6 +1084,19 @@ export class ContractTransitionService {
|
||||
): Promise<void> {
|
||||
const role = dto.role as ContractSignerRole;
|
||||
|
||||
// Both sign() and counterSign() land here — who signed what, and whether the
|
||||
// ink came from the request or the signer's saved profile signature.
|
||||
logCtx(
|
||||
{
|
||||
contractId: contract.id,
|
||||
reference: contract.reference,
|
||||
role,
|
||||
signerUserId: options.signerUserId,
|
||||
usedDrawnImage: Boolean(dto.signatureImageBase64),
|
||||
},
|
||||
{ path: "contractSignatures", mode: "push" },
|
||||
);
|
||||
|
||||
// Resolve the signature image. The client may send a freshly-drawn image, or
|
||||
// omit it to reuse the signer's saved profile signature. Fall back to the
|
||||
// saved one whenever no image is supplied.
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
} from '@nestjs/common';
|
||||
import { InjectDataSource } from '@nestjs/typeorm';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { insertWithGeneratedReference } from '@edr/api-common';
|
||||
import { insertWithGeneratedReference, logCtx } from '@edr/api-common';
|
||||
|
||||
import { YardCountry } from '@edr/types';
|
||||
//
|
||||
@@ -811,6 +811,18 @@ export class ContractsService {
|
||||
throw new NotFoundException(`Contract ${id} not found`);
|
||||
}
|
||||
|
||||
// Entry state for every contract flow (submit, approve, sign, suspend…) —
|
||||
// see the equivalent in BookingsService.findById.
|
||||
logCtx(
|
||||
{
|
||||
id: contract.id,
|
||||
reference: contract.reference,
|
||||
statusAtEntry: contract.status,
|
||||
companyId: contract.companyId,
|
||||
},
|
||||
{ path: "contract" },
|
||||
);
|
||||
|
||||
if (contract.files && contract.files.length > 0) {
|
||||
contract.files = await Promise.all(
|
||||
contract.files.map(async (file: FileRecord) => {
|
||||
|
||||
Reference in New Issue
Block a user