拼板印
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

46 lines
1.1 KiB

import { TrackerEvents } from './monitorEnum'
export class Error {
constructor(eventName, error) {
this.eventName = eventName
this.error = error
}
getCurrentEnv() {
if (this.eventName == TrackerEvents.jsError) {
this.error = {
message: this.error.message,
stack: this.error.stack
}
}
return {
activePage: this.getActivePage()?.route || 'none',
accountInfo: this.getLocalStorage(),
eventName: this.eventName,
time: this.getTime(),
error: this.error,
extraInfo: this.getExtraInfo()
}
}
getActivePage() {
const curPages = getCurrentPages()
if (curPages.length) {
return curPages[curPages.length - 1]
}
return null
}
getLocalStorage() {
return {
token: wx.getStorageSync('qnToken'),
userInfo: wx.getStorageSync('userInfo')
}
}
getTime() {
let date = new Date()
return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`
}
getExtraInfo() {
return this.extraInfo
}
setExtraInfo(extraInfo) {
this.extraInfo = extraInfo
}
}