@cloudcare/browser-core 2.0.4 → 2.0.6
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.
- package/cjs/browser/addEventListener.js +57 -0
- package/cjs/browser/fetchObservable.js +4 -5
- package/cjs/browser/pageExitObservable.js +4 -2
- package/cjs/browser/runOnReadyState.js +21 -0
- package/cjs/browser/xhrObservable.js +7 -5
- package/cjs/configuration/configuration.js +5 -3
- package/cjs/console/consoleObservable.js +3 -1
- package/cjs/dataMap.js +1 -0
- package/cjs/helper/byteUtils.js +26 -0
- package/cjs/helper/contextHistory.js +4 -2
- package/cjs/helper/createEventRateLimiter.js +3 -1
- package/cjs/helper/errorTools.js +4 -2
- package/cjs/helper/instrumentMethod.js +2 -4
- package/cjs/helper/serialisation/contextManager.js +84 -0
- package/cjs/helper/serialisation/heavyCustomerDataWarning.js +34 -0
- package/cjs/helper/serialisation/jsonStringify.js +57 -0
- package/cjs/helper/serialisation/rowData.js +50 -0
- package/cjs/helper/timer.js +29 -0
- package/cjs/helper/tools.js +10 -331
- package/cjs/index.js +117 -0
- package/cjs/init.js +6 -6
- package/cjs/report/reportObservable.js +4 -2
- package/cjs/session/sessionCookieStore.js +3 -1
- package/cjs/session/sessionManagement.js +10 -5
- package/cjs/session/sessionStore.js +10 -4
- package/cjs/transport/batch.js +40 -91
- package/cjs/transport/flushController.js +121 -0
- package/cjs/transport/httpRequest.js +6 -2
- package/cjs/transport/index.js +9 -1
- package/cjs/transport/sendWithRetryStrategy.js +8 -4
- package/cjs/transport/startBatchWithReplica.js +10 -2
- package/cjs/user/index.js +18 -0
- package/cjs/user/user.js +42 -0
- package/esm/browser/addEventListener.js +46 -0
- package/esm/browser/fetchObservable.js +4 -3
- package/esm/browser/pageExitObservable.js +2 -1
- package/esm/browser/runOnReadyState.js +12 -0
- package/esm/browser/xhrObservable.js +6 -5
- package/esm/configuration/configuration.js +2 -1
- package/esm/console/consoleObservable.js +2 -1
- package/esm/dataMap.js +1 -0
- package/esm/helper/byteUtils.js +16 -0
- package/esm/helper/contextHistory.js +1 -0
- package/esm/helper/createEventRateLimiter.js +1 -0
- package/esm/helper/errorTools.js +2 -1
- package/esm/helper/instrumentMethod.js +1 -3
- package/esm/helper/serialisation/contextManager.js +70 -0
- package/esm/helper/serialisation/heavyCustomerDataWarning.js +20 -0
- package/esm/helper/serialisation/jsonStringify.js +46 -0
- package/esm/helper/serialisation/rowData.js +33 -0
- package/esm/helper/timer.js +14 -0
- package/esm/helper/tools.js +1 -292
- package/esm/index.js +10 -1
- package/esm/init.js +6 -6
- package/esm/report/reportObservable.js +3 -2
- package/esm/session/sessionCookieStore.js +1 -0
- package/esm/session/sessionManagement.js +5 -2
- package/esm/session/sessionStore.js +7 -2
- package/esm/transport/batch.js +31 -85
- package/esm/transport/flushController.js +114 -0
- package/esm/transport/httpRequest.js +5 -2
- package/esm/transport/index.js +2 -1
- package/esm/transport/sendWithRetryStrategy.js +3 -1
- package/esm/transport/startBatchWithReplica.js +9 -2
- package/esm/user/index.js +1 -0
- package/esm/user/user.js +32 -0
- package/package.json +22 -22
- package/src/browser/addEventListener.js +50 -0
- package/src/browser/fetchObservable.js +5 -5
- package/src/browser/pageExitObservable.js +4 -5
- package/src/browser/runOnReadyState.js +16 -0
- package/src/browser/xhrObservable.js +57 -32
- package/src/configuration/configuration.js +1 -1
- package/src/console/consoleObservable.js +22 -12
- package/src/dataMap.js +1 -0
- package/src/helper/byteUtils.js +17 -0
- package/src/helper/contextHistory.js +1 -1
- package/src/helper/createEventRateLimiter.js +7 -9
- package/src/helper/errorTools.js +2 -1
- package/src/helper/instrumentMethod.js +1 -2
- package/src/helper/serialisation/contextManager.js +79 -0
- package/src/helper/serialisation/heavyCustomerDataWarning.js +28 -0
- package/src/helper/serialisation/jsonStringify.js +47 -0
- package/src/helper/serialisation/rowData.js +41 -0
- package/src/helper/timer.js +21 -0
- package/src/helper/tools.js +2 -301
- package/src/index.js +11 -0
- package/src/init.js +6 -6
- package/src/report/reportObservable.js +40 -25
- package/src/session/sessionCookieStore.js +24 -14
- package/src/session/sessionManagement.js +34 -17
- package/src/session/sessionStore.js +7 -2
- package/src/transport/batch.js +39 -91
- package/src/transport/flushController.js +115 -0
- package/src/transport/httpRequest.js +13 -6
- package/src/transport/index.js +1 -0
- package/src/transport/sendWithRetryStrategy.js +3 -7
- package/src/transport/startBatchWithReplica.js +11 -7
- package/src/user/index.js +1 -0
- package/src/user/user.js +31 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { newRetryState, sendWithRetryStrategy } from './sendWithRetryStrategy'
|
|
2
|
-
|
|
2
|
+
import { addEventListener } from '../browser/addEventListener'
|
|
3
3
|
/**
|
|
4
4
|
* Use POST request without content type to:
|
|
5
5
|
* - avoid CORS preflight requests
|
|
@@ -100,10 +100,17 @@ function isKeepAliveSupported() {
|
|
|
100
100
|
function sendXHR(url, data, onResponse) {
|
|
101
101
|
const request = new XMLHttpRequest()
|
|
102
102
|
request.open('POST', url, true)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
addEventListener(
|
|
104
|
+
request,
|
|
105
|
+
'loadend',
|
|
106
|
+
function () {
|
|
107
|
+
if (typeof onResponse === 'function') {
|
|
108
|
+
onResponse({ status: request.status })
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
once: true
|
|
107
113
|
}
|
|
108
|
-
|
|
114
|
+
)
|
|
115
|
+
request.send(data)
|
|
109
116
|
}
|
package/src/transport/index.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
ONE_KIBI_BYTE,
|
|
4
|
-
ONE_MEBI_BYTE,
|
|
5
|
-
ONE_SECOND
|
|
6
|
-
} from '../helper/tools'
|
|
1
|
+
import { clocksNow, ONE_SECOND } from '../helper/tools'
|
|
2
|
+
import { ONE_MEBI_BYTE, ONE_KIBI_BYTE } from '../helper/byteUtils'
|
|
7
3
|
import { ErrorSource } from '../helper/errorTools'
|
|
8
|
-
|
|
4
|
+
import { setTimeout } from '../helper/timer'
|
|
9
5
|
export var MAX_ONGOING_BYTES_COUNT = 80 * ONE_KIBI_BYTE
|
|
10
6
|
export var MAX_ONGOING_REQUESTS = 32
|
|
11
7
|
export var MAX_QUEUE_BYTES_COUNT = 3 * ONE_MEBI_BYTE
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { Batch } from './batch'
|
|
2
2
|
import { createHttpRequest } from './httpRequest'
|
|
3
|
-
|
|
3
|
+
import { createFlushController } from './flushController'
|
|
4
4
|
export function startBatchWithReplica(
|
|
5
5
|
configuration,
|
|
6
6
|
endpointUrl,
|
|
7
7
|
reportError,
|
|
8
|
-
pageExitObservable
|
|
8
|
+
pageExitObservable,
|
|
9
|
+
sessionExpireObservable
|
|
9
10
|
) {
|
|
10
11
|
var primaryBatch = createBatch(endpointUrl)
|
|
11
12
|
|
|
@@ -16,11 +17,14 @@ export function startBatchWithReplica(
|
|
|
16
17
|
configuration.batchBytesLimit,
|
|
17
18
|
reportError
|
|
18
19
|
),
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
20
|
+
createFlushController({
|
|
21
|
+
messagesLimit: configuration.batchMessagesLimit,
|
|
22
|
+
bytesLimit: configuration.batchBytesLimit,
|
|
23
|
+
durationLimit: configuration.flushTimeout,
|
|
24
|
+
pageExitObservable: pageExitObservable,
|
|
25
|
+
sessionExpireObservable: sessionExpireObservable
|
|
26
|
+
}),
|
|
27
|
+
configuration.messageBytesLimit
|
|
24
28
|
)
|
|
25
29
|
}
|
|
26
30
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './user'
|
package/src/user/user.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { display } from '../helper/display'
|
|
2
|
+
import { assign, getType, each } from '../helper/tools'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Clone input data and ensure known user properties (id, name, email)
|
|
6
|
+
* are strings, as defined here:
|
|
7
|
+
* https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
|
|
8
|
+
*/
|
|
9
|
+
export function sanitizeUser(newUser) {
|
|
10
|
+
// We shallow clone only to prevent mutation of user data.
|
|
11
|
+
var user = assign({}, newUser)
|
|
12
|
+
var keys = ['id', 'name', 'email']
|
|
13
|
+
each(keys, function (key) {
|
|
14
|
+
if (key in user) {
|
|
15
|
+
user[key] = String(user[key])
|
|
16
|
+
}
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
return user
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Simple check to ensure user is valid
|
|
24
|
+
*/
|
|
25
|
+
export function checkUser(newUser) {
|
|
26
|
+
var isValid = getType(newUser) === 'object'
|
|
27
|
+
if (!isValid) {
|
|
28
|
+
display.error('Unsupported user:', newUser)
|
|
29
|
+
}
|
|
30
|
+
return isValid
|
|
31
|
+
}
|