Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ [RUM-1013] early exit when no configuration provided #2417

Merged
merged 1 commit into from
Sep 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions packages/logs/src/boot/logsPublicApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,12 @@ describe('logs entry', () => {
expect(startLogs).toHaveBeenCalled()
})

it('should not start when the configuration is missing', () => {
;(LOGS.init as () => void)()
expect(displaySpy).toHaveBeenCalled()
expect(startLogs).not.toHaveBeenCalled()
})

it('should not start when the configuration is invalid', () => {
LOGS.init(INVALID_INIT_CONFIGURATION)
expect(displaySpy).toHaveBeenCalled()
Expand Down
4 changes: 4 additions & 0 deletions packages/logs/src/boot/logsPublicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ export function makeLogsPublicApi(startLogsImpl: StartLogs) {
logger: mainLogger,

init: monitor((initConfiguration: LogsInitConfiguration) => {
if (!initConfiguration) {
display.error('Missing configuration')
return
}
// This function should be available, regardless of initialization success.
getInitConfigurationStrategy = () => deepClone(initConfiguration)

Expand Down
6 changes: 6 additions & 0 deletions packages/rum-core/src/boot/rumPublicApi.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ describe('rum public api', () => {
expect(startRumSpy).toHaveBeenCalled()
})

it('should not start when the configuration is missing', () => {
;(rumPublicApi.init as () => void)()
expect(displaySpy).toHaveBeenCalled()
expect(startRumSpy).not.toHaveBeenCalled()
})

it('should not start when the configuration is invalid', () => {
rumPublicApi.init(INVALID_INIT_CONFIGURATION)
expect(displaySpy).toHaveBeenCalled()
Expand Down
4 changes: 4 additions & 0 deletions packages/rum-core/src/boot/rumPublicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ export function makeRumPublicApi(
}

function initRum(initConfiguration: RumInitConfiguration) {
if (!initConfiguration) {
display.error('Missing configuration')
return
}
// This function should be available, regardless of initialization success.
getInitConfigurationStrategy = () => deepClone<InitConfiguration>(initConfiguration)

Expand Down