@arms/rum-core
Advanced tools
Comparing version
@@ -128,3 +128,2 @@ "use strict"; | ||
_proto.mergeEvent = function mergeEvent(ctx, events, view) { | ||
var _config$net; | ||
var config = ctx.getConfig(); | ||
@@ -161,5 +160,3 @@ var session = ctx.session; | ||
}, | ||
net: { | ||
model: (_config$net = config.net) === null || _config$net === void 0 ? void 0 : _config$net.model | ||
}, | ||
net: {}, | ||
view: view, | ||
@@ -166,0 +163,0 @@ events: events |
@@ -7,3 +7,4 @@ import { IClient, IConfiguration } from "../types/client"; | ||
constructor(config?: IConfiguration); | ||
updateFromRemoteConfig(config: any): void; | ||
getCombinedConfig(config?: IConfiguration): any; | ||
updateFromRemoteConfig(config: any, reSetup?: boolean): void; | ||
/** | ||
@@ -10,0 +11,0 @@ * 初始化 |
@@ -18,19 +18,29 @@ "use strict"; | ||
if (config && this.init) { | ||
var combinedConf; | ||
if ((0, _combineConfig.isRemoteConfigEnable)(config) && (0, _is.isFunction)(this.getLocalConfig)) { | ||
var localConfig = this.getLocalConfig(0, config.pid); | ||
combinedConf = (0, _combineConfig["default"])(config, localConfig); | ||
} | ||
this.init(combinedConf || config); | ||
this.init(config); | ||
} | ||
// if (config && this.init) { | ||
// this.init(this.getCombinedConfig(config)); | ||
// 拉取远程配置进行更新 | ||
this.updateFromRemoteConfig(config); | ||
} | ||
// // 拉取远程配置进行更新 | ||
// this.updateFromRemoteConfig(config); | ||
// } | ||
} | ||
var _proto = Shell.prototype; | ||
_proto.updateFromRemoteConfig = function updateFromRemoteConfig(config) { | ||
_proto.getCombinedConfig = function getCombinedConfig(config) { | ||
var combinedConf; | ||
if ((0, _combineConfig.isRemoteConfigEnable)(config) && (0, _is.isFunction)(this.getLocalConfig)) { | ||
var localConfig = this.getLocalConfig(0, config.pid); | ||
combinedConf = (0, _combineConfig["default"])(config, localConfig); | ||
} | ||
return combinedConf || config; | ||
}; | ||
_proto.updateFromRemoteConfig = function updateFromRemoteConfig(config, reSetup) { | ||
if (reSetup === void 0) { | ||
reSetup = true; | ||
} | ||
// 请求动态配置 | ||
if (config.pid && (0, _combineConfig.isRemoteConfigEnable)(config) && (0, _is.isFunction)(this.getRemoteConfig)) { | ||
var that = this; | ||
this.getRemoteConfig((0, _combineConfig.getRemoteConfigUrl)(config), config).then(function (remoteConfig) { | ||
var proms = this.getRemoteConfig((0, _combineConfig.getRemoteConfigUrl)(config), config); | ||
proms === null || proms === void 0 ? void 0 : proms.then(function (remoteConfig) { | ||
if (!remoteConfig || remoteConfig.errorStatus !== undefined) return; | ||
@@ -41,10 +51,11 @@ var combinedConf = (0, _combineConfig["default"])(config, remoteConfig); | ||
if (!combinedConf) return; | ||
if ((0, _is.isObject)(console) && (0, _is.isFunction)(console.log)) { | ||
console.log("合并后动态配置后的新配置:\n", combinedConf); | ||
// 存储到本地 | ||
if ((0, _is.isFunction)(that.storeRemoteConfig)) { | ||
that.storeRemoteConfig(remoteConfig, config.pid); | ||
} | ||
if (reSetup === false || config.remoteConfig.reSetup === false) return; | ||
var context = that.client.getContext(); | ||
// 更新配置 | ||
context.setConfig(combinedConf); | ||
// 逐个更新collector | ||
@@ -58,7 +69,2 @@ var collectors = that.client.getCollectors(); | ||
}); | ||
// 存储到本地 | ||
if ((0, _is.isFunction)(that.storeRemoteConfig)) { | ||
that.storeRemoteConfig(remoteConfig, config.pid); | ||
} | ||
}); | ||
@@ -65,0 +71,0 @@ } |
{ | ||
"name": "@arms/rum-core", | ||
"version": "0.0.34", | ||
"version": "0.0.35", | ||
"description": "arms rum javascript sdk core", | ||
@@ -5,0 +5,0 @@ "author": "guangli.fj <guangli.fj@alibaba-inc.com>", |
63288
0.26%1935
0.31%