@arms/rum-core 0.0.25-beta.8 → 0.0.25-beta.9

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.
@@ -1,5 +1,5 @@
1
1
  import { IClient, IConfiguration } from "../types/client";
2
- import { RumEvent, RumExceptionEvent } from "../types/rum-event";
2
+ import { RumCustomEvent, RumEvent, RumExceptionEvent, RumResourceEvent } from "../types/rum-event";
3
3
  import { IShell } from "../types/shell";
4
4
  export default abstract class Shell implements IShell {
5
5
  client: IClient;
@@ -21,9 +21,13 @@ export default abstract class Shell implements IShell {
21
21
  /**
22
22
  * 自定义事件上报
23
23
  */
24
- sendCustom(payload: RumEvent): void;
24
+ sendCustom(payload: RumCustomEvent): void;
25
25
  /**
26
26
  * 自定义异常上报
27
27
  */
28
28
  sendException(payload: RumExceptionEvent): void;
29
+ /**
30
+ * 自定义资源上报
31
+ */
32
+ sendResource(payload: RumResourceEvent): void;
29
33
  }
@@ -5,11 +5,12 @@ exports.__esModule = true;
5
5
  exports["default"] = void 0;
6
6
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
7
7
  var _rumEvent = require("../types/rum-event");
8
- var _rumCore = require("@arms/rum-core");
8
+ var _client = _interopRequireDefault(require("../model/client"));
9
+ var _is = require("../utils/is");
9
10
  var Shell = exports["default"] = /*#__PURE__*/function () {
10
11
  function Shell(config) {
11
12
  this.client = void 0;
12
- this.client = new _rumCore.Client();
13
+ this.client = new _client["default"]();
13
14
  if (config && this.init) {
14
15
  this.init(config);
15
16
  }
@@ -65,5 +66,19 @@ var Shell = exports["default"] = /*#__PURE__*/function () {
65
66
  });
66
67
  this.sendEvent(data);
67
68
  };
69
+ /**
70
+ * 自定义资源上报
71
+ */
72
+ _proto.sendResource = function sendResource(payload) {
73
+ if (!payload.name || !payload.type || !(0, _is.isNumber)(payload.duration)) {
74
+ return;
75
+ }
76
+ var data = (0, _extends2["default"])({
77
+ times: 1
78
+ }, payload, {
79
+ event_type: _rumEvent.RumEventType.RESOURCE
80
+ });
81
+ this.sendEvent(data);
82
+ };
68
83
  return Shell;
69
84
  }();
@@ -98,9 +98,16 @@ export interface IConfiguration {
98
98
  /**
99
99
  * 各个 collector config
100
100
  */
101
- collectors?: any;
101
+ collectors?: {
102
+ [key: string]: unknown;
103
+ };
104
+ /**
105
+ * 事件过滤器配置
106
+ */
102
107
  filters?: {
103
- [key: string]: MatchOption | MatchOption[];
108
+ view?: MatchOption | MatchOption[];
109
+ resource?: MatchOption | MatchOption[];
110
+ exception?: MatchOption | MatchOption[];
104
111
  };
105
112
  [key: string]: any;
106
113
  }
@@ -21,6 +21,7 @@ export interface RumBaseEvent {
21
21
  timestamp?: number;
22
22
  times?: number;
23
23
  view?: IViewData;
24
+ snapshots?: string;
24
25
  [key: string]: BaseObjectValue;
25
26
  }
26
27
  export interface RumViewEvent extends RumBaseEvent {
@@ -43,14 +44,13 @@ export interface RumViewEvent extends RumBaseEvent {
43
44
  }
44
45
  export interface RumResourceEvent extends RumBaseEvent {
45
46
  name?: string;
46
- type: string;
47
+ type?: string;
47
48
  method?: string;
48
- status_code?: number;
49
+ status_code?: number | string;
49
50
  message?: string;
50
- success: 0 | 1;
51
- provider_type?: string;
51
+ success?: -1 | 0 | 1;
52
52
  trace_id?: string;
53
- duration: number;
53
+ duration?: number;
54
54
  size?: number;
55
55
  connect_duration?: number;
56
56
  ssl_duration?: number;
@@ -58,12 +58,13 @@ export interface RumResourceEvent extends RumBaseEvent {
58
58
  redirect_duration?: number;
59
59
  first_byte_duration?: number;
60
60
  download_duration?: number;
61
- url: string;
61
+ url?: string;
62
62
  timing_data?: string;
63
+ tracing_data?: string;
63
64
  }
64
65
  export interface RumExceptionEvent extends RumBaseEvent {
65
66
  source?: string;
66
- type?: 'crash' | 'cutsom' | 'error' | 'blank';
67
+ type?: 'crash' | 'custom' | 'error' | 'blank';
67
68
  name?: string;
68
69
  message?: string;
69
70
  file?: string;
@@ -85,7 +86,6 @@ export interface RumActionEvent extends RumBaseEvent {
85
86
  name?: string;
86
87
  target_name?: string;
87
88
  duration?: number;
88
- snapshots?: string;
89
89
  }
90
90
  export interface RumCustomEvent extends RumBaseEvent {
91
91
  type: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arms/rum-core",
3
- "version": "0.0.25-beta.8",
3
+ "version": "0.0.25-beta.9",
4
4
  "description": "arms rum javascript sdk core",
5
5
  "author": "guangli.fj <guangli.fj@alibaba-inc.com>",
6
6
  "license": "ISC",