@arms/rum-core 0.0.35 → 0.0.37

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.
Files changed (48) hide show
  1. package/es/index.d.ts +18 -0
  2. package/es/index.js +18 -0
  3. package/es/model/client.d.ts +21 -0
  4. package/es/model/client.js +76 -0
  5. package/es/model/context.d.ts +18 -0
  6. package/es/model/context.js +44 -0
  7. package/es/model/reporter.d.ts +31 -0
  8. package/es/model/reporter.js +196 -0
  9. package/es/model/shell.d.ts +51 -0
  10. package/es/model/shell.js +160 -0
  11. package/es/style.js +1 -0
  12. package/es/types/client.d.ts +170 -0
  13. package/es/types/client.js +7 -0
  14. package/es/types/collector.d.ts +7 -0
  15. package/es/types/collector.js +1 -0
  16. package/es/types/processor.d.ts +8 -0
  17. package/es/types/processor.js +1 -0
  18. package/es/types/reporter.d.ts +8 -0
  19. package/es/types/reporter.js +1 -0
  20. package/es/types/rum-event.d.ts +179 -0
  21. package/es/types/rum-event.js +27 -0
  22. package/es/types/shell.d.ts +28 -0
  23. package/es/types/shell.js +1 -0
  24. package/es/utils/base.d.ts +60 -0
  25. package/es/utils/base.js +216 -0
  26. package/es/utils/combineConfig.d.ts +15 -0
  27. package/es/utils/combineConfig.js +101 -0
  28. package/es/utils/exception.d.ts +7 -0
  29. package/es/utils/exception.js +10 -0
  30. package/es/utils/is.d.ts +12 -0
  31. package/es/utils/is.js +39 -0
  32. package/es/utils/match.d.ts +7 -0
  33. package/es/utils/match.js +40 -0
  34. package/es/utils/number.d.ts +17 -0
  35. package/es/utils/number.js +40 -0
  36. package/es/utils/polyfills.d.ts +7 -0
  37. package/es/utils/polyfills.js +28 -0
  38. package/es/utils/trace.d.ts +28 -0
  39. package/es/utils/trace.js +105 -0
  40. package/es/utils/verify.d.ts +2 -0
  41. package/es/utils/verify.js +35 -0
  42. package/lib/model/context.js +6 -0
  43. package/lib/types/client.d.ts +8 -0
  44. package/lib/types/rum-event.d.ts +3 -1
  45. package/lib/types/rum-event.js +1 -0
  46. package/lib/utils/base.d.ts +2 -2
  47. package/lib/utils/base.js +10 -6
  48. 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
+ }
@@ -24,6 +24,12 @@ var Context = /*#__PURE__*/function () {
24
24
  return this.views;
25
25
  };
26
26
  _proto.addView = function addView(view) {
27
+ var index = this.views.findIndex(function (v) {
28
+ return v.id === view.id;
29
+ });
30
+ if (index >= 0) {
31
+ this.views.splice(index, 1);
32
+ }
27
33
  this.views.push(view);
28
34
  };
29
35
  _proto.removeView = function removeView(viewId) {
@@ -158,5 +158,13 @@ export interface IConfiguration {
158
158
  properties?: {
159
159
  [key: string]: number | string;
160
160
  };
161
+ /**
162
+ * 检测元素是否溢出的弹性长度
163
+ */
164
+ overflowPx?: number;
165
+ /**
166
+ * 检测正则匹配内容
167
+ */
168
+ regexp?: string;
161
169
  [key: string]: unknown;
162
170
  }
@@ -117,7 +117,8 @@ export declare enum AppType {
117
117
  browser = "browser",
118
118
  miniapp = "miniapp",
119
119
  minigame = "minigame",
120
- uniapp = "uniapp"
120
+ uniapp = "uniapp",
121
+ reactnative = "reactnative"
121
122
  }
122
123
  export interface RumEventBundle {
123
124
  app: {
@@ -170,6 +171,7 @@ export interface RumEventBundle {
170
171
  net?: {
171
172
  model?: string;
172
173
  name?: string;
174
+ ip?: string;
173
175
  };
174
176
  events: Array<RumEvent>;
175
177
  properties?: BaseObject;
@@ -26,5 +26,6 @@ var AppType = exports.AppType = /*#__PURE__*/function (AppType) {
26
26
  AppType["miniapp"] = "miniapp";
27
27
  AppType["minigame"] = "minigame";
28
28
  AppType["uniapp"] = "uniapp";
29
+ AppType["reactnative"] = "reactnative";
29
30
  return AppType;
30
31
  }({});
@@ -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(this, args);
35
+ callback.apply(ctx, args);
32
36
  if ((0, _is.isFunction)(registeredMethod)) {
33
- return registeredMethod.apply(this, args);
37
+ return registeredMethod.apply(ctx, args);
34
38
  }
35
39
  };
36
40
  }
@@ -65,7 +69,7 @@ function generateGUID() {
65
69
  }, '').replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/, '\$1-\$2-\$3-\$4-\$5');
66
70
  }
67
71
  } catch (e) {
68
- //
72
+ guid = '';
69
73
  }
70
74
  if (!guid) {
71
75
  guid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
@@ -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.35",
3
+ "version": "0.0.37",
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"