2026-07-20 16:05:17 +00:00
// Module ID: 1077
2026-07-25 08:10:48 +00:00
// Function ID: 12396
2026-07-20 16:05:17 +00:00
// Name: enrichWithThreadInformation
2026-07-23 10:11:24 +00:00
// Dependencies: [77, 794, 1004, 1048]
2026-07-20 16:05:17 +00:00
// Exports: addProfileToGlobalCache, addProfilesToEnvelope, attachProfiledThreadToEvent, createProfileChunkPayload, createProfilingEvent, findProfiledTransactionsFromEnvelope, getActiveProfilesCount, hasLegacyProfiling, isAutomatedPageLoadSpan, shouldProfileSession, shouldProfileSpanLegacy, startJSSelfProfile, takeProfileFromGlobalCache, validateProfileChunk
// Module 1077 (enrichWithThreadInformation)
2026-07-23 10:11:24 +00:00
import _defineProperty from "_defineProperty" ;
import StringResult from "_defineProperty" ;
2026-07-20 16:05:17 +00:00
function enrichWithThreadInformation ( samples ) {
let tmp = samples ;
if ( ! ( "thread_metadata" in samples ) ) {
tmp = convertJSSelfProfileToSampledFormat ( samples ) ;
}
return tmp ;
}
function createProfilePayload ( event _id , arg1 , resources , type ) {
if ( "transaction" !== type . type ) {
const _TypeError2 = TypeError ;
const typeError = new TypeError ( "Profiling events may only be attached to transactions, this should never occur." ) ;
throw typeError ;
} else if ( null == resources ) {
const _TypeError = TypeError ;
const _HermesInternal2 = HermesInternal ;
const typeError1 = new TypeError ( "Cannot construct profiling event envelope without a valid profile. Got " + resources + " instead." ) ;
throw typeError1 ;
} else {
const contexts = type . contexts ;
let trace _id ;
if ( null != contexts ) {
const trace = contexts . trace ;
if ( null != trace ) {
trace _id = trace . trace _id ;
}
}
let DEBUG _BUILD = "string" === tmp2 ;
if ( DEBUG _BUILD ) {
DEBUG _BUILD = 32 !== trace _id . length ;
}
if ( DEBUG _BUILD ) {
2026-07-23 10:11:24 +00:00
DEBUG _BUILD = require ( 1048 ) . DEBUG _BUILD ;
2026-07-20 16:05:17 +00:00
}
if ( DEBUG _BUILD ) {
2026-07-23 10:11:24 +00:00
const debug = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
debug . log ( "[Profiling] Invalid traceId: " + trace _id + " on profiled event" ) ;
}
let str5 = "" ;
if ( "string" === typeof trace _id ) {
str5 = trace _id ;
}
if ( arg1 ) {
if ( "number" === typeof type . timestamp ) {
let result = 1000 * type . timestamp ;
} else {
2026-07-23 10:11:24 +00:00
let obj1 = require ( 794 ) /* registerSpanErrorInstrumentation */ ;
2026-07-20 16:05:17 +00:00
result = 1000 * obj1 . timestampInSeconds ( ) ;
}
let obj = { event _id } ;
const _Date = Date ;
const date = new Date ( arg1 ) ;
obj . timestamp = date . toISOString ( ) ;
obj . platform = "javascript" ;
obj . version = "1" ;
obj . release = type . release || "" ;
let DEFAULT _ENVIRONMENT = type . environment ;
if ( ! DEFAULT _ENVIRONMENT ) {
2026-07-23 10:11:24 +00:00
DEFAULT _ENVIRONMENT = require ( 794 ) /* registerSpanErrorInstrumentation */ . DEFAULT _ENVIRONMENT ;
2026-07-20 16:05:17 +00:00
}
obj . environment = DEFAULT _ENVIRONMENT ;
2026-07-23 10:11:24 +00:00
obj = { name : "javascript" , version : require ( 1004 ) /* ignoreNextOnError */ . WINDOW . navigator . userAgent } ;
2026-07-20 16:05:17 +00:00
obj . runtime = obj ;
2026-07-23 10:11:24 +00:00
obj1 = { name : c6 , version : c7 , build _number : str3 } ;
2026-07-20 16:05:17 +00:00
obj . os = obj1 ;
2026-07-23 10:11:24 +00:00
const obj2 = { locale : str4 , model : c10 , manufacturer : str3 , architecture : c8 , is _emulator : false } ;
2026-07-20 16:05:17 +00:00
obj . device = obj2 ;
const obj3 = { images : applyDebugMetadata ( resources . resources ) } ;
obj . debug _meta = obj3 ;
obj . profile = tmp10 ;
const obj4 = { name : type . transaction || "" } ;
event _id = type . event _id ;
if ( ! event _id ) {
2026-07-23 10:11:24 +00:00
event _id = require ( 794 ) /* registerSpanErrorInstrumentation */ . uuid4 ( ) ;
const obj10 = require ( 794 ) /* registerSpanErrorInstrumentation */ ;
2026-07-20 16:05:17 +00:00
}
obj4 . id = event _id ;
obj4 . trace _id = str5 ;
2026-07-23 10:11:24 +00:00
obj4 . active _thread _id = closure _4 ;
2026-07-20 16:05:17 +00:00
obj4 . relative _start _ns = "0" ;
const result1 = 1000000 * ( result - arg1 ) ;
obj4 . relative _end _ns = result1 . toFixed ( 0 ) ;
const items = [ obj4 ] ;
obj . transactions = items ;
return obj ;
} else if ( "number" === typeof type . start _timestamp ) {
let result2 = 1000 * type . start _timestamp ;
} else {
2026-07-23 10:11:24 +00:00
obj = require ( 794 ) /* registerSpanErrorInstrumentation */ ;
2026-07-20 16:05:17 +00:00
result2 = 1000 * obj . timestampInSeconds ( ) ;
}
}
}
function convertJSSelfProfileToSampledFormat ( samples ) {
2026-07-23 10:11:24 +00:00
const _require = samples ;
const _defineProperty = 0 ;
obj = { samples : [ ] , stacks : [ ] , frames : [ ] , thread _metadata : _defineProperty ( { } , timestamp , obj ) } ;
2026-07-20 16:05:17 +00:00
obj = { name : closure _5 } ;
const first = samples . samples [ 0 ] ;
if ( first ) {
2026-07-23 10:11:24 +00:00
timestamp = first . timestamp ;
let result = _require ( 794 ) . browserPerformanceTimeOrigin ( ) ;
2026-07-20 16:05:17 +00:00
const _performance = performance ;
if ( "number" === typeof performance . timeOrigin ) {
const _performance2 = performance ;
let num2 = performance . timeOrigin ;
} else {
num2 = result ;
if ( ! result ) {
num2 = 0 ;
}
}
if ( ! result ) {
result = num2 ;
}
closure _5 = num2 - result ;
samples = samples . samples ;
const item = samples . forEach ( ( stackId ) => {
let tmp9 ;
if ( undefined === stackId . stackId ) {
if ( undefined === closure _1 ) {
closure _1 = closure _2 ;
obj . stacks [ closure _1 ] = [ ] ;
closure _2 = closure _2 + 1 ;
}
2026-07-23 10:11:24 +00:00
obj = { } ;
2026-07-20 16:05:17 +00:00
const result = ( stackId . timestamp + closure _5 - timestamp ) * obj ;
obj . elapsed _since _start _ns = result . toFixed ( 0 ) ;
obj . stack _id = closure _1 ;
obj . thread _id = timestamp ;
obj . samples [ arg1 ] = obj ;
} else {
2026-07-23 10:11:24 +00:00
let tmp11 = samples . stacks [ stackId . stackId ] ;
2026-07-20 16:05:17 +00:00
const items = [ ] ;
if ( tmp11 ) {
do {
let arr = items . push ( tmp11 . frameId ) ;
2026-07-23 10:11:24 +00:00
let tmp2 = samples ;
let tmp3 = samples . frames [ tmp11 . frameId ] ;
2026-07-20 16:05:17 +00:00
let tmp4 = tmp3 ;
if ( tmp3 ) {
2026-07-23 10:11:24 +00:00
let tmp5 = obj ;
tmp4 = undefined === obj . frames [ tmp11 . frameId ] ;
2026-07-20 16:05:17 +00:00
}
if ( tmp4 ) {
2026-07-23 10:11:24 +00:00
let tmp6 = obj ;
2026-07-20 16:05:17 +00:00
obj = { function : tmp3 . name } ;
let tmp7 ;
if ( "number" === typeof tmp3 . resourceId ) {
2026-07-23 10:11:24 +00:00
let tmp8 = samples ;
tmp7 = samples . resources [ tmp3 . resourceId ] ;
2026-07-20 16:05:17 +00:00
}
obj . abs _path = tmp7 ;
( { line : obj . lineno , column : obj . colno } = tmp3 ) ;
2026-07-23 10:11:24 +00:00
obj . frames [ tmp11 . frameId ] = obj ;
2026-07-20 16:05:17 +00:00
}
tmp9 = undefined ;
if ( undefined !== tmp11 . parentId ) {
2026-07-23 10:11:24 +00:00
let tmp10 = samples ;
tmp9 = samples . stacks [ tmp11 . parentId ] ;
2026-07-20 16:05:17 +00:00
}
tmp11 = tmp9 ;
} while ( tmp9 ) ;
}
obj = { } ;
const result1 = ( stackId . timestamp + closure _5 - timestamp ) * obj ;
obj . elapsed _since _start _ns = result1 . toFixed ( 0 ) ;
obj . stack _id = closure _2 ;
obj . thread _id = timestamp ;
obj . stacks [ closure _2 ] = items ;
obj . samples [ arg1 ] = obj ;
closure _2 = closure _2 + 1 ;
}
} ) ;
return obj ;
} else {
return obj ;
}
}
function applyDebugMetadata ( resources ) {
2026-07-23 10:11:24 +00:00
const client = require ( 794 ) /* registerSpanErrorInstrumentation */ . getClient ( ) ;
2026-07-20 16:05:17 +00:00
let options ;
if ( null != client ) {
options = client . getOptions ( ) ;
}
let stackParser ;
if ( null != options ) {
stackParser = options . stackParser ;
}
if ( stackParser ) {
2026-07-23 10:11:24 +00:00
let debugImagesForResources = require ( 794 ) /* registerSpanErrorInstrumentation */ . getDebugImagesForResources ( stackParser , resources ) ;
const obj3 = require ( 794 ) /* registerSpanErrorInstrumentation */ ;
2026-07-20 16:05:17 +00:00
} else {
debugImagesForResources = [ ] ;
}
return debugImagesForResources ;
}
function isValidSampleRate ( concat ) {
if ( "number" === typeof concat ) {
if ( "number" === tmp ) {
const _isNaN = isNaN ;
return flag2 ;
}
2026-07-23 10:11:24 +00:00
flag2 = true === concat ;
2026-07-20 16:05:17 +00:00
if ( ! flag2 ) {
flag2 = false === concat ;
}
if ( ! flag2 ) {
let tmp3 = concat < 0 ;
if ( ! tmp3 ) {
tmp3 = concat > 1 ;
}
let flag4 = ! tmp3 ;
if ( tmp3 ) {
flag4 = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
const _HermesInternal = HermesInternal ;
debug . warn ( "[Profiling] Invalid sample rate. Sample rate must be between 0 and 1. Got " + concat + "." ) ;
flag4 = false ;
}
}
flag2 = flag4 ;
}
}
flag2 = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug2 = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
const _JSON = JSON ;
const json = JSON . stringify ( concat ) ;
const _JSON2 = JSON ;
const _HermesInternal2 = HermesInternal ;
debug2 . warn ( "[Profiling] Invalid sample rate. Sample rate must be a boolean or a number between 0 and 1. Got " + json + " of type " + JSON . stringify ( tmp ) + "." ) ;
flag2 = false ;
}
}
Object . defineProperty ( exports , Symbol . toStringTag , { value : "Module" } ) ;
2026-07-23 10:11:24 +00:00
let c3 = 1000000 ;
let tmp2 = "window" in require ( "registerSpanErrorInstrumentation" ) . GLOBAL _OBJ ;
2026-07-20 16:05:17 +00:00
if ( tmp2 ) {
2026-07-23 10:11:24 +00:00
tmp2 = require ( "registerSpanErrorInstrumentation" ) . GLOBAL _OBJ . window === require ( "registerSpanErrorInstrumentation" ) . GLOBAL _OBJ ;
2026-07-20 16:05:17 +00:00
}
if ( tmp2 ) {
tmp2 = "undefined" === typeof globalThis . importScripts ;
}
let str2 = "worker" ;
if ( tmp2 ) {
str2 = "main" ;
}
2026-07-23 10:11:24 +00:00
const _navigator = require ( "ignoreNextOnError" ) . WINDOW . navigator ;
let c6 = "" ;
let c7 = "" ;
let c8 = "" ;
2026-07-20 16:05:17 +00:00
let str3 ;
if ( null != _navigator ) {
str3 = _navigator . userAgent ;
}
if ( ! str3 ) {
str3 = "" ;
}
2026-07-23 10:11:24 +00:00
let c10 = "" ;
2026-07-20 16:05:17 +00:00
let str4 ;
if ( null != _navigator ) {
str4 = _navigator . language ;
}
if ( ! str4 ) {
let first ;
if ( null != _navigator ) {
const languages = _navigator . languages ;
if ( null != languages ) {
first = languages [ 0 ] ;
}
}
str4 = first ;
}
if ( ! str4 ) {
str4 = "" ;
}
let userAgentData ;
if ( null != _navigator ) {
userAgentData = _navigator . userAgentData ;
}
let tmp6 = "object" === typeof userAgentData && null !== userAgentData ;
if ( tmp6 ) {
tmp6 = "getHighEntropyValues" in userAgentData ;
}
if ( tmp6 ) {
2026-07-23 10:11:24 +00:00
const highEntropyValues = userAgentData . getHighEntropyValues ( [ "architecture" , "model" , "platform" , "platformVersion" , "fullVersionList" ] ) ;
2026-07-20 16:05:17 +00:00
highEntropyValues . then ( ( platform ) => {
let closure _6 = platform . platform || "" ;
let closure _8 = platform . architecture || "" ;
let closure _10 = platform . model || "" ;
let closure _7 = platform . platformVersion || "" ;
const fullVersionList = platform . fullVersionList ;
if ( null != fullVersionList ) {
if ( fullVersionList . length ) {
const _HermesInternal = HermesInternal ;
let closure _9 = "" + tmp . brand + " " + tmp . version ;
}
}
} ) . catch ( ( arg0 ) => {
} ) ;
const nextPromise = highEntropyValues . then ( ( platform ) => {
let closure _6 = platform . platform || "" ;
let closure _8 = platform . architecture || "" ;
let closure _10 = platform . model || "" ;
let closure _7 = platform . platformVersion || "" ;
const fullVersionList = platform . fullVersionList ;
if ( null != fullVersionList ) {
if ( fullVersionList . length ) {
const _HermesInternal = HermesInternal ;
let closure _9 = "" + tmp . brand + " " + tmp . version ;
}
}
} ) ;
}
2026-07-23 10:11:24 +00:00
let c12 = false ;
2026-07-20 16:05:17 +00:00
const map = new Map ( ) ;
export const MAX _PROFILE _DURATION _MS = 30000 ;
export const PROFILER _THREAD _ID _STRING = StringResult ;
export const PROFILER _THREAD _NAME = str2 ;
2026-07-23 10:11:24 +00:00
export const addProfileToGlobalCache = function addProfileToGlobalCache ( outer3 _2 , arg1 ) {
const result = map . set ( outer3 _2 , arg1 ) ;
2026-07-20 16:05:17 +00:00
if ( map . size > 30 ) {
const value = map . keys ( ) . next ( ) . value ;
if ( undefined !== value ) {
map . delete ( value ) ;
}
const iter = map . keys ( ) ;
}
} ;
export const addProfilesToEnvelope = function addProfilesToEnvelope ( arg0 , arg1 ) {
if ( arg1 . length ) {
const tmp3 = arg1 [ Symbol . iterator ] ( ) ;
while ( tmp3 !== undefined ) {
let tmp6 = arg0 ;
let arr = arg0 [ 1 ] ;
let obj = { type : "profile" } ;
let items = [ obj , tmp4 ] ;
arr = arr . push ( items ) ;
2026-07-23 10:11:24 +00:00
continue ;
2026-07-20 16:05:17 +00:00
}
return arg0 ;
} else {
return arg0 ;
}
} ;
export { applyDebugMetadata } ;
export const attachProfiledThreadToEvent = function attachProfiledThreadToEvent ( contexts ) {
if ( null != contexts ) {
const contexts3 = contexts . contexts ;
if ( null != contexts3 ) {
if ( contexts3 . profile ) {
if ( contexts . contexts ) {
contexts = contexts . contexts ;
let trace ;
if ( null != contexts ) {
trace = contexts . trace ;
}
if ( null == trace ) {
trace = { } ;
}
const obj = { } ;
const contexts2 = contexts . contexts ;
let data ;
if ( null != contexts2 ) {
trace = contexts2 . trace ;
if ( null != trace ) {
data = trace . data ;
}
}
if ( null == data ) {
data = { } ;
}
2026-07-23 10:11:24 +00:00
obj . data = Object . assign ( { } , data , _defineProperty ( _defineProperty ( { } , "thread.id" , closure _4 ) , "thread.name" , "thread.name" ) ) ;
2026-07-20 16:05:17 +00:00
contexts . contexts . trace = Object . assign ( { } , trace , obj ) ;
const spans = contexts . spans ;
if ( null != spans ) {
const item = spans . forEach ( ( data ) => {
data = data . data ;
if ( ! data ) {
data = { } ;
}
2026-07-23 10:11:24 +00:00
data . data = Object . assign ( { } , data , outer1 _2 ( outer1 _2 ( { } , "thread.id" , outer1 _4 ) , "thread.name" , outer1 _5 ) ) ;
2026-07-20 16:05:17 +00:00
} ) ;
}
}
}
}
}
return contexts ;
} ;
export { convertJSSelfProfileToSampledFormat } ;
export const createProfileChunkPayload = function createProfileChunkPayload ( frames , _client , _profilerId ) {
let uuid4Result = _profilerId ;
if ( null == frames ) {
const _TypeError = TypeError ;
const _HermesInternal = HermesInternal ;
const typeError = new TypeError ( "Cannot construct profiling event envelope without a valid profile. Got " + frames + " instead." ) ;
throw typeError ;
} else {
const items = [ ] ;
for ( let num = 0 ; num < frames . frames . length ; num = num + 1 ) {
let tmp2 = frames . frames [ num ] ;
if ( tmp2 ) {
let obj = { function : tmp2 . name } ;
let tmp3 ;
if ( "number" === typeof tmp2 . resourceId ) {
tmp3 = frames . resources [ tmp2 . resourceId ] ;
}
obj . abs _path = tmp3 ;
( { line : obj . lineno , column : obj . colno } = tmp2 ) ;
items [ num ] = obj ;
}
}
const items1 = [ ] ;
for ( let num2 = 0 ; num2 < frames . stacks . length ; num2 = num2 + 1 ) {
let tmp4 = frames . stacks [ num2 ] ;
if ( tmp4 ) {
let items2 = [ ] ;
let tmp5 = tmp4 ;
let tmp6 = tmp4 ;
if ( tmp4 ) {
do {
let arr = items2 . push ( tmp5 . frameId ) ;
2026-07-23 10:11:24 +00:00
tmp8 = undefined ;
2026-07-20 16:05:17 +00:00
if ( undefined !== tmp5 . parentId ) {
tmp8 = frames . stacks [ tmp5 . parentId ] ;
}
tmp5 = tmp8 ;
tmp6 = tmp8 ;
} while ( tmp8 ) ;
}
items1 [ num2 ] = items2 ;
let tmp9 = tmp6 ;
let tmp10 = items2 ;
}
}
2026-07-23 10:11:24 +00:00
let obj1 = require ( 794 ) /* registerSpanErrorInstrumentation */ ;
2026-07-20 16:05:17 +00:00
let result = obj1 . browserPerformanceTimeOrigin ( ) ;
const _performance = performance ;
if ( "number" === typeof performance . timeOrigin ) {
const _performance2 = performance ;
let num4 = performance . timeOrigin ;
} else {
num4 = result ;
if ( ! result ) {
num4 = 0 ;
}
}
if ( ! result ) {
result = num4 ;
}
const items3 = [ ] ;
for ( let num6 = 0 ; num6 < frames . samples . length ; num6 = num6 + 1 ) {
let tmp16 = frames . samples [ num6 ] ;
if ( tmp16 ) {
let result1 = ( num4 + ( tmp16 . timestamp - tmp15 ) ) / 1000 ;
obj = { } ;
let stackId = tmp16 . stackId ;
let num7 = 0 ;
if ( null != stackId ) {
num7 = stackId ;
}
obj . stack _id = num7 ;
2026-07-23 10:11:24 +00:00
let tmp18 = closure _4 ;
obj . thread _id = closure _4 ;
2026-07-20 16:05:17 +00:00
obj . timestamp = result1 ;
items3 [ num6 ] = obj ;
let tmp19 = stackId ;
let tmp20 = result1 ;
}
}
obj = { frames : items , stacks : items1 , samples : items3 } ;
obj1 = { name : str2 } ;
2026-07-23 10:11:24 +00:00
obj . thread _metadata = _defineProperty ( { } , closure _4 , obj1 ) ;
2026-07-20 16:05:17 +00:00
const options = _client . getOptions ( ) ;
let sdk ;
if ( null != _client . getSdkMetadata ) {
const sdkMetadata = _client . getSdkMetadata ( ) ;
if ( null != sdkMetadata ) {
sdk = sdkMetadata . sdk ;
}
}
2026-07-23 10:11:24 +00:00
const obj2 = { chunk _id : require ( 794 ) /* registerSpanErrorInstrumentation */ . uuid4 ( ) } ;
2026-07-20 16:05:17 +00:00
const obj3 = { } ;
let name ;
if ( null != sdk ) {
name = sdk . name ;
}
let str = "sentry.javascript.browser" ;
if ( null != name ) {
str = name ;
}
obj3 . name = str ;
let version ;
if ( null != sdk ) {
version = sdk . version ;
}
2026-07-23 10:11:24 +00:00
str2 = "0.0.0" ;
2026-07-20 16:05:17 +00:00
if ( null != version ) {
str2 = version ;
}
obj3 . version = str2 ;
obj2 . client _sdk = obj3 ;
if ( ! uuid4Result ) {
2026-07-23 10:11:24 +00:00
uuid4Result = require ( 794 ) /* registerSpanErrorInstrumentation */ . uuid4 ( ) ;
const obj9 = require ( 794 ) /* registerSpanErrorInstrumentation */ ;
2026-07-20 16:05:17 +00:00
}
obj2 . profiler _id = uuid4Result ;
obj2 . platform = "javascript" ;
obj2 . version = "2" ;
const release = options . release ;
let str5 = "" ;
if ( null != release ) {
str5 = release ;
}
obj2 . release = str5 ;
const environment = options . environment ;
let str6 = "production" ;
if ( null != environment ) {
str6 = environment ;
}
obj2 . environment = str6 ;
const obj4 = { images : applyDebugMetadata ( frames . resources ) } ;
obj2 . debug _meta = obj4 ;
obj2 . profile = obj ;
return obj2 ;
}
} ;
export { createProfilePayload } ;
export const createProfilingEvent = function createProfilingEvent ( event _id , arg1 , samples , type ) {
if ( samples . samples . length < 2 ) {
let flag = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug2 = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug2 . log ( "[Profiling] Discarding profile because it contains less than 2 samples" ) ;
flag = false ;
}
} else {
flag = ! tmp ;
if ( ! samples . frames . length ) {
flag = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug . log ( "[Profiling] Discarding profile because it contains no frames" ) ;
flag = false ;
}
}
}
let tmp12 = null ;
if ( flag ) {
tmp12 = createProfilePayload ( event _id , arg1 , samples , type ) ;
}
return tmp12 ;
} ;
export { enrichWithThreadInformation } ;
export const findProfiledTransactionsFromEnvelope = function findProfiledTransactionsFromEnvelope ( arg0 ) {
const items = [ ] ;
2026-07-23 10:11:24 +00:00
items ( 794 ) . forEachEnvelopeItem ( arg0 , ( arg0 , arg1 ) => {
2026-07-20 16:05:17 +00:00
if ( "transaction" === arg1 ) {
let num = 1 ;
if ( 1 < arg0 . length ) {
do {
let tmp3 = arg0 [ num ] ;
let profile _id = null != tmp3 ;
if ( profile _id ) {
let contexts = tmp3 . contexts ;
profile _id = null != contexts ;
let tmp2 = contexts ;
}
let tmp4 = tmp2 ;
if ( profile _id ) {
let profile = tmp2 . profile ;
profile _id = null != profile ;
tmp4 = profile ;
}
if ( profile _id ) {
profile _id = tmp4 . profile _id ;
}
if ( profile _id ) {
2026-07-23 10:11:24 +00:00
let tmp5 = items ;
let arr = items . push ( arg0 [ num ] ) ;
2026-07-20 16:05:17 +00:00
}
num = num + 1 ;
tmp2 = tmp4 ;
} while ( num < arg0 . length ) ;
}
}
} ) ;
return items ;
} ;
export const getActiveProfilesCount = function getActiveProfilesCount ( ) {
return map . size ;
} ;
export const hasLegacyProfiling = function hasLegacyProfiling ( options ) {
return undefined !== options . profilesSampleRate ;
} ;
export const isAutomatedPageLoadSpan = function isAutomatedPageLoadSpan ( rootSpan ) {
2026-07-23 10:11:24 +00:00
return "pageload" === require ( 794 ) /* registerSpanErrorInstrumentation */ . spanToJSON ( rootSpan ) . op ;
2026-07-20 16:05:17 +00:00
} ;
export { isValidSampleRate } ;
export const shouldProfileSession = function shouldProfileSession ( options ) {
2026-07-23 10:11:24 +00:00
if ( c12 ) {
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug4 = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug4 . log ( "[Profiling] Profiling has been disabled for the duration of the current user session as the JS Profiler could not be started." ) ;
}
return false ;
} else {
if ( "trace" !== options . profileLifecycle ) {
if ( "manual" !== options . profileLifecycle ) {
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug3 = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug3 . warn ( "[Profiling] Session not sampled. Invalid `profileLifecycle` option." ) ;
}
return false ;
}
}
const profileSessionSampleRate = options . profileSessionSampleRate ;
if ( isValidSampleRate ( profileSessionSampleRate ) ) {
if ( profileSessionSampleRate ) {
const _Math = Math ;
let flag2 = Math . random ( ) <= profileSessionSampleRate ;
} else {
flag2 = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug2 = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug2 . log ( "[Profiling] Discarding profile because profileSessionSampleRate is not defined or set to 0" ) ;
flag2 = false ;
}
}
} else {
let flag = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug . warn ( "[Profiling] Discarding profile because of invalid profileSessionSampleRate." ) ;
flag = false ;
}
return flag ;
}
}
} ;
export const shouldProfileSpanLegacy = function shouldProfileSpanLegacy ( rootSpan ) {
2026-07-23 10:11:24 +00:00
if ( c12 ) {
if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug5 = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug5 . log ( "[Profiling] Profiling has been disabled for the duration of the current user session." ) ;
}
return false ;
} else if ( rootSpan . isRecording ( ) ) {
let num3 = 1 ;
2026-07-23 10:11:24 +00:00
const client = tmp ( 794 ) . getClient ( ) ;
2026-07-20 16:05:17 +00:00
let options ;
if ( null != client ) {
options = client . getOptions ( ) ;
}
if ( options ) {
let concat = options . profilesSampleRate ;
if ( isValidSampleRate ( concat ) ) {
if ( concat ) {
let tmp25 = true === concat ;
if ( ! tmp25 ) {
const _Math = Math ;
tmp25 = Math . random ( ) < concat ;
}
let flag6 = tmp25 ;
if ( ! tmp25 ) {
flag6 = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
2026-07-20 16:05:17 +00:00
num3 = require ( dependencyMap [ num3 ] ) . debug ;
const _Number = Number ;
const _HermesInternal = HermesInternal ;
concat = HermesInternal . concat ;
num3 . log ( concat ( Number ( concat ) , ")" ) ) ;
flag6 = false ;
const NumberResult = Number ( concat ) ;
}
}
let flag4 = flag6 ;
} else {
flag4 = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
2026-07-20 16:05:17 +00:00
const debug4 = require ( dependencyMap [ num3 ] ) . debug ;
debug4 . log ( "[Profiling] Discarding profile because a negative sampling decision was inherited or profileSampleRate is set to 0" ) ;
flag4 = false ;
}
}
} else {
let flag3 = false ;
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
2026-07-20 16:05:17 +00:00
const debug3 = require ( dependencyMap [ num3 ] ) . debug ;
debug3 . warn ( "[Profiling] Discarding profile because of invalid sample rate." ) ;
flag3 = false ;
}
return flag3 ;
}
} else {
2026-07-23 10:11:24 +00:00
if ( require ( 1048 ) . DEBUG _BUILD ) {
2026-07-20 16:05:17 +00:00
const debug2 = require ( dependencyMap [ num3 ] ) . debug ;
debug2 . log ( "[Profiling] Profiling disabled, no options found." ) ;
}
return false ;
}
2026-07-23 10:11:24 +00:00
const tmpResult = tmp ( 794 ) ;
2026-07-20 16:05:17 +00:00
} else {
2026-07-23 10:11:24 +00:00
if ( tmp ( 1048 ) . DEBUG _BUILD ) {
const debug = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug . log ( "[Profiling] Discarding profile because root span was not sampled." ) ;
}
return false ;
}
} ;
export const startJSSelfProfile = function startJSSelfProfile ( ) {
2026-07-23 10:11:24 +00:00
const Profiler = require ( 1004 ) /* ignoreNextOnError */ . WINDOW . Profiler ;
2026-07-20 16:05:17 +00:00
let tmp = Profiler ;
if ( "function" === typeof Profiler ) {
const _Math = Math ;
const obj = { sampleInterval : 10 , maxBufferSize : Math . floor ( 3000 ) } ;
const prototype = tmp . prototype ;
tmp = new tmp ( obj ) ;
return tmp ;
2026-07-23 10:11:24 +00:00
} else if ( require ( 1048 ) . DEBUG _BUILD ) {
const debug = require ( 794 ) /* registerSpanErrorInstrumentation */ . debug ;
2026-07-20 16:05:17 +00:00
debug . log ( "[Profiling] Profiling is not supported by this browser, Profiler interface missing on window object." ) ;
}
} ;
export const takeProfileFromGlobalCache = function takeProfileFromGlobalCache ( arg0 ) {
const value = map . get ( arg0 ) ;
if ( value ) {
map . delete ( arg0 ) ;
}
return value ;
} ;
export const validateProfileChunk = function validateProfileChunk ( profileChunkPayload ) {
if ( profileChunkPayload ) {
if ( "object" === typeof profileChunkPayload ) {
function isHex32 ( profiler _id ) {
let isMatch = "string" === typeof profiler _id ;
if ( isMatch ) {
isMatch = /^[a-f0-9]{32}$/ . test ( profiler _id ) ;
const obj = /^[a-f0-9]{32}$/ ;
}
return isMatch ;
}
if ( isHex32 ( profileChunkPayload . profiler _id ) ) {
if ( tmp15 ( profileChunkPayload . chunk _id ) ) {
if ( profileChunkPayload . client _sdk ) {
const profile = profileChunkPayload . profile ;
if ( profile ) {
const _Array = Array ;
if ( ! Array . isArray ( tmp5 . frames ) ) {
let obj = { reason : "profile has no frames" } ;
}
const _Array2 = Array ;
if ( ! Array . isArray ( tmp5 . stacks ) ) {
obj = { reason : "profile has no stacks" } ;
}
const _Array3 = Array ;
if ( ! Array . isArray ( tmp5 . samples ) ) {
let obj1 = { reason : "profile has no samples" } ;
}
const obj2 = { valid : true } ;
obj1 = obj2 ;
} else {
const obj3 = { reason : "missing profile data" } ;
return obj3 ;
}
} else {
const obj4 = { reason : "missing client_sdk metadata" } ;
return obj4 ;
}
} else {
const obj5 = { reason : "missing or invalid chunk_id" } ;
return obj5 ;
}
} else {
obj = { reason : "missing or invalid profiler_id" } ;
return obj ;
}
2026-07-23 10:11:24 +00:00
tmp15 = isHex32 ;
2026-07-20 16:05:17 +00:00
}
}
return { reason : "chunk is not an object" } ;
} ;