2026-07-29 08:29:29 +00:00
// Module ID: 1100
// Function ID: 1101
// Name: UIProfiler
// Dependencies: [5, 41, 42, 1101, 1072, 817]
// Module 1100 (UIProfiler)
2026-08-24 06:08:38 +00:00
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */ ;
import closure _2 from "_classCallCheck" /* 41 */ ;
import _createClass from "_createClass" /* 42 */ ;
2026-07-29 08:29:29 +00:00
let closure _0 = require ;
const UIProfiler = dependencyMap ;
Object . defineProperty ( exports , Symbol . toStringTag , { value : "Module" } ) ;
closure _0 = undefined ;
class UIProfiler {
constructor ( ) {
2026-08-24 06:08:38 +00:00
tmp = closure _2 ( this , UIProfiler ) ;
2026-07-29 08:29:29 +00:00
this . _client = undefined ;
this . _profiler = undefined ;
this . _chunkTimer = undefined ;
this . _profilerId = undefined ;
this . _isRunning = false ;
this . _sessionSampled = false ;
this . _lifecycleMode = undefined ;
set = new Set ( ) ;
this . _activeRootSpanIds = set ;
map = new Map ( ) ;
this . _rootSpanTimeouts = map ;
return ;
}
}
let obj = {
key : "initialize" ,
value : function initialize ( getOptions ) {
const obj = { } ;
const profileLifecycle = getOptions . getOptions ( ) . profileLifecycle ;
const shouldProfileSessionResult = callback ( UIProfiler [ 3 ] ) . shouldProfileSession ( getOptions . getOptions ( ) ) ;
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug = tmp ( tmp2 [ 5 ] ) . debug ;
const _HermesInternal = HermesInternal ;
debug . log ( "[Profiling] Initializing profiler (lifecycle='" + profileLifecycle + "')." ) ;
}
if ( ! shouldProfileSessionResult ) {
if ( tmp ( tmp2 [ 4 ] ) . DEBUG _BUILD ) {
const debug2 = tmp ( tmp2 [ 5 ] ) . debug ;
debug2 . log ( "[Profiling] Session not sampled. Skipping lifecycle profiler initialization." ) ;
}
}
const obj2 = callback ( UIProfiler [ 3 ] ) ;
obj . _profilerId = callback ( UIProfiler [ 5 ] ) . uuid4 ( ) ;
obj . _client = getOptions ;
obj . _sessionSampled = shouldProfileSessionResult ;
obj . _lifecycleMode = profileLifecycle ;
if ( "trace" === profileLifecycle ) {
const result = obj . _setupTraceLifecycleListeners ( getOptions ) ;
}
}
} ;
let items = [
obj ,
{
key : "start" ,
value : function start ( ) {
const self = this ;
if ( "trace" !== this . _lifecycleMode ) {
if ( self . _isRunning ) {
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug3 = tmp8 ( tmp9 [ 5 ] ) . debug ;
debug3 . warn ( "[Profiling] Profile session is already running, `uiProfiler.start()` is a no-op." ) ;
}
tmp8 = callback ;
tmp9 = UIProfiler ;
} else if ( self . _sessionSampled ) {
self . _beginProfiling ( ) ;
} else {
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug2 = tmp4 ( tmp5 [ 5 ] ) . debug ;
debug2 . warn ( "[Profiling] Session is not sampled, `uiProfiler.start()` is a no-op." ) ;
}
tmp4 = callback ;
tmp5 = UIProfiler ;
}
} else {
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug = tmp ( tmp2 [ 5 ] ) . debug ;
debug . warn ( "[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.start()` are ignored in trace mode." ) ;
}
tmp = callback ;
tmp2 = UIProfiler ;
}
}
} ,
{
key : "stop" ,
value : function stop ( ) {
const self = this ;
if ( "trace" !== this . _lifecycleMode ) {
if ( self . _isRunning ) {
self . _endProfiling ( ) ;
} else {
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug2 = tmp4 ( tmp5 [ 5 ] ) . debug ;
debug2 . warn ( "[Profiling] Profiler is not running, `uiProfiler.stop()` is a no-op." ) ;
}
tmp4 = callback ;
tmp5 = UIProfiler ;
}
} else {
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug = tmp ( tmp2 [ 5 ] ) . debug ;
debug . warn ( "[Profiling] `profileLifecycle` is set to \"trace\". Calls to `uiProfiler.stop()` are ignored in trace mode." ) ;
}
tmp = callback ;
tmp2 = UIProfiler ;
}
}
} ,
{
key : "notifyRootSpanActive" ,
value : function notifyRootSpanActive ( rootSpan ) {
const self = this ;
if ( "trace" === this . _lifecycleMode ) {
if ( self . _sessionSampled ) {
const spanId = rootSpan . spanContext ( ) . spanId ;
if ( spanId ) {
const _activeRootSpanIds = self . _activeRootSpanIds ;
if ( ! _activeRootSpanIds . has ( spanId ) ) {
const result = self . _registerTraceRootSpan ( spanId ) ;
const size = self . _activeRootSpanIds . size ;
if ( 1 === size ) {
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug = tmp3 ( tmp4 [ 5 ] ) . debug ;
debug . log ( "[Profiling] Detected already active root span during setup. Active root spans now:" , size ) ;
}
self . _beginProfiling ( ) ;
tmp3 = callback ;
tmp4 = UIProfiler ;
}
}
}
}
}
}
} ,
{
key : "_beginProfiling" ,
value : function _beginProfiling ( ) {
const self = this ;
if ( ! this . _isRunning ) {
self . _isRunning = true ;
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug = tmp ( tmp2 [ 5 ] ) . debug ;
debug . log ( "[Profiling] Started profiling with profiler ID:" , self . _profilerId ) ;
}
const globalScope = callback ( UIProfiler [ 5 ] ) . getGlobalScope ( ) ;
const obj = { profiler _id : null } ;
obj [ 0 ] = self . _profilerId ;
globalScope . setContext ( "profile" , obj ) ;
const result = self . _startProfilerInstance ( ) ;
if ( self . _profiler ) {
const result1 = self . _startPeriodicChunking ( ) ;
} else {
if ( tmp ( tmp2 [ 4 ] ) . DEBUG _BUILD ) {
const debug2 = tmp ( tmp2 [ 5 ] ) . debug ;
debug2 . log ( "[Profiling] Failed to start JS Profiler; stopping." ) ;
}
self . _resetProfilerInfo ( ) ;
}
const tmpResult = callback ( UIProfiler [ 5 ] ) ;
}
}
} ,
{
key : "_endProfiling" ,
value : function _endProfiling ( ) {
const self = this ;
if ( this . _isRunning ) {
self . _isRunning = false ;
if ( self . _chunkTimer ) {
const _clearTimeout = clearTimeout ;
clearTimeout ( self . _chunkTimer ) ;
self . _chunkTimer = undefined ;
}
const result = self . _clearAllRootSpanTimeouts ( ) ;
self . _collectCurrentChunk ( ) . catch ( ( arg0 ) => {
if ( callback ( table [ 4 ] ) . DEBUG _BUILD ) {
const debug = callback ( table [ 5 ] ) . debug ;
debug . error ( "[Profiling] Failed to collect current profile chunk on `stop()`:" , arg0 ) ;
}
} ) ;
if ( "manual" === self . _lifecycleMode ) {
const globalScope = callback ( UIProfiler [ 5 ] ) . getGlobalScope ( ) ;
globalScope . setContext ( "profile" , { } ) ;
const obj = callback ( UIProfiler [ 5 ] ) ;
}
const _collectCurrentChunkResult = self . _collectCurrentChunk ( ) ;
}
}
} ,
{
key : "_setupTraceLifecycleListeners" ,
value : function _setupTraceLifecycleListeners ( on ) {
const self = this ;
on . on ( "spanStart" , ( isRecording ) => {
if ( self . _sessionSampled ) {
if ( isRecording === tmpResult . getRootSpan ( isRecording ) ) {
if ( isRecording . isRecording ( ) ) {
const spanId = isRecording . spanContext ( ) . spanId ;
if ( spanId ) {
const _activeRootSpanIds = obj . _activeRootSpanIds ;
if ( ! _activeRootSpanIds . has ( spanId ) ) {
const result = obj . _registerTraceRootSpan ( spanId ) ;
const size = obj . _activeRootSpanIds . size ;
if ( 1 === size ) {
2026-08-24 06:08:38 +00:00
if ( self ( closure _1 _1 [ 4 ] ) . DEBUG _BUILD ) {
const debug3 = self ( closure _1 _1 [ 5 ] ) . debug ;
2026-07-29 08:29:29 +00:00
const _HermesInternal = HermesInternal ;
debug3 . log ( "[Profiling] Root span " + spanId + " started. Profiling active while there are active root spans (count=" + size + ")." ) ;
}
obj . _beginProfiling ( ) ;
}
}
}
2026-08-24 06:08:38 +00:00
} else if ( self ( closure _1 _1 [ 4 ] ) . DEBUG _BUILD ) {
const debug2 = self ( closure _1 _1 [ 5 ] ) . debug ;
2026-07-29 08:29:29 +00:00
debug2 . log ( "[Profiling] Discarding profile because root span was not sampled." ) ;
}
}
tmpResult = tmp ( tmp2 [ 5 ] ) ;
} else if ( tmp ( tmp2 [ 4 ] ) . DEBUG _BUILD ) {
2026-08-24 06:08:38 +00:00
const debug = self ( closure _1 _1 [ 5 ] ) . debug ;
2026-07-29 08:29:29 +00:00
debug . log ( "[Profiling] Span not profiled because of negative sampling decision for user session." ) ;
}
} ) ;
on . on ( "spanEnd" , ( spanContext ) => {
if ( self . _sessionSampled ) {
const spanId = spanContext . spanContext ( ) . spanId ;
if ( spanId ) {
const _activeRootSpanIds = obj . _activeRootSpanIds ;
if ( _activeRootSpanIds . has ( spanId ) ) {
const _activeRootSpanIds2 = obj . _activeRootSpanIds ;
_activeRootSpanIds2 . delete ( spanId ) ;
const size = obj . _activeRootSpanIds . size ;
2026-08-24 06:08:38 +00:00
if ( self ( closure _1 _1 [ 4 ] ) . DEBUG _BUILD ) {
2026-07-29 08:29:29 +00:00
let debug = tmp3 ( tmp4 [ 5 ] ) . debug ;
const _HermesInternal = HermesInternal ;
debug . log ( "[Profiling] Root span with ID " + spanId + " ended. Will continue profiling for as long as there are active root spans (currently: " + size + ")." ) ;
}
if ( 0 === size ) {
obj . _collectCurrentChunk ( ) . catch ( ( arg0 ) => {
if ( callback ( table [ 4 ] ) . DEBUG _BUILD ) {
const debug = callback ( table [ 5 ] ) . debug ;
debug . error ( "[Profiling] Failed to collect current profile chunk on last `spanEnd`:" , arg0 ) ;
}
} ) ;
obj . _endProfiling ( ) ;
const _collectCurrentChunkResult = obj . _collectCurrentChunk ( ) ;
}
tmp3 = self ;
2026-08-24 06:08:38 +00:00
tmp4 = closure _1 _1 ;
2026-07-29 08:29:29 +00:00
}
}
}
} ) ;
}
} ,
{
key : "_resetProfilerInfo" ,
value : function _resetProfilerInfo ( ) {
this . _isRunning = false ;
const globalScope = callback ( UIProfiler [ 5 ] ) . getGlobalScope ( ) ;
globalScope . setContext ( "profile" , { } ) ;
}
} ,
{
key : "_clearAllRootSpanTimeouts" ,
value : function _clearAllRootSpanTimeouts ( ) {
let _rootSpanTimeouts = this . _rootSpanTimeouts ;
const item = _rootSpanTimeouts . forEach ( ( arg0 ) => clearTimeout ( arg0 ) ) ;
_rootSpanTimeouts = this . _rootSpanTimeouts ;
_rootSpanTimeouts . clear ( ) ;
}
} ,
{
key : "_registerTraceRootSpan" ,
value : function _registerTraceRootSpan ( spanId ) {
const self = this ;
2026-08-24 06:08:38 +00:00
closure _0 = spanId ;
2026-07-29 08:29:29 +00:00
const _activeRootSpanIds = this . _activeRootSpanIds ;
_activeRootSpanIds . add ( spanId ) ;
const _rootSpanTimeouts = this . _rootSpanTimeouts ;
const result = _rootSpanTimeouts . set ( spanId , setTimeout ( ( ) => self . _onRootSpanTimeout ( closure _0 ) , 300000 ) ) ;
}
} ,
{
key : "_startProfilerInstance" ,
value : function _startProfilerInstance ( ) {
const _profiler = this . _profiler ;
let stopped ;
if ( _profiler != null ) {
stopped = _profiler . stopped ;
}
if ( false !== stopped ) {
const startJSSelfProfileResult = callback ( UIProfiler [ 3 ] ) . startJSSelfProfile ( ) ;
if ( startJSSelfProfileResult ) {
this . _profiler = startJSSelfProfileResult ;
} else if ( tmp2 ( tmp3 [ 4 ] ) . DEBUG _BUILD ) {
const debug = tmp2 ( tmp3 [ 5 ] ) . debug ;
debug . log ( "[Profiling] Failed to start JS Profiler." ) ;
}
const obj = callback ( UIProfiler [ 3 ] ) ;
}
}
} ,
{
key : "_startPeriodicChunking" ,
value : function _startPeriodicChunking ( ) {
const self = this ;
if ( this . _isRunning ) {
const _setTimeout = setTimeout ;
tmp . _chunkTimer = setTimeout ( ( ) => {
self . _collectCurrentChunk ( ) . catch ( ( arg0 ) => {
if ( callback ( table [ 4 ] ) . DEBUG _BUILD ) {
const debug = callback ( table [ 5 ] ) . debug ;
debug . error ( "[Profiling] Failed to collect current profile chunk during periodic chunking:" , arg0 ) ;
}
} ) ;
if ( self . _isRunning ) {
const result = obj . _startProfilerInstance ( ) ;
if ( obj . _profiler ) {
const result1 = obj . _startPeriodicChunking ( ) ;
} else {
obj . _resetProfilerInfo ( ) ;
}
}
} , 60000 ) ;
}
}
} ,
{
key : "_onRootSpanTimeout" ,
value : function _onRootSpanTimeout ( closure _0 ) {
const self = this ;
const _rootSpanTimeouts = this . _rootSpanTimeouts ;
if ( _rootSpanTimeouts . has ( closure _0 ) ) {
const _rootSpanTimeouts2 = self . _rootSpanTimeouts ;
_rootSpanTimeouts2 . delete ( closure _0 ) ;
const _activeRootSpanIds = self . _activeRootSpanIds ;
if ( _activeRootSpanIds . has ( closure _0 ) ) {
if ( callback ( UIProfiler [ 4 ] ) . DEBUG _BUILD ) {
const debug = tmp2 ( tmp3 [ 5 ] ) . debug ;
const _HermesInternal = HermesInternal ;
debug . log ( "[Profiling] Reached 5-minute timeout for root span " + closure _0 + ". You likely started a manual root span that never called `.end()`." ) ;
}
const _activeRootSpanIds2 = self . _activeRootSpanIds ;
_activeRootSpanIds2 . delete ( closure _0 ) ;
if ( 0 === self . _activeRootSpanIds . size ) {
self . _endProfiling ( ) ;
}
tmp2 = callback ;
tmp3 = UIProfiler ;
}
}
}
} ,
,
] ;
obj = { key : "_collectCurrentChunk" , value : null } ;
closure _0 = asyncGeneratorStep ( function ( ) {
const self = this ;
2026-08-24 06:08:38 +00:00
c6 = 0 ;
c7 = 0 ;
c4 = 0 ;
2026-07-29 08:29:29 +00:00
return ( function * ( ) {
if ( c7 === 2 ) {
c7 = 3 ;
HermesBuiltin . throwTypeError ( ) ;
} else if ( tmp7 === 3 ) {
if ( arg0 === 1 ) {
throw arg1 ;
} else if ( arg0 === 2 ) {
let obj = { value : null , done : true } ;
obj [ 0 ] = arg1 ;
return obj ;
} else {
2026-08-24 06:08:38 +00:00
return { value : "HermesInternal" , done : null } ;
2026-07-29 08:29:29 +00:00
}
} else {
try {
c7 = 2 ;
if ( 0 === c6 ) {
if ( arg0 === 1 ) {
c7 = 3 ;
throw arg1 ;
} else if ( arg0 === 2 ) {
c7 = 3 ;
obj = { value : null , done : true } ;
obj [ 0 ] = arg1 ;
return obj ;
} else {
2026-08-24 06:08:38 +00:00
closure _3 = _self ;
closure _2 = tmp3 ;
closure _1 = tmp5 ;
2026-07-29 08:29:29 +00:00
_self = undefined ;
closure _1 = undefined ;
closure _2 = undefined ;
const _profiler = _self . _profiler ;
_self . _profiler = undefined ;
if ( _profiler ) {
2026-08-24 06:08:38 +00:00
c4 = 1 ;
2026-07-29 08:29:29 +00:00
c6 = 2 ;
c7 = 1 ;
2026-08-24 06:08:38 +00:00
obj1 = { value : null , done : false } ;
2026-07-29 08:29:29 +00:00
obj1 [ 0 ] = _profiler . stop ( ) ;
return obj1 ;
}
}
} else {
if ( 1 === tmp8 ) {
c4 = 0 ;
2026-08-24 06:08:38 +00:00
closure _3 = closure _5 ;
if ( self ( closure _1 _1 [ 4 ] ) . DEBUG _BUILD ) {
const debug3 = self ( closure _1 _1 [ 5 ] ) . debug ;
debug3 . log ( "[Profiling] Error while stopping JS Profiler for chunk:" , closure _3 ) ;
2026-07-29 08:29:29 +00:00
}
} else if ( arg0 === 1 ) {
c7 = 3 ;
throw arg1 ;
} else if ( arg0 === 2 ) {
c4 = 0 ;
c7 = 3 ;
const obj2 = { value : null , done : true } ;
obj2 [ 0 ] = arg1 ;
return obj2 ;
} else {
_self = arg1 ;
2026-08-24 06:08:38 +00:00
closure _1 = self ( closure _1 _1 [ 3 ] ) . createProfileChunkPayload ( _self , closure _3 . _client , closure _3 . _profilerId ) ;
const obj6 = self ( closure _1 _1 [ 3 ] ) ;
closure _2 = self ( closure _1 _1 [ 3 ] ) . validateProfileChunk ( closure _1 ) ;
2026-07-29 08:29:29 +00:00
if ( ! ( "reason" in closure _2 ) ) {
2026-08-24 06:08:38 +00:00
closure _3 . _sendProfileChunk ( closure _1 _1 ) ;
if ( self ( closure _1 _1 [ 4 ] ) . DEBUG _BUILD ) {
const debug = self ( closure _1 _1 [ 5 ] ) . debug ;
2026-07-29 08:29:29 +00:00
debug . log ( "[Profiling] Collected browser profile chunk." ) ;
}
c4 = 0 ;
}
2026-08-24 06:08:38 +00:00
const obj7 = self ( closure _1 _1 [ 3 ] ) ;
2026-07-29 08:29:29 +00:00
}
2026-08-24 06:08:38 +00:00
if ( self ( closure _1 _1 [ 4 ] ) . DEBUG _BUILD ) {
const debug2 = self ( closure _1 _1 [ 5 ] ) . debug ;
debug2 . log ( "[Profiling] Discarding invalid profile chunk (this is probably a bug in the SDK):" , closure _1 _2 . reason ) ;
2026-07-29 08:29:29 +00:00
}
c4 = 0 ;
c7 = 3 ;
obj = { value : null , done : true } ;
obj [ 0 ] = undefined ;
return obj ;
}
c7 = 3 ;
} catch ( tmp42 ) {
closure _5 = tmp42 ;
if ( tmp4 === c4 ) {
c7 = tmp2 ;
throw tmp42 ;
} else {
c6 = tmp ;
}
}
}
} ) ( ) ;
} ) ;
obj [ 1 ] = function _collectCurrentChunk ( ) {
const self = this ;
const apply = closure _0 . apply ;
if ( typeof apply === "unknown" ) {
let applyArgumentsResult = HermesBuiltin . applyArguments ( self ) ;
} else {
applyArgumentsResult = apply ( self , arguments ) ;
}
return applyArgumentsResult ;
} ;
items [ 13 ] = obj ;
items [ 14 ] = {
key : "_sendProfileChunk" ,
2026-08-24 06:08:38 +00:00
value : function _sendProfileChunk ( closure _1 _1 ) {
2026-07-29 08:29:29 +00:00
const _client = this . _client ;
let obj = callback ( UIProfiler [ 5 ] ) ;
const getSdkMetadata = _client . getSdkMetadata ;
let sdkMetadata ;
if ( getSdkMetadata != null ) {
sdkMetadata = getSdkMetadata ( ) ;
}
const sdkMetadataForEnvelopeHeader = obj . getSdkMetadataForEnvelopeHeader ( sdkMetadata ) ;
const dsn = _client . getDsn ( ) ;
let tmpResult = tmp ( tmp2 [ 5 ] ) ;
obj = { event _id : null , sent _at : null } ;
tmpResult = tmp ( tmp2 [ 5 ] ) ;
obj [ 0 ] = tmpResult . uuid4 ( ) ;
obj [ 1 ] = new Date ( ) . toISOString ( ) ;
let tmp6 = sdkMetadataForEnvelopeHeader ;
if ( sdkMetadataForEnvelopeHeader ) {
obj = { sdk : null } ;
obj [ 0 ] = sdkMetadataForEnvelopeHeader ;
tmp6 = obj ;
}
const merged = Object . assign ( tmp6 ) ;
let tmp8 = _client . getOptions ( ) . tunnel && dsn ;
if ( tmp8 ) {
2026-08-24 06:08:38 +00:00
obj1 = { dsn : null } ;
2026-07-29 08:29:29 +00:00
obj1 [ 0 ] = tmp ( tmp2 [ 5 ] ) . dsnToString ( dsn ) ;
tmp8 = obj1 ;
const tmpResult1 = tmp ( tmp2 [ 5 ] ) ;
}
const merged1 = Object . assign ( tmp8 ) ;
2026-08-24 06:08:38 +00:00
const items = [ { type : "profile_chunk" } , closure _1 _1 ] ;
2026-07-29 08:29:29 +00:00
const items1 = [ items ] ;
const date = new Date ( ) ;
_client . sendEnvelope ( tmpResult . createEnvelope ( obj , items1 ) ) . then ( null , ( arg0 ) => {
if ( callback ( table [ 4 ] ) . DEBUG _BUILD ) {
const debug = callback ( table [ 5 ] ) . debug ;
debug . error ( "Error while sending profile chunk envelope:" , arg0 ) ;
}
} ) ;
}
} ;
export const UIProfiler = _createClass ( UIProfiler , items ) ;