@arms/rum-core 0.0.22 → 0.0.25-beta.7
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/lib/types/rum-event.d.ts +35 -4
- package/lib/utils/base.d.ts +12 -0
- package/lib/utils/base.js +42 -2
- package/lib/utils/number.d.ts +8 -0
- package/lib/utils/number.js +29 -0
- package/lib/utils/polyfills.js +3 -3
- package/package.json +1 -1
package/lib/types/rum-event.d.ts
CHANGED
|
@@ -29,7 +29,9 @@ export interface RumViewEvent extends RumBaseEvent {
|
|
|
29
29
|
largest_contentful_paint?: number;
|
|
30
30
|
first_input_delay?: number;
|
|
31
31
|
cumulative_layout_shift?: number;
|
|
32
|
+
first_input_time?: number;
|
|
32
33
|
loading_time?: number;
|
|
34
|
+
first_paint?: number;
|
|
33
35
|
first_contentful_paint?: number;
|
|
34
36
|
dom_interactive?: number;
|
|
35
37
|
dom_content_loaded?: number;
|
|
@@ -61,7 +63,7 @@ export interface RumResourceEvent extends RumBaseEvent {
|
|
|
61
63
|
}
|
|
62
64
|
export interface RumExceptionEvent extends RumBaseEvent {
|
|
63
65
|
source?: string;
|
|
64
|
-
type?: 'crash' | 'cutsom' | 'error';
|
|
66
|
+
type?: 'crash' | 'cutsom' | 'error' | 'blank';
|
|
65
67
|
name?: string;
|
|
66
68
|
message?: string;
|
|
67
69
|
file?: string;
|
|
@@ -99,9 +101,12 @@ export declare enum AppType {
|
|
|
99
101
|
export interface RumEventBundle {
|
|
100
102
|
app: {
|
|
101
103
|
id: string;
|
|
102
|
-
env?: string;
|
|
103
|
-
version?: string;
|
|
104
104
|
type: AppType;
|
|
105
|
+
name?: string;
|
|
106
|
+
version?: string;
|
|
107
|
+
channel?: string;
|
|
108
|
+
env?: string;
|
|
109
|
+
package?: string;
|
|
105
110
|
};
|
|
106
111
|
user: {
|
|
107
112
|
id: string;
|
|
@@ -115,8 +120,34 @@ export interface RumEventBundle {
|
|
|
115
120
|
id: string;
|
|
116
121
|
name: string;
|
|
117
122
|
};
|
|
123
|
+
device?: {
|
|
124
|
+
id?: string;
|
|
125
|
+
type?: string;
|
|
126
|
+
brand?: string;
|
|
127
|
+
model?: string;
|
|
128
|
+
name?: string;
|
|
129
|
+
};
|
|
130
|
+
os?: {
|
|
131
|
+
type?: string;
|
|
132
|
+
version?: string;
|
|
133
|
+
container?: string;
|
|
134
|
+
container_version?: string;
|
|
135
|
+
};
|
|
136
|
+
geo?: {
|
|
137
|
+
country?: string;
|
|
138
|
+
country_id?: string;
|
|
139
|
+
province?: string;
|
|
140
|
+
province_id?: string;
|
|
141
|
+
city?: string;
|
|
142
|
+
city_id?: string;
|
|
143
|
+
};
|
|
144
|
+
isp?: {
|
|
145
|
+
id?: string;
|
|
146
|
+
name?: string;
|
|
147
|
+
};
|
|
118
148
|
net?: {
|
|
119
|
-
model
|
|
149
|
+
model?: string;
|
|
150
|
+
name?: string;
|
|
120
151
|
};
|
|
121
152
|
events: Array<RumEvent>;
|
|
122
153
|
}
|
package/lib/utils/base.d.ts
CHANGED
|
@@ -13,3 +13,15 @@ export declare function generateGUID(): string;
|
|
|
13
13
|
* @return {String}
|
|
14
14
|
*/
|
|
15
15
|
export declare function generateUUID(len?: number): string;
|
|
16
|
+
/**
|
|
17
|
+
* @desc 函数防抖
|
|
18
|
+
* @param func 回调函数
|
|
19
|
+
* @param wait 延迟执行毫秒数
|
|
20
|
+
*/
|
|
21
|
+
export declare function debounce(func: Function, wait: number): () => void;
|
|
22
|
+
/**
|
|
23
|
+
* @desc 函数延迟执行
|
|
24
|
+
* @param func 回调函数
|
|
25
|
+
* @param wait 延迟执行毫秒数
|
|
26
|
+
*/
|
|
27
|
+
export declare function delay(func: Function, wait: number, ...args: any[]): number;
|
package/lib/utils/base.js
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
+
exports.debounce = debounce;
|
|
5
|
+
exports.delay = delay;
|
|
4
6
|
exports.generateGUID = generateGUID;
|
|
5
7
|
exports.generateUUID = generateUUID;
|
|
6
8
|
exports.interceptFunction = interceptFunction;
|
|
9
|
+
var _is = require("./is");
|
|
7
10
|
/**
|
|
8
11
|
* 劫持函数
|
|
9
12
|
*/
|
|
@@ -13,9 +16,9 @@ function interceptFunction(target, name, callback) {
|
|
|
13
16
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
14
17
|
args[_key] = arguments[_key];
|
|
15
18
|
}
|
|
16
|
-
callback.apply(
|
|
19
|
+
callback.apply(this, args);
|
|
17
20
|
if (registeredMethod) {
|
|
18
|
-
return registeredMethod.apply(
|
|
21
|
+
return registeredMethod.apply(this, args);
|
|
19
22
|
}
|
|
20
23
|
};
|
|
21
24
|
}
|
|
@@ -62,4 +65,41 @@ function generateUUID(len) {
|
|
|
62
65
|
str.splice(i * 3 + 2, 0, d[i]);
|
|
63
66
|
}
|
|
64
67
|
return str.join('');
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* @desc 函数防抖
|
|
72
|
+
* @param func 回调函数
|
|
73
|
+
* @param wait 延迟执行毫秒数
|
|
74
|
+
*/
|
|
75
|
+
function debounce(func, wait) {
|
|
76
|
+
var timer;
|
|
77
|
+
if (!(0, _is.isFunction)(func)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
return function () {
|
|
81
|
+
var context = this;
|
|
82
|
+
var args = arguments;
|
|
83
|
+
if (timer) {
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
}
|
|
86
|
+
timer = setTimeout(function () {
|
|
87
|
+
func.apply(context, args);
|
|
88
|
+
}, wait);
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @desc 函数延迟执行
|
|
94
|
+
* @param func 回调函数
|
|
95
|
+
* @param wait 延迟执行毫秒数
|
|
96
|
+
*/
|
|
97
|
+
function delay(func, wait) {
|
|
98
|
+
if (!(0, _is.isFunction)(func)) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
102
|
+
args[_key2 - 2] = arguments[_key2];
|
|
103
|
+
}
|
|
104
|
+
return setTimeout.apply(void 0, [func, +wait || 0].concat(args));
|
|
65
105
|
}
|
package/lib/utils/number.d.ts
CHANGED
|
@@ -4,3 +4,11 @@
|
|
|
4
4
|
*/
|
|
5
5
|
export declare function performDraw(threshold: number): boolean;
|
|
6
6
|
export declare function round(num: number, decimals: 0 | 1 | 2 | 3 | 4): number;
|
|
7
|
+
/**
|
|
8
|
+
* 保留指定位数的小数
|
|
9
|
+
* @param num 原数据
|
|
10
|
+
* @param decimal 小数位数
|
|
11
|
+
* @param min 限制最小值,否则返回undefined
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
export declare function formatNumber(num: number, decimal?: number, min?: number): number;
|
package/lib/utils/number.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
+
exports.formatNumber = formatNumber;
|
|
4
5
|
exports.performDraw = performDraw;
|
|
5
6
|
exports.round = round;
|
|
6
7
|
/**
|
|
@@ -12,4 +13,32 @@ function performDraw(threshold) {
|
|
|
12
13
|
}
|
|
13
14
|
function round(num, decimals) {
|
|
14
15
|
return +num.toFixed(decimals);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 保留指定位数的小数
|
|
20
|
+
* @param num 原数据
|
|
21
|
+
* @param decimal 小数位数
|
|
22
|
+
* @param min 限制最小值,否则返回undefined
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
function formatNumber(num, decimal, min) {
|
|
26
|
+
if (decimal === void 0) {
|
|
27
|
+
decimal = 3;
|
|
28
|
+
}
|
|
29
|
+
if (min === void 0) {
|
|
30
|
+
min = 0;
|
|
31
|
+
}
|
|
32
|
+
if (!num) {
|
|
33
|
+
return num;
|
|
34
|
+
}
|
|
35
|
+
var str = num.toString();
|
|
36
|
+
var index = str.indexOf('.');
|
|
37
|
+
if (index !== -1) {
|
|
38
|
+
str = str.substring(0, decimal + index + 1);
|
|
39
|
+
} else {
|
|
40
|
+
str = str.substring(0);
|
|
41
|
+
}
|
|
42
|
+
var result = parseFloat(str);
|
|
43
|
+
return result >= min ? result : undefined;
|
|
15
44
|
}
|
package/lib/utils/polyfills.js
CHANGED
|
@@ -7,9 +7,9 @@ exports.find = find;
|
|
|
7
7
|
exports.startsWith = startsWith;
|
|
8
8
|
function find(array, predicate) {
|
|
9
9
|
for (var i = 0; i < array.length; i += 1) {
|
|
10
|
-
var
|
|
11
|
-
if (predicate(
|
|
12
|
-
return
|
|
10
|
+
var item = array[i];
|
|
11
|
+
if (predicate(item, i)) {
|
|
12
|
+
return item;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
return undefined;
|