@arms/rum-core 0.0.39 → 0.1.1

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 (53) hide show
  1. package/es/index.d.ts +3 -0
  2. package/es/index.js +3 -0
  3. package/es/model/client.d.ts +2 -1
  4. package/es/model/client.js +2 -2
  5. package/es/model/configManager.d.ts +58 -0
  6. package/es/model/configManager.js +177 -0
  7. package/es/model/context.d.ts +3 -1
  8. package/es/model/context.js +13 -2
  9. package/es/model/reporter.d.ts +2 -4
  10. package/es/model/reporter.js +53 -11
  11. package/es/model/shell.d.ts +1 -15
  12. package/es/model/shell.js +62 -52
  13. package/es/types/client.d.ts +60 -8
  14. package/es/types/client.js +6 -1
  15. package/es/types/config.d.ts +49 -0
  16. package/es/types/config.js +1 -0
  17. package/es/types/rum-event.d.ts +2 -0
  18. package/es/utils/base.d.ts +4 -4
  19. package/es/utils/base.js +70 -42
  20. package/es/utils/combineConfig.js +89 -101
  21. package/es/utils/match.d.ts +6 -0
  22. package/es/utils/match.js +34 -0
  23. package/es/utils/trace.d.ts +5 -1
  24. package/es/utils/url.d.ts +2 -0
  25. package/es/utils/url.js +61 -0
  26. package/lib/index.d.ts +3 -0
  27. package/lib/index.js +21 -0
  28. package/lib/model/client.d.ts +2 -1
  29. package/lib/model/client.js +2 -2
  30. package/lib/model/configManager.d.ts +58 -0
  31. package/lib/model/configManager.js +182 -0
  32. package/lib/model/context.d.ts +3 -1
  33. package/lib/model/context.js +13 -2
  34. package/lib/model/reporter.d.ts +2 -4
  35. package/lib/model/reporter.js +54 -11
  36. package/lib/model/shell.d.ts +1 -15
  37. package/lib/model/shell.js +61 -53
  38. package/lib/types/client.d.ts +60 -8
  39. package/lib/types/client.js +5 -1
  40. package/lib/types/config.d.ts +49 -0
  41. package/lib/types/config.js +3 -0
  42. package/lib/types/rum-event.d.ts +2 -0
  43. package/lib/utils/base.d.ts +4 -4
  44. package/lib/utils/base.js +71 -43
  45. package/lib/utils/combineConfig.js +90 -107
  46. package/lib/utils/match.d.ts +6 -0
  47. package/lib/utils/match.js +35 -0
  48. package/lib/utils/trace.d.ts +5 -1
  49. package/lib/utils/url.d.ts +2 -0
  50. package/lib/utils/url.js +65 -0
  51. package/package.json +2 -2
  52. package/es/utils/combineConfig.d.ts +0 -15
  53. package/lib/utils/combineConfig.d.ts +0 -15
