拼板印
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.
 
 
 
 

30 lines
946 B

import { IBehaviorItemType, TrackerEvents } from './monitorEnum'
export const appHooks = ['onUnhandledRejection', 'onError']
export function rewriteApp(monitor) {
const originApp = App
App = function (appOptions) {
appHooks.forEach((methodName) => {
const originMethod = appOptions[methodName]
appOptions[methodName] = function (param) {
monitor.pushBehaviorItem({
belong: 'app',
method: methodName,
activePage: null,
type: IBehaviorItemType.fn,
args: param
})
const error = param
if (methodName === 'onUnhandledRejection') {
monitor.handleErrorEvent(TrackerEvents.unHandleRejection, error)
}
if (methodName === 'onError') {
monitor.handleErrorEvent(TrackerEvents.jsError, error)
}
return originMethod && originMethod.call(this, param)
}
})
return originApp(appOptions)
}
}