@arms/rum-core 0.0.25-beta.7 → 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.
@@ -6,7 +6,7 @@ var _rumEvent = require("../types/rum-event");
6
6
  var _exception = require("../utils/exception");
7
7
  var _is = require("../utils/is");
8
8
  var FLUSH_TIME = 3000;
9
- var MAX_EVENT_COUNT = 50;
9
+ var MAX_EVENT_COUNT = 20;
10
10
  var Reporter = exports["default"] = /*#__PURE__*/function () {
11
11
  function Reporter() {
12
12
  this.name = 'reporter';
@@ -1,5 +1,5 @@
1
1
  import { IClient, IConfiguration } from "../types/client";
2
- import { RumEvent } 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;
@@ -19,7 +19,15 @@ export default abstract class Shell implements IShell {
19
19
  abstract setConfig<T extends keyof IConfiguration>(key: T, value: IConfiguration[T]): void;
20
20
  abstract setConfig(value: IConfiguration): void;
21
21
  /**
22
- * 自定义上传数据
22
+ * 自定义事件上报
23
23
  */
24
- sendCustom(payload: RumEvent): void;
24
+ sendCustom(payload: RumCustomEvent): void;
25
+ /**
26
+ * 自定义异常上报
27
+ */
28
+ sendException(payload: RumExceptionEvent): void;
29
+ /**
30
+ * 自定义资源上报
31
+ */
32
+ sendResource(payload: RumResourceEvent): void;
25
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
  }
@@ -38,7 +39,7 @@ var Shell = exports["default"] = /*#__PURE__*/function () {
38
39
  * set config
39
40
  */;
40
41
  /**
41
- * 自定义上传数据
42
+ * 自定义事件上报
42
43
  */
43
44
  _proto.sendCustom = function sendCustom(payload) {
44
45
  if (!payload.name || !payload.type) {
@@ -49,5 +50,35 @@ var Shell = exports["default"] = /*#__PURE__*/function () {
49
50
  });
50
51
  this.sendEvent(data);
51
52
  };
53
+ /**
54
+ * 自定义异常上报
55
+ */
56
+ _proto.sendException = function sendException(payload) {
57
+ if (!payload.name || !payload.message) {
58
+ return;
59
+ }
60
+ var data = (0, _extends2["default"])({
61
+ times: 1
62
+ }, payload, {
63
+ event_type: _rumEvent.RumEventType.EXCEPTION,
64
+ type: 'custom',
65
+ source: 'custom'
66
+ });
67
+ this.sendEvent(data);
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
+ };
52
83
  return Shell;
53
84
  }();
@@ -2,6 +2,7 @@ import { ICollector } from './collector';
2
2
  import { IProcessor } from './processor';
3
3
  import { IReporter } from './reporter';
4
4
  import { RumEvent, RumEventBundle, IViewData } from './rum-event';
5
+ import { MatchOption } from "../utils/match";
5
6
  export declare enum EventType {
6
7
  /**
7
8
  * 收集数据
@@ -97,6 +98,16 @@ export interface IConfiguration {
97
98
  /**
98
99
  * 各个 collector config
99
100
  */
100
- collectors?: any;
101
+ collectors?: {
102
+ [key: string]: unknown;
103
+ };
104
+ /**
105
+ * 事件过滤器配置
106
+ */
107
+ filters?: {
108
+ view?: MatchOption | MatchOption[];
109
+ resource?: MatchOption | MatchOption[];
110
+ exception?: MatchOption | MatchOption[];
111
+ };
101
112
  [key: string]: any;
102
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.7",
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",