@cloudcare/browser-logs 3.1.23 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/bundle/dataflux-logs.js +1 -1
  2. package/cjs/boot/buildEnv.js +1 -1
  3. package/cjs/boot/logsPublicApi.js +35 -62
  4. package/cjs/boot/logsPublicApi.js.map +1 -1
  5. package/cjs/boot/preStartLogs.js +72 -0
  6. package/cjs/boot/preStartLogs.js.map +1 -0
  7. package/cjs/boot/startLogs.js +57 -38
  8. package/cjs/boot/startLogs.js.map +1 -1
  9. package/cjs/domain/assembly.js +5 -7
  10. package/cjs/domain/assembly.js.map +1 -1
  11. package/cjs/domain/contexts/commonContext.js +17 -0
  12. package/cjs/domain/contexts/commonContext.js.map +1 -0
  13. package/cjs/domain/contexts/internalContext.js.map +1 -0
  14. package/cjs/domain/createErrorFieldFromRawError.js +20 -0
  15. package/cjs/domain/createErrorFieldFromRawError.js.map +1 -0
  16. package/cjs/domain/logger.js +61 -54
  17. package/cjs/domain/logger.js.map +1 -1
  18. package/cjs/domain/logsCollection/console/consoleCollection.js +5 -5
  19. package/cjs/domain/logsCollection/console/consoleCollection.js.map +1 -1
  20. package/cjs/domain/logsCollection/logger/loggerCollection.js +37 -20
  21. package/cjs/domain/logsCollection/logger/loggerCollection.js.map +1 -1
  22. package/cjs/domain/logsCollection/networkError/networkErrorCollection.js +11 -6
  23. package/cjs/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -1
  24. package/cjs/domain/logsCollection/report/reportCollection.js +6 -15
  25. package/cjs/domain/logsCollection/report/reportCollection.js.map +1 -1
  26. package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
  27. package/cjs/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -1
  28. package/cjs/domain/reportError.js +24 -0
  29. package/cjs/domain/reportError.js.map +1 -0
  30. package/cjs/transport/startLogsBatch.js +6 -2
  31. package/cjs/transport/startLogsBatch.js.map +1 -1
  32. package/esm/boot/buildEnv.js +1 -1
  33. package/esm/boot/logsPublicApi.js +36 -63
  34. package/esm/boot/logsPublicApi.js.map +1 -1
  35. package/esm/boot/preStartLogs.js +66 -0
  36. package/esm/boot/preStartLogs.js.map +1 -0
  37. package/esm/boot/startLogs.js +57 -38
  38. package/esm/boot/startLogs.js.map +1 -1
  39. package/esm/domain/assembly.js +6 -8
  40. package/esm/domain/assembly.js.map +1 -1
  41. package/esm/domain/contexts/commonContext.js +11 -0
  42. package/esm/domain/contexts/commonContext.js.map +1 -0
  43. package/esm/domain/contexts/internalContext.js.map +1 -0
  44. package/esm/domain/createErrorFieldFromRawError.js +14 -0
  45. package/esm/domain/createErrorFieldFromRawError.js.map +1 -0
  46. package/esm/domain/logger.js +62 -55
  47. package/esm/domain/logger.js.map +1 -1
  48. package/esm/domain/logsCollection/console/consoleCollection.js +5 -5
  49. package/esm/domain/logsCollection/console/consoleCollection.js.map +1 -1
  50. package/esm/domain/logsCollection/logger/loggerCollection.js +39 -22
  51. package/esm/domain/logsCollection/logger/loggerCollection.js.map +1 -1
  52. package/esm/domain/logsCollection/networkError/networkErrorCollection.js +12 -7
  53. package/esm/domain/logsCollection/networkError/networkErrorCollection.js.map +1 -1
  54. package/esm/domain/logsCollection/report/reportCollection.js +7 -16
  55. package/esm/domain/logsCollection/report/reportCollection.js.map +1 -1
  56. package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -5
  57. package/esm/domain/logsCollection/rumtimeError/runtimeErrorCollection.js.map +1 -1
  58. package/esm/domain/reportError.js +18 -0
  59. package/esm/domain/reportError.js.map +1 -0
  60. package/esm/transport/startLogsBatch.js +7 -3
  61. package/esm/transport/startLogsBatch.js.map +1 -1
  62. package/package.json +4 -3
  63. package/src/boot/logsPublicApi.js +52 -86
  64. package/src/boot/preStartLogs.js +94 -0
  65. package/src/boot/startLogs.js +83 -60
  66. package/src/domain/assembly.js +7 -12
  67. package/src/domain/contexts/commonContext.js +10 -0
  68. package/src/domain/createErrorFieldFromRawError.js +13 -0
  69. package/src/domain/logger.js +89 -63
  70. package/src/domain/logsCollection/console/consoleCollection.js +5 -9
  71. package/src/domain/logsCollection/logger/loggerCollection.js +46 -25
  72. package/src/domain/logsCollection/networkError/networkErrorCollection.js +11 -7
  73. package/src/domain/logsCollection/report/reportCollection.js +9 -16
  74. package/src/domain/logsCollection/rumtimeError/runtimeErrorCollection.js +2 -6
  75. package/src/domain/reportError.js +21 -0
  76. package/src/transport/startLogsBatch.js +6 -4
  77. package/types/configuration.d.ts +2 -2
  78. package/types/logger.d.ts +3 -22
  79. package/cjs/domain/internalContext.js.map +0 -1
  80. package/esm/domain/internalContext.js.map +0 -1
  81. /package/cjs/domain/{internalContext.js → contexts/internalContext.js} +0 -0
  82. /package/esm/domain/{internalContext.js → contexts/internalContext.js} +0 -0
  83. /package/src/domain/{internalContext.js → contexts/internalContext.js} +0 -0
