@cloudcare/browser-core 1.1.3 → 1.2.1
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/{cookie.js → browser/cookie.js} +6 -37
- package/cjs/browser/fetchObservable.js +91 -0
- package/cjs/browser/xhrObservable.js +118 -0
- package/cjs/configuration/configuration.js +70 -0
- package/cjs/configuration/transportConfiguration.js +64 -0
- package/cjs/console/consoleObservable.js +84 -0
- package/cjs/dataMap.js +26 -21
- package/cjs/error/trackRuntimeError.js +27 -0
- package/cjs/helper/catchUserErrors.js +20 -0
- package/cjs/helper/contextHistory.js +134 -0
- package/cjs/helper/createEventRateLimiter.js +47 -0
- package/cjs/helper/deviceInfo.js +8 -25
- package/cjs/helper/display.js +31 -0
- package/cjs/helper/enums.js +28 -2
- package/cjs/helper/errorTools.js +63 -2
- package/cjs/helper/instrumentMethod.js +93 -0
- package/cjs/helper/lifeCycle.js +5 -3
- package/cjs/helper/observable.js +40 -2
- package/cjs/helper/tools.js +185 -9
- package/cjs/index.js +153 -23
- package/cjs/init.js +17 -27
- package/cjs/report/reportObservable.js +112 -0
- package/cjs/session/sessionConstants.js +13 -0
- package/cjs/session/sessionCookieStore.js +188 -0
- package/cjs/session/sessionManagement.js +96 -0
- package/cjs/session/sessionStore.js +150 -0
- package/cjs/synthetics/syntheticsWorkerValues.js +32 -0
- package/cjs/synthetics/usr.js +32 -0
- package/cjs/tracekit/computeStackTrace.js +73 -563
- package/cjs/tracekit/index.js +3 -15
- package/cjs/tracekit/tracekit.js +113 -0
- package/cjs/transport/batch.js +332 -0
- package/cjs/transport/httpRequest.js +112 -0
- package/cjs/transport/index.js +29 -0
- package/cjs/transport/sendWithRetryStrategy.js +177 -0
- package/cjs/transport/startBatchWithReplica.js +24 -0
- package/esm/{cookie.js → browser/cookie.js} +4 -35
- package/esm/browser/fetchObservable.js +77 -0
- package/esm/browser/xhrObservable.js +106 -0
- package/esm/configuration/configuration.js +55 -0
- package/esm/configuration/transportConfiguration.js +54 -0
- package/esm/console/consoleObservable.js +70 -0
- package/esm/dataMap.js +26 -21
- package/esm/error/trackRuntimeError.js +16 -0
- package/esm/helper/catchUserErrors.js +12 -0
- package/esm/helper/contextHistory.js +106 -0
- package/esm/helper/createEventRateLimiter.js +38 -0
- package/esm/helper/deviceInfo.js +6 -25
- package/esm/helper/display.js +21 -0
- package/esm/helper/enums.js +25 -1
- package/esm/helper/errorTools.js +58 -3
- package/esm/helper/instrumentMethod.js +81 -0
- package/esm/helper/lifeCycle.js +5 -3
- package/esm/helper/observable.js +39 -3
- package/esm/helper/tools.js +147 -1
- package/esm/index.js +17 -7
- package/esm/init.js +17 -22
- package/esm/report/reportObservable.js +98 -0
- package/esm/session/sessionConstants.js +3 -0
- package/esm/session/sessionCookieStore.js +168 -0
- package/esm/session/sessionManagement.js +78 -0
- package/esm/session/sessionStore.js +139 -0
- package/esm/synthetics/syntheticsWorkerValues.js +15 -0
- package/esm/synthetics/usr.js +18 -0
- package/esm/tracekit/computeStackTrace.js +73 -557
- package/esm/tracekit/index.js +1 -1
- package/esm/tracekit/tracekit.js +103 -0
- package/esm/transport/batch.js +316 -0
- package/esm/transport/httpRequest.js +104 -0
- package/esm/transport/index.js +3 -0
- package/esm/transport/sendWithRetryStrategy.js +165 -0
- package/esm/transport/startBatchWithReplica.js +15 -0
- package/package.json +2 -2
- package/src/.DS_Store +0 -0
- package/src/{cookie.js → browser/cookie.js} +6 -34
- package/src/browser/fetchObservable.js +86 -0
- package/src/browser/xhrObservable.js +102 -0
- package/src/configuration/configuration.js +61 -0
- package/src/configuration/transportConfiguration.js +42 -0
- package/src/console/consoleObservable.js +65 -0
- package/src/dataMap.js +26 -21
- package/src/error/trackRuntimeError.js +19 -0
- package/src/helper/catchUserErrors.js +12 -0
- package/src/helper/contextHistory.js +85 -0
- package/src/helper/createEventRateLimiter.js +37 -0
- package/src/helper/deviceInfo.js +5 -51
- package/src/helper/display.js +21 -0
- package/src/helper/enums.js +38 -14
- package/src/helper/errorTools.js +76 -12
- package/src/helper/instrumentMethod.js +97 -0
- package/src/helper/lifeCycle.js +5 -3
- package/src/helper/observable.js +33 -2
- package/src/helper/tools.js +135 -4
- package/src/index.js +18 -7
- package/src/init.js +17 -18
- package/src/report/reportObservable.js +113 -0
- package/src/session/sessionConstants.js +3 -0
- package/src/session/sessionCookieStore.js +159 -0
- package/src/session/sessionManagement.js +89 -0
- package/src/session/sessionStore.js +139 -0
- package/src/synthetics/syntheticsWorkerValues.js +22 -0
- package/src/synthetics/usr.js +18 -0
- package/src/tracekit/computeStackTrace.js +75 -551
- package/src/tracekit/index.js +1 -1
- package/src/tracekit/tracekit.js +100 -0
- package/src/transport/batch.js +289 -0
- package/src/transport/httpRequest.js +109 -0
- package/src/transport/index.js +3 -0
- package/src/transport/sendWithRetryStrategy.js +186 -0
- package/src/transport/startBatchWithReplica.js +26 -0
- package/cjs/configuration.js +0 -193
- package/cjs/errorCollection.js +0 -167
- package/cjs/fetchProxy.js +0 -161
- package/cjs/helper/errorFilter.js +0 -47
- package/cjs/sessionManagement.js +0 -221
- package/cjs/tracekit/report.js +0 -289
- package/cjs/transport.js +0 -373
- package/cjs/xhrProxy.js +0 -122
- package/esm/configuration.js +0 -176
- package/esm/errorCollection.js +0 -141
- package/esm/fetchProxy.js +0 -115
- package/esm/helper/errorFilter.js +0 -38
- package/esm/sessionManagement.js +0 -195
- package/esm/tracekit/report.js +0 -273
- package/esm/transport.js +0 -357
- package/esm/xhrProxy.js +0 -110
- package/src/configuration.js +0 -161
- package/src/errorCollection.js +0 -170
- package/src/fetchProxy.js +0 -108
- package/src/helper/errorFilter.js +0 -38
- package/src/sessionManagement.js +0 -224
- package/src/tracekit/report.js +0 -284
- package/src/transport.js +0 -380
- package/src/xhrProxy.js +0 -106
package/esm/dataMap.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { RumEventType } from './helper/enums';
|
|
2
2
|
export var commonTags = {
|
|
3
|
+
action_id: 'action.id',
|
|
3
4
|
sdk_name: '_dd.sdk_name',
|
|
4
5
|
sdk_version: '_dd.sdk_version',
|
|
5
6
|
app_id: 'application.id',
|
|
6
|
-
env: '
|
|
7
|
-
service: '
|
|
8
|
-
version: '
|
|
7
|
+
env: 'env',
|
|
8
|
+
service: 'service',
|
|
9
|
+
version: 'version',
|
|
9
10
|
userid: 'user.id',
|
|
10
11
|
user_email: 'user.email',
|
|
11
12
|
user_name: 'user.name',
|
|
@@ -92,27 +93,31 @@ export var dataMap = {
|
|
|
92
93
|
error: {
|
|
93
94
|
type: RumEventType.ERROR,
|
|
94
95
|
tags: {
|
|
96
|
+
error_id: 'error.id',
|
|
95
97
|
trace_id: '_dd.trace_id',
|
|
96
98
|
span_id: '_dd.span_id',
|
|
97
99
|
error_source: 'error.source',
|
|
98
100
|
error_type: 'error.type',
|
|
99
|
-
error_handling: 'error.handling',
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
error_handling: 'error.handling' // resource_url: 'error.resource.url',
|
|
102
|
+
// resource_url_host: 'error.resource.url_host',
|
|
103
|
+
// resource_url_path: 'error.resource.url_path',
|
|
104
|
+
// resource_url_path_group: 'error.resource.url_path_group',
|
|
105
|
+
// resource_status: 'error.resource.status',
|
|
106
|
+
// resource_status_group: 'error.resource.status_group',
|
|
107
|
+
// resource_method: 'error.resource.method'
|
|
108
|
+
|
|
107
109
|
},
|
|
108
110
|
fields: {
|
|
109
111
|
error_message: ['string', 'error.message'],
|
|
110
|
-
error_stack: ['string', 'error.stack']
|
|
112
|
+
error_stack: ['string', 'error.stack'],
|
|
113
|
+
error_causes: ['string', 'error.causes']
|
|
111
114
|
}
|
|
112
115
|
},
|
|
113
116
|
long_task: {
|
|
114
117
|
type: RumEventType.LONG_TASK,
|
|
115
|
-
tags: {
|
|
118
|
+
tags: {
|
|
119
|
+
long_task_id: 'long_task.id'
|
|
120
|
+
},
|
|
116
121
|
fields: {
|
|
117
122
|
duration: 'long_task.duration'
|
|
118
123
|
}
|
|
@@ -120,7 +125,6 @@ export var dataMap = {
|
|
|
120
125
|
action: {
|
|
121
126
|
type: RumEventType.ACTION,
|
|
122
127
|
tags: {
|
|
123
|
-
action_id: 'action.id',
|
|
124
128
|
action_name: 'action.target.name',
|
|
125
129
|
action_type: 'action.type'
|
|
126
130
|
},
|
|
@@ -128,6 +132,7 @@ export var dataMap = {
|
|
|
128
132
|
duration: 'action.loading_time',
|
|
129
133
|
action_error_count: 'action.error.count',
|
|
130
134
|
action_resource_count: 'action.resource.count',
|
|
135
|
+
action_frustration_types: 'action.frustration.type',
|
|
131
136
|
action_long_task_count: 'action.long_task.count'
|
|
132
137
|
}
|
|
133
138
|
},
|
|
@@ -136,13 +141,13 @@ export var dataMap = {
|
|
|
136
141
|
tags: {
|
|
137
142
|
error_source: 'error.source',
|
|
138
143
|
error_type: 'error.type',
|
|
139
|
-
error_resource_url: '
|
|
140
|
-
error_resource_url_host: '
|
|
141
|
-
error_resource_url_path: '
|
|
142
|
-
error_resource_url_path_group: '
|
|
143
|
-
error_resource_status: '
|
|
144
|
-
error_resource_status_group: '
|
|
145
|
-
error_resource_method: '
|
|
144
|
+
error_resource_url: 'http.url',
|
|
145
|
+
error_resource_url_host: 'http.url_host',
|
|
146
|
+
error_resource_url_path: 'http.url_path',
|
|
147
|
+
error_resource_url_path_group: 'http.url_path_group',
|
|
148
|
+
error_resource_status: 'http.status_code',
|
|
149
|
+
error_resource_status_group: 'http.status_group',
|
|
150
|
+
error_resource_method: 'http.method',
|
|
146
151
|
action_id: 'user_action.id',
|
|
147
152
|
service: 'service',
|
|
148
153
|
status: 'status'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ErrorSource, computeRawError } from '../helper/errorTools';
|
|
2
|
+
import { clocksNow } from '../helper/tools';
|
|
3
|
+
import { ErrorHandling } from '../helper/enums';
|
|
4
|
+
import { startUnhandledErrorCollection } from '../tracekit';
|
|
5
|
+
export function trackRuntimeError(errorObservable) {
|
|
6
|
+
return startUnhandledErrorCollection(function (stackTrace, originalError) {
|
|
7
|
+
errorObservable.notify(computeRawError({
|
|
8
|
+
stackTrace: stackTrace,
|
|
9
|
+
originalError: originalError,
|
|
10
|
+
startClocks: clocksNow(),
|
|
11
|
+
nonErrorPrefix: 'Uncaught',
|
|
12
|
+
source: ErrorSource.SOURCE,
|
|
13
|
+
handling: ErrorHandling.UNHANDLED
|
|
14
|
+
}));
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { relativeNow, ONE_MINUTE, filter, map } from './tools';
|
|
2
|
+
var END_OF_TIMES = Infinity;
|
|
3
|
+
export var CLEAR_OLD_CONTEXTS_INTERVAL = ONE_MINUTE;
|
|
4
|
+
export function ContextHistory(expireDelay) {
|
|
5
|
+
this.expireDelay = expireDelay;
|
|
6
|
+
this.entries = [];
|
|
7
|
+
|
|
8
|
+
var _this = this;
|
|
9
|
+
|
|
10
|
+
this.clearOldContextsInterval = setInterval(function () {
|
|
11
|
+
_this.clearOldContexts();
|
|
12
|
+
}, CLEAR_OLD_CONTEXTS_INTERVAL);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
ContextHistory.prototype.add = function (context, startTime) {
|
|
16
|
+
var _this = this;
|
|
17
|
+
|
|
18
|
+
var entry = {
|
|
19
|
+
context: context,
|
|
20
|
+
startTime: startTime,
|
|
21
|
+
endTime: END_OF_TIMES,
|
|
22
|
+
remove: function remove() {
|
|
23
|
+
var index = _this.entries.indexOf(entry);
|
|
24
|
+
|
|
25
|
+
if (index >= 0) {
|
|
26
|
+
_this.entries.splice(index, 1);
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
close: function close(endTime) {
|
|
30
|
+
entry.endTime = endTime;
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
this.entries.unshift(entry);
|
|
34
|
+
return entry;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
ContextHistory.prototype.find = function (startTime) {
|
|
38
|
+
if (typeof startTime === 'undefined') {
|
|
39
|
+
startTime = END_OF_TIMES;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
for (var entry of this.entries) {
|
|
43
|
+
if (entry.startTime <= startTime) {
|
|
44
|
+
if (startTime <= entry.endTime) {
|
|
45
|
+
return entry.context;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
break;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Helper function to close the currently active context, if any. This method assumes that entries
|
|
54
|
+
* are not overlapping.
|
|
55
|
+
*/
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
ContextHistory.prototype.closeActive = function (endTime) {
|
|
59
|
+
var latestEntry = this.entries[0];
|
|
60
|
+
|
|
61
|
+
if (latestEntry && latestEntry.endTime === END_OF_TIMES) {
|
|
62
|
+
latestEntry.close(endTime);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Return all contexts that were active during `startTime`, or all currently active contexts if no
|
|
67
|
+
* `startTime` is provided.
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
ContextHistory.prototype.findAll = function (startTime) {
|
|
72
|
+
if (typeof startTime === 'undefined') {
|
|
73
|
+
startTime = END_OF_TIMES;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
var result = filter(this.entries, function (entry) {
|
|
77
|
+
return entry.startTime <= startTime && startTime <= entry.endTime;
|
|
78
|
+
});
|
|
79
|
+
return map(result, function (entry) {
|
|
80
|
+
return entry.context;
|
|
81
|
+
});
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Remove all entries from this collection.
|
|
85
|
+
*/
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
ContextHistory.prototype.reset = function () {
|
|
89
|
+
this.entries = [];
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Stop internal garbage collection of past entries.
|
|
93
|
+
*/
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
ContextHistory.prototype.stop = function () {
|
|
97
|
+
clearInterval(this.clearOldContextsInterval);
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
ContextHistory.prototype.clearOldContexts = function () {
|
|
101
|
+
var oldTimeThreshold = relativeNow() - this.expireDelay;
|
|
102
|
+
|
|
103
|
+
while (this.entries.length > 0 && this.entries[this.entries.length - 1].endTime < oldTimeThreshold) {
|
|
104
|
+
this.entries.pop();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { ErrorSource } from './errorTools';
|
|
2
|
+
import { clocksNow, ONE_MINUTE } from './tools';
|
|
3
|
+
export function createEventRateLimiter(eventType, limit, onLimitReached) {
|
|
4
|
+
var eventCount = 0;
|
|
5
|
+
var allowNextEvent = false;
|
|
6
|
+
return {
|
|
7
|
+
isLimitReached: function isLimitReached() {
|
|
8
|
+
if (eventCount === 0) {
|
|
9
|
+
setTimeout(function () {
|
|
10
|
+
eventCount = 0;
|
|
11
|
+
}, ONE_MINUTE);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
eventCount += 1;
|
|
15
|
+
|
|
16
|
+
if (eventCount <= limit || allowNextEvent) {
|
|
17
|
+
allowNextEvent = false;
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (eventCount === limit + 1) {
|
|
22
|
+
allowNextEvent = true;
|
|
23
|
+
|
|
24
|
+
try {
|
|
25
|
+
onLimitReached({
|
|
26
|
+
message: 'Reached max number of ' + eventType + 's by minute: ' + limit,
|
|
27
|
+
source: ErrorSource.AGENT,
|
|
28
|
+
startClocks: clocksNow()
|
|
29
|
+
});
|
|
30
|
+
} finally {
|
|
31
|
+
allowNextEvent = false;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
}
|
package/esm/helper/deviceInfo.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { display } from '../helper/display';
|
|
1
2
|
var VariableLibrary = {
|
|
2
3
|
navigator: typeof window.navigator != 'undefined' ? window.navigator : {},
|
|
3
4
|
// 信息map
|
|
4
5
|
infoMap: {
|
|
5
6
|
engine: ['WebKit', 'Trident', 'Gecko', 'Presto'],
|
|
6
7
|
browser: ['Safari', 'Chrome', 'Edge', 'IE', 'IE 11', 'IE 10', 'IE 9', 'IE 8', 'IE 7', 'Firefox', 'Firefox Focus', 'Chromium', 'Opera', 'Vivaldi', 'Yandex', 'Arora', 'Lunascape', 'QupZilla', 'Coc Coc', 'Kindle', 'Iceweasel', 'Konqueror', 'Iceape', 'SeaMonkey', 'Epiphany', '360', '360SE', '360EE', 'UC', 'QQBrowser', 'QQ', 'Baidu', 'Maxthon', 'Sogou', 'LBBROWSER', '2345Explorer', 'TheWorld', 'XiaoMi', 'Quark', 'Qiyu', 'Wechat',, 'WechatWork', 'Taobao', 'Alipay', 'Weibo', 'Douban', 'Suning', 'iQiYi'],
|
|
7
|
-
os: ['Windows', '
|
|
8
|
+
os: ['Windows', 'Linux', 'Mac OS', 'Android', 'Ubuntu', 'FreeBSD', 'Debian', 'iOS', 'Windows Phone', 'BlackBerry', 'MeeGo', 'Symbian', 'Chrome OS', 'WebOS'],
|
|
8
9
|
device: ['Mobile', 'Tablet', 'iPad']
|
|
9
10
|
}
|
|
10
11
|
}; // 方法库
|
|
@@ -22,12 +23,7 @@ var MethodLibrary = {
|
|
|
22
23
|
Safari: u.indexOf('Safari') > -1,
|
|
23
24
|
Chrome: u.indexOf('Chrome') > -1 || u.indexOf('CriOS') > -1,
|
|
24
25
|
IE: u.indexOf('MSIE') > -1 || u.indexOf('Trident') > -1,
|
|
25
|
-
|
|
26
|
-
'IE 10': u.indexOf('MSIE 10.0') > -1 && u.indexOf('Trident') > -1,
|
|
27
|
-
'IE 9': u.indexOf('MSIE 9.0') > -1 && u.indexOf('Trident') > -1,
|
|
28
|
-
'IE 8': u.indexOf('MSIE 9.0') > -1 && u.indexOf('Trident') > -1,
|
|
29
|
-
'IE 7': u.indexOf('MSIE 7.0') > -1 && u.indexOf('Trident') > -1,
|
|
30
|
-
Edge: u.indexOf('Edg') > -1 || u.indexOf('Edge') > -1,
|
|
26
|
+
Edge: u.indexOf('Edge') > -1,
|
|
31
27
|
Firefox: u.indexOf('Firefox') > -1 || u.indexOf('FxiOS') > -1,
|
|
32
28
|
'Firefox Focus': u.indexOf('Focus') > -1,
|
|
33
29
|
Chromium: u.indexOf('Chromium') > -1,
|
|
@@ -53,14 +49,13 @@ var MethodLibrary = {
|
|
|
53
49
|
Baidu: u.indexOf('Baidu') > -1 || u.indexOf('BIDUBrowser') > -1,
|
|
54
50
|
Maxthon: u.indexOf('Maxthon') > -1,
|
|
55
51
|
Sogou: u.indexOf('MetaSr') > -1 || u.indexOf('Sogou') > -1,
|
|
56
|
-
LBBROWSER: u.indexOf('LBBROWSER') > -1
|
|
52
|
+
LBBROWSER: u.indexOf('LBBROWSER') > -1,
|
|
57
53
|
'2345Explorer': u.indexOf('2345Explorer') > -1,
|
|
58
54
|
TheWorld: u.indexOf('TheWorld') > -1,
|
|
59
55
|
XiaoMi: u.indexOf('MiuiBrowser') > -1,
|
|
60
56
|
Quark: u.indexOf('Quark') > -1,
|
|
61
57
|
Qiyu: u.indexOf('Qiyu') > -1,
|
|
62
58
|
Wechat: u.indexOf('MicroMessenger') > -1,
|
|
63
|
-
WechatWork: u.indexOf('wxwork/') > -1,
|
|
64
59
|
Taobao: u.indexOf('AliApp(TB') > -1,
|
|
65
60
|
Alipay: u.indexOf('AliApp(AP') > -1,
|
|
66
61
|
Weibo: u.indexOf('Weibo') > -1,
|
|
@@ -69,20 +64,6 @@ var MethodLibrary = {
|
|
|
69
64
|
iQiYi: u.indexOf('IqiyiApp') > -1,
|
|
70
65
|
// 系统或平台
|
|
71
66
|
Windows: u.indexOf('Windows') > -1,
|
|
72
|
-
'Windows 2000': u.indexOf('Windows NT 5.0') > -1 || u.indexOf('Windows 2000') > -1,
|
|
73
|
-
'Windows XP': u.indexOf('Windows NT 5.1') > -1 || u.indexOf('Windows XP') > -1,
|
|
74
|
-
'Windows Server 2003': u.indexOf('Windows NT 5.2') > -1,
|
|
75
|
-
'Windows Vista': u.indexOf('Windows NT 6.0') > -1,
|
|
76
|
-
'Windows 7': u.indexOf('Windows 7') > -1 || u.indexOf('Windows NT 6.1') > -1,
|
|
77
|
-
'Windows 8': u.indexOf('Windows 8') > -1 || u.indexOf('Windows NT 6.2') > -1,
|
|
78
|
-
'Windows 8.1': u.indexOf('Windows 8.1') > -1 || u.indexOf('Windows NT 6.3') > -1,
|
|
79
|
-
'Windows ME': u.indexOf('Win 9x 4.90') > -1 || u.indexOf('Windows ME') > -1,
|
|
80
|
-
'Windows 10': u.indexOf('Windows 10.0') > -1 || u.indexOf('Windows NT 10.0') > -1,
|
|
81
|
-
'Windows 98': u.indexOf('Windows 98') > -1 || u.indexOf('Win98') > -1,
|
|
82
|
-
'Windows 95': u.indexOf('Windows 95') > -1 || u.indexOf('Win95') > -1 || u.indexOf('Windows_95') > -1,
|
|
83
|
-
'Windows NT 4.0': u.indexOf('Windows NT 4.0') > -1 || u.indexOf('WinNT4.0') > -1 || u.indexOf('WinNT') > -1,
|
|
84
|
-
'Windows CE': u.indexOf('Windows CE') > -1,
|
|
85
|
-
'Windows 3.11': u.indexOf('Win16') > -1,
|
|
86
67
|
Linux: u.indexOf('Linux') > -1 || u.indexOf('X11') > -1,
|
|
87
68
|
'Mac OS': u.indexOf('Macintosh') > -1,
|
|
88
69
|
Android: u.indexOf('Android') > -1 || u.indexOf('Adr') > -1,
|
|
@@ -170,7 +151,7 @@ var MethodLibrary = {
|
|
|
170
151
|
if (osVersion[_this.os]) {
|
|
171
152
|
_this.osVersion = osVersion[_this.os]();
|
|
172
153
|
|
|
173
|
-
if (_this.osVersion
|
|
154
|
+
if (_this.osVersion === u) {
|
|
174
155
|
_this.osVersion = '';
|
|
175
156
|
}
|
|
176
157
|
}
|
|
@@ -537,7 +518,7 @@ var MethodLibrary = {
|
|
|
537
518
|
callback(position);
|
|
538
519
|
}, // 位置获取失败
|
|
539
520
|
function (error) {
|
|
540
|
-
|
|
521
|
+
display.warn(error);
|
|
541
522
|
});
|
|
542
523
|
}
|
|
543
524
|
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export var ConsoleApiName = {
|
|
2
|
+
log: 'log',
|
|
3
|
+
debug: 'debug',
|
|
4
|
+
info: 'info',
|
|
5
|
+
warn: 'warn',
|
|
6
|
+
error: 'error'
|
|
7
|
+
};
|
|
8
|
+
export var display = function display(api) {
|
|
9
|
+
var args = [].slice.call(arguments, 1);
|
|
10
|
+
|
|
11
|
+
if (!Object.prototype.hasOwnProperty.call(ConsoleApiName, api)) {
|
|
12
|
+
api = ConsoleApiName.log;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
display[api].apply(display, args);
|
|
16
|
+
};
|
|
17
|
+
display.debug = console.debug.bind(console);
|
|
18
|
+
display.log = console.log.bind(console);
|
|
19
|
+
display.info = console.info.bind(console);
|
|
20
|
+
display.warn = console.warn.bind(console);
|
|
21
|
+
display.error = console.error.bind(console);
|
package/esm/helper/enums.js
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
export var DOM_EVENT = {
|
|
2
2
|
BEFORE_UNLOAD: 'beforeunload',
|
|
3
3
|
CLICK: 'click',
|
|
4
|
+
DBL_CLICK: 'dblclick',
|
|
4
5
|
KEY_DOWN: 'keydown',
|
|
5
6
|
LOAD: 'load',
|
|
6
7
|
POP_STATE: 'popstate',
|
|
7
8
|
SCROLL: 'scroll',
|
|
8
9
|
TOUCH_START: 'touchstart',
|
|
10
|
+
TOUCH_END: 'touchend',
|
|
11
|
+
TOUCH_MOVE: 'touchmove',
|
|
9
12
|
VISIBILITY_CHANGE: 'visibilitychange',
|
|
10
13
|
DOM_CONTENT_LOADED: 'DOMContentLoaded',
|
|
11
14
|
POINTER_DOWN: 'pointerdown',
|
|
@@ -13,7 +16,19 @@ export var DOM_EVENT = {
|
|
|
13
16
|
POINTER_CANCEL: 'pointercancel',
|
|
14
17
|
HASH_CHANGE: 'hashchange',
|
|
15
18
|
PAGE_HIDE: 'pagehide',
|
|
16
|
-
MOUSE_DOWN: 'mousedown'
|
|
19
|
+
MOUSE_DOWN: 'mousedown',
|
|
20
|
+
MOUSE_UP: 'mouseup',
|
|
21
|
+
MOUSE_MOVE: 'mousemove',
|
|
22
|
+
FOCUS: 'focus',
|
|
23
|
+
BLUR: 'blur',
|
|
24
|
+
CONTEXT_MENU: 'contextmenu',
|
|
25
|
+
RESIZE: 'resize',
|
|
26
|
+
CHANGE: 'change',
|
|
27
|
+
INPUT: 'input',
|
|
28
|
+
PLAY: 'play',
|
|
29
|
+
PAUSE: 'pause',
|
|
30
|
+
SECURITY_POLICY_VIOLATION: 'securitypolicyviolation',
|
|
31
|
+
SELECTION_CHANGE: 'selectionchange'
|
|
17
32
|
};
|
|
18
33
|
export var ResourceType = {
|
|
19
34
|
DOCUMENT: 'document',
|
|
@@ -31,6 +46,11 @@ export var ActionType = {
|
|
|
31
46
|
CLICK: 'click',
|
|
32
47
|
CUSTOM: 'custom'
|
|
33
48
|
};
|
|
49
|
+
export var FrustrationType = {
|
|
50
|
+
RAGE_CLICK: 'rage_click',
|
|
51
|
+
ERROR_CLICK: 'error_click',
|
|
52
|
+
DEAD_CLICK: 'dead_click'
|
|
53
|
+
};
|
|
34
54
|
export var RumEventType = {
|
|
35
55
|
ACTION: 'action',
|
|
36
56
|
ERROR: 'error',
|
|
@@ -39,6 +59,10 @@ export var RumEventType = {
|
|
|
39
59
|
RESOURCE: 'resource',
|
|
40
60
|
LOGGER: 'logger'
|
|
41
61
|
};
|
|
62
|
+
export var ViewLoadingType = {
|
|
63
|
+
INITIAL_LOAD: 'initial_load',
|
|
64
|
+
ROUTE_CHANGE: 'route_change'
|
|
65
|
+
};
|
|
42
66
|
export var RequestType = {
|
|
43
67
|
FETCH: ResourceType.FETCH,
|
|
44
68
|
XHR: ResourceType.XHR
|
package/esm/helper/errorTools.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { each, noop } from './tools';
|
|
1
|
+
import { each, noop, jsonStringify } from './tools';
|
|
2
2
|
import { computeStackTrace } from '../tracekit';
|
|
3
3
|
export var ErrorSource = {
|
|
4
4
|
AGENT: 'agent',
|
|
@@ -8,10 +8,44 @@ export var ErrorSource = {
|
|
|
8
8
|
LOGGER: 'logger',
|
|
9
9
|
CUSTOM: 'custom'
|
|
10
10
|
};
|
|
11
|
+
export function computeRawError(data) {
|
|
12
|
+
var stackTrace = data.stackTrace;
|
|
13
|
+
var originalError = data.originalError;
|
|
14
|
+
var handlingStack = data.handlingStack;
|
|
15
|
+
var startClocks = data.startClocks;
|
|
16
|
+
var nonErrorPrefix = data.nonErrorPrefix;
|
|
17
|
+
var source = data.source;
|
|
18
|
+
var handling = data.handling;
|
|
19
|
+
|
|
20
|
+
if (!stackTrace || stackTrace.message === undefined && !(originalError instanceof Error)) {
|
|
21
|
+
return {
|
|
22
|
+
startClocks: startClocks,
|
|
23
|
+
source: source,
|
|
24
|
+
handling: handling,
|
|
25
|
+
originalError: originalError,
|
|
26
|
+
message: nonErrorPrefix + ' ' + jsonStringify(originalError),
|
|
27
|
+
stack: 'No stack, consider using an instance of Error',
|
|
28
|
+
handlingStack: handlingStack,
|
|
29
|
+
type: stackTrace && stackTrace.name
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
startClocks: startClocks,
|
|
35
|
+
source: source,
|
|
36
|
+
handling: handling,
|
|
37
|
+
originalError: originalError,
|
|
38
|
+
message: stackTrace.message || 'Empty message',
|
|
39
|
+
stack: toStackTraceString(stackTrace),
|
|
40
|
+
handlingStack: handlingStack,
|
|
41
|
+
type: stackTrace.name,
|
|
42
|
+
causes: flattenErrorCauses(originalError, source)
|
|
43
|
+
};
|
|
44
|
+
}
|
|
11
45
|
export function formatUnknownError(stackTrace, errorObject, nonErrorPrefix, handlingStack) {
|
|
12
46
|
if (!stackTrace || stackTrace.message === undefined && !(errorObject instanceof Error)) {
|
|
13
47
|
return {
|
|
14
|
-
message: nonErrorPrefix + '' +
|
|
48
|
+
message: nonErrorPrefix + '' + jsonStringify(errorObject),
|
|
15
49
|
stack: 'No stack, consider using an instance of Error',
|
|
16
50
|
handlingStack: handlingStack,
|
|
17
51
|
type: stackTrace && stackTrace.name
|
|
@@ -58,7 +92,7 @@ export function createHandlingStack() {
|
|
|
58
92
|
return formattedStack;
|
|
59
93
|
}
|
|
60
94
|
export function toStackTraceString(stack) {
|
|
61
|
-
var result = stack
|
|
95
|
+
var result = formatErrorMessage(stack);
|
|
62
96
|
each(stack.stack, function (frame) {
|
|
63
97
|
var func = frame.func === '?' ? '<anonymous>' : frame.func;
|
|
64
98
|
var args = frame.args && frame.args.length > 0 ? '(' + frame.args.join(', ') + ')' : '';
|
|
@@ -70,4 +104,25 @@ export function toStackTraceString(stack) {
|
|
|
70
104
|
}
|
|
71
105
|
export function formatErrorMessage(stack) {
|
|
72
106
|
return (stack.name || 'Error') + ': ' + stack.message;
|
|
107
|
+
}
|
|
108
|
+
export function getFileFromStackTraceString(stack) {
|
|
109
|
+
var execResult = /@ (.+)/.exec(stack);
|
|
110
|
+
return execResult && execResult[1];
|
|
111
|
+
}
|
|
112
|
+
export function flattenErrorCauses(error, parentSource) {
|
|
113
|
+
var currentError = error;
|
|
114
|
+
var causes = [];
|
|
115
|
+
|
|
116
|
+
while (currentError && currentError.cause instanceof Error && causes.length < 10) {
|
|
117
|
+
var stackTrace = computeStackTrace(currentError.cause);
|
|
118
|
+
causes.push({
|
|
119
|
+
message: currentError.cause.message,
|
|
120
|
+
source: parentSource,
|
|
121
|
+
type: stackTrace && stackTrace.name,
|
|
122
|
+
stack: stackTrace && toStackTraceString(stackTrace)
|
|
123
|
+
});
|
|
124
|
+
currentError = currentError.cause;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return causes.length ? causes : undefined;
|
|
73
128
|
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { noop } from './tools';
|
|
2
|
+
export function instrumentMethod(object, method, instrumentationFactory) {
|
|
3
|
+
var original = object[method];
|
|
4
|
+
var instrumentation = instrumentationFactory(original);
|
|
5
|
+
|
|
6
|
+
var instrumentationWrapper = function instrumentationWrapper() {
|
|
7
|
+
if (typeof instrumentation !== 'function') {
|
|
8
|
+
return undefined;
|
|
9
|
+
} // eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
return instrumentation.apply(this, arguments);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
object[method] = instrumentationWrapper;
|
|
16
|
+
return {
|
|
17
|
+
stop: function stop() {
|
|
18
|
+
if (object[method] === instrumentationWrapper) {
|
|
19
|
+
object[method] = original;
|
|
20
|
+
} else {
|
|
21
|
+
instrumentation = original;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export function instrumentMethodAndCallOriginal(object, method, aliasOption) {
|
|
27
|
+
return instrumentMethod(object, method, function (original) {
|
|
28
|
+
return function () {
|
|
29
|
+
var result;
|
|
30
|
+
|
|
31
|
+
if (aliasOption && aliasOption.before) {
|
|
32
|
+
aliasOption.before.apply(this, arguments);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (typeof original === 'function') {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
|
|
37
|
+
result = original.apply(this, arguments);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (aliasOption && aliasOption.after) {
|
|
41
|
+
aliasOption.after.apply(this, arguments);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
export function instrumentSetter(object, property, after) {
|
|
49
|
+
var originalDescriptor = Object.getOwnPropertyDescriptor(object, property);
|
|
50
|
+
|
|
51
|
+
if (!originalDescriptor || !originalDescriptor.set || !originalDescriptor.configurable) {
|
|
52
|
+
return {
|
|
53
|
+
stop: noop
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
var instrumentation = function instrumentation(thisObject, value) {
|
|
58
|
+
// put hooked setter into event loop to avoid of set latency
|
|
59
|
+
setTimeout(function () {
|
|
60
|
+
after(thisObject, value);
|
|
61
|
+
}, 0);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
var instrumentationWrapper = function instrumentationWrapper(value) {
|
|
65
|
+
originalDescriptor.set.call(this, value);
|
|
66
|
+
instrumentation(this, value);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
Object.defineProperty(object, property, {
|
|
70
|
+
set: instrumentationWrapper
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
stop: function stop() {
|
|
74
|
+
if (Object.getOwnPropertyDescriptor(object, property) && Object.getOwnPropertyDescriptor(object, property).set === instrumentationWrapper) {
|
|
75
|
+
Object.defineProperty(object, property, originalDescriptor);
|
|
76
|
+
} else {
|
|
77
|
+
instrumentation = noop;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
}
|
package/esm/helper/lifeCycle.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { each, filter } from './tools';
|
|
2
2
|
export var LifeCycleEventType = {
|
|
3
|
-
|
|
3
|
+
PERFORMANCE_ENTRIES_COLLECTED: 'PERFORMANCE_ENTRIES_COLLECTED',
|
|
4
4
|
AUTO_ACTION_CREATED: 'AUTO_ACTION_CREATED',
|
|
5
5
|
AUTO_ACTION_COMPLETED: 'AUTO_ACTION_COMPLETED',
|
|
6
|
-
AUTO_ACTION_DISCARDED: 'AUTO_ACTION_DISCARDED',
|
|
7
6
|
VIEW_CREATED: 'VIEW_CREATED',
|
|
8
7
|
VIEW_UPDATED: 'VIEW_UPDATED',
|
|
9
8
|
VIEW_ENDED: 'VIEW_ENDED',
|
|
10
9
|
SESSION_RENEWED: 'SESSION_RENEWED',
|
|
10
|
+
SESSION_EXPIRED: 'SESSION_EXPIRED',
|
|
11
11
|
DOM_MUTATED: 'DOM_MUTATED',
|
|
12
12
|
BEFORE_UNLOAD: 'BEFORE_UNLOAD',
|
|
13
13
|
REQUEST_STARTED: 'REQUEST_STARTED',
|
|
@@ -16,7 +16,9 @@ export var LifeCycleEventType = {
|
|
|
16
16
|
RUM_EVENT_COLLECTED: 'RUM_EVENT_COLLECTED',
|
|
17
17
|
RAW_ERROR_COLLECTED: 'RAW_ERROR_COLLECTED',
|
|
18
18
|
RECORD_STARTED: 'RECORD_STARTED',
|
|
19
|
-
RECORD_STOPPED: 'RECORD_STOPPED'
|
|
19
|
+
RECORD_STOPPED: 'RECORD_STOPPED',
|
|
20
|
+
RAW_LOG_COLLECTED: 'RAW_LOG_COLLECTED',
|
|
21
|
+
LOG_COLLECTED: 'LOG_COLLECTED'
|
|
20
22
|
};
|
|
21
23
|
export function LifeCycle() {
|
|
22
24
|
this.callbacks = [];
|
package/esm/helper/observable.js
CHANGED
|
@@ -1,12 +1,32 @@
|
|
|
1
|
-
import { each } from './tools';
|
|
1
|
+
import { each, filter, map } from './tools';
|
|
2
2
|
|
|
3
|
-
var _Observable = function _Observable() {
|
|
3
|
+
var _Observable = function _Observable(onFirstSubscribe) {
|
|
4
4
|
this.observers = [];
|
|
5
|
+
this.onLastUnsubscribe = undefined;
|
|
6
|
+
this.onFirstSubscribe = onFirstSubscribe;
|
|
5
7
|
};
|
|
6
8
|
|
|
7
9
|
_Observable.prototype = {
|
|
8
10
|
subscribe: function subscribe(f) {
|
|
11
|
+
if (!this.observers.length && this.onFirstSubscribe) {
|
|
12
|
+
this.onLastUnsubscribe = this.onFirstSubscribe() || undefined;
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
this.observers.push(f);
|
|
16
|
+
|
|
17
|
+
var _this = this;
|
|
18
|
+
|
|
19
|
+
return {
|
|
20
|
+
unsubscribe: function unsubscribe() {
|
|
21
|
+
_this.observers = filter(_this.observers, function (other) {
|
|
22
|
+
return f !== other;
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
if (!_this.observers.length && _this.onLastUnsubscribe) {
|
|
26
|
+
_this.onLastUnsubscribe();
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
};
|
|
10
30
|
},
|
|
11
31
|
notify: function notify(data) {
|
|
12
32
|
each(this.observers, function (observer) {
|
|
@@ -14,4 +34,20 @@ _Observable.prototype = {
|
|
|
14
34
|
});
|
|
15
35
|
}
|
|
16
36
|
};
|
|
17
|
-
export var Observable = _Observable;
|
|
37
|
+
export var Observable = _Observable;
|
|
38
|
+
export function mergeObservables() {
|
|
39
|
+
var observables = [].slice.call(arguments);
|
|
40
|
+
var globalObservable = new Observable(function () {
|
|
41
|
+
var subscriptions = map(observables, function (observable) {
|
|
42
|
+
return observable.subscribe(function (data) {
|
|
43
|
+
return globalObservable.notify(data);
|
|
44
|
+
});
|
|
45
|
+
});
|
|
46
|
+
return function () {
|
|
47
|
+
return each(subscriptions, function (subscription) {
|
|
48
|
+
return subscription.unsubscribe();
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
});
|
|
52
|
+
return globalObservable;
|
|
53
|
+
}
|