From db9b257b0b06c883e41215b8ff808c7cf4ae3e96 Mon Sep 17 00:00:00 2001 From: Thomas Lebeau Date: Thu, 4 Apr 2024 12:25:48 +0200 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20move=20LogsEventDomainCont?= =?UTF-8?q?ext=20type=20to=20own=20file=20to=20fix=20ts=20module=20isolati?= =?UTF-8?q?on=20compatibility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/logs/src/domain/configuration.ts | 2 +- packages/logs/src/domain/lifeCycle.ts | 11 ++--------- .../src/domain/networkError/networkErrorCollection.ts | 3 ++- packages/logs/src/domainContext.types.ts | 9 +++++++++ 4 files changed, 14 insertions(+), 11 deletions(-) create mode 100644 packages/logs/src/domainContext.types.ts diff --git a/packages/logs/src/domain/configuration.ts b/packages/logs/src/domain/configuration.ts index e2708e555e..e59d7f3f97 100644 --- a/packages/logs/src/domain/configuration.ts +++ b/packages/logs/src/domain/configuration.ts @@ -12,7 +12,7 @@ import { objectValues, } from '@datadog/browser-core' import type { LogsEvent } from '../logsEvent.types' -import type { LogsEventDomainContext } from './lifeCycle' +import type { LogsEventDomainContext } from '../domainContext.types' export interface LogsInitConfiguration extends InitConfiguration { beforeSend?: ((event: T, context: LogsEventDomainContext) => boolean) | undefined diff --git a/packages/logs/src/domain/lifeCycle.ts b/packages/logs/src/domain/lifeCycle.ts index 35f452abc2..64ac8ee6b2 100644 --- a/packages/logs/src/domain/lifeCycle.ts +++ b/packages/logs/src/domain/lifeCycle.ts @@ -1,7 +1,8 @@ import { AbstractLifeCycle } from '@datadog/browser-core' -import type { Context, ErrorSource } from '@datadog/browser-core' +import type { Context } from '@datadog/browser-core' import type { LogsEvent } from '../logsEvent.types' import type { CommonContext, RawLogsEvent } from '../rawLogsEvent.types' +import type { LogsEventDomainContext } from '../domainContext.types' export const enum LifeCycleEventType { RAW_LOG_COLLECTED, @@ -16,14 +17,6 @@ interface LifeCycleEventMap { export const LifeCycle = AbstractLifeCycle export type LifeCycle = AbstractLifeCycle -export type LogsEventDomainContext = T extends typeof ErrorSource.NETWORK - ? NetworkLogsEventDomainContext - : never - -type NetworkLogsEventDomainContext = { - isAborted: boolean -} - export interface RawLogsEventCollectedData { rawLogsEvent: E messageContext?: object diff --git a/packages/logs/src/domain/networkError/networkErrorCollection.ts b/packages/logs/src/domain/networkError/networkErrorCollection.ts index 2913921fa1..ab2a4cb409 100644 --- a/packages/logs/src/domain/networkError/networkErrorCollection.ts +++ b/packages/logs/src/domain/networkError/networkErrorCollection.ts @@ -13,7 +13,8 @@ import { isServerError, } from '@datadog/browser-core' import type { LogsConfiguration } from '../configuration' -import type { LifeCycle, LogsEventDomainContext } from '../lifeCycle' +import type { LifeCycle } from '../lifeCycle' +import type { LogsEventDomainContext } from '../../domainContext.types' import { LifeCycleEventType } from '../lifeCycle' import { StatusType } from '../logger' diff --git a/packages/logs/src/domainContext.types.ts b/packages/logs/src/domainContext.types.ts new file mode 100644 index 0000000000..b24ac486bf --- /dev/null +++ b/packages/logs/src/domainContext.types.ts @@ -0,0 +1,9 @@ +import type { ErrorSource } from '@datadog/browser-core' + +export type LogsEventDomainContext = T extends typeof ErrorSource.NETWORK + ? NetworkLogsEventDomainContext + : never + +export type NetworkLogsEventDomainContext = { + isAborted: boolean +}