diff --git a/src/client/services/bff.httpClient.service.ts b/src/client/services/bff.httpClient.service.ts index d061d4263f..302c499334 100644 --- a/src/client/services/bff.httpClient.service.ts +++ b/src/client/services/bff.httpClient.service.ts @@ -22,6 +22,8 @@ export class BffHttpClientService implements HttpClientService { (request: InternalAxiosRequestConfig) => { const transactionId = uuid4(); request.headers['x-transaction-id'] = transactionId; + // FIXME (GAFI 16-05-2024): On est d'accord que là, si j'ai 2 requêtes qui partent coup sur coup, le transactionId + // de la première est écrasé par la seconde ? this.logger.setTransactionId(transactionId); return request; }, diff --git a/src/client/services/logger.service.test.ts b/src/client/services/logger.service.test.ts index 51c408fff3..0dad366390 100644 --- a/src/client/services/logger.service.test.ts +++ b/src/client/services/logger.service.test.ts @@ -8,9 +8,7 @@ const SentryMock = jest.mocked(Sentry, { shallow: true }); const SentryScopeMock = { setTag: jest.fn(), } as unknown as Sentry.Scope; -SentryMock.configureScope.mockImplementation((callback) => { - callback(SentryScopeMock); -}); +SentryMock.getCurrentScope.mockReturnValue(SentryScopeMock); describe('LoggerService', () => { const sessionId = 'ma-session-id'; diff --git a/src/client/services/logger.service.ts b/src/client/services/logger.service.ts index 791bcad477..258eb655ac 100644 --- a/src/client/services/logger.service.ts +++ b/src/client/services/logger.service.ts @@ -2,9 +2,8 @@ import * as Sentry from '@sentry/nextjs'; export class LoggerService { constructor(sessionId?: string) { - Sentry.configureScope((scope: Sentry.Scope) => { - scope.setTag('session_id', sessionId); - }); + const scope = Sentry.getCurrentScope(); + scope.setTag('session_id', sessionId); } private static log( @@ -27,8 +26,7 @@ export class LoggerService { } setTransactionId(transactionId: string): void { - Sentry.configureScope((scope) => { - scope.setTag('transaction_id', transactionId); - }); + const scope = Sentry.getCurrentScope(); + scope.setTag('transaction_id', transactionId); } }