Skip to content

Commit

Permalink
👌 LogsEventsFormat -> LogsEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaudan committed Dec 14, 2020
1 parent 7ca9758 commit 578f648
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions packages/logs/src/boot/logs.entry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ import {
UserConfiguration,
} from '@datadog/browser-core'
import { HandlerType, Logger, LogsMessage, StatusType } from '../domain/logger'
import { LogsEventsFormat } from '../logsEventsFormat'
import { LogsEvent } from '../logsEvent.types'
import { startLogs } from './logs'

export interface LogsUserConfiguration extends UserConfiguration {
forwardErrorsToLogs?: boolean
beforeSend?: (event: LogsEventsFormat) => void
beforeSend?: (event: LogsEvent) => void
}

export interface LoggerConfiguration {
Expand Down
10 changes: 5 additions & 5 deletions packages/logs/src/boot/logs.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import sinon from 'sinon'

import { Logger, LogsMessage, StatusType } from '../domain/logger'
import { LogsEventsFormat } from '../logsEventsFormat'
import { LogsEvent } from '../logsEvent.types'
import { buildAssemble, doStartLogs } from './logs'

interface SentMessage extends LogsMessage {
Expand Down Expand Up @@ -129,13 +129,13 @@ describe('logs', () => {

describe('assemble', () => {
let assemble: (message: LogsMessage, currentContext: Context) => Context | undefined
let beforeSend: (event: LogsEventsFormat) => void
let beforeSend: (event: LogsEvent) => void

beforeEach(() => {
beforeSend = noop
assemble = buildAssemble(session, {
...(baseConfiguration as Configuration),
beforeSend: (x: LogsEventsFormat) => beforeSend(x),
beforeSend: (x: LogsEvent) => beforeSend(x),
})
window.DD_RUM = {
getInternalContext: noop,
Expand Down Expand Up @@ -188,15 +188,15 @@ describe('logs', () => {
})

it('should allow modification on sensitive field', () => {
beforeSend = (event: LogsEventsFormat) => (event.message = 'modified')
beforeSend = (event: LogsEvent) => (event.message = 'modified')

const assembledMessage = assemble(DEFAULT_MESSAGE, {})

expect(assembledMessage!.message).toBe('modified')
})

it('should reject modification on non sensitive field', () => {
beforeSend = (event: LogsEventsFormat) => ((event.service as any) = 'modified')
beforeSend = (event: LogsEvent) => ((event.service as any) = 'modified')

const assembledMessage = assemble(DEFAULT_MESSAGE, {})

Expand Down
4 changes: 2 additions & 2 deletions packages/logs/src/boot/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
} from '@datadog/browser-core'
import { Logger, LogsMessage } from '../domain/logger'
import { LoggerSession, startLoggerSession } from '../domain/loggerSession'
import { LogsEventsFormat } from '../logsEventsFormat'
import { LogsEvent } from '../logsEvent.types'
import { buildEnv } from './buildEnv'
import { LogsUserConfiguration } from './logs.entry'

Expand Down Expand Up @@ -126,7 +126,7 @@ export function buildAssemble(session: LoggerSession, configuration: Configurati
)
if (configuration.beforeSend) {
limitModification(
contextualizedMessage as LogsEventsFormat & Context,
contextualizedMessage as LogsEvent & Context,
FIELDS_WITH_SENSITIVE_DATA,
configuration.beforeSend
)
Expand Down
2 changes: 1 addition & 1 deletion packages/logs/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export { Datacenter } from '@datadog/browser-core'
export { StatusType, HandlerType, Logger, LogsMessage } from './domain/logger'
export { LogsUserConfiguration, Status, LoggerConfiguration, LogsGlobal, datadogLogs } from './boot/logs.entry'
export { LogsEventsFormat } from './logsEventsFormat'
export { LogsEvent } from './logsEvent.types'
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface LogsEventsFormat {
export interface LogsEvent {
/**
* Start of the log in ms from epoch
*/
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/lib/framework/eventsRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LogsEventsFormat } from '@datadog/browser-logs'
import { LogsEvent } from '@datadog/browser-logs'
import { RumEventsFormat } from '@datadog/browser-rum'
import {
isRumErrorEvent,
Expand All @@ -12,7 +12,7 @@ type IntakeType = 'logs' | 'rum' | 'internalMonitoring'

export class EventRegistry {
readonly rum: RumEventsFormat[] = []
readonly logs: LogsEventsFormat[] = []
readonly logs: LogsEvent[] = []
readonly internalMonitoring: ServerInternalMonitoringMessage[] = []

push(type: IntakeType, event: any) {
Expand Down
1 change: 0 additions & 1 deletion test/e2e/scenario/logs.scenario.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { LogsEventsFormat } from '@datadog/browser-logs'
import { createTest } from '../lib/framework'
import { browserExecute, browserExecuteAsync, flushBrowserLogs, withBrowserLogs } from '../lib/helpers/browser'
import { flushEvents } from '../lib/helpers/sdk'
Expand Down

0 comments on commit 578f648

Please sign in to comment.