import { addGlobalEventProcessor , getCurrentHub } from "@sentry/core" ; import { Event , Integration } from "@sentry/types" ; import { appName as currentAppName , sdk } from "../crossPlatform" ; /** UserAgent */ export class System implements Integration { inheritDoc public name : string = System . id ; inheritDoc public static id : string = "System" ; inheritDoc public setupOnce ( ) { addGlobalEventProcessor ( ( event ) => { if ( getCurrentHub ( ) . getIntegration ( System ) ) { try { const systemInfo = sdk . getSystemInfoSync ( ) ; const { SDKVersion = "0.0.0" , batteryLevel , currentBattery , battery , brand , language , model , pixelRatio , platform , screenHeight , screenWidth , statusBarHeight , system , version , windowHeight , windowWidth , wifiSignal , app , appName , storage , fontSizeSetting } = systemInfo ; const [ systemName , systemVersion ] = system . split ( " " ) ; return { ... event , contexts : { ... event . contexts , device : { brand , battery_level : batteryLevel || currentBattery || battery , model , screen_dpi : pixelRatio } , os : { name : systemName || system , version : systemVersion || system } , extra : { SDKVersion , language , platform , screenHeight , screenWidth , statusBarHeight , version , windowHeight , windowWidth , wifiSignal , fontSizeSetting , storage , app : app || appName || currentAppName } } } ; } catch ( e ) { console . warn ( `sentry-miniapp get system info fail: ${ e }` ) ; } } return event ; } ) ; } }