@@ -1,81 +1,30 @@
1
1
  import {
2
- BoundedBuffer,
3
2
  createContextManager,
4
3
  makePublicApi,
5
4
  CustomerDataType,
6
- display,
7
- deepClone,
8
- timeStampNow,
9
5
  checkUser,
10
6
  sanitizeUser,
11
7
  monitor,
12
- storeContextManager
8
+ storeContextManager,
9
+ displayAlreadyInitializedError,
10
+ assign
13
11
  } from '@cloudcare/browser-core'
14
- import { validateAndBuildLogsConfiguration } from '../domain/configuration'
15
12
  import { Logger } from '../domain/logger'
13
+ import { buildCommonContext } from '../domain/contexts/commonContext'
14
+ import { createPreStartStrategy } from './preStartLogs'
16
15
  var LOGS_STORAGE_KEY = 'logs'
17
16
  export function makeLogsPublicApi(startLogsImpl) {
18
- var isAlreadyInitialized = false
19
-
20
17
  var globalContextManager = createContextManager(
21
18
  CustomerDataType.GlobalContext
22
19
  )
23
20
  var userContextManager = createContextManager(CustomerDataType.User)
24
- var customLoggers = {}
25
- var getInternalContextStrategy = function () {
26
- return undefined
27
- }
28
-
29
- var beforeInitLoggerLog = new BoundedBuffer()
30
-
31
- var handleLogStrategy = function (
32
- logsMessage,
33
- logger,
34
- savedCommonContext,
35
- date
36
- ) {
37
- if (typeof savedCommonContext === 'undefined') {
38
- savedCommonContext = deepClone(buildCommonContext())
39
- }
40
- if (typeof date === 'undefined') {
41
- date = timeStampNow()
42
- }
43
- beforeInitLoggerLog.add(function () {
44
- return handleLogStrategy(logsMessage, logger, savedCommonContext, date)
45
- })
46
- }
47
21
 
48
- var getInitConfigurationStrategy = function () {
49
- return undefined
22
+ function getCommonContext() {
23
+ return buildCommonContext(globalContextManager, userContextManager)
50
24
  }
51
-
52
- var mainLogger = new Logger(function () {
53
- return handleLogStrategy.apply(this, arguments)
54
- })
55
-
56
- function buildCommonContext() {
57
- return {
58
- view: {
59
- referrer: document.referrer,
60
- url: window.location.href
61
- },
62
- context: globalContextManager.getContext(),
63
- user: userContextManager.getContext()
64
- }
65
- }
66
-
67
- return makePublicApi({
68
- logger: mainLogger,
69
-
70
- init: monitor(function (initConfiguration) {
71
- if (!canInitLogs(initConfiguration)) {
72
- return
73
- }
74
-
75
- var configuration = validateAndBuildLogsConfiguration(initConfiguration)
76
- if (!configuration) {
77
- return
78
- }
25
+ var strategy = createPreStartStrategy(
26
+ getCommonContext,
27
+ function (initConfiguration, configuration) {
79
28
  if (initConfiguration.storeContextsToLocal) {
80
29
  storeContextManager(
81
30
  configuration,
@@ -90,19 +39,28 @@ export function makeLogsPublicApi(startLogsImpl) {
90
39
  CustomerDataType.User
91
40
  )
92
41
  }
93
- var _startLogsImpl = startLogsImpl(
42
+
43
+ var startLogsResult = startLogsImpl(
44
+ initConfiguration,
94
45
  configuration,
95
- buildCommonContext,
96
- mainLogger
46
+ getCommonContext
97
47
  )
98
- handleLogStrategy = _startLogsImpl.handleLog
99
- getInternalContextStrategy = _startLogsImpl.getInternalContext
100
- getInitConfigurationStrategy = function () {
101
- return deepClone(initConfiguration)
102
- }
103
- beforeInitLoggerLog.drain()
104
48
 
105
- isAlreadyInitialized = true
49
+ strategy = createPostStartStrategy(initConfiguration, startLogsResult)
50
+ return startLogsResult
51
+ }
52
+ )
53
+ var customLoggers = {}
54
+
55
+ var mainLogger = new Logger(function () {
56
+ return strategy.handleLog.apply(this, arguments)
57
+ })
58
+
59
+ return makePublicApi({
60
+ logger: mainLogger,
61
+
62
+ init: monitor(function (initConfiguration) {
63
+ return strategy.init(initConfiguration)
106
64
  }),
107
65
 
108
66
  getGlobalContext: monitor(function () {
@@ -131,12 +89,12 @@ export function makeLogsPublicApi(startLogsImpl) {
131
89
  }
132
90
  customLoggers[name] = new Logger(
133
91
  function () {
134
- return handleLogStrategy(this.arguments)
92
+ return strategy.handleLog.apply(this, arguments)
135
93
  },
136
- name,
94
+ sanitize(name),
137
95
  conf.handler,
138
96
  conf.level,
139
- conf.context
97
+ sanitize(conf.context)
140
98
  )
141
99
  return customLoggers[name]
142
100
  }),
@@ -146,11 +104,11 @@ export function makeLogsPublicApi(startLogsImpl) {
146
104
  }),
147
105
 
148
106
  getInitConfiguration: monitor(function () {
149
- return getInitConfigurationStrategy()
107
+ return strategy.getInitConfiguration()
150
108
  }),
151
109
 
152
110
  getInternalContext: monitor(function (startTime) {
153
- return getInternalContextStrategy(startTime)
111
+ return strategy.getInternalContext(startTime)
154
112
  }),
155
113
  setUser: monitor(function (newUser) {
156
114
  if (checkUser(newUser)) {
@@ -163,19 +121,27 @@ export function makeLogsPublicApi(startLogsImpl) {
163
121
  removeUserProperty: monitor(function (key) {
164
122
  return userContextManager.removeContextProperty(key)
165
123
  }),
124
+ setUserProperty: monitor(function (key, property) {
125
+ var newUser = {}
126
+ newUser[key] = property
127
+ var sanitizedProperty = sanitizeUser(newUser)[key]
128
+ userContextManager.setContextProperty(key, sanitizedProperty)
129
+ }),
166
130
  clearUser: monitor(function () {
167
131
  return userContextManager.clearContext()
168
132
  })
169
133
  })
170
-
171
- function canInitLogs(initConfiguration) {
172
- if (isAlreadyInitialized) {
173
- if (!initConfiguration.silentMultipleInit) {
174
- display.error('DD_LOGS is already initialized.')
134
+ }
135
+ function createPostStartStrategy(initConfiguration, startLogsResult) {
136
+ return assign(
137
+ {
138
+ init: function (initConfiguration) {
139
+ displayAlreadyInitializedError('DATAFLUX_LOGS', initConfiguration)
140
+ },
141
+ getInitConfiguration: function () {
142
+ return initConfiguration
175
143
  }
176
- return false
177
- }
178
-
179
- return true
180
- }
144
+ },
145
+ startLogsResult
146
+ )
181
147
  }
@@ -0,0 +1,94 @@
1
+ import {
2
+ createBoundedBuffer,
3
+ assign,
4
+ canUseEventBridge,
5
+ display,
6
+ displayAlreadyInitializedError,
7
+ initFetchObservable,
8
+ noop,
9
+ timeStampNow
10
+ } from '@cloudcare/browser-core'
11
+ import { validateAndBuildLogsConfiguration } from '../domain/configuration'
12
+
13
+ export function createPreStartStrategy(getCommonContext, doStartLogs) {
14
+ const bufferApiCalls = createBoundedBuffer()
15
+ let cachedInitConfiguration
16
+ let cachedConfiguration
17
+
18
+ function tryStartLogs() {
19
+ if (!cachedConfiguration || !cachedInitConfiguration) {
20
+ return
21
+ }
22
+
23
+ var startLogsResult = doStartLogs(
24
+ cachedInitConfiguration,
25
+ cachedConfiguration
26
+ )
27
+ bufferApiCalls.drain(startLogsResult)
28
+ }
29
+
30
+ return {
31
+ init: function (initConfiguration) {
32
+ if (!initConfiguration) {
33
+ display.error('Missing configuration')
34
+ return
35
+ }
36
+ // Set the experimental feature flags as early as possible, so we can use them in most places
37
+
38
+ if (canUseEventBridge()) {
39
+ initConfiguration =
40
+ overrideInitConfigurationForBridge(initConfiguration)
41
+ }
42
+
43
+ // Expose the initial configuration regardless of initialization success.
44
+ cachedInitConfiguration = initConfiguration
45
+
46
+ if (cachedConfiguration) {
47
+ displayAlreadyInitializedError('DATAFLUX_LOGS', initConfiguration)
48
+ return
49
+ }
50
+
51
+ const configuration = validateAndBuildLogsConfiguration(initConfiguration)
52
+ if (!configuration) {
53
+ return
54
+ }
55
+
56
+ cachedConfiguration = configuration
57
+ // Instrumuent fetch to track network requests
58
+ // This is needed in case the consent is not granted and some cutsomer
59
+ // library (Apollo Client) is storing uninstrumented fetch to be used later
60
+ // The subscrption is needed so that the instrumentation process is completed
61
+ initFetchObservable().subscribe(noop)
62
+
63
+ tryStartLogs()
64
+ },
65
+
66
+ getInitConfiguration: function () {
67
+ return cachedInitConfiguration
68
+ },
69
+
70
+ getInternalContext: noop,
71
+
72
+ handleLog: function (message, statusType, handlingStack, context, date) {
73
+ if (context === undefined) {
74
+ context = getCommonContext()
75
+ }
76
+ if (date === undefined) {
77
+ date = timeStampNow()
78
+ }
79
+ bufferApiCalls.add(function (startLogsResult) {
80
+ startLogsResult.handleLog(
81
+ message,
82
+ statusType,
83
+ handlingStack,
84
+ context,
85
+ date
86
+ )
87
+ })
88
+ }
89
+ }
90
+ }
91
+
92
+ function overrideInitConfigurationForBridge(initConfiguration) {
93
+ return assign({}, initConfiguration, { clientToken: 'empty' })
94
+ }
@@ -1,13 +1,16 @@
1
1
  import {
2
- ErrorSource,
3
2
  LifeCycle,
4
- LifeCycleEventType,
5
3
  createPageExitObservable,
6
4
  areCookiesAuthorized,
5
+ willSyntheticsInjectRum,
7
6
  startTelemetry,
8
7
  startBatchWithReplica,
9
8
  canUseEventBridge,
10
- TelemetryService
9
+ TelemetryService,
10
+ drainPreStartTelemetry,
11
+ createIdentityEncoder,
12
+ addTelemetryConfiguration,
13
+ deepClone
11
14
  } from '@cloudcare/browser-core'
12
15
  import {
13
16
  startLogsSessionManager,
@@ -20,60 +23,28 @@ import { startNetworkErrorCollection } from '../domain/logsCollection/networkErr
20
23
  import { startRuntimeErrorCollection } from '../domain/logsCollection/rumtimeError/runtimeErrorCollection'
21
24
  import { startLoggerCollection } from '../domain/logsCollection/logger/loggerCollection'
22
25
  import { startLogsBatch } from '../transport/startLogsBatch'
23
- import { StatusType } from '../domain/logger'
24
- import { startInternalContext } from '../domain/internalContext'
25
-
26
- export function startLogs(configuration, buildCommonContext, mainLogger) {
26
+ import { startInternalContext } from '../domain/contexts/internalContext'
27
+ import { startReportError } from '../domain/reportError'
28
+ export function startLogs(initConfiguration, configuration, getCommonContext) {
27
29
  var lifeCycle = new LifeCycle()
28
-
29
- var reportError = function (error) {
30
- lifeCycle.notify(LifeCycleEventType.RAW_LOG_COLLECTED, {
31
- rawLogsEvent: {
32
- message: error.message,
33
- date: error.startClocks.timeStamp,
34
- error: {
35
- origin: ErrorSource.AGENT
36
- },
37
- origin: ErrorSource.AGENT,
38
- status: StatusType.error
39
- }
40
- })
41
- }
30
+ var cleanupTasks = []
31
+ var reportError = startReportError(lifeCycle)
42
32
  var pageExitObservable = createPageExitObservable()
43
- var session = areCookiesAuthorized(configuration.cookieOptions)
44
- ? startLogsSessionManager(configuration)
45
- : startLogsSessionManagerStub(configuration)
33
+ var session =
34
+ areCookiesAuthorized(configuration.cookieOptions) &&
35
+ !canUseEventBridge() &&
36
+ !willSyntheticsInjectRum()
37
+ ? startLogsSessionManager(configuration)
38
+ : startLogsSessionManagerStub(configuration)
46
39
  const telemetry = startLogsTelemetry(
40
+ initConfiguration,
47
41
  configuration,
48
42
  reportError,
49
43
  pageExitObservable,
50
- session.expireObservable
44
+ session
51
45
  )
52
- telemetry.setContextProvider(function () {
53
- var RUMInternalContext = getRUMInternalContext()
54
- return {
55
- application: {
56
- id:
57
- RUMInternalContext &&
58
- RUMInternalContext.application &&
59
- RUMInternalContext.application.id
60
- },
61
- session: {
62
- id: session.findTrackedSession() && session.findTrackedSession().id
63
- },
64
- view: {
65
- id:
66
- RUMInternalContext &&
67
- RUMInternalContext.view &&
68
- RUMInternalContext.view.id
69
- },
70
- action: {
71
- id:
72
- RUMInternalContext &&
73
- RUMInternalContext.userAction &&
74
- RUMInternalContext.userAction.id
75
- }
76
- }
46
+ cleanupTasks.push(function () {
47
+ telemetry.stop()
77
48
  })
78
49
  startNetworkErrorCollection(configuration, lifeCycle)
79
50
  startRuntimeErrorCollection(configuration, lifeCycle)
@@ -85,45 +56,97 @@ export function startLogs(configuration, buildCommonContext, mainLogger) {
85
56
  session,
86
57
  configuration,
87
58
  lifeCycle,
88
- buildCommonContext,
89
- mainLogger,
59
+ getCommonContext,
90
60
  reportError
91
61
  )
92
62
  if (!canUseEventBridge()) {
93
- startLogsBatch(
63
+ var _startLogsBatch = startLogsBatch(
94
64
  configuration,
95
65
  lifeCycle,
96
66
  reportError,
97
67
  pageExitObservable,
98
- session.expireObservable
68
+ session
99
69
  )
70
+ cleanupTasks.push(function () {
71
+ _startLogsBatch.stop()
72
+ })
100
73
  }
101
74
 
102
75
  var internalContext = startInternalContext(session)
103
76
 
104
77
  return {
105
78
  handleLog: _startLoggerCollection.handleLog,
106
- getInternalContext: internalContext.get
79
+ getInternalContext: internalContext.get,
80
+ stop: function () {
81
+ cleanupTasks.forEach(function (task) {
82
+ task()
83
+ })
84
+ }
107
85
  }
108
86
  }
109
87
  function startLogsTelemetry(
88
+ initConfiguration,
110
89
  configuration,
111
90
  reportError,
112
91
  pageExitObservable,
113
- sessionExpireObservable
92
+ session
114
93
  ) {
115
94
  const telemetry = startTelemetry(TelemetryService.LOGS, configuration)
95
+ telemetry.setContextProvider(function () {
96
+ var RUMInternalContext = getRUMInternalContext()
97
+ return {
98
+ application: {
99
+ id:
100
+ RUMInternalContext &&
101
+ RUMInternalContext.application &&
102
+ RUMInternalContext.application.id
103
+ },
104
+ session: {
105
+ id: session.findTrackedSession() && session.findTrackedSession().id
106
+ },
107
+ view: {
108
+ id:
109
+ RUMInternalContext &&
110
+ RUMInternalContext.view &&
111
+ RUMInternalContext.view.id
112
+ },
113
+ action: {
114
+ id:
115
+ RUMInternalContext &&
116
+ RUMInternalContext.userAction &&
117
+ RUMInternalContext.userAction.id
118
+ }
119
+ }
120
+ })
121
+ var cleanupTasks = []
116
122
  if (!canUseEventBridge()) {
117
123
  var telemetryBatch = startBatchWithReplica(
118
124
  configuration,
119
- configuration.rumEndpoint,
125
+ { endpoint: configuration.rumEndpoint, encoder: createIdentityEncoder() },
120
126
  reportError,
121
127
  pageExitObservable,
122
- sessionExpireObservable
128
+ session.expireObservable
123
129
  )
124
- telemetry.observable.subscribe(function (event) {
130
+ cleanupTasks.push(function () {
131
+ telemetryBatch.stop()
132
+ })
133
+ var telemetrySubscription = telemetry.observable.subscribe(function (
134
+ event
135
+ ) {
125
136
  telemetryBatch.add(event)
126
137
  })
138
+ cleanupTasks.push(function () {
139
+ telemetrySubscription.unsubscribe()
140
+ })
141
+ }
142
+ drainPreStartTelemetry()
143
+ addTelemetryConfiguration(deepClone(initConfiguration))
144
+ return {
145
+ telemetry: telemetry,
146
+ stop: function () {
147
+ cleanupTasks.forEach(function (task) {
148
+ task()
149
+ })
150
+ }
127
151
  }
128
- return telemetry
129
152
  }
@@ -12,15 +12,13 @@ import {
12
12
  isNullUndefinedDefaultValue
13
13
  } from '@cloudcare/browser-core'
14
14
 
15
- import { STATUSES, HandlerType } from './logger'
16
- import { isAuthorized } from './logsCollection/logger/loggerCollection'
15
+ import { STATUSES } from './logger'
17
16
 
18
17
  export function startLogsAssembly(
19
18
  sessionManager,
20
19
  configuration,
21
20
  lifeCycle,
22
- buildCommonContext,
23
- mainLogger,
21
+ getCommonContext,
24
22
  reportError
25
23
  ) {
26
24
  var statusWithCustom = STATUSES.concat(['custom'])
@@ -33,18 +31,17 @@ export function startLogsAssembly(
33
31
  )
34
32
  })
35
33
  lifeCycle.subscribe(LifeCycleEventType.RAW_LOG_COLLECTED, function (data) {
36
- // { rawLogsEvent, messageContext = undefined, savedCommonContext = undefined, logger = mainLogger }
37
34
  var rawLogsEvent = data.rawLogsEvent
38
35
  var messageContext = data.messageContext || undefined
39
36
  var savedCommonContext = data.savedCommonContext || undefined
40
- var logger = data.logger || mainLogger
37
+ var domainContext = data.domainContext
41
38
  var startTime = getRelativeTime(rawLogsEvent.date)
42
39
  var session = sessionManager.findTrackedSession(startTime)
43
40
 
44
41
  if (!session) {
45
42
  return
46
43
  }
47
- var commonContext = savedCommonContext || buildCommonContext()
44
+ var commonContext = savedCommonContext || getCommonContext()
48
45
  var log = extend2Lev(
49
46
  {
50
47
  service: configuration.service || 'browser',
@@ -67,15 +64,13 @@ export function startLogsAssembly(
67
64
  commonContext.context,
68
65
  getRUMInternalContext(startTime),
69
66
  rawLogsEvent,
70
- logger.getContext(),
71
67
  messageContext
72
68
  )
73
69
 
74
70
  if (
75
- !isAuthorized(rawLogsEvent.status, HandlerType.http, logger) ||
76
- (configuration.beforeSend && configuration.beforeSend(log) === false) ||
77
- (log.error &&
78
- log.error.origin !== ErrorSource.AGENT &&
71
+ (configuration.beforeSend &&
72
+ configuration.beforeSend(log, domainContext) === false) ||
73
+ (log.origin !== ErrorSource.AGENT &&
79
74
  isNullUndefinedDefaultValue(
80
75
  logRateLimiters[log.status],
81
76
  logRateLimiters['custom']
@@ -0,0 +1,10 @@
1
+ export function buildCommonContext(globalContextManager, userContextManager) {
2
+ return {
3
+ view: {
4
+ referrer: document.referrer,
5
+ url: window.location.href
6
+ },
7
+ context: globalContextManager.getContext(),
8
+ user: userContextManager.getContext()
9
+ }
10
+ }
@@ -0,0 +1,13 @@
1
+ export function createErrorFieldFromRawError(rawError, options) {
2
+ if (options === undefined) {
3
+ options = {}
4
+ }
5
+ var includeMessage = options.includeMessage || false
6
+ return {
7
+ stack: rawError.stack,
8
+ kind: rawError.type,
9
+ message: includeMessage ? rawError.message : undefined,
10
+ causes: rawError.causes,
11
+ handling: rawError.handling
12
+ }
13
+ }