@arms/rum-core 0.0.29 → 0.0.31

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.
@@ -129,11 +129,21 @@ var Reporter = exports["default"] = /*#__PURE__*/function () {
129
129
  var config = ctx.getConfig();
130
130
  var session = ctx.session;
131
131
  var sessionId = session.getSessionId();
132
- events.forEach(function (event) {
133
- if (event.session_id === sessionId) {
134
- delete event.session_id;
132
+ // events.forEach(event => {
133
+ // if (event.session_id === sessionId) {
134
+ // delete event.session_id;
135
+ // }
136
+ // });
137
+ for (var i = 0; i < events.length; i++) {
138
+ var e = events[i];
139
+ if (e.session_id === sessionId) {
140
+ delete e.session_id;
141
+ } else {
142
+ events.splice(i, 1);
143
+ i--;
135
144
  }
136
- });
145
+ }
146
+ if (events.length === 0) return;
137
147
  var bundle = {
138
148
  app: {
139
149
  id: config.pid,
@@ -1,5 +1,5 @@
1
1
  import { IClient, IConfiguration } from "../types/client";
2
- import { RumCustomEvent, RumEvent, RumExceptionEvent, RumResourceEvent } from "../types/rum-event";
2
+ import { RumCustomEvent, RumEvent, RumExceptionEvent, RumResourceEvent, RumViewEvent } from "../types/rum-event";
3
3
  import { IShell } from "../types/shell";
4
4
  export default abstract class Shell implements IShell {
5
5
  client: IClient;
@@ -22,10 +22,14 @@ export default abstract class Shell implements IShell {
22
22
  * 自定义事件上报
23
23
  */
24
24
  sendCustom(payload: RumCustomEvent): void;
25
+ /**
26
+ * 自定义视图上报
27
+ */
28
+ sendView(payload: RumViewEvent): void;
25
29
  /**
26
30
  * 自定义异常上报
27
31
  */
28
- sendException(payload: RumExceptionEvent): void;
32
+ sendException(payload: RumExceptionEvent | Error): void;
29
33
  /**
30
34
  * 自定义资源上报
31
35
  */
@@ -50,6 +50,31 @@ var Shell = exports["default"] = /*#__PURE__*/function () {
50
50
  });
51
51
  this.sendEvent(data);
52
52
  };
53
+ /**
54
+ * 自定义视图上报
55
+ */
56
+ _proto.sendView = function sendView(payload) {
57
+ if (!(0, _is.isObject)(payload)) {
58
+ return;
59
+ }
60
+ if (!payload.type) {
61
+ payload.type = 'custom';
62
+ }
63
+ if (payload.type === 'custom') {
64
+ var n = 0;
65
+ ['t1', 't2', 't3'].forEach(function (key) {
66
+ if (!(0, _is.isNumber)(payload[key])) {
67
+ delete payload[key];
68
+ }
69
+ key in payload && n++;
70
+ });
71
+ if (n === 0) return;
72
+ }
73
+ var data = (0, _extends2["default"])({}, payload, {
74
+ event_type: _rumEvent.RumEventType.VIEW
75
+ });
76
+ this.sendEvent(data);
77
+ };
53
78
  /**
54
79
  * 自定义异常上报
55
80
  */
@@ -57,8 +82,14 @@ var Shell = exports["default"] = /*#__PURE__*/function () {
57
82
  if (!payload.name || !payload.message) {
58
83
  return;
59
84
  }
85
+ var name = payload.name,
86
+ message = payload.message,
87
+ stack = payload.stack;
60
88
  var data = (0, _extends2["default"])({
61
- times: 1
89
+ times: 1,
90
+ name: name,
91
+ message: message,
92
+ stack: stack
62
93
  }, payload, {
63
94
  event_type: _rumEvent.RumEventType.EXCEPTION,
64
95
  type: 'custom',
@@ -113,6 +113,14 @@ export interface IConfiguration {
113
113
  flushTime?: number;
114
114
  maxEventCount?: number;
115
115
  };
116
+ /**
117
+ * 配置下发
118
+ * - 运行时动态配置更新,根据端侧特点来做定制化配置
119
+ */
120
+ remoteConfig?: Boolean | {
121
+ enable?: boolean;
122
+ url?: string;
123
+ };
116
124
  /**
117
125
  * session config
118
126
  */
@@ -28,7 +28,7 @@ export interface RumBaseEvent extends BaseObject {
28
28
  }
29
29
  export interface RumViewEvent extends RumBaseEvent {
30
30
  loading_type?: 'initial_load' | 'route_change';
31
- type: 'pv' | 'perf' | 'webvitals';
31
+ type: 'pv' | 'perf' | 'webvitals' | 'custom';
32
32
  largest_contentful_paint?: number;
33
33
  first_input_delay?: number;
34
34
  cumulative_layout_shift?: number;
@@ -40,6 +40,9 @@ export interface RumViewEvent extends RumBaseEvent {
40
40
  dom_content_loaded?: number;
41
41
  dom_complete?: number;
42
42
  load_event?: number;
43
+ t1?: number;
44
+ t2?: number;
45
+ t3?: number;
43
46
  referrer?: string;
44
47
  url?: string;
45
48
  timing_data?: string;
@@ -83,13 +86,14 @@ export interface RumExceptionEvent extends RumBaseEvent {
83
86
  column?: number;
84
87
  }
85
88
  export interface RumLongTaskEvent extends RumBaseEvent {
86
- view_name: string;
87
89
  source?: string;
88
90
  type?: string;
89
91
  message?: string;
90
- count: number;
92
+ duration?: number;
93
+ fps?: number;
91
94
  stack?: string;
92
95
  caused_by?: string;
96
+ snapshots: string;
93
97
  }
94
98
  export interface RumActionEvent extends RumBaseEvent {
95
99
  type?: string;
@@ -104,15 +108,16 @@ export interface RumCustomEvent extends RumBaseEvent {
104
108
  value: number;
105
109
  }
106
110
  export interface RumApplicationEvent extends RumBaseEvent {
107
- type: string;
108
- name: string;
111
+ state: string;
112
+ scene: string;
109
113
  duration: number;
110
114
  }
111
115
  export type RumEvent = RumViewEvent | RumResourceEvent | RumExceptionEvent | RumActionEvent | RumCustomEvent | RumApplicationEvent;
112
116
  export declare enum AppType {
113
117
  browser = "browser",
114
118
  miniapp = "miniapp",
115
- uniapp = "uniapp"
119
+ uniapp = "uniapp",
120
+ minigame = "minigame"
116
121
  }
117
122
  export interface RumEventBundle {
118
123
  app: {
@@ -123,6 +128,7 @@ export interface RumEventBundle {
123
128
  channel?: string;
124
129
  env?: string;
125
130
  package?: string;
131
+ framework?: string;
126
132
  };
127
133
  user: {
128
134
  id: string;
@@ -25,5 +25,6 @@ var AppType = exports.AppType = /*#__PURE__*/function (AppType) {
25
25
  AppType["browser"] = "browser";
26
26
  AppType["miniapp"] = "miniapp";
27
27
  AppType["uniapp"] = "uniapp";
28
+ AppType["minigame"] = "minigame";
28
29
  return AppType;
29
30
  }({});
@@ -6,7 +6,6 @@ exports.makeTracingHeaders = makeTracingHeaders;
6
6
  exports.parseTracingOptions = parseTracingOptions;
7
7
  var _match = require("./match");
8
8
  var _is = require("./is");
9
- var _jsBase = require("js-base64");
10
9
  function isTraceOption(option) {
11
10
  return option && (0, _match.isMatchOption)(option.match) && (0, _is.isArray)(option.propagatorTypes);
12
11
  }
@@ -35,14 +34,16 @@ function makeTracingHeaders(traceId, spanId, sampled, propagatorTypes, subOption
35
34
  tracingHeaders['X-B3-Sampled'] = sample;
36
35
  break;
37
36
  case 'sw8':
38
- // https://github.com/apache/skywalking-client-js
39
- var traceIdStr = String((0, _jsBase.encode)(traceId));
40
- var segmentId = String((0, _jsBase.encode)(spanId));
41
- var service = String((0, _jsBase.encode)(subOption.appId));
42
- var instance = String((0, _jsBase.encode)(subOption.appVersion));
43
- var endpoint = String((0, _jsBase.encode)(subOption.viewName));
44
- var peer = String((0, _jsBase.encode)(subOption.host));
45
- tracingHeaders['sw8'] = sample + "-" + traceIdStr + "-" + segmentId + "-" + 0 + "-" + service + "-" + instance + "-" + endpoint + "-" + peer;
37
+ if ((0, _is.isFunction)(btoa)) {
38
+ // https://github.com/apache/skywalking-client-js
39
+ var traceIdStr = btoa(traceId);
40
+ var segmentId = btoa(spanId);
41
+ var service = btoa(subOption.appId);
42
+ var instance = btoa(subOption.appVersion);
43
+ var endpoint = btoa(subOption.viewName);
44
+ var peer = btoa(subOption.host);
45
+ tracingHeaders['sw8'] = sample + "-" + traceIdStr + "-" + segmentId + "-" + 0 + "-" + service + "-" + instance + "-" + endpoint + "-" + peer;
46
+ }
46
47
  break;
47
48
  case 'tracecontext':
48
49
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arms/rum-core",
3
- "version": "0.0.29",
3
+ "version": "0.0.31",
4
4
  "description": "arms rum javascript sdk core",
5
5
  "author": "guangli.fj <guangli.fj@alibaba-inc.com>",
6
6
  "license": "ISC",
@@ -22,8 +22,7 @@
22
22
  "test": "node ./__tests__/@arms/core.test.js"
23
23
  },
24
24
  "dependencies": {
25
- "events": "^3.3.0",
26
- "js-base64": "^3.7.7"
25
+ "events": "^3.3.0"
27
26
  },
28
27
  "devDependencies": {
29
28
  "@babel/runtime": "^7.24.5",