Commit 3e676b87 by liimin

feat(logger, homeframe): 延迟初始化远程日志以符合隐私政策要求

调整日志工具类初始化逻辑,分离本地与远程日志初始化;新增initRemote方法延迟初始化远程日志,写入日志时增加远程实例存在检查;在首页框架用户同意隐私政策后调用初始化方法。
1 parent 7dd16daa
......@@ -127,6 +127,9 @@ export default {
vueContext: this
})
// 初始化远程日志(Sentry),此时用户已同意隐私政策
uni.$logger.initRemote()
this._ws = new Ws()
this._ws.connect()
......
......@@ -13,9 +13,15 @@ class Logger {
this.init()
}
init() {
const user = this.getUserInfo()
this.remote = new RemoteLog(user)
// 本地日志立即初始化,确保记录每一个用户操作
this.local = new LocalLog()
// remote(Sentry)延迟初始化,等用户同意隐私政策后由 initRemote() 调用
}
// 延迟初始化远程日志(Sentry),在用户同意隐私政策后调用(如 HomeFrame mounted)
initRemote() {
if (this.remote) return
const user = this.getUserInfo()
this.remote = new RemoteLog(user)
}
debug(info) {
this.write(LogLevel.DEBUG, info)
......@@ -30,7 +36,9 @@ class Logger {
this.write(LogLevel.ERROR, info)
}
write(level, info) {
this.remote[level](info)
if (this.remote) {
this.remote[level](info)
}
this.local[level](info)
}
getUserInfo() {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!