Skip to content

Commit

Permalink
♻️ move LogsEventDomainContext type to own file to fix ts module isol…
Browse files Browse the repository at this point in the history
…ation compatibility
  • Loading branch information
thomas-lebeau committed Apr 4, 2024
1 parent 3f9cd43 commit db9b257
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion packages/logs/src/domain/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?: (<T extends LogsEvent>(event: T, context: LogsEventDomainContext<T['origin']>) => boolean) | undefined
Expand Down
11 changes: 2 additions & 9 deletions packages/logs/src/domain/lifeCycle.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -16,14 +17,6 @@ interface LifeCycleEventMap {
export const LifeCycle = AbstractLifeCycle<LifeCycleEventMap>
export type LifeCycle = AbstractLifeCycle<LifeCycleEventMap>

export type LogsEventDomainContext<T extends ErrorSource> = T extends typeof ErrorSource.NETWORK
? NetworkLogsEventDomainContext
: never

type NetworkLogsEventDomainContext = {
isAborted: boolean
}

export interface RawLogsEventCollectedData<E extends RawLogsEvent = RawLogsEvent> {
rawLogsEvent: E
messageContext?: object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
9 changes: 9 additions & 0 deletions packages/logs/src/domainContext.types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { ErrorSource } from '@datadog/browser-core'

export type LogsEventDomainContext<T extends ErrorSource> = T extends typeof ErrorSource.NETWORK
? NetworkLogsEventDomainContext
: never

export type NetworkLogsEventDomainContext = {
isAborted: boolean
}

0 comments on commit db9b257

Please sign in to comment.