@sdc-monitor/demo
Version:
<div align="center"> <a href="#" target="_blank"> <img src="https://i.loli.net/2021/07/28/EvPwd4NjVH3tBfO.jpg" alt="mito-logo" height="90"> </a> <p>A Lightweight SDK For Monitor Web</p>
49 lines (41 loc) • 1.31 kB
text/typescript
import { isWxMiniEnv } from '@sdc-monitor/utils'
import { initBatteryInfo, initMemoryWarning, initNetworkInfo, initWxHideReport, initWxPerformance, initWxNetwork } from './wx/index'
import Store from './core/store'
import { version } from '../package.json'
import { WxPerformanceInitOptions } from './types/index'
class WxPerformance {
appId: string
version: string
private readonly store: Store
constructor(options: WxPerformanceInitOptions) {
if (!isWxMiniEnv) {
return
}
const {
appId,
report,
immediately = true,
ignoreUrl,
maxBreadcrumbs = 10,
needNetworkStatus = true,
needBatteryInfo = true,
needMemoryWarning = true,
onAppHideReport = true
} = options
this.appId = appId
this.version = version
const store = new Store({ appId, report, immediately, ignoreUrl, maxBreadcrumbs })
this.store = store
initBatteryInfo(store, needBatteryInfo)
initNetworkInfo(store, needNetworkStatus)
initMemoryWarning(store, needMemoryWarning)
// 如果 immediately为false 会在appHide的时候发送数据
initWxHideReport(store, immediately, onAppHideReport)
initWxPerformance(store)
initWxNetwork(store)
}
customPaint() {
this.store.customPaint()
}
}
export { WxPerformance }