11import  {  HttpService  }  from  '@nestjs/axios' ; 
22import  {  Logger  }  from  '@nestjs/common' ; 
33import  {  AxiosError ,  AxiosRequestConfig ,  AxiosResponse ,  InternalAxiosRequestConfig  }  from  'axios' ; 
4- import  {  IntegrationLoggerDto  }  from  '@infrastructure/integrations/common/audit' ; 
4+ import  {  IntegrationLoggerDto  }  from  '@infrastructure/integrations/shared/audit' ; 
5+ import  {  TracerContextAudit  }  from  '@shared/audit' ; 
56
67/** 
78 * Class responsible for managing API integration audit logs. 
@@ -11,10 +12,10 @@ import { IntegrationLoggerDto } from '@infrastructure/integrations/common/audit'
1112 * 
1213 * ```typescript 
1314 * import { WebhookIntegrationClientProvider } from '@core/providers/integrations'; 
14-  * import { Injectable, Logger } from '@nestjs/common '; 
15+  * import { Injectable, Logger } from '@nestjs/shared '; 
1516 * import { firstValueFrom } from 'rxjs'; 
1617 * import { HttpService } from '@nestjs/axios'; 
17-  * import { IntegrationAuditCommon } from '@infrastructure/integrations/common /audit'; 
18+  * import { IntegrationAuditCommon } from '@infrastructure/integrations/shared /audit'; 
1819 * 
1920 * @Injectable () 
2021 * export class WebhookIntegrationClientProviderImpl implements WebhookIntegrationClientProvider { 
@@ -83,6 +84,7 @@ export class IntegrationAuditCommon {
8384      config . headers  =  { } ; 
8485    } 
8586    config . headers [ 'request-start-time' ]  =  process . hrtime ( ) ; 
87+     config . headers [ 'x-tracer-id' ]  =  TracerContextAudit . getContextTracerId ( ) ; 
8688    return  config ; 
8789  } 
8890
@@ -126,7 +128,7 @@ export class IntegrationAuditCommon {
126128   */ 
127129  private  logAudit ( config : AxiosRequestConfig ,  responseData : any ,  status : number ,  startTime : [ number ,  number ] ,  isError : boolean  =  false ) : void { 
128130    const  integrationLoggerDto  =  this . createIntegrationLoggerDto ( config ,  responseData ,  status ,  startTime ) ; 
129-     const  logMessage  =  `[AUDIT LOG]  ${ JSON . stringify ( integrationLoggerDto ) } ` ; 
131+     const  logMessage  =  JSON . stringify ( integrationLoggerDto ) ; 
130132    if  ( isError )  { 
131133      this . logger . error ( logMessage ) ; 
132134      return ; 
@@ -144,8 +146,9 @@ export class IntegrationAuditCommon {
144146   * @returns  An `IntegrationLoggerDto` object containing the audit information. 
145147   */ 
146148  private  createIntegrationLoggerDto ( config : AxiosRequestConfig ,  responseData : any ,  status : number ,  startTime : [ number ,  number ] ) : IntegrationLoggerDto  { 
149+     const  tracerId  =  < string > config . headers [ 'x-tracer-id' ] ; 
147150    const  method  =  `${ config . method ?. toUpperCase ( ) } ${ config . url }  ; 
148-     return  new  IntegrationLoggerDto ( this . application ,  method ,  config . headers ,  config . params ,  config . data ,  responseData ,  status ,  startTime ) ; 
151+     return  new  IntegrationLoggerDto ( tracerId ,   this . application ,  method ,  config . headers ,  config . params ,  config . data ,  responseData ,  status ,  startTime ) ; 
149152  } 
150153
151154  /** 
0 commit comments