@@ -0,0 +1,61 @@
1
+ var safeDecode = function safeDecode(str) {
2
+ // 添加空值检查
3
+ if (str.length === 0) return "";
4
+ try {
5
+ // 先处理加号,然后进行 URL 解码
6
+ return decodeURIComponent(str.replace(/\+/g, ' '));
7
+ } catch (_unused) {
8
+ // 解码失败时的降级处理:处理常见的 URL 编码字符
9
+ return str.replace(/\+/g, ' ').replace(/%20/g, ' ').replace(/%2F/g, '/').replace(/%3D/g, '=').replace(/%26/g, '&').replace(/%3F/g, '?');
10
+ }
11
+ };
12
+ var getQueryString = function getQueryString(input) {
13
+ // 添加空值检查
14
+ if (input.length === 0) return "";
15
+
16
+ // 移除 hash 部分,然后提取查询字符串
17
+ var hashIndex = input.indexOf('#');
18
+ var withoutHash = hashIndex >= 0 ? input.slice(0, hashIndex) : input;
19
+ var queryStart = withoutHash.indexOf('?');
20
+ if (queryStart === -1) return "";
21
+ return withoutHash.slice(queryStart + 1);
22
+ };
23
+ export function getUrlParams(input) {
24
+ // 输入验证:检查是否为有效字符串
25
+ if (typeof input !== 'string' || !input.trim()) return {};
26
+ var params = {};
27
+ var query = getQueryString(input);
28
+
29
+ // 提前检查空查询
30
+ if (!query) return params;
31
+
32
+ // 使用 for 循环提高性能
33
+ var pairs = query.split('&');
34
+ for (var i = 0; i < pairs.length; i++) {
35
+ var pair = pairs[i];
36
+
37
+ // 跳过空键值对
38
+ if (!pair) continue;
39
+
40
+ // 查找第一个等号作为分隔符
41
+ var separatorIndex = pair.indexOf('=');
42
+ // 检查键是否存在且不为空
43
+ if (separatorIndex <= 0) continue;
44
+ var key = safeDecode(pair.slice(0, separatorIndex));
45
+ // 处理值为空的情况(如 key=)
46
+ var value = separatorIndex < pair.length - 1 ? safeDecode(pair.slice(separatorIndex + 1)) : "";
47
+
48
+ // 处理重复键:将单个值转换为数组
49
+ var existing = params[key];
50
+ if (existing !== undefined) {
51
+ if (Array.isArray(existing)) {
52
+ existing.push(value);
53
+ } else {
54
+ params[key] = [existing, value];
55
+ }
56
+ } else {
57
+ params[key] = value;
58
+ }
59
+ }
60
+ return params;
61
+ }
package/lib/index.d.ts CHANGED
@@ -2,12 +2,14 @@ import Client from './model/client';
2
2
  import Context from './model/context';
3
3
  import Reporter from './model/reporter';
4
4
  import Shell from './model/shell';
5
+ export * from './model/configManager';
5
6
  export * from './types/client';
6
7
  export * from './types/collector';
7
8
  export * from './types/processor';
8
9
  export * from './types/reporter';
9
10
  export * from './types/rum-event';
10
11
  export * from './types/shell';
12
+ export * from './types/config';
11
13
  export * from './utils/base';
12
14
  export * from './utils/polyfills';
13
15
  export * from './utils/is';
@@ -15,4 +17,5 @@ export * from './utils/number';
15
17
  export * from './utils/match';
16
18
  export * from './utils/trace';
17
19
  export * from './utils/verify';
20
+ export * from './utils/url';
18
21
  export { Client, Context, Reporter, Shell };
package/lib/index.js CHANGED
@@ -16,6 +16,13 @@ var _reporter = _interopRequireDefault(require("./model/reporter"));
16
16
  exports.Reporter = _reporter["default"];
17
17
  var _shell = _interopRequireDefault(require("./model/shell"));
18
18
  exports.Shell = _shell["default"];
19
+ var _configManager = require("./model/configManager");
20
+ Object.keys(_configManager).forEach(function (key) {
21
+ if (key === "default" || key === "__esModule") return;
22
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
23
+ if (key in exports && exports[key] === _configManager[key]) return;
24
+ exports[key] = _configManager[key];
25
+ });
19
26
  var _client2 = require("./types/client");
