@arms/rum-core 0.1.1 → 0.1.2
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.
- package/es/model/configManager.js +2 -1
- package/es/model/shell.js +15 -54
- package/lib/model/configManager.js +2 -1
- package/lib/model/shell.js +15 -54
- package/package.json +1 -1
- package/es/utils/combineConfig.js +0 -89
- package/lib/utils/combineConfig.js +0 -90
|
@@ -7,7 +7,8 @@ function parseRemoteConfig(config) {
|
|
|
7
7
|
enable: remoteConfig.enable !== false && !!(remoteConfig.url || remoteConfig.region),
|
|
8
8
|
url: remoteConfig.url || '',
|
|
9
9
|
mode: remoteConfig.mode || 'launch-first',
|
|
10
|
-
cacheTimeout: remoteConfig.cacheTimeout || 3600000
|
|
10
|
+
cacheTimeout: remoteConfig.cacheTimeout || 3600000,
|
|
11
|
+
region: remoteConfig.region
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
|
package/es/model/shell.js
CHANGED
|
@@ -2,57 +2,33 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
import { RumEventType } from "../types/rum-event";
|
|
3
3
|
import Client from '../model/client';
|
|
4
4
|
import { isNumber, isObject } from "../utils/is";
|
|
5
|
-
// import combineConfig, { isRemoteConfigEnable, getRemoteConfigUrl } from "../utils/combineConfig";
|
|
6
5
|
var Shell = /*#__PURE__*/function () {
|
|
7
6
|
function Shell(config) {
|
|
7
|
+
// private callbacks: Function[] = [];
|
|
8
|
+
// private initialized = false;
|
|
8
9
|
this.client = void 0;
|
|
9
10
|
this.client = new Client();
|
|
10
11
|
if (config && this.init) {
|
|
11
12
|
this.init(config);
|
|
13
|
+
// const p = this.init(config) as Promise<Shell>;
|
|
14
|
+
// if(isFunction(p?.then)){
|
|
15
|
+
// p.then(this.shellReady);
|
|
16
|
+
// } else {
|
|
17
|
+
// this.shellReady()
|
|
18
|
+
// }
|
|
12
19
|
}
|
|
13
20
|
}
|
|
14
21
|
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
// const localConfig = this.getLocalConfig(0, config.pid);
|
|
19
|
-
// combinedConf = combineConfig(config, localConfig);
|
|
20
|
-
// }
|
|
21
|
-
// return combinedConf || config;
|
|
22
|
+
// private shellReady = () => {
|
|
23
|
+
// this.initialized = true;
|
|
24
|
+
// this.callbacks.forEach(cb => cb());
|
|
22
25
|
// }
|
|
23
26
|
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
27
|
-
// const that = this;
|
|
28
|
-
// const proms = this.getRemoteConfig(getRemoteConfigUrl(config), config);
|
|
29
|
-
// proms?.then(remoteConfig => {
|
|
30
|
-
// if(!remoteConfig || remoteConfig.errorStatus !== undefined) return;
|
|
31
|
-
// const combinedConf = combineConfig(config, remoteConfig);
|
|
32
|
-
//
|
|
33
|
-
// // 无有效的新配置,无需更新
|
|
34
|
-
// if(!combinedConf) return;
|
|
35
|
-
//
|
|
36
|
-
// // 存储到本地
|
|
37
|
-
// if(isFunction(that.storeRemoteConfig)) {
|
|
38
|
-
// that.storeRemoteConfig(remoteConfig, config.pid);
|
|
39
|
-
// }
|
|
40
|
-
//
|
|
41
|
-
// if(reSetup === false || config.remoteConfig.reSetup === false) return;
|
|
42
|
-
//
|
|
43
|
-
// const context = that.client.getContext();
|
|
44
|
-
// // 更新配置
|
|
45
|
-
// context.setConfig(combinedConf);
|
|
46
|
-
// // 逐个更新collector
|
|
47
|
-
// const collectors = that.client.getCollectors();
|
|
48
|
-
// collectors.forEach(collector => {
|
|
49
|
-
// if(isFunction(collector.destroy)) {
|
|
50
|
-
// collector.destroy();
|
|
51
|
-
// collector.setup(context, that.client.sendEvent);
|
|
52
|
-
// }
|
|
53
|
-
// });
|
|
54
|
-
// });
|
|
27
|
+
// onReady(callback: Function) {
|
|
28
|
+
// if (this.initialized) {
|
|
29
|
+
// callback();
|
|
55
30
|
// }
|
|
31
|
+
// this.callbacks.push(callback);
|
|
56
32
|
// }
|
|
57
33
|
|
|
58
34
|
/**
|
|
@@ -74,21 +50,6 @@ var Shell = /*#__PURE__*/function () {
|
|
|
74
50
|
}
|
|
75
51
|
}
|
|
76
52
|
|
|
77
|
-
// /**
|
|
78
|
-
// * 获取远程配置
|
|
79
|
-
// */
|
|
80
|
-
// abstract getRemoteConfig(url: string, config: any): object;
|
|
81
|
-
//
|
|
82
|
-
// /**
|
|
83
|
-
// * 存储远程配置到本地
|
|
84
|
-
// */
|
|
85
|
-
// abstract storeRemoteConfig(config: any, pid: string): boolean;
|
|
86
|
-
//
|
|
87
|
-
// /**
|
|
88
|
-
// * 提取本地存储的配置
|
|
89
|
-
// */
|
|
90
|
-
// abstract getLocalConfig(duration: number, pid: string): any;
|
|
91
|
-
|
|
92
53
|
/**
|
|
93
54
|
* set config
|
|
94
55
|
*/;
|
|
@@ -12,7 +12,8 @@ function parseRemoteConfig(config) {
|
|
|
12
12
|
enable: remoteConfig.enable !== false && !!(remoteConfig.url || remoteConfig.region),
|
|
13
13
|
url: remoteConfig.url || '',
|
|
14
14
|
mode: remoteConfig.mode || 'launch-first',
|
|
15
|
-
cacheTimeout: remoteConfig.cacheTimeout || 3600000
|
|
15
|
+
cacheTimeout: remoteConfig.cacheTimeout || 3600000,
|
|
16
|
+
region: remoteConfig.region
|
|
16
17
|
};
|
|
17
18
|
}
|
|
18
19
|
|
package/lib/model/shell.js
CHANGED
|
@@ -7,57 +7,33 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
7
7
|
var _rumEvent = require("../types/rum-event");
|
|
8
8
|
var _client = _interopRequireDefault(require("../model/client"));
|
|
9
9
|
var _is = require("../utils/is");
|
|
10
|
-
// import combineConfig, { isRemoteConfigEnable, getRemoteConfigUrl } from "../utils/combineConfig";
|
|
11
10
|
var Shell = exports["default"] = /*#__PURE__*/function () {
|
|
12
11
|
function Shell(config) {
|
|
12
|
+
// private callbacks: Function[] = [];
|
|
13
|
+
// private initialized = false;
|
|
13
14
|
this.client = void 0;
|
|
14
15
|
this.client = new _client["default"]();
|
|
15
16
|
if (config && this.init) {
|
|
16
17
|
this.init(config);
|
|
18
|
+
// const p = this.init(config) as Promise<Shell>;
|
|
19
|
+
// if(isFunction(p?.then)){
|
|
20
|
+
// p.then(this.shellReady);
|
|
21
|
+
// } else {
|
|
22
|
+
// this.shellReady()
|
|
23
|
+
// }
|
|
17
24
|
}
|
|
18
25
|
}
|
|
19
26
|
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
// const localConfig = this.getLocalConfig(0, config.pid);
|
|
24
|
-
// combinedConf = combineConfig(config, localConfig);
|
|
25
|
-
// }
|
|
26
|
-
// return combinedConf || config;
|
|
27
|
+
// private shellReady = () => {
|
|
28
|
+
// this.initialized = true;
|
|
29
|
+
// this.callbacks.forEach(cb => cb());
|
|
27
30
|
// }
|
|
28
31
|
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
// const that = this;
|
|
33
|
-
// const proms = this.getRemoteConfig(getRemoteConfigUrl(config), config);
|
|
34
|
-
// proms?.then(remoteConfig => {
|
|
35
|
-
// if(!remoteConfig || remoteConfig.errorStatus !== undefined) return;
|
|
36
|
-
// const combinedConf = combineConfig(config, remoteConfig);
|
|
37
|
-
//
|
|
38
|
-
// // 无有效的新配置,无需更新
|
|
39
|
-
// if(!combinedConf) return;
|
|
40
|
-
//
|
|
41
|
-
// // 存储到本地
|
|
42
|
-
// if(isFunction(that.storeRemoteConfig)) {
|
|
43
|
-
// that.storeRemoteConfig(remoteConfig, config.pid);
|
|
44
|
-
// }
|
|
45
|
-
//
|
|
46
|
-
// if(reSetup === false || config.remoteConfig.reSetup === false) return;
|
|
47
|
-
//
|
|
48
|
-
// const context = that.client.getContext();
|
|
49
|
-
// // 更新配置
|
|
50
|
-
// context.setConfig(combinedConf);
|
|
51
|
-
// // 逐个更新collector
|
|
52
|
-
// const collectors = that.client.getCollectors();
|
|
53
|
-
// collectors.forEach(collector => {
|
|
54
|
-
// if(isFunction(collector.destroy)) {
|
|
55
|
-
// collector.destroy();
|
|
56
|
-
// collector.setup(context, that.client.sendEvent);
|
|
57
|
-
// }
|
|
58
|
-
// });
|
|
59
|
-
// });
|
|
32
|
+
// onReady(callback: Function) {
|
|
33
|
+
// if (this.initialized) {
|
|
34
|
+
// callback();
|
|
60
35
|
// }
|
|
36
|
+
// this.callbacks.push(callback);
|
|
61
37
|
// }
|
|
62
38
|
|
|
63
39
|
/**
|
|
@@ -79,21 +55,6 @@ var Shell = exports["default"] = /*#__PURE__*/function () {
|
|
|
79
55
|
}
|
|
80
56
|
}
|
|
81
57
|
|
|
82
|
-
// /**
|
|
83
|
-
// * 获取远程配置
|
|
84
|
-
// */
|
|
85
|
-
// abstract getRemoteConfig(url: string, config: any): object;
|
|
86
|
-
//
|
|
87
|
-
// /**
|
|
88
|
-
// * 存储远程配置到本地
|
|
89
|
-
// */
|
|
90
|
-
// abstract storeRemoteConfig(config: any, pid: string): boolean;
|
|
91
|
-
//
|
|
92
|
-
// /**
|
|
93
|
-
// * 提取本地存储的配置
|
|
94
|
-
// */
|
|
95
|
-
// abstract getLocalConfig(duration: number, pid: string): any;
|
|
96
|
-
|
|
97
58
|
/**
|
|
98
59
|
* set config
|
|
99
60
|
*/;
|
package/package.json
CHANGED
|
@@ -1,89 +0,0 @@
|
|
|
1
|
-
// import{ getType, toRegFormat} from './base';
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// // 需要检查是否需要字符串格式化为正则的配置路径
|
|
5
|
-
// const REG_FORMAT_PATHS = [
|
|
6
|
-
// 'filters.exception',
|
|
7
|
-
// 'filters.resource',
|
|
8
|
-
// 'tracing.allowedUrls.[].match'
|
|
9
|
-
// ];
|
|
10
|
-
//
|
|
11
|
-
// export function isRemoteConfigEnable(config: any) {
|
|
12
|
-
// return config.remoteConfig === true ||
|
|
13
|
-
// (config.remoteConfig && config.remoteConfig.enable !== false);
|
|
14
|
-
// }
|
|
15
|
-
//
|
|
16
|
-
// /**
|
|
17
|
-
// *
|
|
18
|
-
// * @param config
|
|
19
|
-
// * @returns
|
|
20
|
-
// */
|
|
21
|
-
// export function getRemoteConfigUrl(config: any){
|
|
22
|
-
// if(config.remoteConfig && config.remoteConfig.url) {
|
|
23
|
-
// return config.remoteConfig.url;
|
|
24
|
-
// }
|
|
25
|
-
// const sereis = config.pid.split('@');
|
|
26
|
-
// if(!sereis || sereis.length<2) return;
|
|
27
|
-
// const timestamp = Date.now();
|
|
28
|
-
// return `//${sereis[0]}-sdk.rum.aliyuncs.com/config/${config.remoteConfig.region || 'cn-hangzhou'}/${sereis[1]}?t=${timestamp}`;
|
|
29
|
-
// }
|
|
30
|
-
//
|
|
31
|
-
// /**
|
|
32
|
-
// *
|
|
33
|
-
// * @param oldConfig
|
|
34
|
-
// * @param remoteConfig
|
|
35
|
-
// */
|
|
36
|
-
// function doCover(oldConfig: any ={}, remoteConfig: any ={}){
|
|
37
|
-
// for(const key in oldConfig) {
|
|
38
|
-
// if(key === 'pid' || key === 'endpoint') continue;
|
|
39
|
-
// if(remoteConfig?.[key] === undefined) continue;
|
|
40
|
-
// const oldV = oldConfig[key];
|
|
41
|
-
// const newV = remoteConfig?.[key];
|
|
42
|
-
// if(getType(oldV) === 'object' && getType(newV) === 'object') {
|
|
43
|
-
// doCover(oldV, newV);
|
|
44
|
-
// } else {
|
|
45
|
-
// oldConfig[key] = newV;
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
// }
|
|
49
|
-
//
|
|
50
|
-
// /**
|
|
51
|
-
// *
|
|
52
|
-
// * @param oldConfig
|
|
53
|
-
// * @param remoteConfig
|
|
54
|
-
// */
|
|
55
|
-
// function doSupplement(oldConfig: any ={}, remoteConfig: any ={}) {
|
|
56
|
-
// for(const key in remoteConfig) {
|
|
57
|
-
// if(oldConfig?.[key] === undefined) {
|
|
58
|
-
// oldConfig[key] = remoteConfig[key];
|
|
59
|
-
// } else {
|
|
60
|
-
// const oldV = oldConfig[key];
|
|
61
|
-
// const newV = remoteConfig[key];
|
|
62
|
-
// if(getType(oldV) === 'object' && getType(newV) === 'object') {
|
|
63
|
-
// doSupplement(oldV, newV);
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
//
|
|
69
|
-
// /**
|
|
70
|
-
// *
|
|
71
|
-
// * @param oldConfig
|
|
72
|
-
// * @param remoteConfig
|
|
73
|
-
// * @returns config
|
|
74
|
-
// */
|
|
75
|
-
// function combineConfig(oldConfig={}, remoteConfig=null) {
|
|
76
|
-
// if(!remoteConfig) return null;
|
|
77
|
-
// if(getType(oldConfig) !== 'object' || getType(remoteConfig) !== 'object') return null;
|
|
78
|
-
// const config = {...oldConfig};
|
|
79
|
-
// // 先检查远程配置的,是否有需要将字符串格式化为正则的
|
|
80
|
-
// toRegFormat(remoteConfig, REG_FORMAT_PATHS);
|
|
81
|
-
// // 执行覆盖
|
|
82
|
-
// doCover(config, remoteConfig);
|
|
83
|
-
// // 执行补充
|
|
84
|
-
// doSupplement(config, remoteConfig);
|
|
85
|
-
// return config;
|
|
86
|
-
// }
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
// export default combineConfig;
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// import{ getType, toRegFormat} from './base';
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// // 需要检查是否需要字符串格式化为正则的配置路径
|
|
5
|
-
// const REG_FORMAT_PATHS = [
|
|
6
|
-
// 'filters.exception',
|
|
7
|
-
// 'filters.resource',
|
|
8
|
-
// 'tracing.allowedUrls.[].match'
|
|
9
|
-
// ];
|
|
10
|
-
//
|
|
11
|
-
// export function isRemoteConfigEnable(config: any) {
|
|
12
|
-
// return config.remoteConfig === true ||
|
|
13
|
-
// (config.remoteConfig && config.remoteConfig.enable !== false);
|
|
14
|
-
// }
|
|
15
|
-
//
|
|
16
|
-
// /**
|
|
17
|
-
// *
|
|
18
|
-
// * @param config
|
|
19
|
-
// * @returns
|
|
20
|
-
// */
|
|
21
|
-
// export function getRemoteConfigUrl(config: any){
|
|
22
|
-
// if(config.remoteConfig && config.remoteConfig.url) {
|
|
23
|
-
// return config.remoteConfig.url;
|
|
24
|
-
// }
|
|
25
|
-
// const sereis = config.pid.split('@');
|
|
26
|
-
// if(!sereis || sereis.length<2) return;
|
|
27
|
-
// const timestamp = Date.now();
|
|
28
|
-
// return `//${sereis[0]}-sdk.rum.aliyuncs.com/config/${config.remoteConfig.region || 'cn-hangzhou'}/${sereis[1]}?t=${timestamp}`;
|
|
29
|
-
// }
|
|
30
|
-
//
|
|
31
|
-
// /**
|
|
32
|
-
// *
|
|
33
|
-
// * @param oldConfig
|
|
34
|
-
// * @param remoteConfig
|
|
35
|
-
// */
|
|
36
|
-
// function doCover(oldConfig: any ={}, remoteConfig: any ={}){
|
|
37
|
-
// for(const key in oldConfig) {
|
|
38
|
-
// if(key === 'pid' || key === 'endpoint') continue;
|
|
39
|
-
// if(remoteConfig?.[key] === undefined) continue;
|
|
40
|
-
// const oldV = oldConfig[key];
|
|
41
|
-
// const newV = remoteConfig?.[key];
|
|
42
|
-
// if(getType(oldV) === 'object' && getType(newV) === 'object') {
|
|
43
|
-
// doCover(oldV, newV);
|
|
44
|
-
// } else {
|
|
45
|
-
// oldConfig[key] = newV;
|
|
46
|
-
// }
|
|
47
|
-
// }
|
|
48
|
-
// }
|
|
49
|
-
//
|
|
50
|
-
// /**
|
|
51
|
-
// *
|
|
52
|
-
// * @param oldConfig
|
|
53
|
-
// * @param remoteConfig
|
|
54
|
-
// */
|
|
55
|
-
// function doSupplement(oldConfig: any ={}, remoteConfig: any ={}) {
|
|
56
|
-
// for(const key in remoteConfig) {
|
|
57
|
-
// if(oldConfig?.[key] === undefined) {
|
|
58
|
-
// oldConfig[key] = remoteConfig[key];
|
|
59
|
-
// } else {
|
|
60
|
-
// const oldV = oldConfig[key];
|
|
61
|
-
// const newV = remoteConfig[key];
|
|
62
|
-
// if(getType(oldV) === 'object' && getType(newV) === 'object') {
|
|
63
|
-
// doSupplement(oldV, newV);
|
|
64
|
-
// }
|
|
65
|
-
// }
|
|
66
|
-
// }
|
|
67
|
-
// }
|
|
68
|
-
//
|
|
69
|
-
// /**
|
|
70
|
-
// *
|
|
71
|
-
// * @param oldConfig
|
|
72
|
-
// * @param remoteConfig
|
|
73
|
-
// * @returns config
|
|
74
|
-
// */
|
|
75
|
-
// function combineConfig(oldConfig={}, remoteConfig=null) {
|
|
76
|
-
// if(!remoteConfig) return null;
|
|
77
|
-
// if(getType(oldConfig) !== 'object' || getType(remoteConfig) !== 'object') return null;
|
|
78
|
-
// const config = {...oldConfig};
|
|
79
|
-
// // 先检查远程配置的,是否有需要将字符串格式化为正则的
|
|
80
|
-
// toRegFormat(remoteConfig, REG_FORMAT_PATHS);
|
|
81
|
-
// // 执行覆盖
|
|
82
|
-
// doCover(config, remoteConfig);
|
|
83
|
-
// // 执行补充
|
|
84
|
-
// doSupplement(config, remoteConfig);
|
|
85
|
-
// return config;
|
|
86
|
-
// }
|
|
87
|
-
//
|
|
88
|
-
//
|
|
89
|
-
// export default combineConfig;
|
|
90
|
-
"use strict";
|