diff --git a/packages/rum-core/src/boot/rumPublicApi.spec.ts b/packages/rum-core/src/boot/rumPublicApi.spec.ts index 34fbf300f1..f8596e68da 100644 --- a/packages/rum-core/src/boot/rumPublicApi.spec.ts +++ b/packages/rum-core/src/boot/rumPublicApi.spec.ts @@ -1,4 +1,4 @@ -import { ErrorSource, ONE_SECOND, RelativeTime, getTimeStamp, display, TimeStamp } from '@datadog/browser-core' +import { ONE_SECOND, RelativeTime, getTimeStamp, display, TimeStamp } from '@datadog/browser-core' import { setup, TestSetupBuilder } from '../../test/specHelper' import { ActionType } from '../rawRumEvent.types' import { makeRumPublicApi, RumPublicApi, RumInitConfiguration, StartRum } from './rumPublicApi' @@ -280,27 +280,12 @@ describe('rum public api', () => { context: undefined, error: new Error('foo'), handlingStack: jasmine.any(String), - source: ErrorSource.CUSTOM, startClocks: jasmine.any(Object), }, { context: {}, user: {} }, ]) }) - it('allows setting an ErrorSource', () => { - rumPublicApi.init(DEFAULT_INIT_CONFIGURATION) - rumPublicApi.addError(new Error('foo'), undefined, ErrorSource.SOURCE) - expect(addErrorSpy.calls.argsFor(0)[0].source).toBe(ErrorSource.SOURCE) - }) - - it('fallbacks to ErrorSource.CUSTOM if an invalid source is given', () => { - const displaySpy = spyOn(display, 'error') - rumPublicApi.init(DEFAULT_INIT_CONFIGURATION) - rumPublicApi.addError(new Error('foo'), undefined, 'invalid' as any) - expect(addErrorSpy.calls.argsFor(0)[0].source).toBe(ErrorSource.CUSTOM) - expect(displaySpy).toHaveBeenCalledWith("DD_RUM.addError: Invalid source 'invalid'") - }) - it('should generate a handling stack', () => { rumPublicApi.init(DEFAULT_INIT_CONFIGURATION) function triggerError() { diff --git a/packages/rum-core/src/boot/rumPublicApi.ts b/packages/rum-core/src/boot/rumPublicApi.ts index c9ac4e8aee..bf14d7baa4 100644 --- a/packages/rum-core/src/boot/rumPublicApi.ts +++ b/packages/rum-core/src/boot/rumPublicApi.ts @@ -6,7 +6,6 @@ import { Context, createContextManager, deepClone, - ErrorSource, isPercentage, makePublicApi, monitor, @@ -20,7 +19,6 @@ import { callMonitored, createHandlingStack, } from '@datadog/browser-core' -import { ProvidedSource } from '../domain/rumEventsCollection/error/errorCollection' import { RumEventDomainContext } from '../domainContext.types' import { CommonContext, User, ActionType } from '../rawRumEvent.types' import { RumEvent } from '../rumEvent.types' @@ -161,21 +159,13 @@ export function makeRumPublicApi(startRumImpl: S rumPublicApi.addAction(name, context as Context) }, - addError: (error: unknown, context?: object, source: ProvidedSource = ErrorSource.CUSTOM) => { + addError: (error: unknown, context?: object) => { const handlingStack = createHandlingStack() callMonitored(() => { - let checkedSource: ProvidedSource - if (source === ErrorSource.CUSTOM || source === ErrorSource.NETWORK || source === ErrorSource.SOURCE) { - checkedSource = source - } else { - display.error(`DD_RUM.addError: Invalid source '${source as string}'`) - checkedSource = ErrorSource.CUSTOM - } addErrorStrategy({ error, handlingStack, context: deepClone(context as Context), - source: checkedSource, startClocks: clocksNow(), }) }) diff --git a/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.spec.ts b/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.spec.ts index 619b6f97fa..8dee16bf4d 100644 --- a/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.spec.ts +++ b/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.spec.ts @@ -33,7 +33,6 @@ describe('error collection', () => { addError({ error, handlingStack: 'Error: handling foo', - source: ErrorSource.CUSTOM, startClocks: { relative: 1234 as RelativeTime, timeStamp: 123456789 as TimeStamp }, }) @@ -69,7 +68,6 @@ describe('error collection', () => { context: { foo: 'bar' }, error: new Error('foo'), handlingStack: 'Error: handling foo', - source: ErrorSource.CUSTOM, startClocks: { relative: 1234 as RelativeTime, timeStamp: 123456789 as TimeStamp }, }) expect(rawRumEvents[0].customerContext).toEqual({ @@ -83,7 +81,6 @@ describe('error collection', () => { { error: new Error('foo'), handlingStack: 'Error: handling foo', - source: ErrorSource.CUSTOM, startClocks: { relative: 1234 as RelativeTime, timeStamp: 123456789 as TimeStamp }, }, { context: { foo: 'bar' }, user: {} } @@ -99,7 +96,6 @@ describe('error collection', () => { { error: new Error('foo'), handlingStack: 'Error: handling foo', - source: ErrorSource.CUSTOM, startClocks: { relative: 1234 as RelativeTime, timeStamp: 123456789 as TimeStamp }, }, { context: {}, user: { id: 'foo' } } @@ -113,7 +109,6 @@ describe('error collection', () => { const { rawRumEvents } = setupBuilder.build() addError({ error: { foo: 'bar' }, - source: ErrorSource.CUSTOM, handlingStack: 'Error: handling foo', startClocks: { relative: 1234 as RelativeTime, timeStamp: 123456789 as TimeStamp }, }) diff --git a/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.ts b/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.ts index 4253302cc2..ff21473f7d 100644 --- a/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.ts +++ b/packages/rum-core/src/domain/rumEventsCollection/error/errorCollection.ts @@ -4,6 +4,7 @@ import { Context, formatUnknownError, RawError, + ErrorSource, ClocksState, generateUUID, ErrorHandling, @@ -20,12 +21,9 @@ export interface ProvidedError { startClocks: ClocksState error: unknown context?: Context - source: ProvidedSource handlingStack: string } -export type ProvidedSource = 'custom' | 'network' | 'source' - export function startErrorCollection( lifeCycle: LifeCycle, configuration: Configuration, @@ -54,10 +52,10 @@ export function doStartErrorCollection(lifeCycle: LifeCycle, foregroundContexts: return { addError: ( - { error, handlingStack, startClocks, context: customerContext, source }: ProvidedError, + { error, handlingStack, startClocks, context: customerContext }: ProvidedError, savedCommonContext?: CommonContext ) => { - const rawError = computeRawError(error, handlingStack, startClocks, source) + const rawError = computeRawError(error, handlingStack, startClocks) lifeCycle.notify(LifeCycleEventType.RAW_ERROR_COLLECTED, { customerContext, savedCommonContext, @@ -67,16 +65,11 @@ export function doStartErrorCollection(lifeCycle: LifeCycle, foregroundContexts: } } -function computeRawError( - error: unknown, - handlingStack: string, - startClocks: ClocksState, - source: ProvidedSource -): RawError { +function computeRawError(error: unknown, handlingStack: string, startClocks: ClocksState): RawError { const stackTrace = error instanceof Error ? computeStackTrace(error) : undefined return { startClocks, - source, + source: ErrorSource.CUSTOM, originalError: error, ...formatUnknownError(stackTrace, error, 'Provided', handlingStack), handling: ErrorHandling.HANDLED, diff --git a/packages/rum-core/src/index.ts b/packages/rum-core/src/index.ts index 96a9722b4d..4c6c092da8 100644 --- a/packages/rum-core/src/index.ts +++ b/packages/rum-core/src/index.ts @@ -5,7 +5,6 @@ export { makeRumPublicApi, StartRum, } from './boot/rumPublicApi' -export { ProvidedSource } from './domain/rumEventsCollection/error/errorCollection' export { RumEvent, RumActionEvent, diff --git a/packages/rum-recorder/src/index.ts b/packages/rum-recorder/src/index.ts index e6e2cae791..281939ae89 100644 --- a/packages/rum-recorder/src/index.ts +++ b/packages/rum-recorder/src/index.ts @@ -2,7 +2,6 @@ export { datadogRum } from './boot/recorder.entry' export { CommonProperties, - ProvidedSource, RumInitConfiguration, RumUserConfiguration, // Events diff --git a/packages/rum/src/index.ts b/packages/rum/src/index.ts index 16abaeffdf..3d5ef5e41a 100644 --- a/packages/rum/src/index.ts +++ b/packages/rum/src/index.ts @@ -2,7 +2,6 @@ export { datadogRum } from './boot/rum.entry' export { CommonProperties, - ProvidedSource, RumPublicApi as RumGlobal, RumInitConfiguration, RumUserConfiguration,