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

[RUMF-1176] collect other console logs new #1316

Merged
merged 30 commits into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
e552db1
Add console observable
amortemousque Feb 4, 2022
bf39e51
🔥 Delete trackConsoleError
amortemousque Feb 4, 2022
4ba65d7
Add console observable to rum
amortemousque Feb 4, 2022
3ef80e6
Add console observable to Logs
amortemousque Feb 4, 2022
a1c5cbb
👌 Add trackConsoleError
amortemousque Feb 7, 2022
933269a
👌 Update console log event observable
amortemousque Feb 7, 2022
eed7e68
👌 Move source computation to Log and RUM
amortemousque Feb 7, 2022
e6a6b43
Use an enum + keep current behavior
amortemousque Feb 7, 2022
03a9de3
Add feature flag forward-logs
amortemousque Feb 7, 2022
60ea273
✅ Add tests
amortemousque Feb 8, 2022
7ff6239
✨ Add forwardConsoleLogs init config option
amortemousque Feb 8, 2022
1063bad
Fix rum console error tracking
amortemousque Feb 8, 2022
cf3a4cd
Merge branch 'main' into aymeric/collect-other-console-logs-new
amortemousque Feb 8, 2022
7fc700c
✅ Add test for forwardErrorsToLogs: 'all'
amortemousque Feb 8, 2022
4abf4f2
👌 Namings
amortemousque Feb 9, 2022
9a874c3
👌 Ensure that only allowed api are instrumented.
amortemousque Feb 9, 2022
32a4393
👌 Remove CONSOLE_APIS
amortemousque Feb 9, 2022
4b8ea23
👌 Clearer cast comment
amortemousque Feb 9, 2022
197dadc
Update error observable naming
amortemousque Feb 9, 2022
d10b0dd
👌 Move console observable into domain
amortemousque Feb 9, 2022
5cd4d91
👌 Add mergeObservables tests
amortemousque Feb 9, 2022
18b2dbe
✅ Update test to ensure the api is instrumented once
amortemousque Feb 9, 2022
f88969c
Make removeDuplicates IE compatible
amortemousque Feb 9, 2022
aa2669c
Merge branch 'main' into aymeric/collect-other-console-logs-new
amortemousque Feb 10, 2022
d3792a5
👌 Code style
amortemousque Feb 10, 2022
3c3176c
👌 Add removeDuplicates test
amortemousque Feb 10, 2022
fc3d57e
Fix naming
amortemousque Feb 10, 2022
7e26428
Fix test flackyness
amortemousque Feb 11, 2022
e35baea
Merge branch 'main' into aymeric/collect-other-console-logs-new
amortemousque Feb 15, 2022
109ce1f
Simplify validateAndBuildLogsConfiguration
amortemousque Feb 15, 2022
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
2 changes: 0 additions & 2 deletions packages/core/src/browser/consoleObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ export const ConsoleApiName = {

export type ConsoleApiName = typeof ConsoleApiName[keyof typeof ConsoleApiName]

export const CONSOLE_APIS = Object.keys(ConsoleApiName) as ConsoleApiName[]

export interface ConsoleLog {
message: string
api: ConsoleApiName
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export { Context, ContextArray, ContextValue } from './tools/context'
export { areCookiesAuthorized, getCookie, setCookie, deleteCookie, COOKIE_ACCESS_DELAY } from './browser/cookie'
export { initXhrObservable, XhrCompleteContext, XhrStartContext } from './browser/xhrObservable'
export { initFetchObservable, FetchCompleteContext, FetchStartContext, FetchContext } from './browser/fetchObservable'
export { initConsoleObservable, ConsoleLog, ConsoleApiName, CONSOLE_APIS } from './browser/consoleObservable'
export { initConsoleObservable, ConsoleLog, ConsoleApiName } from './browser/consoleObservable'
export { BoundedBuffer } from './tools/boundedBuffer'
export { catchUserErrors } from './tools/catchUserErrors'
export { createContextManager } from './tools/contextManager'
Expand Down
5 changes: 3 additions & 2 deletions packages/logs/src/domain/configuration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CONSOLE_APIS, display, resetExperimentalFeatures, updateExperimentalFeatures } from '@datadog/browser-core'
import { ConsoleApiName, display, resetExperimentalFeatures, updateExperimentalFeatures } from '@datadog/browser-core'
import { validateAndBuildLogsConfiguration } from './configuration'

const DEFAULT_INIT_CONFIGURATION = { clientToken: 'xxx' }
Expand Down Expand Up @@ -28,6 +28,7 @@ describe('validateAndBuildLogsConfiguration', () => {
let displaySpy: jasmine.Spy<typeof display.error>
const errorMessage =
'Forward Console Logs should be "all" or an array with allowed values "log", "debug", "info", "warn", "error"'

beforeEach(() => {
displaySpy = spyOn(display, 'error')
updateExperimentalFeatures(['forward-logs'])
Expand Down Expand Up @@ -71,7 +72,7 @@ describe('validateAndBuildLogsConfiguration', () => {
expect(
validateAndBuildLogsConfiguration({ ...DEFAULT_INIT_CONFIGURATION, forwardConsoleLogs: 'all' })!
.forwardConsoleLogs
).toEqual(CONSOLE_APIS)
).toEqual(Object.keys(ConsoleApiName) as ConsoleApiName[])
})
})

Expand Down
12 changes: 6 additions & 6 deletions packages/logs/src/domain/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
isExperimentalFeatureEnabled,
removeDuplicates,
ConsoleApiName,
CONSOLE_APIS,
includes,
} from '@datadog/browser-core'
import { buildEnv } from '../boot/buildEnv'
Expand Down Expand Up @@ -40,23 +39,24 @@ export function validateAndBuildLogsConfiguration(
return
}

const allowedConsoleApis = Object.keys(ConsoleApiName) as ConsoleApiName[]
let forwardConsoleLogs: StatusType[] = []
if (isExperimentalFeatureEnabled('forward-logs') && initConfiguration.forwardConsoleLogs !== undefined) {
if (
(initConfiguration.forwardConsoleLogs !== 'all' && !Array.isArray(initConfiguration.forwardConsoleLogs)) ||
(Array.isArray(initConfiguration.forwardConsoleLogs) &&
initConfiguration.forwardConsoleLogs.some((api) => !includes(CONSOLE_APIS, api)))
initConfiguration.forwardConsoleLogs.some((api) => !includes(allowedConsoleApis, api)))
amortemousque marked this conversation as resolved.
Show resolved Hide resolved
) {
display.error(
`Forward Console Logs should be "all" or an array with allowed values ${CONSOLE_APIS.map(
(api) => `"${api}"`
).join(', ')}`
`Forward Console Logs should be "all" or an array with allowed values ${allowedConsoleApis
.map((api) => `"${api}"`)
.join(', ')}`
amortemousque marked this conversation as resolved.
Show resolved Hide resolved
)
return
}

forwardConsoleLogs =
initConfiguration.forwardConsoleLogs === 'all' ? CONSOLE_APIS : initConfiguration.forwardConsoleLogs
initConfiguration.forwardConsoleLogs === 'all' ? allowedConsoleApis : initConfiguration.forwardConsoleLogs
}

if (initConfiguration.forwardErrorsToLogs) {
Expand Down