20
27
  Object.keys(_client2).forEach(function (key) {
21
28
  if (key === "default" || key === "__esModule") return;
@@ -58,6 +65,13 @@ Object.keys(_shell2).forEach(function (key) {
58
65
  if (key in exports && exports[key] === _shell2[key]) return;
59
66
  exports[key] = _shell2[key];
60
67
  });
68
+ var _config = require("./types/config");
69
+ Object.keys(_config).forEach(function (key) {
70
+ if (key === "default" || key === "__esModule") return;
71
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
72
+ if (key in exports && exports[key] === _config[key]) return;
73
+ exports[key] = _config[key];
74
+ });
61
75
  var _base = require("./utils/base");
62
76
  Object.keys(_base).forEach(function (key) {
63
77
  if (key === "default" || key === "__esModule") return;
@@ -106,4 +120,11 @@ Object.keys(_verify).forEach(function (key) {
106
120
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
107
121
  if (key in exports && exports[key] === _verify[key]) return;
108
122
  exports[key] = _verify[key];
123
+ });
124
+ var _url = require("./utils/url");
125
+ Object.keys(_url).forEach(function (key) {
126
+ if (key === "default" || key === "__esModule") return;
127
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
128
+ if (key in exports && exports[key] === _url[key]) return;
129
+ exports[key] = _url[key];
109
130
  });
@@ -1,4 +1,5 @@
1
1
  import { IClient, IConfiguration, IContext, IRumSession } from '../types/client';
2
+ import { IConfigManager } from "../types/config";
2
3
  import { RumEvent } from '../types/rum-event';
3
4
  import { IProcessor } from '../types/processor';
4
5
  import { ICollector } from '../types/collector';
@@ -9,7 +10,7 @@ declare class Client implements IClient {
9
10
  private processors;
10
11
  private reporter;
11
12
  private ctx;
12
- init(config: IConfiguration, rumSession?: IRumSession): void;
13
+ init(config: IConfiguration, rumSession?: IRumSession, configManager?: IConfigManager): void;
13
14
  sendEvent: (payload: RumEvent) => void;
14
15
  setContext(ctx: IContext): void;
15
16
  getContext(): IContext;
@@ -23,9 +23,9 @@ var Client = /*#__PURE__*/function () {
23
23
  };
24
24
  }
25
25
  var _proto = Client.prototype;
26
- _proto.init = function init(config, rumSession) {
26
+ _proto.init = function init(config, rumSession, configManager) {
27
27
  var _this2 = this;
28
- this.ctx = new _context["default"](config, rumSession);
28
+ this.ctx = new _context["default"](config, rumSession, configManager);
29
29
  var ctx = this.ctx,
30
30
  collectors = this.collectors,
31
31
  processors = this.processors,
@@ -0,0 +1,58 @@
1
+ import { ICacheConfiguration, IConfigManager } from '../types/config';
2
+ import { IConfiguration } from '../types/client';
3
+ /**
4
+ * 配置管理器
5
+ * 提供配置管理的通用实现,各平台可以继承并实现特定方法
6
+ */
7
+ export declare abstract class ConfigManager implements IConfigManager {
8
+ protected currentConfig: IConfiguration | null;
9
+ protected initialized: boolean;
10
+ /**
11
+ * 初始化配置管理器
12
+ * @param config 初始配置
13
+ */
14
+ init(config: IConfiguration): Promise<void>;
15
+ /**
16
+ * 获取配置
17
+ * @returns 配置数据
18
+ */
19
+ getConfig(): IConfiguration;
20
+ /**
21
+ * 更新配置
22
+ * @param config 新配置
23
+ */
24
+ setConfig(config: Partial<IConfiguration>): Promise<void>;
25
+ /**
26
+ * 检查缓存是否有效
27
+ * @param cachedData 缓存数据
28
+ * @param cacheTimeout 缓存超时时间
29
+ */
30
+ protected isCacheValid(cachedData: any, cacheTimeout?: number): boolean;
31
+ /**
32
+ * 合并配置
33
+ * @param remoteCfg 远程配置
34
+ * @returns 合并后的配置
35
+ */
36
+ mergeRemoteCfg(remoteCfg: any): IConfiguration | null;
37
+ abstract fetchRemoteCfg(config: IConfiguration): Promise<any>;
38
+ /**
39
+ * 抽象方法:获取本地存储的配置
40
+ * 各平台需要实现此方法来适配不同的本地存储方式
41
+ */
42
+ abstract getCacheConfig(): Promise<ICacheConfiguration> | ICacheConfiguration | void;
43
+ /**
44
+ * 抽象方法:存储配置到本地
45
+ * 各平台需要实现此方法来适配不同的本地存储方式
46
+ * @param config 配置数据
47
+ */
48
+ abstract setCacheConfig(config: ICacheConfiguration): void;
49
+ /**
50
+ * 抽象方法:解析远端配置为本地配置
51
+ * @param json 远端下发的配置数据
52
+ */
53
+ abstract parseConfig(json: any): unknown;
54
+ /**
55
+ * 销毁配置管理器
56
+ */
57
+ destroy(): void;
58
+ }
@@ -0,0 +1,182 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ exports.__esModule = true;
5
+ exports.ConfigManager = void 0;
6
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
8
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
9
+ function parseRemoteConfig(config) {
10
+ var remoteConfig = config.remoteConfig || {};
11
+ return {
12
+ enable: remoteConfig.enable !== false && !!(remoteConfig.url || remoteConfig.region),
13
+ url: remoteConfig.url || '',
14
+ mode: remoteConfig.mode || 'launch-first',
15
+ cacheTimeout: remoteConfig.cacheTimeout || 3600000
16
+ };
17
+ }
18
+
19
+ /**
20
+ * 配置管理器
21
+ * 提供配置管理的通用实现,各平台可以继承并实现特定方法
22
+ */
23
+ var ConfigManager = exports.ConfigManager = /*#__PURE__*/function () {
24
+ function ConfigManager() {
25
+ this.currentConfig = null;
26
+ this.initialized = false;
27
+ }
28
+ var _proto = ConfigManager.prototype;
29
+ /**
30
+ * 初始化配置管理器
31
+ * @param config 初始配置
32
+ */
33
+ _proto.init =
34
+ /*#__PURE__*/
35
+ function () {
36
+ var _init = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(config) {
37
+ var _this = this;
38
+ var remoteConfig, cacheConfig, asyncConfigPromise;
39
+ return _regenerator["default"].wrap(function _callee$(_context) {
40
+ while (1) switch (_context.prev = _context.next) {
41
+ case 0:
42
+ if (!this.initialized) {
43
+ _context.next = 2;
44
+ break;
45
+ }
46
+ return _context.abrupt("return");
47
+ case 2:
48
+ this.currentConfig = (0, _extends2["default"])({}, config);
49
+ this.initialized = true;
50
+ remoteConfig = parseRemoteConfig(config);
51
+ this.currentConfig.remoteConfig = remoteConfig;
52
+ if (remoteConfig.enable) {
53
+ _context.next = 8;
54
+ break;
55
+ }
56
+ return _context.abrupt("return");
57
+ case 8:
58
+ _context.next = 10;
59
+ return this.getCacheConfig();
60
+ case 10:
61
+ cacheConfig = _context.sent;
62
+ if (cacheConfig && cacheConfig.content) {
63
+ this.currentConfig = this.mergeRemoteCfg(cacheConfig.content);
64
+ }
65
+ if (!this.isCacheValid(cacheConfig, remoteConfig.cacheTimeout)) {
66
+ _context.next = 14;
67
+ break;
68
+ }
69
+ return _context.abrupt("return");
70
+ case 14:
71
+ asyncConfigPromise = this.fetchRemoteCfg(this.currentConfig).then(function (resp) {
72
+ if (!resp) return;
73
+ var asyncRemoteConfig = _this.parseConfig(resp);
74
+ _this.currentConfig = _this.mergeRemoteCfg(asyncRemoteConfig);
75
+ _this.setCacheConfig({
76
+ timestamp: Date.now(),
77
+ content: resp
78
+ });
79
+ });
80
+ if (!(remoteConfig.mode === 'remote-first')) {
81
+ _context.next = 18;
82
+ break;
83
+ }
84
+ _context.next = 18;
85
+ return asyncConfigPromise;
86
+ case 18:
87
+ case "end":
88
+ return _context.stop();
89
+ }
90
+ }, _callee, this);
91
+ }));
92
+ function init(_x) {
93
+ return _init.apply(this, arguments);
94
+ }
95
+ return init;
96
+ }()
97
+ /**
98
+ * 获取配置
99
+ * @returns 配置数据
100
+ */
101
+ ;
102
+ _proto.getConfig = function getConfig() {
103
+ if (!this.currentConfig) {
104
+ throw new Error('Config not initialized');
105
+ }
106
+ return this.currentConfig;
107
+ }
108
+
109
+ /**
110
+ * 更新配置
111
+ * @param config 新配置
112
+ */;
113
+ _proto.setConfig =
114
+ /*#__PURE__*/
115
+ function () {
116
+ var _setConfig = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee2(config) {
117
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
118
+ while (1) switch (_context2.prev = _context2.next) {
119
+ case 0:
120
+ if (this.currentConfig) {
121
+ _context2.next = 2;
122
+ break;
123
+ }
124
+ return _context2.abrupt("return");
125
+ case 2:
126
+ this.currentConfig = (0, _extends2["default"])({}, this.currentConfig, config);
127
+ case 3:
128
+ case "end":
129
+ return _context2.stop();
130
+ }
131
+ }, _callee2, this);
132
+ }));
133
+ function setConfig(_x2) {
134
+ return _setConfig.apply(this, arguments);
135
+ }
136
+ return setConfig;
137
+ }()
138
+ /**
139
+ * 检查缓存是否有效
140
+ * @param cachedData 缓存数据
141
+ * @param cacheTimeout 缓存超时时间
142
+ */
143
+ ;
144
+ _proto.isCacheValid = function isCacheValid(cachedData, cacheTimeout) {
145
+ if (!cachedData || !cachedData.timestamp) {
146
+ return false;
147
+ }
148
+ var timeout = cacheTimeout || 3600000; // 默认1小时
149
+ return Date.now() - cachedData.timestamp < timeout;
150
+ }
151
+
152
+ /**
153
+ * 合并配置
154
+ * @param remoteCfg 远程配置
155
+ * @returns 合并后的配置
156
+ */;
157
+ _proto.mergeRemoteCfg = function mergeRemoteCfg(remoteCfg) {
158
+ var _this$currentConfig = this.currentConfig,
159
+ pid = _this$currentConfig.pid,
160
+ app = _this$currentConfig.app,
161
+ endpoint = _this$currentConfig.endpoint,
162
+ remoteConfig = _this$currentConfig.remoteConfig,
163
+ beforeReport = _this$currentConfig.beforeReport,
164
+ properties = _this$currentConfig.properties;
165
+ return (0, _extends2["default"])({}, this.currentConfig, remoteCfg, {
166
+ pid: pid,
167
+ app: app,
168
+ endpoint: endpoint,
169
+ remoteConfig: remoteConfig,
170
+ beforeReport: beforeReport,
171
+ properties: properties
172
+ });
173
+ };
174
+ /**
175
+ * 销毁配置管理器
176
+ */
177
+ _proto.destroy = function destroy() {
178
+ this.currentConfig = null;
179
+ this.initialized = false;
180
+ };
181
+ return ConfigManager;
182
+ }();
@@ -1,11 +1,13 @@
1
1
  import { IConfiguration, IContext, IRumSession } from "../types/client";
