@cloudcare/browser-core 3.0.22 → 3.0.29
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 +9 -7
- package/cjs/browser/fetchObservable.js +5 -3
- package/cjs/console/consoleObservable.js +5 -1
- package/cjs/dataMap.js +5 -1
- package/cjs/helper/errorTools.js +7 -3
- package/cjs/helper/instrumentMethod.js +4 -2
- package/cjs/helper/monitor.js +59 -0
- package/cjs/helper/readBytesFromStream.js +5 -3
- package/cjs/helper/timer.js +4 -2
- package/cjs/helper/tools.js +2 -20
- package/cjs/index.js +13 -0
- package/cjs/init.js +13 -19
- package/cjs/report/reportObservable.js +4 -3
- package/cjs/transport/batch.js +2 -2
- package/cjs/transport/httpRequest.js +5 -3
- package/esm/browser/addEventListener.js +8 -7
- package/esm/browser/fetchObservable.js +4 -3
- package/esm/console/consoleObservable.js +4 -1
- package/esm/dataMap.js +5 -1
- package/esm/helper/errorTools.js +6 -3
- package/esm/helper/instrumentMethod.js +3 -2
- package/esm/helper/monitor.js +40 -0
- package/esm/helper/readBytesFromStream.js +4 -3
- package/esm/helper/timer.js +3 -2
- package/esm/helper/tools.js +2 -18
- package/esm/index.js +1 -0
- package/esm/init.js +12 -18
- package/esm/report/reportObservable.js +3 -3
- package/esm/transport/batch.js +2 -2
- package/esm/transport/httpRequest.js +4 -3
- package/package.json +2 -2
- package/src/browser/addEventListener.js +8 -7
- package/src/browser/fetchObservable.js +12 -3
- package/src/console/consoleObservable.js +4 -2
- package/src/dataMap.js +6 -1
- package/src/helper/errorTools.js +6 -5
- package/src/helper/instrumentMethod.js +5 -2
- package/src/helper/monitor.js +44 -0
- package/src/helper/observable.js +10 -8
- package/src/helper/readBytesFromStream.js +5 -5
- package/src/helper/timer.js +3 -3
- package/src/helper/tools.js +1 -17
- package/src/index.js +1 -0
- package/src/init.js +19 -21
- package/src/report/reportObservable.js +3 -2
- package/src/transport/batch.js +4 -4
- package/src/transport/httpRequest.js +5 -4
package/src/init.js
CHANGED
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
callback()
|
|
6
|
-
}
|
|
7
|
-
})
|
|
8
|
-
return global
|
|
9
|
-
}
|
|
1
|
+
import { each, assign } from './helper/tools'
|
|
2
|
+
import { setDebugMode } from './helper/monitor'
|
|
3
|
+
import { catchUserErrors } from './helper/catchUserErrors'
|
|
4
|
+
|
|
10
5
|
export function makePublicApi(stub) {
|
|
11
|
-
var publicApi =
|
|
12
|
-
|
|
13
|
-
callback
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
var publicApi = assign(
|
|
7
|
+
{
|
|
8
|
+
onReady: function (callback) {
|
|
9
|
+
callback()
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
stub
|
|
13
|
+
)
|
|
16
14
|
|
|
17
15
|
// Add an "hidden" property to set debug mode. We define it that way to hide it
|
|
18
16
|
// as much as possible but of course it's not a real protection.
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
Object.defineProperty(publicApi, '_setDebug', {
|
|
18
|
+
get: function () {
|
|
19
|
+
return setDebugMode
|
|
20
|
+
},
|
|
21
|
+
enumerable: false
|
|
22
|
+
})
|
|
25
23
|
|
|
26
24
|
return publicApi
|
|
27
25
|
}
|
|
@@ -30,7 +28,7 @@ export function defineGlobal(global, name, api) {
|
|
|
30
28
|
global[name] = api
|
|
31
29
|
if (existingGlobalVariable && existingGlobalVariable.q) {
|
|
32
30
|
each(existingGlobalVariable.q, function (fn) {
|
|
33
|
-
fn()
|
|
31
|
+
catchUserErrors(fn, 'onReady callback threw an error:')()
|
|
34
32
|
})
|
|
35
33
|
}
|
|
36
34
|
}
|
|
@@ -3,6 +3,7 @@ import { mergeObservables, Observable } from '../helper/observable'
|
|
|
3
3
|
import { includes, safeTruncate, filter, each } from '../helper/tools'
|
|
4
4
|
import { addEventListener } from '../browser/addEventListener'
|
|
5
5
|
import { DOM_EVENT } from '../helper/enums'
|
|
6
|
+
import { monitor } from '../helper/monitor'
|
|
6
7
|
export var RawReportType = {
|
|
7
8
|
intervention: 'intervention',
|
|
8
9
|
deprecation: 'deprecation',
|
|
@@ -30,11 +31,11 @@ function createReportObservable(reportTypes) {
|
|
|
30
31
|
return
|
|
31
32
|
}
|
|
32
33
|
|
|
33
|
-
var handleReports = function (reports) {
|
|
34
|
+
var handleReports = monitor(function (reports) {
|
|
34
35
|
each(reports, function (report) {
|
|
35
36
|
observable.notify(buildRawReportFromReport(report))
|
|
36
37
|
})
|
|
37
|
-
}
|
|
38
|
+
})
|
|
38
39
|
|
|
39
40
|
var observer = new window.ReportingObserver(handleReports, {
|
|
40
41
|
types: reportTypes,
|
package/src/transport/batch.js
CHANGED
|
@@ -76,13 +76,13 @@ export var processedMessageByDataMap = function (message) {
|
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
if (
|
|
79
|
-
message.
|
|
80
|
-
isObject(message.
|
|
81
|
-
!isEmptyObject(message.
|
|
79
|
+
message.context &&
|
|
80
|
+
isObject(message.context) &&
|
|
81
|
+
!isEmptyObject(message.context)
|
|
82
82
|
) {
|
|
83
83
|
// 自定义tag, 存储成field
|
|
84
84
|
var _tagKeys = []
|
|
85
|
-
each(message.
|
|
85
|
+
each(message.context, function (_value, _key) {
|
|
86
86
|
// 如果和之前tag重名,则舍弃
|
|
87
87
|
if (filterFileds.indexOf(_key) > -1) return
|
|
88
88
|
filterFileds.push(_key)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { newRetryState, sendWithRetryStrategy } from './sendWithRetryStrategy'
|
|
2
2
|
import { addEventListener } from '../browser/addEventListener'
|
|
3
|
+
import { monitor } from '../helper/monitor'
|
|
3
4
|
/**
|
|
4
5
|
* Use POST request without content type to:
|
|
5
6
|
* - avoid CORS preflight requests
|
|
@@ -74,15 +75,15 @@ export function fetchKeepAliveStrategy(
|
|
|
74
75
|
keepalive: true,
|
|
75
76
|
mode: 'cors'
|
|
76
77
|
}).then(
|
|
77
|
-
function (response) {
|
|
78
|
+
monitor(function (response) {
|
|
78
79
|
if (typeof onResponse === 'function') {
|
|
79
80
|
onResponse({ status: response.status, type: response.type })
|
|
80
81
|
}
|
|
81
|
-
},
|
|
82
|
-
function () {
|
|
82
|
+
}),
|
|
83
|
+
monitor(function () {
|
|
83
84
|
// failed to queue the request
|
|
84
85
|
sendXHR(url, data, onResponse)
|
|
85
|
-
}
|
|
86
|
+
})
|
|
86
87
|
)
|
|
87
88
|
} else {
|
|
88
89
|
sendXHR(url, data, onResponse)
|