import { DEFAULT_NAVIGATION_NAME } from '../constant' ; import { EventProcessor , Integration , reducer , Span , SpanContext , TransactionContext , utils } from '../shared' ; import { Transaction } from './transaction' ; import { MPVitals } from './vitals' ; /**
 * Tracing integration for React Native.
 */ export class MPTracing implements Integration { inheritDoc public static id : string = "MPTracing" ; inheritDoc public name : string = MPTracing . id ; private _getCurrentHub ? : ( ) => reducer . Hub ; /**
     *  Registers routing and request instrumentation.
     */ public setupOnce ( addGlobalEventProcessor , getCurrentHub ) { this . _getCurrentHub = getCurrentHub ; this . _createRouteTransaction ( ) ; } /** Create route transaction. */ private _createRouteTransaction ( ) { if ( ! this . _getCurrentHub ) { utils . logger . warn ( `hub 必须存在` ) ; return undefined ; } const hub = this . _getCurrentHub ( ) ; const context = { name : DEFAULT_NAVIGATION_NAME } ; const transaction = Transaction . instance ( context , hub ) ; transaction . initSpanRecorder ( ) ; MPVitals . instance ( ) ; } } export function _startChild ( transaction , { startTimestamp , ... ctx } ) { if ( startTimestamp && transaction . startTimestamp > startTimestamp ) { transaction . startTimestamp = startTimestamp ; } return transaction . startChild ( { startTimestamp , ... ctx , } ) ; }