2
2
  import { RumEvent, IViewData } from "../types/rum-event";
3
+ import { IConfigManager } from "../types/config";
3
4
  declare class Context implements IContext {
4
5
  private config;
5
6
  private rumEvent;
6
7
  private views;
7
8
  session: IRumSession;
8
- constructor(config: IConfiguration, rumSession?: IRumSession);
9
+ configManager: IConfigManager;
10
+ constructor(config: IConfiguration, rumSession?: IRumSession, configManager?: IConfigManager);
9
11
  getConfig(): IConfiguration;
10
12
  setConfig(config: IConfiguration): void;
11
13
  getViews(): IViewData[];
@@ -3,22 +3,33 @@
3
3
  exports.__esModule = true;
4
4
  exports["default"] = void 0;
5
5
  var Context = /*#__PURE__*/function () {
6
- function Context(config, rumSession) {
6
+ function Context(config, rumSession, configManager) {
7
7
  this.config = config;
8
8
  this.rumEvent = void 0;
9
9
  this.views = [];
10
10
  this.session = void 0;
11
+ this.configManager = void 0;
11
12
  if (rumSession) {
12
13
  this.session = rumSession;
13
14
  this.session.init(this);
14
15
  }
16
+ if (configManager) {
17
+ this.configManager = configManager;
18
+ }
15
19
  }
16
20
  var _proto = Context.prototype;
17
21
  _proto.getConfig = function getConfig() {
22
+ if (this.configManager) {
23
+ return this.configManager.getConfig();
24
+ }
18
25
  return this.config;
19
26
  };
20
27
  _proto.setConfig = function setConfig(config) {
21
- this.config = config;
28
+ if (this.configManager) {
29
+ this.configManager.setConfig(config);
30
+ } else {
31
+ this.config = config;
32
+ }
22
33
  };
23
34
  _proto.getViews = function getViews() {
24
35
  return this.views;
@@ -10,10 +10,7 @@ export default abstract class Reporter {
10
10
  protected ctx: IContext;
11
11
  private timer;
12
12
  private _init;
13
- getReportCfg(): {
14
- flushTime?: number;
15
- maxEventCount?: number;
16
- };
13
+ getReportCfg(): import("../types/client").IReportConfig;
17
14
  report(ctx: IContext): void;
18
15
  private pushToQueue;
19
16
  /**
@@ -21,6 +18,7 @@ export default abstract class Reporter {
21
18
  */
22
19
  protected flushEventQueue(): void;
23
20
  mergeEvent(ctx: IContext, events: RumEvent[], view: IViewData): void;
21
+ private tryRequest;
24
22
  /**
25
23
  * 接口请求由各平台 sdk reporter 实现
26
24
  */
@@ -1,11 +1,16 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  exports.__esModule = true;
4
5
  exports["default"] = void 0;
6
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
7
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
5
9
  var _rumEvent = require("../types/rum-event");
6
10
  var _exception = require("../utils/exception");
7
11
  var _is = require("../utils/is");
8
12
  var _verify = require("../utils/verify");
13
+ var _url = require("../utils/url");
9
14
  var FLUSH_TIME = 3000;
10
15
  var MAX_EVENT_COUNT = 20;
11
16
  var attrs = ['app', 'user', 'device', 'os', 'geo', 'isp', 'net', 'properties'];
@@ -147,7 +152,8 @@ var Reporter = exports["default"] = /*#__PURE__*/function () {
147
152
  }
148
153
  }
149
154
  if (events.length === 0) return;
150
- var bundle = {
155
+ var extend = (0, _url.getUrlParams)(config.endpoint);
156
+ var bundle = (0, _extends2["default"])({
151
157
  app: {
152
158
  id: config.pid,
153
159
  env: config.env || 'prod',
@@ -163,7 +169,7 @@ var Reporter = exports["default"] = /*#__PURE__*/function () {
163
169
  net: {},
164
170
  view: view,
165
171
  events: events
166
- };
172
+ }, extend);
167
173
  attrs.forEach(function (key) {
168
174
  var obj = config[key];
169
175
  (0, _is.isObject)(obj) && Object.keys(obj).forEach(function (k) {
@@ -184,17 +190,54 @@ var Reporter = exports["default"] = /*#__PURE__*/function () {
184
190
  bundle = config.beforeReport(bundle);
185
191
  if (!bundle) return;
186
192
  }
187
- this.request(ctx, bundle);
188
- }
189
-
190
- // /**
191
- // * 接口请求由各平台 sdk reporter 实现
192
- // */
193
- // abstract request(ctx: IContext, events: RumEvent[], view: IViewData): void;
194
-
193
+ this.tryRequest(bundle);
194
+ };
195
+ _proto.tryRequest = /*#__PURE__*/function () {
196
+ var _tryRequest = (0, _asyncToGenerator2["default"])(/*#__PURE__*/_regenerator["default"].mark(function _callee(bundle, retry) {
197
+ var _this$ctx$getConfig,
198
+ _reportConfig$maxRetr,
199
+ _reportConfig$retryDe,
200
+ _this2 = this;
201
+ var reportConfig, maxRetryCount, retryDelay;
202
+ return _regenerator["default"].wrap(function _callee$(_context) {
203
+ while (1) switch (_context.prev = _context.next) {
204
+ case 0:
205
+ if (retry === void 0) {
206
+ retry = 0;
207
+ }
208
+ reportConfig = (_this$ctx$getConfig = this.ctx.getConfig()) === null || _this$ctx$getConfig === void 0 ? void 0 : _this$ctx$getConfig.reportConfig;
209
+ maxRetryCount = (_reportConfig$maxRetr = reportConfig === null || reportConfig === void 0 ? void 0 : reportConfig.maxRetryCount) !== null && _reportConfig$maxRetr !== void 0 ? _reportConfig$maxRetr : 0;
210
+ retryDelay = (_reportConfig$retryDe = reportConfig === null || reportConfig === void 0 ? void 0 : reportConfig.retryDelay) !== null && _reportConfig$retryDe !== void 0 ? _reportConfig$retryDe : 3000;
211
+ _context.prev = 4;
212
+ bundle._retry = retry;
213
+ _context.next = 8;
214
+ return this.request(this.ctx, bundle);
215
+ case 8:
216
+ _context.next = 13;
217
+ break;
218
+ case 10:
219
+ _context.prev = 10;
220
+ _context.t0 = _context["catch"](4);
221
+ if (retry < maxRetryCount - 1) {
222
+ setTimeout(function () {
223
+ return _this2.tryRequest(bundle, retry + 1);
224
+ }, retryDelay);
225
+ }
226
+ case 13:
227
+ case "end":
228
+ return _context.stop();
229
+ }
230
+ }, _callee, this, [[4, 10]]);
231
+ }));
232
+ function tryRequest(_x, _x2) {
233
+ return _tryRequest.apply(this, arguments);
234
+ }
235
+ return tryRequest;
236
+ }()
195
237
  /**
196
238
  * 接口请求由各平台 sdk reporter 实现
197
- */;
239
+ */
240
+ ;
198
241
  /**
199
242
  * 初始化时
200
243
  */
@@ -4,29 +4,15 @@ import { IShell } from "../types/shell";
4
4
  export default abstract class Shell implements IShell {
5
5
  client: IClient;
6
6
  constructor(config?: IConfiguration);
7
- getCombinedConfig(config?: IConfiguration): any;
8
- updateFromRemoteConfig(config: any, reSetup?: boolean): void;
9
7
  /**
10
8
  * 初始化
11
9
  */
12
- abstract init(configuration: IConfiguration): void;
10
+ abstract init(configuration: IConfiguration): Promise<Shell> | Shell;
13
11
  sendEvent(payload: RumEvent): void;
14
12
  /**
15
13
  * get config
16
14
  */
17
15
  getConfig(): IConfiguration;
18
- /**
19
- * 获取远程配置
20
- */
21
- abstract getRemoteConfig(url: string, config: any): object;
22
- /**
23
- * 存储远程配置到本地
24
- */
25
- abstract storeRemoteConfig(config: any, pid: string): boolean;
26
- /**
27
- * 提取本地存储的配置
28
- */
29
- abstract getLocalConfig(duration: number, pid: string): any;
30
16
  /**
31
17
  * set config
32
18
  */