@arms/rum-core 0.0.35 → 0.0.36
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/es/index.d.ts +18 -0
- package/es/index.js +18 -0
- package/es/model/client.d.ts +21 -0
- package/es/model/client.js +76 -0
- package/es/model/context.d.ts +18 -0
- package/es/model/context.js +38 -0
- package/es/model/reporter.d.ts +31 -0
- package/es/model/reporter.js +196 -0
- package/es/model/shell.d.ts +51 -0
- package/es/model/shell.js +160 -0
- package/es/style.js +1 -0
- package/es/types/client.d.ts +162 -0
- package/es/types/client.js +7 -0
- package/es/types/collector.d.ts +7 -0
- package/es/types/collector.js +1 -0
- package/es/types/processor.d.ts +8 -0
- package/es/types/processor.js +1 -0
- package/es/types/reporter.d.ts +8 -0
- package/es/types/reporter.js +1 -0
- package/es/types/rum-event.d.ts +177 -0
- package/es/types/rum-event.js +26 -0
- package/es/types/shell.d.ts +28 -0
- package/es/types/shell.js +1 -0
- package/es/utils/base.d.ts +60 -0
- package/es/utils/base.js +216 -0
- package/es/utils/combineConfig.d.ts +15 -0
- package/es/utils/combineConfig.js +101 -0
- package/es/utils/exception.d.ts +7 -0
- package/es/utils/exception.js +10 -0
- package/es/utils/is.d.ts +12 -0
- package/es/utils/is.js +39 -0
- package/es/utils/match.d.ts +7 -0
- package/es/utils/match.js +40 -0
- package/es/utils/number.d.ts +17 -0
- package/es/utils/number.js +40 -0
- package/es/utils/polyfills.d.ts +7 -0
- package/es/utils/polyfills.js +28 -0
- package/es/utils/trace.d.ts +28 -0
- package/es/utils/trace.js +105 -0
- package/es/utils/verify.d.ts +2 -0
- package/es/utils/verify.js +35 -0
- package/lib/utils/base.d.ts +2 -2
- package/lib/utils/base.js +9 -5
- package/package.json +6 -2
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { isNumber, isObject, isString } from "./is";
|
|
2
|
+
export function verifyProperties(attrs) {
|
|
3
|
+
if (!isObject(attrs)) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
var copyAttrs = Object.assign({}, attrs);
|
|
7
|
+
Object.keys(copyAttrs).forEach(function (key) {
|
|
8
|
+
var val = copyAttrs[key];
|
|
9
|
+
// 验证 key 长度
|
|
10
|
+
if (key.length > 50) {
|
|
11
|
+
var shortKey = key.substring(0, 50);
|
|
12
|
+
copyAttrs[shortKey] = val;
|
|
13
|
+
delete copyAttrs[key];
|
|
14
|
+
key = shortKey;
|
|
15
|
+
}
|
|
16
|
+
// 验证 value 类型和长度
|
|
17
|
+
if (!isString(val) && !isNumber(val)) {
|
|
18
|
+
delete copyAttrs[key];
|
|
19
|
+
} else if (isString(val) && val.length > 2e3) {
|
|
20
|
+
copyAttrs[key] = val.substring(0, 2e3);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
var keys = Object.keys(copyAttrs);
|
|
24
|
+
if (!keys.length) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
if (keys.length > 20) {
|
|
28
|
+
keys.forEach(function (key, index) {
|
|
29
|
+
if (index > 19) {
|
|
30
|
+
delete copyAttrs[key];
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return copyAttrs;
|
|
35
|
+
}
|
package/lib/utils/base.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* 劫持函数或原型
|
|
3
3
|
*/
|
|
4
|
-
export declare function interceptFunction(target: any, name: string, callback: Function): void;
|
|
4
|
+
export declare function interceptFunction(target: any, name: string, callback: Function, isPrototype?: boolean): void;
|
|
5
5
|
/**
|
|
6
6
|
* 还原函数
|
|
7
7
|
*/
|
package/lib/utils/base.js
CHANGED
|
@@ -19,18 +19,22 @@ var PRE_SUF_FIX = '__';
|
|
|
19
19
|
var TYPE_REG = /^\[object ([a-z]*)\]$/;
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* 劫持函数或原型
|
|
23
23
|
*/
|
|
24
|
-
function interceptFunction(target, name, callback) {
|
|
24
|
+
function interceptFunction(target, name, callback, isPrototype) {
|
|
25
|
+
if (isPrototype === void 0) {
|
|
26
|
+
isPrototype = false;
|
|
27
|
+
}
|
|
25
28
|
var registeredMethod = target[name];
|
|
26
29
|
target["" + PRE_SUF_FIX + name + PRE_SUF_FIX] = registeredMethod;
|
|
27
30
|
target[name] = function () {
|
|
31
|
+
var ctx = isPrototype ? this : target;
|
|
28
32
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
29
33
|
args[_key] = arguments[_key];
|
|
30
34
|
}
|
|
31
|
-
callback.apply(
|
|
35
|
+
callback.apply(ctx, args);
|
|
32
36
|
if ((0, _is.isFunction)(registeredMethod)) {
|
|
33
|
-
return registeredMethod.apply(
|
|
37
|
+
return registeredMethod.apply(ctx, args);
|
|
34
38
|
}
|
|
35
39
|
};
|
|
36
40
|
}
|
|
@@ -185,7 +189,7 @@ function transStrToReg(str) {
|
|
|
185
189
|
}
|
|
186
190
|
|
|
187
191
|
/**
|
|
188
|
-
*
|
|
192
|
+
*
|
|
189
193
|
* @param config 配置
|
|
190
194
|
* @param keys 需要转换的字段
|
|
191
195
|
*/
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arms/rum-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.36",
|
|
4
4
|
"description": "arms rum javascript sdk core",
|
|
5
5
|
"author": "guangli.fj <guangli.fj@alibaba-inc.com>",
|
|
6
6
|
"license": "ISC",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
|
+
"module": "es/index.js",
|
|
8
9
|
"directories": {
|
|
9
10
|
"lib": "lib",
|
|
11
|
+
"es": "es",
|
|
10
12
|
"test": "__tests__"
|
|
11
13
|
},
|
|
12
14
|
"files": [
|
|
13
|
-
"lib"
|
|
15
|
+
"lib",
|
|
16
|
+
"es",
|
|
17
|
+
"dist"
|
|
14
18
|
],
|
|
15
19
|
"publishConfig": {
|
|
16
20
|
"access": "public"
|