shatter_monitor
Version:
A SDK for monitoring browser errors
38 lines (32 loc) • 1.23 kB
text/typescript
import { ErrorForShatter } from './shatter_error/index'
import { PerformanceForShatter } from './shatter_performance/index'
import { BehaviorForShatter } from './shatter_behavior/index'
import { InitOptions } from './types/index'
import { isString } from 'utils'
import { ShatterErrorVue } from './shatter_error/vue/index'
class ShatterInit {
static shatterSupport = {
ErrorForShatter,
PerformanceForShatter,
BehaviorForShatter
}
constructor(options: InitOptions){
const { usage } = options
const defaultShatter = 'ErrorForShatter'
const staticShatterSupport = ShatterInit.shatterSupport
const shatterArray = []
if (usage === 'all') {
shatterArray.push(...Object.keys(staticShatterSupport))
} else if (Array.isArray(usage)){
shatterArray.push(...usage)
} else if (isString(usage)){
shatterArray.push(usage)
} else {
shatterArray.push(defaultShatter)
}
shatterArray.forEach((item) => {
new staticShatterSupport[item](options)
})
}
}
export { ErrorForShatter, PerformanceForShatter, BehaviorForShatter, ShatterInit, ShatterErrorVue }