@sentry/react-native 8.5.0 → 8.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (408) hide show
  1. package/RNSentry.podspec +1 -1
  2. package/android/build.gradle +2 -2
  3. package/android/expo-handler/build.gradle +20 -0
  4. package/android/expo-handler/src/main/java/io/sentry/react/expo/SentryExpoPackage.java +22 -0
  5. package/android/expo-handler/src/main/java/io/sentry/react/expo/SentryReactNativeHostHandler.java +48 -0
  6. package/android/expo-stubs/README.md +7 -0
  7. package/android/expo-stubs/build.gradle +23 -0
  8. package/android/expo-stubs/gradle/wrapper/gradle-wrapper.jar +0 -0
  9. package/android/expo-stubs/gradle/wrapper/gradle-wrapper.properties +7 -0
  10. package/android/expo-stubs/gradlew +251 -0
  11. package/android/expo-stubs/gradlew.bat +94 -0
  12. package/android/expo-stubs/settings.gradle +1 -0
  13. package/android/expo-stubs/src/main/java/expo/modules/core/interfaces/Package.java +11 -0
  14. package/android/expo-stubs/src/main/java/expo/modules/core/interfaces/ReactNativeHostHandler.java +7 -0
  15. package/android/libs/expo-stubs.jar +0 -0
  16. package/android/libs/replay-stubs.jar +0 -0
  17. package/android/replay-stubs/build.gradle +1 -1
  18. package/android/src/main/java/io/sentry/react/RNSentryFrameDelayCollector.java +128 -0
  19. package/android/src/main/java/io/sentry/react/RNSentryModuleImpl.java +63 -11
  20. package/android/src/main/java/io/sentry/react/RNSentryVersion.java +1 -1
  21. package/android/src/newarch/java/io/sentry/react/RNSentryModule.java +6 -0
  22. package/android/src/oldarch/java/io/sentry/react/RNSentryModule.java +6 -0
  23. package/dist/js/NativeLogListener.d.ts.map +1 -1
  24. package/dist/js/NativeLogListener.js.map +1 -1
  25. package/dist/js/NativeRNSentry.d.ts +1 -0
  26. package/dist/js/NativeRNSentry.d.ts.map +1 -1
  27. package/dist/js/NativeRNSentry.js.map +1 -1
  28. package/dist/js/RNSentryReplayMaskNativeComponent.d.ts.map +1 -1
  29. package/dist/js/RNSentryReplayMaskNativeComponent.js +1 -2
  30. package/dist/js/RNSentryReplayMaskNativeComponent.js.map +1 -1
  31. package/dist/js/RNSentryReplayUnmaskNativeComponent.d.ts.map +1 -1
  32. package/dist/js/RNSentryReplayUnmaskNativeComponent.js +1 -2
  33. package/dist/js/RNSentryReplayUnmaskNativeComponent.js.map +1 -1
  34. package/dist/js/breadcrumb.d.ts.map +1 -1
  35. package/dist/js/breadcrumb.js.map +1 -1
  36. package/dist/js/client.d.ts.map +1 -1
  37. package/dist/js/client.js +1 -1
  38. package/dist/js/client.js.map +1 -1
  39. package/dist/js/feedback/FeedbackButton.d.ts +2 -1
  40. package/dist/js/feedback/FeedbackButton.d.ts.map +1 -1
  41. package/dist/js/feedback/FeedbackButton.js +5 -4
  42. package/dist/js/feedback/FeedbackButton.js.map +1 -1
  43. package/dist/js/feedback/{FeedbackWidget.d.ts → FeedbackForm.d.ts} +5 -5
  44. package/dist/js/feedback/FeedbackForm.d.ts.map +1 -0
  45. package/dist/js/feedback/{FeedbackWidget.js → FeedbackForm.js} +32 -30
  46. package/dist/js/feedback/FeedbackForm.js.map +1 -0
  47. package/dist/js/feedback/FeedbackForm.styles.d.ts +11 -0
  48. package/dist/js/feedback/FeedbackForm.styles.d.ts.map +1 -0
  49. package/dist/js/feedback/{FeedbackWidget.styles.js → FeedbackForm.styles.js} +1 -1
  50. package/dist/js/feedback/FeedbackForm.styles.js.map +1 -0
  51. package/dist/js/feedback/{FeedbackWidget.theme.d.ts → FeedbackForm.theme.d.ts} +7 -5
  52. package/dist/js/feedback/FeedbackForm.theme.d.ts.map +1 -0
  53. package/dist/js/feedback/{FeedbackWidget.theme.js → FeedbackForm.theme.js} +1 -1
  54. package/dist/js/feedback/FeedbackForm.theme.js.map +1 -0
  55. package/{ts3.8/dist/js/feedback/FeedbackWidget.types.d.ts → dist/js/feedback/FeedbackForm.types.d.ts} +305 -299
  56. package/dist/js/feedback/FeedbackForm.types.d.ts.map +1 -0
  57. package/dist/js/feedback/FeedbackForm.types.js +2 -0
  58. package/dist/js/feedback/FeedbackForm.types.js.map +1 -0
  59. package/dist/js/feedback/{FeedbackWidgetManager.d.ts → FeedbackFormManager.d.ts} +12 -4
  60. package/dist/js/feedback/FeedbackFormManager.d.ts.map +1 -0
  61. package/dist/js/feedback/{FeedbackWidgetManager.js → FeedbackFormManager.js} +22 -13
  62. package/dist/js/feedback/FeedbackFormManager.js.map +1 -0
  63. package/dist/js/feedback/{FeedbackWidgetProvider.d.ts → FeedbackFormProvider.d.ts} +10 -10
  64. package/dist/js/feedback/FeedbackFormProvider.d.ts.map +1 -0
  65. package/dist/js/feedback/{FeedbackWidgetProvider.js → FeedbackFormProvider.js} +18 -15
  66. package/dist/js/feedback/FeedbackFormProvider.js.map +1 -0
  67. package/dist/js/feedback/ScreenshotButton.d.ts +2 -2
  68. package/dist/js/feedback/ScreenshotButton.d.ts.map +1 -1
  69. package/dist/js/feedback/ScreenshotButton.js +6 -5
  70. package/dist/js/feedback/ScreenshotButton.js.map +1 -1
  71. package/dist/js/feedback/ShakeToReportBug.d.ts.map +1 -1
  72. package/dist/js/feedback/ShakeToReportBug.js.map +1 -1
  73. package/dist/js/feedback/defaults.d.ts +2 -2
  74. package/dist/js/feedback/defaults.d.ts.map +1 -1
  75. package/dist/js/feedback/defaults.js.map +1 -1
  76. package/dist/js/feedback/integration.d.ts +13 -13
  77. package/dist/js/feedback/integration.d.ts.map +1 -1
  78. package/dist/js/feedback/integration.js.map +1 -1
  79. package/dist/js/feedback/lazy.d.ts +5 -0
  80. package/dist/js/feedback/lazy.d.ts.map +1 -1
  81. package/dist/js/feedback/lazy.js +12 -0
  82. package/dist/js/feedback/lazy.js.map +1 -1
  83. package/dist/js/feedback/utils.d.ts.map +1 -1
  84. package/dist/js/feedback/utils.js +1 -0
  85. package/dist/js/feedback/utils.js.map +1 -1
  86. package/dist/js/index.d.ts +12 -3
  87. package/dist/js/index.d.ts.map +1 -1
  88. package/dist/js/index.js +12 -3
  89. package/dist/js/index.js.map +1 -1
  90. package/dist/js/integrations/appRegistry.d.ts.map +1 -1
  91. package/dist/js/integrations/appRegistry.js.map +1 -1
  92. package/dist/js/integrations/breadcrumbs.d.ts.map +1 -1
  93. package/dist/js/integrations/breadcrumbs.js +1 -1
  94. package/dist/js/integrations/breadcrumbs.js.map +1 -1
  95. package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
  96. package/dist/js/integrations/debugsymbolicator.js +4 -5
  97. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  98. package/dist/js/integrations/debugsymbolicatorutils.d.ts.map +1 -1
  99. package/dist/js/integrations/debugsymbolicatorutils.js.map +1 -1
  100. package/dist/js/integrations/default.d.ts.map +1 -1
  101. package/dist/js/integrations/default.js +1 -2
  102. package/dist/js/integrations/default.js.map +1 -1
  103. package/dist/js/integrations/devicecontext.d.ts.map +1 -1
  104. package/dist/js/integrations/devicecontext.js +1 -1
  105. package/dist/js/integrations/devicecontext.js.map +1 -1
  106. package/dist/js/integrations/expoconstants.d.ts.map +1 -1
  107. package/dist/js/integrations/expoconstants.js.map +1 -1
  108. package/dist/js/integrations/expocontext.d.ts.map +1 -1
  109. package/dist/js/integrations/expocontext.js.map +1 -1
  110. package/dist/js/integrations/expoupdateslistener.d.ts.map +1 -1
  111. package/dist/js/integrations/expoupdateslistener.js +0 -1
  112. package/dist/js/integrations/expoupdateslistener.js.map +1 -1
  113. package/dist/js/integrations/graphql.d.ts.map +1 -1
  114. package/dist/js/integrations/graphql.js.map +1 -1
  115. package/dist/js/integrations/logEnricherIntegration.d.ts.map +1 -1
  116. package/dist/js/integrations/logEnricherIntegration.js +1 -1
  117. package/dist/js/integrations/logEnricherIntegration.js.map +1 -1
  118. package/dist/js/integrations/modulesloader.d.ts.map +1 -1
  119. package/dist/js/integrations/modulesloader.js.map +1 -1
  120. package/dist/js/integrations/nativelinkederrors.d.ts.map +1 -1
  121. package/dist/js/integrations/nativelinkederrors.js +1 -0
  122. package/dist/js/integrations/nativelinkederrors.js.map +1 -1
  123. package/dist/js/integrations/primitiveTagIntegration.d.ts.map +1 -1
  124. package/dist/js/integrations/primitiveTagIntegration.js.map +1 -1
  125. package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
  126. package/dist/js/integrations/reactnativeerrorhandlers.js +2 -1
  127. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  128. package/dist/js/integrations/reactnativeerrorhandlersutils.d.ts.map +1 -1
  129. package/dist/js/integrations/reactnativeerrorhandlersutils.js +0 -5
  130. package/dist/js/integrations/reactnativeerrorhandlersutils.js.map +1 -1
  131. package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -1
  132. package/dist/js/integrations/reactnativeinfo.js.map +1 -1
  133. package/dist/js/integrations/release.d.ts.map +1 -1
  134. package/dist/js/integrations/release.js +1 -1
  135. package/dist/js/integrations/release.js.map +1 -1
  136. package/dist/js/integrations/rewriteframes.d.ts.map +1 -1
  137. package/dist/js/integrations/rewriteframes.js.map +1 -1
  138. package/dist/js/integrations/screenshot.d.ts.map +1 -1
  139. package/dist/js/integrations/screenshot.js +1 -1
  140. package/dist/js/integrations/screenshot.js.map +1 -1
  141. package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
  142. package/dist/js/integrations/sdkinfo.js.map +1 -1
  143. package/dist/js/integrations/spotlight.d.ts.map +1 -1
  144. package/dist/js/integrations/spotlight.js.map +1 -1
  145. package/dist/js/integrations/supabase.d.ts.map +1 -1
  146. package/dist/js/integrations/supabase.js.map +1 -1
  147. package/dist/js/integrations/viewhierarchy.d.ts.map +1 -1
  148. package/dist/js/integrations/viewhierarchy.js +1 -1
  149. package/dist/js/integrations/viewhierarchy.js.map +1 -1
  150. package/dist/js/misc.js.map +1 -1
  151. package/dist/js/options.d.ts +1 -1
  152. package/dist/js/options.d.ts.map +1 -1
  153. package/dist/js/options.js.map +1 -1
  154. package/dist/js/playground/examples.d.ts.map +1 -1
  155. package/dist/js/playground/examples.js.map +1 -1
  156. package/dist/js/playground/modal.d.ts +2 -2
  157. package/dist/js/playground/modal.d.ts.map +1 -1
  158. package/dist/js/playground/modal.js +5 -103
  159. package/dist/js/playground/modal.js.map +1 -1
  160. package/dist/js/playground/modal.styles.d.ts +100 -0
  161. package/dist/js/playground/modal.styles.d.ts.map +1 -0
  162. package/dist/js/playground/modal.styles.js +98 -0
  163. package/dist/js/playground/modal.styles.js.map +1 -0
  164. package/dist/js/profiling/cache.js +2 -2
  165. package/dist/js/profiling/cache.js.map +1 -1
  166. package/dist/js/profiling/convertHermesProfile.d.ts.map +1 -1
  167. package/dist/js/profiling/convertHermesProfile.js.map +1 -1
  168. package/dist/js/profiling/debugid.d.ts.map +1 -1
  169. package/dist/js/profiling/debugid.js.map +1 -1
  170. package/dist/js/profiling/hermes.d.ts.map +1 -1
  171. package/dist/js/profiling/hermes.js.map +1 -1
  172. package/dist/js/profiling/integration.d.ts.map +1 -1
  173. package/dist/js/profiling/integration.js.map +1 -1
  174. package/dist/js/profiling/types.d.ts.map +1 -1
  175. package/dist/js/profiling/types.js.map +1 -1
  176. package/dist/js/profiling/utils.d.ts.map +1 -1
  177. package/dist/js/profiling/utils.js +1 -1
  178. package/dist/js/profiling/utils.js.map +1 -1
  179. package/dist/js/replay/CustomMask.d.ts +1 -1
  180. package/dist/js/replay/CustomMask.d.ts.map +1 -1
  181. package/dist/js/replay/CustomMask.js +1 -1
  182. package/dist/js/replay/CustomMask.js.map +1 -1
  183. package/dist/js/replay/CustomMask.web.d.ts +1 -1
  184. package/dist/js/replay/CustomMask.web.d.ts.map +1 -1
  185. package/dist/js/replay/CustomMask.web.js +2 -2
  186. package/dist/js/replay/CustomMask.web.js.map +1 -1
  187. package/dist/js/replay/browserReplay.d.ts.map +1 -1
  188. package/dist/js/replay/browserReplay.js +0 -2
  189. package/dist/js/replay/browserReplay.js.map +1 -1
  190. package/dist/js/replay/mobilereplay.d.ts.map +1 -1
  191. package/dist/js/replay/mobilereplay.js +21 -2
  192. package/dist/js/replay/mobilereplay.js.map +1 -1
  193. package/dist/js/replay/networkUtils.d.ts +0 -1
  194. package/dist/js/replay/networkUtils.d.ts.map +1 -1
  195. package/dist/js/replay/networkUtils.js.map +1 -1
  196. package/dist/js/replay/xhrUtils.d.ts.map +1 -1
  197. package/dist/js/replay/xhrUtils.js.map +1 -1
  198. package/dist/js/scopeSync.d.ts.map +1 -1
  199. package/dist/js/scopeSync.js +1 -1
  200. package/dist/js/scopeSync.js.map +1 -1
  201. package/dist/js/sdk.d.ts +21 -0
  202. package/dist/js/sdk.d.ts.map +1 -1
  203. package/dist/js/sdk.js +42 -18
  204. package/dist/js/sdk.js.map +1 -1
  205. package/dist/js/tools/ModulesCollector.js +1 -1
  206. package/dist/js/tools/ModulesCollector.js.map +1 -1
  207. package/dist/js/tools/collectModules.js +0 -1
  208. package/dist/js/tools/collectModules.js.map +1 -1
  209. package/dist/js/tools/easBuildHooks.d.ts.map +1 -1
  210. package/dist/js/tools/easBuildHooks.js +13 -14
  211. package/dist/js/tools/easBuildHooks.js.map +1 -1
  212. package/dist/js/tools/enableLogger.js +1 -2
  213. package/dist/js/tools/enableLogger.js.map +1 -1
  214. package/dist/js/tools/metroMiddleware.d.ts.map +1 -1
  215. package/dist/js/tools/metroMiddleware.js.map +1 -1
  216. package/dist/js/tools/metroconfig.d.ts.map +1 -1
  217. package/dist/js/tools/metroconfig.js +10 -12
  218. package/dist/js/tools/metroconfig.js.map +1 -1
  219. package/dist/js/tools/sentryBabelTransformerUtils.d.ts.map +1 -1
  220. package/dist/js/tools/sentryBabelTransformerUtils.js +9 -10
  221. package/dist/js/tools/sentryBabelTransformerUtils.js.map +1 -1
  222. package/dist/js/tools/sentryMetroSerializer.d.ts.map +1 -1
  223. package/dist/js/tools/sentryMetroSerializer.js +6 -7
  224. package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
  225. package/dist/js/tools/sentryOptionsSerializer.d.ts.map +1 -1
  226. package/dist/js/tools/sentryOptionsSerializer.js +3 -5
  227. package/dist/js/tools/sentryOptionsSerializer.js.map +1 -1
  228. package/dist/js/tools/sentryReleaseInjector.d.ts +1 -1
  229. package/dist/js/tools/sentryReleaseInjector.d.ts.map +1 -1
  230. package/dist/js/tools/sentryReleaseInjector.js.map +1 -1
  231. package/dist/js/tools/utils.d.ts.map +1 -1
  232. package/dist/js/tools/utils.js +7 -10
  233. package/dist/js/tools/utils.js.map +1 -1
  234. package/dist/js/tools/vendor/metro/countLines.d.ts.map +1 -1
  235. package/dist/js/tools/vendor/metro/utils.d.ts.map +1 -1
  236. package/dist/js/tools/vendor/metro/utils.js +5 -5
  237. package/dist/js/tools/vendor/metro/utils.js.map +1 -1
  238. package/dist/js/touchevents.d.ts.map +1 -1
  239. package/dist/js/touchevents.js +19 -19
  240. package/dist/js/touchevents.js.map +1 -1
  241. package/dist/js/tracing/expoAsset.js.map +1 -1
  242. package/dist/js/tracing/expoImage.d.ts.map +1 -1
  243. package/dist/js/tracing/expoImage.js +1 -1
  244. package/dist/js/tracing/expoImage.js.map +1 -1
  245. package/dist/js/tracing/expoRouter.d.ts.map +1 -1
  246. package/dist/js/tracing/expoRouter.js.map +1 -1
  247. package/dist/js/tracing/gesturetracing.d.ts.map +1 -1
  248. package/dist/js/tracing/gesturetracing.js.map +1 -1
  249. package/dist/js/tracing/integrations/appStart.d.ts +19 -1
  250. package/dist/js/tracing/integrations/appStart.d.ts.map +1 -1
  251. package/dist/js/tracing/integrations/appStart.js +144 -9
  252. package/dist/js/tracing/integrations/appStart.js.map +1 -1
  253. package/dist/js/tracing/integrations/nativeFrames.d.ts.map +1 -1
  254. package/dist/js/tracing/integrations/nativeFrames.js +47 -1
  255. package/dist/js/tracing/integrations/nativeFrames.js.map +1 -1
  256. package/dist/js/tracing/integrations/stalltracking.d.ts +1 -1
  257. package/dist/js/tracing/integrations/stalltracking.d.ts.map +1 -1
  258. package/dist/js/tracing/integrations/stalltracking.js +4 -2
  259. package/dist/js/tracing/integrations/stalltracking.js.map +1 -1
  260. package/dist/js/tracing/integrations/timeToDisplayIntegration.d.ts.map +1 -1
  261. package/dist/js/tracing/integrations/timeToDisplayIntegration.js +15 -15
  262. package/dist/js/tracing/integrations/timeToDisplayIntegration.js.map +1 -1
  263. package/dist/js/tracing/integrations/userInteraction.d.ts.map +1 -1
  264. package/dist/js/tracing/integrations/userInteraction.js.map +1 -1
  265. package/dist/js/tracing/onSpanEndUtils.d.ts.map +1 -1
  266. package/dist/js/tracing/onSpanEndUtils.js +43 -14
  267. package/dist/js/tracing/onSpanEndUtils.js.map +1 -1
  268. package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
  269. package/dist/js/tracing/reactnativenavigation.js.map +1 -1
  270. package/dist/js/tracing/reactnativeprofiler.d.ts.map +1 -1
  271. package/dist/js/tracing/reactnativeprofiler.js +2 -2
  272. package/dist/js/tracing/reactnativeprofiler.js.map +1 -1
  273. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  274. package/dist/js/tracing/reactnativetracing.js +0 -1
  275. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  276. package/dist/js/tracing/reactnavigation.d.ts +3 -0
  277. package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
  278. package/dist/js/tracing/reactnavigation.js +6 -4
  279. package/dist/js/tracing/reactnavigation.js.map +1 -1
  280. package/dist/js/tracing/span.d.ts +2 -17
  281. package/dist/js/tracing/span.d.ts.map +1 -1
  282. package/dist/js/tracing/span.js +1 -1
  283. package/dist/js/tracing/span.js.map +1 -1
  284. package/dist/js/tracing/timeToDisplayFallback.d.ts.map +1 -1
  285. package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
  286. package/dist/js/tracing/timetodisplay.js +42 -19
  287. package/dist/js/tracing/timetodisplay.js.map +1 -1
  288. package/dist/js/tracing/timetodisplaynative.d.ts +1 -1
  289. package/dist/js/tracing/timetodisplaynative.d.ts.map +1 -1
  290. package/dist/js/tracing/timetodisplaynative.js +5 -4
  291. package/dist/js/tracing/timetodisplaynative.js.map +1 -1
  292. package/dist/js/tracing/types.js.map +1 -1
  293. package/dist/js/tracing/utils.d.ts.map +1 -1
  294. package/dist/js/tracing/utils.js.map +1 -1
  295. package/dist/js/transports/encodePolyfill.d.ts +1 -1
  296. package/dist/js/transports/encodePolyfill.d.ts.map +1 -1
  297. package/dist/js/transports/encodePolyfill.js.map +1 -1
  298. package/dist/js/transports/native.d.ts.map +1 -1
  299. package/dist/js/transports/native.js.map +1 -1
  300. package/dist/js/utils/AsyncExpiringMap.js.map +1 -1
  301. package/dist/js/utils/encode.js.map +1 -1
  302. package/dist/js/utils/envelope.d.ts.map +1 -1
  303. package/dist/js/utils/envelope.js.map +1 -1
  304. package/dist/js/utils/environment.d.ts.map +1 -1
  305. package/dist/js/utils/environment.js.map +1 -1
  306. package/dist/js/utils/expomodules.d.ts.map +1 -1
  307. package/dist/js/utils/expomodules.js.map +1 -1
  308. package/dist/js/utils/fill.js +1 -1
  309. package/dist/js/utils/fill.js.map +1 -1
  310. package/dist/js/utils/ignorerequirecyclelogs.js.map +1 -1
  311. package/dist/js/utils/normalize.js +2 -2
  312. package/dist/js/utils/normalize.js.map +1 -1
  313. package/dist/js/utils/outcome.js.map +1 -1
  314. package/dist/js/utils/primitiveConverter.js.map +1 -1
  315. package/dist/js/utils/release.js.map +1 -1
  316. package/dist/js/utils/rnlibraries.d.ts.map +1 -1
  317. package/dist/js/utils/rnlibraries.js +1 -7
  318. package/dist/js/utils/rnlibraries.js.map +1 -1
  319. package/dist/js/utils/safe.d.ts.map +1 -1
  320. package/dist/js/utils/safe.js.map +1 -1
  321. package/dist/js/utils/span.d.ts.map +1 -1
  322. package/dist/js/utils/span.js.map +1 -1
  323. package/dist/js/utils/worldwide.d.ts +0 -1
  324. package/dist/js/utils/worldwide.d.ts.map +1 -1
  325. package/dist/js/utils/worldwide.js.map +1 -1
  326. package/dist/js/utils/xhr.d.ts +0 -1
  327. package/dist/js/utils/xhr.d.ts.map +1 -1
  328. package/dist/js/utils/xhr.js.map +1 -1
  329. package/dist/js/vendor/base64-js/fromByteArray.js +1 -1
  330. package/dist/js/vendor/base64-js/fromByteArray.js.map +1 -1
  331. package/dist/js/vendor/buffer/utf8ToBytes.js +1 -1
  332. package/dist/js/vendor/buffer/utf8ToBytes.js.map +1 -1
  333. package/dist/js/vendor/react-native/index.d.ts.map +1 -1
  334. package/dist/js/vendor/react-native/index.js.map +1 -1
  335. package/dist/js/version.d.ts +1 -1
  336. package/dist/js/version.js +1 -1
  337. package/dist/js/version.js.map +1 -1
  338. package/dist/js/wrapper.d.ts +1 -0
  339. package/dist/js/wrapper.d.ts.map +1 -1
  340. package/dist/js/wrapper.js +20 -9
  341. package/dist/js/wrapper.js.map +1 -1
  342. package/expo-module.config.json +7 -0
  343. package/ios/RNSentry.mm +18 -1
  344. package/ios/RNSentryReplay.mm +1 -1
  345. package/ios/RNSentrySDK.m +1 -1
  346. package/ios/RNSentryStart.m +4 -1
  347. package/ios/RNSentryTimeToDisplay.m +48 -32
  348. package/ios/RNSentryVersion.m +1 -1
  349. package/ios/SentryScreenFramesWrapper.h +2 -0
  350. package/ios/SentryScreenFramesWrapper.m +35 -0
  351. package/package.json +18 -22
  352. package/plugin/build/logger.js +1 -1
  353. package/plugin/build/utils.js +2 -0
  354. package/plugin/build/withSentry.js +1 -2
  355. package/plugin/build/withSentryAndroid.js +2 -0
  356. package/plugin/build/withSentryAndroidGradlePlugin.d.ts +1 -1
  357. package/plugin/build/withSentryAndroidGradlePlugin.js +1 -1
  358. package/plugin/build/withSentryIOS.js +1 -3
  359. package/scripts/eas-build-hook.js +0 -2
  360. package/scripts/expo-upload-sourcemaps.js +0 -1
  361. package/src/js/NativeRNSentry.ts +3 -0
  362. package/src/js/RNSentryReplayMaskNativeComponent.ts +2 -3
  363. package/src/js/RNSentryReplayUnmaskNativeComponent.ts +2 -3
  364. package/ts3.8/dist/js/NativeRNSentry.d.ts +1 -0
  365. package/ts3.8/dist/js/feedback/FeedbackButton.d.ts +2 -1
  366. package/ts3.8/dist/js/feedback/{FeedbackWidget.d.ts → FeedbackForm.d.ts} +5 -5
  367. package/ts3.8/dist/js/feedback/FeedbackForm.styles.d.ts +11 -0
  368. package/ts3.8/dist/js/feedback/{FeedbackWidget.theme.d.ts → FeedbackForm.theme.d.ts} +7 -5
  369. package/{dist/js/feedback/FeedbackWidget.types.d.ts → ts3.8/dist/js/feedback/FeedbackForm.types.d.ts} +305 -299
  370. package/ts3.8/dist/js/feedback/{FeedbackWidgetManager.d.ts → FeedbackFormManager.d.ts} +12 -4
  371. package/ts3.8/dist/js/feedback/{FeedbackWidgetProvider.d.ts → FeedbackFormProvider.d.ts} +10 -10
  372. package/ts3.8/dist/js/feedback/ScreenshotButton.d.ts +2 -2
  373. package/ts3.8/dist/js/feedback/defaults.d.ts +2 -2
  374. package/ts3.8/dist/js/feedback/integration.d.ts +13 -13
  375. package/ts3.8/dist/js/feedback/lazy.d.ts +5 -0
  376. package/ts3.8/dist/js/index.d.ts +12 -3
  377. package/ts3.8/dist/js/options.d.ts +1 -1
  378. package/ts3.8/dist/js/playground/modal.d.ts +2 -2
  379. package/ts3.8/dist/js/playground/modal.styles.d.ts +100 -0
  380. package/ts3.8/dist/js/replay/CustomMask.d.ts +1 -1
  381. package/ts3.8/dist/js/replay/CustomMask.web.d.ts +1 -1
  382. package/ts3.8/dist/js/replay/networkUtils.d.ts +0 -1
  383. package/ts3.8/dist/js/sdk.d.ts +21 -0
  384. package/ts3.8/dist/js/tracing/integrations/appStart.d.ts +19 -1
  385. package/ts3.8/dist/js/tracing/integrations/stalltracking.d.ts +1 -1
  386. package/ts3.8/dist/js/tracing/reactnavigation.d.ts +3 -0
  387. package/ts3.8/dist/js/tracing/span.d.ts +2 -17
  388. package/ts3.8/dist/js/tracing/timetodisplaynative.d.ts +1 -1
  389. package/ts3.8/dist/js/transports/encodePolyfill.d.ts +1 -1
  390. package/ts3.8/dist/js/utils/worldwide.d.ts +0 -1
  391. package/ts3.8/dist/js/utils/xhr.d.ts +0 -1
  392. package/ts3.8/dist/js/version.d.ts +1 -1
  393. package/ts3.8/dist/js/wrapper.d.ts +1 -0
  394. package/dist/js/feedback/FeedbackWidget.d.ts.map +0 -1
  395. package/dist/js/feedback/FeedbackWidget.js.map +0 -1
  396. package/dist/js/feedback/FeedbackWidget.styles.d.ts +0 -11
  397. package/dist/js/feedback/FeedbackWidget.styles.d.ts.map +0 -1
  398. package/dist/js/feedback/FeedbackWidget.styles.js.map +0 -1
  399. package/dist/js/feedback/FeedbackWidget.theme.d.ts.map +0 -1
  400. package/dist/js/feedback/FeedbackWidget.theme.js.map +0 -1
  401. package/dist/js/feedback/FeedbackWidget.types.d.ts.map +0 -1
  402. package/dist/js/feedback/FeedbackWidget.types.js +0 -2
  403. package/dist/js/feedback/FeedbackWidget.types.js.map +0 -1
  404. package/dist/js/feedback/FeedbackWidgetManager.d.ts.map +0 -1
  405. package/dist/js/feedback/FeedbackWidgetManager.js.map +0 -1
  406. package/dist/js/feedback/FeedbackWidgetProvider.d.ts.map +0 -1
  407. package/dist/js/feedback/FeedbackWidgetProvider.js.map +0 -1
  408. package/ts3.8/dist/js/feedback/FeedbackWidget.styles.d.ts +0 -11
@@ -1 +1 @@
1
- {"version":3,"file":"nativeFrames.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/nativeFrames.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,uBAAuB,GAAG,IAAK,CAAC;AAEtC;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,IAAK,CAAC;AAEpC;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,KAAM,CAAC;AAEvC;;;GAGG;AACH,MAAM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S,CAAC,CAAC;YACxB,OAAO,GAAG,IAAI,CAAC;YAEf,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,CAAC,iCAAiC,CAAC,CAAC;gBAC1C,OAAO;aACR;YACD,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC;aACD,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YACvB,IAAI,OAAO,EAAE;gBACX,OAAO;aACR;YACD,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,OAAO,CAAC,EAAU,EAAE,EAAU;IACrC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,uBAAuB,CAAC;AACrD,CAAC","sourcesContent":["import type { Client, Event, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\nimport { debug, getRootSpan, spanToJSON, timestampInSeconds } from '@sentry/core';\nimport type { NativeFramesResponse } from '../../NativeRNSentry';\nimport { AsyncExpiringMap } from '../../utils/AsyncExpiringMap';\nimport { isRootSpan } from '../../utils/span';\nimport { NATIVE } from '../../wrapper';\n\n/**\n * Timeout from the start of a span to fetching the associated native frames.\n */\nconst FETCH_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time end frames data from the native layer will be\n * kept in memory and waiting for the event processing. This ensures that spans\n * which are never processed are not leaking memory.\n */\nconst END_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time start frames data from the native layer will be\n * kept in memory and waiting for span end. This ensures that spans\n * which never end or are not processed are not leaking memory.\n */\nconst START_FRAMES_TIMEOUT_MS = 60_000;\n\n/**\n * A margin of error of 50ms is allowed for the async native bridge call.\n * Anything larger would reduce the accuracy of our frames measurements.\n */\nconst MARGIN_OF_ERROR_SECONDS = 0.05;\n\nconst INTEGRATION_NAME = 'NativeFrames';\n\nexport interface FramesMeasurements extends Measurements {\n frames_total: { value: number; unit: MeasurementUnit };\n frames_slow: { value: number; unit: MeasurementUnit };\n frames_frozen: { value: number; unit: MeasurementUnit };\n}\n\ninterface NativeFramesResponseWithTimestamp {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n}\n\nexport const createNativeFramesIntegrations = (enable: boolean | undefined): Integration | undefined => {\n if (!enable && NATIVE.enableNative) {\n // On Android this will free up resource when JS reloaded (native modules stay) and thus JS side of the SDK reinitialized.\n NATIVE.disableNativeFramesTracking();\n return undefined;\n }\n\n return nativeFramesIntegration();\n};\n\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions\n * and frame data (frames.total, frames.slow, frames.frozen) onto all spans.\n */\nexport const nativeFramesIntegration = (): Integration => {\n /** The native frames at the finish time of the most recent child span, keyed by root span ID.\n * Stores promises so the data is available for processEvent to await even before\n * the async native bridge call completes. */\n const _lastChildSpanEndFramesByRootSpan: AsyncExpiringMap<string, NativeFramesResponseWithTimestamp | null> =\n new AsyncExpiringMap({ ttl: START_FRAMES_TIMEOUT_MS });\n const _spanToNativeFramesAtStartMap: AsyncExpiringMap<string, NativeFramesResponse | null> = new AsyncExpiringMap({\n ttl: START_FRAMES_TIMEOUT_MS,\n });\n const _spanToNativeFramesAtEndMap: AsyncExpiringMap<string, NativeFramesResponseWithTimestamp | null> =\n new AsyncExpiringMap({ ttl: END_FRAMES_TIMEOUT_MS });\n\n /**\n * Hooks into the client start and end span events.\n */\n const setup = (client: Client): void => {\n if (!NATIVE.enableNative) {\n debug.warn(\n `[${INTEGRATION_NAME}] This is not available on the Web, Expo Go and other platforms without native modules.`,\n );\n return undefined;\n }\n\n NATIVE.enableNativeFramesTracking();\n client.on('spanStart', fetchStartFramesForSpan);\n client.on('spanEnd', fetchEndFramesForSpan);\n };\n\n const fetchStartFramesForSpan = (span: Span): void => {\n const spanId = span.spanContext().spanId;\n const spanType = isRootSpan(span) ? 'root' : 'child';\n debug.log(`[${INTEGRATION_NAME}] Fetching frames for ${spanType} span start (${spanId}).`);\n\n _spanToNativeFramesAtStartMap.set(\n spanId,\n new Promise<NativeFramesResponse | null>(resolve => {\n fetchNativeFrames()\n .then(frames => resolve(frames))\n .then(undefined, error => {\n debug.log(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n };\n\n /**\n * Fetches end frames for a span and attaches frame data as span attributes.\n *\n * Note: This makes one native bridge call per span end. While this creates O(n) calls\n * for n spans, it's necessary for accuracy. Frame counts are cumulative and continuously\n * incrementing, so each span needs the exact frame count at its end time. Caching would\n * produce incorrect deltas. The native bridge calls are async and non-blocking.\n */\n const fetchEndFramesForSpan = async (span: Span): Promise<void> => {\n const spanId = span.spanContext().spanId;\n const hasStartFrames = _spanToNativeFramesAtStartMap.has(spanId);\n\n if (!hasStartFrames) {\n // We don't have start frames, won't be able to calculate the difference.\n return;\n }\n\n // For child spans: immediately store a promise for fallback end frames before any awaits,\n // so processEvent can find and await it even if this async function hasn't completed yet.\n // Uses the actual span timestamp (not wall-clock time) so it matches the trimmed event.timestamp\n // for idle transactions. Scoped per root span to avoid concurrent transaction interference.\n let childEndFramesPromise: Promise<NativeFramesResponse> | undefined;\n if (!isRootSpan(span)) {\n const rootSpanId = getRootSpan(span).spanContext().spanId;\n const spanTimestamp = spanToJSON(span).timestamp;\n if (spanTimestamp) {\n childEndFramesPromise = fetchNativeFrames();\n _lastChildSpanEndFramesByRootSpan.set(\n rootSpanId,\n childEndFramesPromise\n .then(frames => ({ timestamp: spanTimestamp, nativeFrames: frames }))\n .then(undefined, () => null),\n );\n }\n }\n\n if (isRootSpan(span)) {\n // Root spans: Store end frames for transaction measurements (backward compatibility)\n const timestamp = timestampInSeconds();\n debug.log(`[${INTEGRATION_NAME}] Fetch frames for root span end (${spanId}).`);\n _spanToNativeFramesAtEndMap.set(\n spanId,\n new Promise<NativeFramesResponseWithTimestamp | null>(resolve => {\n fetchNativeFrames()\n .then(frames => {\n resolve({\n timestamp,\n nativeFrames: frames,\n });\n })\n .then(undefined, error => {\n debug.log(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n }\n\n // All spans (root and child): Attach frame data as span attributes\n try {\n const startFrames = await _spanToNativeFramesAtStartMap.get(spanId);\n if (!startFrames) {\n debug.log(`[${INTEGRATION_NAME}] No start frames found for span ${spanId}, skipping frame data.`);\n return;\n }\n\n // For child spans, reuse the already-kicked-off promise to avoid a redundant native bridge call.\n // For root spans, this is the second call to fetchNativeFrames() for the same span.\n // The calls are very close together (microseconds apart), so inconsistency is minimal.\n const endFrames = childEndFramesPromise ? await childEndFramesPromise : await fetchNativeFrames();\n\n // Calculate deltas\n const totalFrames = endFrames.totalFrames - startFrames.totalFrames;\n const slowFrames = endFrames.slowFrames - startFrames.slowFrames;\n const frozenFrames = endFrames.frozenFrames - startFrames.frozenFrames;\n\n // Only attach if we have meaningful data\n if (totalFrames > 0 || slowFrames > 0 || frozenFrames > 0) {\n span.setAttribute('frames.total', totalFrames);\n span.setAttribute('frames.slow', slowFrames);\n span.setAttribute('frames.frozen', frozenFrames);\n debug.log(\n `[${INTEGRATION_NAME}] Attached frame data to span ${spanId}: total=${totalFrames}, slow=${slowFrames}, frozen=${frozenFrames}`,\n );\n }\n } catch (error) {\n debug.log(`[${INTEGRATION_NAME}] Error while capturing end frames for span ${spanId}.`, error);\n }\n };\n\n const processEvent = async (event: Event): Promise<Event> => {\n if (\n event.type !== 'transaction' ||\n !event.transaction ||\n !event.contexts?.trace ||\n !event.timestamp ||\n !event.contexts.trace.span_id\n ) {\n return event;\n }\n\n const traceOp = event.contexts.trace.op;\n const spanId = event.contexts.trace.span_id;\n const startFrames = await _spanToNativeFramesAtStartMap.pop(spanId);\n if (!startFrames) {\n debug.warn(\n `[${INTEGRATION_NAME}] Start frames of transaction ${event.transaction} (eventId, ${event.event_id}) are missing, but the transaction already ended.`,\n );\n return event;\n }\n\n const endFrames = await _spanToNativeFramesAtEndMap.pop(spanId);\n const lastChildFrames = await _lastChildSpanEndFramesByRootSpan.pop(spanId);\n let finalEndFrames: NativeFramesResponse | undefined;\n\n if (endFrames && isClose(endFrames.timestamp, event.timestamp)) {\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n debug.log(`[${INTEGRATION_NAME}] Using frames from root span end (spanId, ${spanId}).`);\n finalEndFrames = endFrames.nativeFrames;\n } else if (lastChildFrames && isClose(lastChildFrames.timestamp, event.timestamp)) {\n // Fallback to the last child span finish if it is within the margin of error of the actual finish timestamp.\n // This handles idle transactions where event.timestamp is trimmed to the last child span's end time.\n debug.log(`[${INTEGRATION_NAME}] Using native frames from last child span end (spanId, ${spanId}).`);\n finalEndFrames = lastChildFrames.nativeFrames;\n } else {\n debug.warn(\n `[${INTEGRATION_NAME}] Frames were collected within larger than margin of error delay for spanId (${spanId}). Dropping the inaccurate values.`,\n );\n return event;\n }\n\n const measurements = {\n frames_total: {\n value: finalEndFrames.totalFrames - startFrames.totalFrames,\n unit: 'none',\n },\n frames_frozen: {\n value: finalEndFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none',\n },\n frames_slow: {\n value: finalEndFrames.slowFrames - startFrames.slowFrames,\n unit: 'none',\n },\n };\n\n if (\n measurements.frames_frozen.value <= 0 &&\n measurements.frames_slow.value <= 0 &&\n measurements.frames_total.value <= 0\n ) {\n debug.warn(\n `[${INTEGRATION_NAME}] Detected zero slow or frozen frames. Not adding measurements to spanId (${spanId}).`,\n );\n return event;\n }\n\n debug.log(\n `[${INTEGRATION_NAME}] Adding measurements to ${traceOp} transaction ${event.transaction}: ${JSON.stringify(\n measurements,\n undefined,\n 2,\n )}`,\n );\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n return event;\n };\n\n return {\n name: INTEGRATION_NAME,\n setup,\n processEvent,\n };\n};\n\nfunction fetchNativeFrames(): Promise<NativeFramesResponse> {\n return new Promise<NativeFramesResponse>((resolve, reject) => {\n let settled = false;\n\n const timeoutId = setTimeout(() => {\n if (!settled) {\n settled = true;\n reject('Fetching native frames took too long. Dropping frames.');\n }\n }, FETCH_FRAMES_TIMEOUT_MS);\n\n NATIVE.fetchNativeFrames()\n .then(value => {\n if (settled) {\n return;\n }\n clearTimeout(timeoutId);\n settled = true;\n\n if (!value) {\n reject('Native frames response is null.');\n return;\n }\n resolve(value);\n })\n .then(undefined, error => {\n if (settled) {\n return;\n }\n clearTimeout(timeoutId);\n settled = true;\n reject(error);\n });\n });\n}\n\nfunction isClose(t1: number, t2: number): boolean {\n return Math.abs(t1 - t2) < MARGIN_OF_ERROR_SECONDS;\n}\n"]}
1
+ {"version":3,"file":"nativeFrames.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/nativeFrames.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAIjG,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAEvC;;GAEG;AACH,MAAM,uBAAuB,GAAG,IAAK,CAAC;AAEtC;;;;GAIG;AACH,MAAM,qBAAqB,GAAG,IAAK,CAAC;AAEpC;;;;GAIG;AACH,MAAM,uBAAuB,GAAG,KAAM,CAAC;AAEvC;;;GAGG;AACH,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC,MAAM,gBAAgB,GAAG,cAAc,CAAC;AAaxC,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,MAA2B,EAA2B,EAAE;IACrG,IAAI,CAAC,MAAM,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;QACnC,0HAA0H;QAC1H,MAAM,CAAC,2BAA2B,EAAE,CAAC;QACrC,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,OAAO,uBAAuB,E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AE;aACvB,IAAI,CAAC,KAAK,CAAC,EAAE;YACZ,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;YACT,CAAC;YACD,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,OAAO,GAAG,IAAI,CAAC;YAEf,IAAI,CAAC,KAAK,EAAE,CAAC;gBACX,MAAM,CAAC,iCAAiC,CAAC,CAAC;gBAC1C,OAAO;YACT,CAAC;YACD,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,CAAC;aACD,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,EAAE;YACvB,IAAI,OAAO,EAAE,CAAC;gBACZ,OAAO;YACT,CAAC;YACD,YAAY,CAAC,SAAS,CAAC,CAAC;YACxB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,CAAC;QAChB,CAAC,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAS,sBAAsB,CAAC,qBAA6B,EAAE,mBAA2B;IACxF,OAAO,uBAAuB,CAC5B,MAAM,CAAC,sBAAsB,CAAC,qBAAqB,EAAE,mBAAmB,CAAC,EACzE,6CAA6C,CAC9C,CAAC;AACJ,CAAC;AAED,SAAS,OAAO,CAAC,EAAU,EAAE,EAAU;IACrC,OAAO,IAAI,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,GAAG,uBAAuB,CAAC;AACrD,CAAC","sourcesContent":["import type { Client, Event, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\n\nimport { debug, getRootSpan, spanIsSampled, spanToJSON, timestampInSeconds } from '@sentry/core';\n\nimport type { NativeFramesResponse } from '../../NativeRNSentry';\n\nimport { AsyncExpiringMap } from '../../utils/AsyncExpiringMap';\nimport { isRootSpan } from '../../utils/span';\nimport { NATIVE } from '../../wrapper';\n\n/**\n * Timeout from the start of a span to fetching the associated native frames.\n */\nconst FETCH_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time end frames data from the native layer will be\n * kept in memory and waiting for the event processing. This ensures that spans\n * which are never processed are not leaking memory.\n */\nconst END_FRAMES_TIMEOUT_MS = 2_000;\n\n/**\n * This is the time start frames data from the native layer will be\n * kept in memory and waiting for span end. This ensures that spans\n * which never end or are not processed are not leaking memory.\n */\nconst START_FRAMES_TIMEOUT_MS = 60_000;\n\n/**\n * A margin of error of 50ms is allowed for the async native bridge call.\n * Anything larger would reduce the accuracy of our frames measurements.\n */\nconst MARGIN_OF_ERROR_SECONDS = 0.05;\n\nconst INTEGRATION_NAME = 'NativeFrames';\n\nexport interface FramesMeasurements extends Measurements {\n frames_total: { value: number; unit: MeasurementUnit };\n frames_slow: { value: number; unit: MeasurementUnit };\n frames_frozen: { value: number; unit: MeasurementUnit };\n}\n\ninterface NativeFramesResponseWithTimestamp {\n timestamp: number;\n nativeFrames: NativeFramesResponse;\n}\n\nexport const createNativeFramesIntegrations = (enable: boolean | undefined): Integration | undefined => {\n if (!enable && NATIVE.enableNative) {\n // On Android this will free up resource when JS reloaded (native modules stay) and thus JS side of the SDK reinitialized.\n NATIVE.disableNativeFramesTracking();\n return undefined;\n }\n\n return nativeFramesIntegration();\n};\n\n/**\n * Instrumentation to add native slow/frozen frames measurements onto transactions\n * and frame data (frames.total, frames.slow, frames.frozen) onto all spans.\n */\nexport const nativeFramesIntegration = (): Integration => {\n /** The native frames at the finish time of the most recent child span, keyed by root span ID.\n * Stores promises so the data is available for processEvent to await even before\n * the async native bridge call completes. */\n const _lastChildSpanEndFramesByRootSpan: AsyncExpiringMap<string, NativeFramesResponseWithTimestamp | null> =\n new AsyncExpiringMap({ ttl: START_FRAMES_TIMEOUT_MS });\n const _spanToNativeFramesAtStartMap: AsyncExpiringMap<string, NativeFramesResponse | null> = new AsyncExpiringMap({\n ttl: START_FRAMES_TIMEOUT_MS,\n });\n const _spanToNativeFramesAtEndMap: AsyncExpiringMap<string, NativeFramesResponseWithTimestamp | null> =\n new AsyncExpiringMap({ ttl: END_FRAMES_TIMEOUT_MS });\n\n /**\n * Hooks into the client start and end span events.\n */\n const setup = (client: Client): void => {\n if (!NATIVE.enableNative) {\n debug.warn(\n `[${INTEGRATION_NAME}] This is not available on the Web, Expo Go and other platforms without native modules.`,\n );\n return undefined;\n }\n\n NATIVE.enableNativeFramesTracking();\n client.on('spanStart', fetchStartFramesForSpan);\n client.on('spanEnd', fetchEndFramesForSpan);\n };\n\n const fetchStartFramesForSpan = (span: Span): void => {\n if (!spanIsSampled(span)) {\n return;\n }\n\n const spanId = span.spanContext().spanId;\n const spanType = isRootSpan(span) ? 'root' : 'child';\n debug.log(`[${INTEGRATION_NAME}] Fetching frames for ${spanType} span start (${spanId}).`);\n\n _spanToNativeFramesAtStartMap.set(\n spanId,\n new Promise<NativeFramesResponse | null>(resolve => {\n fetchNativeFrames()\n .then(frames => resolve(frames))\n .then(undefined, error => {\n debug.log(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n };\n\n /**\n * Fetches end frames for a span and attaches frame data as span attributes.\n *\n * Note: This makes one native bridge call per span end. While this creates O(n) calls\n * for n spans, it's necessary for accuracy. Frame counts are cumulative and continuously\n * incrementing, so each span needs the exact frame count at its end time. Caching would\n * produce incorrect deltas. The native bridge calls are async and non-blocking.\n */\n const fetchEndFramesForSpan = async (span: Span): Promise<void> => {\n const spanId = span.spanContext().spanId;\n const hasStartFrames = _spanToNativeFramesAtStartMap.has(spanId);\n\n if (!hasStartFrames) {\n // We don't have start frames, won't be able to calculate the difference.\n return;\n }\n\n // For child spans: immediately store a promise for fallback end frames before any awaits,\n // so processEvent can find and await it even if this async function hasn't completed yet.\n // Uses the actual span timestamp (not wall-clock time) so it matches the trimmed event.timestamp\n // for idle transactions. Scoped per root span to avoid concurrent transaction interference.\n let childEndFramesPromise: Promise<NativeFramesResponse> | undefined;\n if (!isRootSpan(span)) {\n const rootSpanId = getRootSpan(span).spanContext().spanId;\n const spanTimestamp = spanToJSON(span).timestamp;\n if (spanTimestamp) {\n childEndFramesPromise = fetchNativeFrames();\n _lastChildSpanEndFramesByRootSpan.set(\n rootSpanId,\n childEndFramesPromise\n .then(frames => ({ timestamp: spanTimestamp, nativeFrames: frames }))\n .then(undefined, () => null),\n );\n }\n }\n\n if (isRootSpan(span)) {\n // Root spans: Store end frames for transaction measurements (backward compatibility)\n const timestamp = timestampInSeconds();\n debug.log(`[${INTEGRATION_NAME}] Fetch frames for root span end (${spanId}).`);\n _spanToNativeFramesAtEndMap.set(\n spanId,\n new Promise<NativeFramesResponseWithTimestamp | null>(resolve => {\n fetchNativeFrames()\n .then(frames => {\n resolve({\n timestamp,\n nativeFrames: frames,\n });\n })\n .then(undefined, error => {\n debug.log(`[${INTEGRATION_NAME}] Error while fetching native frames.`, error);\n resolve(null);\n });\n }),\n );\n }\n\n // All spans (root and child): Attach frame data as span attributes\n try {\n const startFrames = await _spanToNativeFramesAtStartMap.get(spanId);\n if (!startFrames) {\n debug.log(`[${INTEGRATION_NAME}] No start frames found for span ${spanId}, skipping frame data.`);\n return;\n }\n\n // For child spans, reuse the already-kicked-off promise to avoid a redundant native bridge call.\n // For root spans, this is the second call to fetchNativeFrames() for the same span.\n // The calls are very close together (microseconds apart), so inconsistency is minimal.\n const endFrames = childEndFramesPromise ? await childEndFramesPromise : await fetchNativeFrames();\n\n // Calculate deltas\n const totalFrames = endFrames.totalFrames - startFrames.totalFrames;\n const slowFrames = endFrames.slowFrames - startFrames.slowFrames;\n const frozenFrames = endFrames.frozenFrames - startFrames.frozenFrames;\n\n // Only attach if we have meaningful data\n if (totalFrames > 0 || slowFrames > 0 || frozenFrames > 0) {\n span.setAttribute('frames.total', totalFrames);\n span.setAttribute('frames.slow', slowFrames);\n span.setAttribute('frames.frozen', frozenFrames);\n debug.log(\n `[${INTEGRATION_NAME}] Attached frame data to span ${spanId}: total=${totalFrames}, slow=${slowFrames}, frozen=${frozenFrames}`,\n );\n\n const spanJson = spanToJSON(span);\n if (spanJson.start_timestamp && spanJson.timestamp) {\n try {\n const delay = await fetchNativeFramesDelay(spanJson.start_timestamp, spanJson.timestamp);\n if (delay != null) {\n span.setAttribute('frames.delay', delay);\n }\n } catch (delayError) {\n debug.log(`[${INTEGRATION_NAME}] Error while fetching frames delay for span ${spanId}.`, delayError);\n }\n }\n }\n } catch (error) {\n debug.log(`[${INTEGRATION_NAME}] Error while capturing end frames for span ${spanId}.`, error);\n }\n };\n\n const processEvent = async (event: Event): Promise<Event> => {\n if (\n event.type !== 'transaction' ||\n !event.transaction ||\n !event.contexts?.trace ||\n !event.timestamp ||\n !event.contexts.trace.span_id\n ) {\n return event;\n }\n\n const traceOp = event.contexts.trace.op;\n const spanId = event.contexts.trace.span_id;\n const startFrames = await _spanToNativeFramesAtStartMap.pop(spanId);\n if (!startFrames) {\n debug.warn(\n `[${INTEGRATION_NAME}] Start frames of transaction ${event.transaction} (eventId, ${event.event_id}) are missing, but the transaction already ended.`,\n );\n return event;\n }\n\n const endFrames = await _spanToNativeFramesAtEndMap.pop(spanId);\n const lastChildFrames = await _lastChildSpanEndFramesByRootSpan.pop(spanId);\n let finalEndFrames: NativeFramesResponse | undefined;\n\n if (endFrames && isClose(endFrames.timestamp, event.timestamp)) {\n // Must be in the margin of error of the actual transaction finish time (finalEndTimestamp)\n debug.log(`[${INTEGRATION_NAME}] Using frames from root span end (spanId, ${spanId}).`);\n finalEndFrames = endFrames.nativeFrames;\n } else if (lastChildFrames && isClose(lastChildFrames.timestamp, event.timestamp)) {\n // Fallback to the last child span finish if it is within the margin of error of the actual finish timestamp.\n // This handles idle transactions where event.timestamp is trimmed to the last child span's end time.\n debug.log(`[${INTEGRATION_NAME}] Using native frames from last child span end (spanId, ${spanId}).`);\n finalEndFrames = lastChildFrames.nativeFrames;\n } else {\n debug.warn(\n `[${INTEGRATION_NAME}] Frames were collected within larger than margin of error delay for spanId (${spanId}). Dropping the inaccurate values.`,\n );\n return event;\n }\n\n const measurements = {\n frames_total: {\n value: finalEndFrames.totalFrames - startFrames.totalFrames,\n unit: 'none',\n },\n frames_frozen: {\n value: finalEndFrames.frozenFrames - startFrames.frozenFrames,\n unit: 'none',\n },\n frames_slow: {\n value: finalEndFrames.slowFrames - startFrames.slowFrames,\n unit: 'none',\n },\n };\n\n if (\n measurements.frames_frozen.value <= 0 &&\n measurements.frames_slow.value <= 0 &&\n measurements.frames_total.value <= 0\n ) {\n debug.warn(\n `[${INTEGRATION_NAME}] Detected zero slow or frozen frames. Not adding measurements to spanId (${spanId}).`,\n );\n return event;\n }\n\n debug.log(\n `[${INTEGRATION_NAME}] Adding measurements to ${traceOp} transaction ${event.transaction}: ${JSON.stringify(\n measurements,\n undefined,\n 2,\n )}`,\n );\n event.measurements = {\n ...(event.measurements ?? {}),\n ...measurements,\n };\n return event;\n };\n\n return {\n name: INTEGRATION_NAME,\n setup,\n processEvent,\n };\n};\n\nfunction withNativeBridgeTimeout<T>(promise: PromiseLike<T>, timeoutMessage: string): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n let settled = false;\n\n const timeoutId = setTimeout(() => {\n if (!settled) {\n settled = true;\n reject(timeoutMessage);\n }\n }, FETCH_FRAMES_TIMEOUT_MS);\n\n promise\n .then(value => {\n if (settled) {\n return;\n }\n clearTimeout(timeoutId);\n settled = true;\n resolve(value);\n })\n .then(undefined, error => {\n if (settled) {\n return;\n }\n clearTimeout(timeoutId);\n settled = true;\n reject(error);\n });\n });\n}\n\nfunction fetchNativeFrames(): Promise<NativeFramesResponse> {\n return new Promise<NativeFramesResponse>((resolve, reject) => {\n let settled = false;\n\n const timeoutId = setTimeout(() => {\n if (!settled) {\n settled = true;\n reject('Fetching native frames took too long. Dropping frames.');\n }\n }, FETCH_FRAMES_TIMEOUT_MS);\n\n NATIVE.fetchNativeFrames()\n .then(value => {\n if (settled) {\n return;\n }\n clearTimeout(timeoutId);\n settled = true;\n\n if (!value) {\n reject('Native frames response is null.');\n return;\n }\n resolve(value);\n })\n .then(undefined, error => {\n if (settled) {\n return;\n }\n clearTimeout(timeoutId);\n settled = true;\n reject(error);\n });\n });\n}\n\nfunction fetchNativeFramesDelay(startTimestampSeconds: number, endTimestampSeconds: number): Promise<number | null> {\n return withNativeBridgeTimeout(\n NATIVE.fetchNativeFramesDelay(startTimestampSeconds, endTimestampSeconds),\n 'Fetching native frames delay took too long.',\n );\n}\n\nfunction isClose(t1: number, t2: number): boolean {\n return Math.abs(t1 - t2) < MARGIN_OF_ERROR_SECONDS;\n}\n"]}
@@ -26,6 +26,6 @@ export declare const stallTrackingIntegration: ({ minimumStallThresholdMs, }?: {
26
26
  * How long in milliseconds an event loop iteration can be delayed for before being considered a "stall."
27
27
  * @default 50
28
28
  */
29
- minimumStallThresholdMs?: number | undefined;
29
+ minimumStallThresholdMs?: number;
30
30
  }) => Integration;
31
31
  //# sourceMappingURL=stalltracking.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stalltracking.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAU,WAAW,EAAE,YAAY,EAAE,eAAe,EAAQ,MAAM,cAAc,CAAC;AAI7F,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMvF,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,CAAC,WAAW,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACxD,CAAC,gBAAgB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IAC7D,CAAC,kBAAkB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;CAChE;AASD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB;IAGnC;;;OAGG;;MAEI,WA0TR,CAAC"}
1
+ {"version":3,"file":"stalltracking.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAU,WAAW,EAAE,YAAY,EAAE,eAAe,EAAQ,MAAM,cAAc,CAAC;AAM7F,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMvF,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,CAAC,WAAW,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IACxD,CAAC,gBAAgB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;IAC7D,CAAC,kBAAkB,CAAC,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,eAAe,CAAA;KAAE,CAAC;CAChE;AASD;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,+BAEtC;IACD;;;OAGG;IACH,uBAAuB,CAAC,EAAE,MAAM,CAAC;CAC7B,KAAG,WA6TR,CAAC"}
@@ -1,4 +1,4 @@
1
- import { debug, getRootSpan, spanToJSON, timestampInSeconds } from '@sentry/core';
1
+ import { debug, getRootSpan, spanIsSampled, spanToJSON, timestampInSeconds } from '@sentry/core';
2
2
  import { AppState } from 'react-native';
3
3
  import { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../../measurements';
4
4
  import { isRootSpan } from '../../utils/span';
@@ -66,6 +66,9 @@ export const stallTrackingIntegration = ({ minimumStallThresholdMs = 50, } = {})
66
66
  if (!isRootSpan(rootSpan)) {
67
67
  return;
68
68
  }
69
+ if (!spanIsSampled(rootSpan)) {
70
+ return;
71
+ }
69
72
  if (statsByRootSpan.has(rootSpan)) {
70
73
  debug.error('[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.');
71
74
  return;
@@ -221,7 +224,6 @@ export const stallTrackingIntegration = ({ minimumStallThresholdMs = 50, } = {})
221
224
  };
222
225
  // Avoids throwing any error if using React Native on a environment that doesn't implement AppState.
223
226
  if (AppState === null || AppState === void 0 ? void 0 : AppState.isAvailable) {
224
- // eslint-disable-next-line @typescript-eslint/unbound-method
225
227
  AppState.addEventListener('change', state.backgroundEventListener);
226
228
  }
227
229
  return {
@@ -1 +1 @@
1
- {"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3F,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAQzC,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,wEAAwE;AACxE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,qIAAqI;AACrI,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,uBAAuB,GAAG,EAAE,MAO1B,EAAE,EAAe,EAAE;IACrB,MAAM,eAAe,GAUjB,IAAI,GAAG,EAAE,CAAC;IAEd,MAAM,KAAK,GAiBP;QACF,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,IAAI;QACb,YAAY,EAAE,KAAK;QACnB,cAAc,EAAE,CAAC;QACjB,cAAc,EAAE,CAAC;QACjB,UAAU,EAAE,CAAC;QACb,uBAAuB,EAAE,CAAC,QAAwB,EAAQ,E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wB,GAAG,GAAS,EAAE;QAC1C,IAAI,eAAe,CAAC,IAAI,GAAG,wBAAwB,EAAE;YACnD,IAAI,OAAO,GAAG,CAAC,CAAC;YAChB,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,GAAG,wBAAwB,CAAC;YAC5D,MAAM,YAAY,GAAG,eAAe,CAAC,IAAI,EAAE,CAAC;YAC5C,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;gBAC5B,IAAI,OAAO,IAAI,GAAG;oBAAE,MAAM;gBAC1B,OAAO,IAAI,CAAC,CAAC;gBACb,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aAC3B;SACF;IACH,CAAC,CAAC;IAEF,oGAAoG;IACpG,IAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,WAAW,EAAE;QACzB,6DAA6D;QAC7D,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,KAAK,CAAC,uBAAuB,CAAC,CAAC;KACpE;IAED,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,KAAK;QAEL,gCAAgC;QAChC,cAAc,EAAE,KAAK;KACP,CAAC;AACnB,CAAC,CAAC","sourcesContent":["/* eslint-disable max-lines */\nimport type { Client, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\nimport { debug, getRootSpan, spanToJSON, timestampInSeconds } from '@sentry/core';\nimport type { AppStateStatus } from 'react-native';\nimport { AppState } from 'react-native';\nimport { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../../measurements';\nimport { isRootSpan } from '../../utils/span';\nimport { getLatestChildSpanEndTimestamp, isNearToNow, setSpanMeasurement } from '../utils';\n\nconst INTEGRATION_NAME = 'StallTracking';\n\nexport interface StallMeasurements extends Measurements {\n [STALL_COUNT]: { value: number; unit: MeasurementUnit };\n [STALL_TOTAL_TIME]: { value: number; unit: MeasurementUnit };\n [STALL_LONGEST_TIME]: { value: number; unit: MeasurementUnit };\n}\n\n/** Margin of error of 20ms */\nconst MARGIN_OF_ERROR_SECONDS = 0.02;\n/** How long between each iteration in the event loop tracker timeout */\nconst LOOP_TIMEOUT_INTERVAL_MS = 50;\n/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */\nconst MAX_RUNNING_TRANSACTIONS = 10;\n\n/**\n * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:\n * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js\n *\n * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.\n * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`\n */\nexport const stallTrackingIntegration = ({\n minimumStallThresholdMs = 50,\n}: {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 50\n */\n minimumStallThresholdMs?: number;\n} = {}): Integration => {\n const statsByRootSpan: Map<\n Span,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n const state: {\n isTracking: boolean;\n timeout: ReturnType<typeof setTimeout> | null;\n isBackground: boolean;\n /** Switch that enables the iteration once app moves from background to foreground. */\n backgroundEventListener: (appState: AppStateStatus) => void;\n /** The last timestamp the iteration ran in milliseconds */\n lastIntervalMs: number;\n /** Total amount of time of all stalls that occurred during the current tracking session */\n totalStallTime: number;\n /** Total number of stalls that occurred during the current tracking session */\n stallCount: number;\n /**\n * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how\n * long the stall is for.\n */\n iteration: () => void;\n } = {\n isTracking: false,\n timeout: null,\n isBackground: false,\n lastIntervalMs: 0,\n totalStallTime: 0,\n stallCount: 0,\n backgroundEventListener: (appState: AppStateStatus): void => {\n if (appState === ('active' as AppStateStatus)) {\n state.isBackground = false;\n if (state.timeout != null) {\n state.lastIntervalMs = timestampInSeconds() * 1000;\n state.iteration();\n }\n } else {\n state.isBackground = true;\n state.timeout !== null && clearTimeout(state.timeout);\n }\n },\n iteration: (): void => {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - state.lastIntervalMs;\n\n if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + minimumStallThresholdMs) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n state.stallCount += 1;\n state.totalStallTime += stallTime;\n\n for (const [transaction, value] of statsByRootSpan.entries()) {\n const longestStallTime = Math.max(value.longestStallTime ?? 0, stallTime);\n\n statsByRootSpan.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n state.lastIntervalMs = now;\n\n if (state.isTracking && !state.isBackground) {\n state.timeout = setTimeout(state.iteration, LOOP_TIMEOUT_INTERVAL_MS);\n }\n },\n };\n\n const setup = (client: Client): void => {\n client.on('spanStart', _onSpanStart);\n client.on('spanEnd', _onSpanEnd);\n };\n\n const _onSpanStart = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n if (statsByRootSpan.has(rootSpan)) {\n debug.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.',\n );\n return;\n }\n\n _startTracking();\n statsByRootSpan.set(rootSpan, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: _getCurrentStats(rootSpan),\n });\n _flushLeakedTransactions();\n };\n\n const _onSpanEnd = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return _onChildSpanEnd(rootSpan);\n }\n\n const transactionStats = statsByRootSpan.get(rootSpan);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n debug.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n return;\n }\n\n // The endTimestamp is always set, but type-wise it's optional\n // https://github.com/getsentry/sentry-javascript/blob/38bd57b0785c97c413f36f89ff931d927e469078/packages/core/src/tracing/sentrySpan.ts#L170\n const endTimestamp = spanToJSON(rootSpan).timestamp;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (isNearToNow(endTimestamp)) {\n statsOnFinish = _getCurrentStats(rootSpan);\n } else {\n // The idleSpan in JS V8 is always trimmed to the last span's endTimestamp (timestamp).\n // The unfinished child spans are removed from the root span after the `spanEnd` event.\n\n const latestChildSpanEnd = getLatestChildSpanEndTimestamp(rootSpan);\n if (latestChildSpanEnd !== endTimestamp) {\n debug.log(\n '[StallTracking] Stall measurements not added due to a custom `endTimestamp` (root end is not equal to the latest child span end).',\n );\n }\n\n if (!transactionStats.atTimestamp) {\n debug.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now. And no previous stats from child end were found.',\n );\n }\n\n if (latestChildSpanEnd === endTimestamp && transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n }\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n debug.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now.',\n 'endTimestamp',\n endTimestamp,\n 'now',\n timestampInSeconds(),\n );\n }\n\n return;\n }\n\n setSpanMeasurement(\n rootSpan,\n STALL_COUNT,\n statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_TOTAL_TIME,\n statsOnFinish.stall_total_time.value - transactionStats.atStart.stall_total_time.value,\n transactionStats.atStart.stall_total_time.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_LONGEST_TIME,\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit,\n );\n };\n\n const _onChildSpanEnd = (childSpan: Span): void => {\n const rootSpan = getRootSpan(childSpan);\n\n const finalEndTimestamp = spanToJSON(childSpan).timestamp;\n if (finalEndTimestamp) {\n _markSpanFinish(rootSpan, finalEndTimestamp);\n }\n };\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n const _markSpanFinish = (rootSpan: Span, childSpanEndTime: number): void => {\n const previousStats = statsByRootSpan.get(rootSpan);\n if (previousStats) {\n if (Math.abs(timestampInSeconds() - childSpanEndTime) > MARGIN_OF_ERROR_SECONDS) {\n debug.log(\n '[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.',\n );\n\n if (previousStats.atTimestamp && previousStats.atTimestamp.timestamp < childSpanEndTime) {\n // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: {\n timestamp: childSpanEndTime,\n stats: _getCurrentStats(rootSpan),\n },\n });\n }\n }\n };\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n const _getCurrentStats = (span: Span): StallMeasurements => {\n return {\n stall_count: { value: state.stallCount, unit: 'none' },\n stall_total_time: { value: state.totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: statsByRootSpan.get(span)?.longestStallTime ?? 0,\n unit: 'millisecond',\n },\n };\n };\n\n /**\n * Start tracking stalls\n */\n const _startTracking = (): void => {\n if (!state.isTracking) {\n state.isTracking = true;\n state.lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n state.iteration();\n }\n };\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n const _stopTracking = (): void => {\n state.isTracking = false;\n\n if (state.timeout !== null) {\n clearTimeout(state.timeout);\n state.timeout = null;\n }\n\n _reset();\n };\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n const _shouldStopTracking = (): void => {\n if (statsByRootSpan.size === 0) {\n _stopTracking();\n }\n };\n\n /**\n * Clears all the collected stats\n */\n const _reset = (): void => {\n state.stallCount = 0;\n state.totalStallTime = 0;\n state.lastIntervalMs = 0;\n statsByRootSpan.clear();\n };\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n const _flushLeakedTransactions = (): void => {\n if (statsByRootSpan.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = statsByRootSpan.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = statsByRootSpan.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n statsByRootSpan.delete(t);\n }\n }\n };\n\n // Avoids throwing any error if using React Native on a environment that doesn't implement AppState.\n if (AppState?.isAvailable) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n AppState.addEventListener('change', state.backgroundEventListener);\n }\n\n return {\n name: INTEGRATION_NAME,\n setup,\n\n /** For testing only @private */\n _internalState: state,\n } as Integration;\n};\n"]}
1
+ {"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/stalltracking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACjG,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,8BAA8B,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3F,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAQzC,8BAA8B;AAC9B,MAAM,uBAAuB,GAAG,IAAI,CAAC;AACrC,wEAAwE;AACxE,MAAM,wBAAwB,GAAG,EAAE,CAAC;AACpC,qIAAqI;AACrI,MAAM,wBAAwB,GAAG,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,EACvC,uBAAuB,GAAG,EAAE,MAO1B,EAAE,EAAe,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K,CAAC,uBAAuB,CAAC,CAAC;IACrE,CAAC;IAED,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,KAAK;QAEL,gCAAgC;QAChC,cAAc,EAAE,KAAK;KACP,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import type { Client, Integration, Measurements, MeasurementUnit, Span } from '@sentry/core';\nimport type { AppStateStatus } from 'react-native';\n\nimport { debug, getRootSpan, spanIsSampled, spanToJSON, timestampInSeconds } from '@sentry/core';\nimport { AppState } from 'react-native';\n\nimport { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../../measurements';\nimport { isRootSpan } from '../../utils/span';\nimport { getLatestChildSpanEndTimestamp, isNearToNow, setSpanMeasurement } from '../utils';\n\nconst INTEGRATION_NAME = 'StallTracking';\n\nexport interface StallMeasurements extends Measurements {\n [STALL_COUNT]: { value: number; unit: MeasurementUnit };\n [STALL_TOTAL_TIME]: { value: number; unit: MeasurementUnit };\n [STALL_LONGEST_TIME]: { value: number; unit: MeasurementUnit };\n}\n\n/** Margin of error of 20ms */\nconst MARGIN_OF_ERROR_SECONDS = 0.02;\n/** How long between each iteration in the event loop tracker timeout */\nconst LOOP_TIMEOUT_INTERVAL_MS = 50;\n/** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */\nconst MAX_RUNNING_TRANSACTIONS = 10;\n\n/**\n * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:\n * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js\n *\n * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.\n * We then would consider that iteration a stall when the total time for that interval to run is greater than `LOOP_TIMEOUT_INTERVAL_MS + minimumStallThreshold`\n */\nexport const stallTrackingIntegration = ({\n minimumStallThresholdMs = 50,\n}: {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 50\n */\n minimumStallThresholdMs?: number;\n} = {}): Integration => {\n const statsByRootSpan: Map<\n Span,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n const state: {\n isTracking: boolean;\n timeout: ReturnType<typeof setTimeout> | null;\n isBackground: boolean;\n /** Switch that enables the iteration once app moves from background to foreground. */\n backgroundEventListener: (appState: AppStateStatus) => void;\n /** The last timestamp the iteration ran in milliseconds */\n lastIntervalMs: number;\n /** Total amount of time of all stalls that occurred during the current tracking session */\n totalStallTime: number;\n /** Total number of stalls that occurred during the current tracking session */\n stallCount: number;\n /**\n * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how\n * long the stall is for.\n */\n iteration: () => void;\n } = {\n isTracking: false,\n timeout: null,\n isBackground: false,\n lastIntervalMs: 0,\n totalStallTime: 0,\n stallCount: 0,\n backgroundEventListener: (appState: AppStateStatus): void => {\n if (appState === ('active' as AppStateStatus)) {\n state.isBackground = false;\n if (state.timeout != null) {\n state.lastIntervalMs = timestampInSeconds() * 1000;\n state.iteration();\n }\n } else {\n state.isBackground = true;\n state.timeout !== null && clearTimeout(state.timeout);\n }\n },\n iteration: (): void => {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - state.lastIntervalMs;\n\n if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + minimumStallThresholdMs) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n state.stallCount += 1;\n state.totalStallTime += stallTime;\n\n for (const [transaction, value] of statsByRootSpan.entries()) {\n const longestStallTime = Math.max(value.longestStallTime ?? 0, stallTime);\n\n statsByRootSpan.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n state.lastIntervalMs = now;\n\n if (state.isTracking && !state.isBackground) {\n state.timeout = setTimeout(state.iteration, LOOP_TIMEOUT_INTERVAL_MS);\n }\n },\n };\n\n const setup = (client: Client): void => {\n client.on('spanStart', _onSpanStart);\n client.on('spanEnd', _onSpanEnd);\n };\n\n const _onSpanStart = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return;\n }\n\n if (!spanIsSampled(rootSpan)) {\n return;\n }\n\n if (statsByRootSpan.has(rootSpan)) {\n debug.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.',\n );\n return;\n }\n\n _startTracking();\n statsByRootSpan.set(rootSpan, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: _getCurrentStats(rootSpan),\n });\n _flushLeakedTransactions();\n };\n\n const _onSpanEnd = (rootSpan: Span): void => {\n if (!isRootSpan(rootSpan)) {\n return _onChildSpanEnd(rootSpan);\n }\n\n const transactionStats = statsByRootSpan.get(rootSpan);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n debug.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n return;\n }\n\n // The endTimestamp is always set, but type-wise it's optional\n // https://github.com/getsentry/sentry-javascript/blob/38bd57b0785c97c413f36f89ff931d927e469078/packages/core/src/tracing/sentrySpan.ts#L170\n const endTimestamp = spanToJSON(rootSpan).timestamp;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (isNearToNow(endTimestamp)) {\n statsOnFinish = _getCurrentStats(rootSpan);\n } else {\n // The idleSpan in JS V8 is always trimmed to the last span's endTimestamp (timestamp).\n // The unfinished child spans are removed from the root span after the `spanEnd` event.\n\n const latestChildSpanEnd = getLatestChildSpanEndTimestamp(rootSpan);\n if (latestChildSpanEnd !== endTimestamp) {\n debug.log(\n '[StallTracking] Stall measurements not added due to a custom `endTimestamp` (root end is not equal to the latest child span end).',\n );\n }\n\n if (!transactionStats.atTimestamp) {\n debug.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now. And no previous stats from child end were found.',\n );\n }\n\n if (latestChildSpanEnd === endTimestamp && transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n }\n\n statsByRootSpan.delete(rootSpan);\n _shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n debug.log(\n '[StallTracking] Stall measurements not added due to `endTimestamp` not being close to now.',\n 'endTimestamp',\n endTimestamp,\n 'now',\n timestampInSeconds(),\n );\n }\n\n return;\n }\n\n setSpanMeasurement(\n rootSpan,\n STALL_COUNT,\n statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_TOTAL_TIME,\n statsOnFinish.stall_total_time.value - transactionStats.atStart.stall_total_time.value,\n transactionStats.atStart.stall_total_time.unit,\n );\n\n setSpanMeasurement(\n rootSpan,\n STALL_LONGEST_TIME,\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit,\n );\n };\n\n const _onChildSpanEnd = (childSpan: Span): void => {\n const rootSpan = getRootSpan(childSpan);\n\n const finalEndTimestamp = spanToJSON(childSpan).timestamp;\n if (finalEndTimestamp) {\n _markSpanFinish(rootSpan, finalEndTimestamp);\n }\n };\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n const _markSpanFinish = (rootSpan: Span, childSpanEndTime: number): void => {\n const previousStats = statsByRootSpan.get(rootSpan);\n if (previousStats) {\n if (Math.abs(timestampInSeconds() - childSpanEndTime) > MARGIN_OF_ERROR_SECONDS) {\n debug.log(\n '[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.',\n );\n\n if (previousStats.atTimestamp && previousStats.atTimestamp.timestamp < childSpanEndTime) {\n // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n statsByRootSpan.set(rootSpan, {\n ...previousStats,\n atTimestamp: {\n timestamp: childSpanEndTime,\n stats: _getCurrentStats(rootSpan),\n },\n });\n }\n }\n };\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n const _getCurrentStats = (span: Span): StallMeasurements => {\n return {\n stall_count: { value: state.stallCount, unit: 'none' },\n stall_total_time: { value: state.totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: statsByRootSpan.get(span)?.longestStallTime ?? 0,\n unit: 'millisecond',\n },\n };\n };\n\n /**\n * Start tracking stalls\n */\n const _startTracking = (): void => {\n if (!state.isTracking) {\n state.isTracking = true;\n state.lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n state.iteration();\n }\n };\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n const _stopTracking = (): void => {\n state.isTracking = false;\n\n if (state.timeout !== null) {\n clearTimeout(state.timeout);\n state.timeout = null;\n }\n\n _reset();\n };\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n const _shouldStopTracking = (): void => {\n if (statsByRootSpan.size === 0) {\n _stopTracking();\n }\n };\n\n /**\n * Clears all the collected stats\n */\n const _reset = (): void => {\n state.stallCount = 0;\n state.totalStallTime = 0;\n state.lastIntervalMs = 0;\n statsByRootSpan.clear();\n };\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n const _flushLeakedTransactions = (): void => {\n if (statsByRootSpan.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = statsByRootSpan.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = statsByRootSpan.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n statsByRootSpan.delete(t);\n }\n }\n };\n\n // Avoids throwing any error if using React Native on a environment that doesn't implement AppState.\n if (AppState?.isAvailable) {\n AppState.addEventListener('change', state.backgroundEventListener);\n }\n\n return {\n name: INTEGRATION_NAME,\n setup,\n\n /** For testing only @private */\n _internalState: state,\n } as Integration;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"timeToDisplayIntegration.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/timeToDisplayIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAY,MAAM,cAAc,CAAC;AAWjE,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAKhD,eAAO,MAAM,wBAAwB,QAAO,WAyE3C,CAAC"}
1
+ {"version":3,"file":"timeToDisplayIntegration.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/timeToDisplayIntegration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAS,WAAW,EAAY,MAAM,cAAc,CAAC;AAajE,eAAO,MAAM,gBAAgB,kBAAkB,CAAC;AAKhD,eAAO,MAAM,wBAAwB,QAAO,WAyE3C,CAAC"}
@@ -28,7 +28,7 @@ export const timeToDisplayIntegration = () => {
28
28
  enableTimeToInitialDisplayForPreloadedRoutes =
29
29
  (_b = (_a = getReactNavigationIntegration(client)) === null || _a === void 0 ? void 0 : _a.options.enableTimeToInitialDisplayForPreloadedRoutes) !== null && _b !== void 0 ? _b : false;
30
30
  },
31
- // eslint-disable-next-line complexity
31
+ // oxlint-disable-next-line eslint(complexity)
32
32
  processEvent: (event) => __awaiter(void 0, void 0, void 0, function* () {
33
33
  var _a, _b, _c, _d, _e;
34
34
  if (event.type !== 'transaction') {
@@ -83,12 +83,12 @@ export const timeToDisplayIntegration = () => {
83
83
  }),
84
84
  };
85
85
  };
86
- function addTimeToInitialDisplay({ event, rootSpanId, transactionStartTimestampSeconds, enableTimeToInitialDisplayForPreloadedRoutes, }) {
87
- var _a;
88
- return __awaiter(this, void 0, void 0, function* () {
86
+ function addTimeToInitialDisplay(_a) {
87
+ return __awaiter(this, arguments, void 0, function* ({ event, rootSpanId, transactionStartTimestampSeconds, enableTimeToInitialDisplayForPreloadedRoutes, }) {
88
+ var _b;
89
89
  const ttidEndTimestampSeconds = yield NATIVE.popTimeToDisplayFor(`ttid-${rootSpanId}`);
90
90
  event.spans = event.spans || [];
91
- let ttidSpan = (_a = event.spans) === null || _a === void 0 ? void 0 : _a.find(span => span.op === UI_LOAD_INITIAL_DISPLAY);
91
+ let ttidSpan = (_b = event.spans) === null || _b === void 0 ? void 0 : _b.find(span => span.op === UI_LOAD_INITIAL_DISPLAY);
92
92
  if (ttidSpan && (ttidSpan.status === undefined || ttidSpan.status === 'ok') && !ttidEndTimestampSeconds) {
93
93
  debug.log(`[${INTEGRATION_NAME}] Ttid span already exists and is ok.`, ttidSpan);
94
94
  return ttidSpan;
@@ -124,12 +124,12 @@ function addTimeToInitialDisplay({ event, rootSpanId, transactionStartTimestampS
124
124
  return ttidSpan;
125
125
  });
126
126
  }
127
- function addAutomaticTimeToInitialDisplay({ event, rootSpanId, transactionStartTimestampSeconds, enableTimeToInitialDisplayForPreloadedRoutes, }) {
128
- var _a, _b, _c, _d, _e, _f;
129
- return __awaiter(this, void 0, void 0, function* () {
127
+ function addAutomaticTimeToInitialDisplay(_a) {
128
+ return __awaiter(this, arguments, void 0, function* ({ event, rootSpanId, transactionStartTimestampSeconds, enableTimeToInitialDisplayForPreloadedRoutes, }) {
129
+ var _b, _c, _d, _e, _f, _g;
130
130
  const ttidNativeTimestampSeconds = yield NATIVE.popTimeToDisplayFor(`ttid-navigation-${rootSpanId}`);
131
131
  const ttidFallbackTimestampSeconds = yield getTimeToInitialDisplayFallback(rootSpanId);
132
- const hasBeenSeen = (_c = (_b = (_a = event.contexts) === null || _a === void 0 ? void 0 : _a.trace) === null || _b === void 0 ? void 0 : _b.data) === null || _c === void 0 ? void 0 : _c[SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN];
132
+ const hasBeenSeen = (_d = (_c = (_b = event.contexts) === null || _b === void 0 ? void 0 : _b.trace) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d[SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN];
133
133
  if (hasBeenSeen && !enableTimeToInitialDisplayForPreloadedRoutes) {
134
134
  debug.log(`[${INTEGRATION_NAME}] Route has been seen and time to initial display is disabled for preloaded routes.`);
135
135
  return undefined;
@@ -139,7 +139,7 @@ function addAutomaticTimeToInitialDisplay({ event, rootSpanId, transactionStartT
139
139
  debug.log(`[${INTEGRATION_NAME}] No automatic ttid end timestamp found for span ${rootSpanId}.`);
140
140
  return undefined;
141
141
  }
142
- const viewNames = (_e = (_d = event.contexts) === null || _d === void 0 ? void 0 : _d.app) === null || _e === void 0 ? void 0 : _e.view_names;
142
+ const viewNames = (_f = (_e = event.contexts) === null || _e === void 0 ? void 0 : _e.app) === null || _f === void 0 ? void 0 : _f.view_names;
143
143
  const screenName = Array.isArray(viewNames) ? viewNames[0] : viewNames;
144
144
  const ttidSpan = createSpanJSON({
145
145
  op: UI_LOAD_INITIAL_DISPLAY,
@@ -152,20 +152,20 @@ function addAutomaticTimeToInitialDisplay({ event, rootSpanId, transactionStartT
152
152
  [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,
153
153
  },
154
154
  });
155
- event.spans = (_f = event.spans) !== null && _f !== void 0 ? _f : [];
155
+ event.spans = (_g = event.spans) !== null && _g !== void 0 ? _g : [];
156
156
  event.spans.push(ttidSpan);
157
157
  return ttidSpan;
158
158
  });
159
159
  }
160
- function addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan, }) {
161
- var _a;
162
- return __awaiter(this, void 0, void 0, function* () {
160
+ function addTimeToFullDisplay(_a) {
161
+ return __awaiter(this, arguments, void 0, function* ({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan, }) {
162
+ var _b;
163
163
  const ttfdEndTimestampSeconds = yield NATIVE.popTimeToDisplayFor(`ttfd-${rootSpanId}`);
164
164
  if (!ttidSpan || !ttfdEndTimestampSeconds) {
165
165
  return undefined;
166
166
  }
167
167
  event.spans = event.spans || [];
168
- let ttfdSpan = (_a = event.spans) === null || _a === void 0 ? void 0 : _a.find(span => span.op === UI_LOAD_FULL_DISPLAY);
168
+ let ttfdSpan = (_b = event.spans) === null || _b === void 0 ? void 0 : _b.find(span => span.op === UI_LOAD_FULL_DISPLAY);
169
169
  let ttfdAdjustedEndTimestampSeconds = ttfdEndTimestampSeconds;
170
170
  const ttfdIsBeforeTtid = ttidSpan.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp;
171
171
  if (ttfdIsBeforeTtid && ttidSpan.timestamp) {
@@ -1 +1 @@
1
- {"version":3,"file":"timeToDisplayIntegration.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/timeToDisplayIntegration.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,QAAQ,CAAC;AACvE,OAAO,EAAE,mCAAmC,EAAE,qCAAqC,EAAE,MAAM,WAAW,CAAC;AACvG,OAAO,EAAE,6BAA6B,EAAE,MAAM,oBAAoB,CAAC;AACnE,OAAO,EAAE,sCAAsC,EAAE,MAAM,uBAAuB,CAAC;AAC/E,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,SAAS,CAAC;AACxE,OAAO,EAAE,+BAA+B,EAAE,MAAM,0BAA0B,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,eAAe,CAAC;AAEhD,MAAM,0BAA0B,GAAG,KAAM,CAAC;AAC1C,MAAM,kBAAkB,GAAG,CAAC,UAAkB,EAAW,EAAE,CAAC,UAAU,GAAG,0BAA0B,CAAC;AAEpG,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAgB,EAAE;IACxD,IAAI,4CAA4C,GAAG,KAAK,CAAC;IAEzD,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,aAAa,CAAC,MAAM;;YAClB,4CAA4C;gBAC1C,MAAA,MAAA,6BAA6B,CAAC,MAAM,CAAC,0CAAE,OAAO,CAAC,4C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QAAQ,CAAE,MAAM,KAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE;YAChD,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;YACvB,QAAQ,CAAC,SAAS,GAAG,+BAA+B,CAAC;YACrD,KAAK,CAAC,GAAG,CAAC,IAAI,gBAAgB,+BAA+B,EAAE,QAAQ,CAAC,CAAC;YACzE,OAAO,QAAQ,CAAC;SACjB;QAED,QAAQ,GAAG,cAAc,CAAC;YACxB,MAAM,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI;YACnE,EAAE,EAAE,oBAAoB;YACxB,WAAW,EAAE,sBAAsB;YACnC,eAAe,EAAE,gCAAgC;YACjD,SAAS,EAAE,+BAA+B;YAC1C,MAAM,EAAE,qCAAqC;YAC7C,cAAc,EAAE,UAAU;YAC1B,IAAI,EAAE;gBACJ,CAAC,gBAAgB,CAAC,EAAE,2BAA2B;aAChD;SACF,CAAC,CAAC;QACH,KAAK,CAAC,GAAG,CAAC,IAAI,gBAAgB,mCAAmC,EAAE,QAAQ,CAAC,CAAC;QAC7E,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;;CACjB","sourcesContent":["import type { Event, Integration, SpanJSON } from '@sentry/core';\nimport { debug } from '@sentry/core';\nimport { NATIVE } from '../../wrapper';\nimport { UI_LOAD_FULL_DISPLAY, UI_LOAD_INITIAL_DISPLAY } from '../ops';\nimport { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from '../origin';\nimport { getReactNavigationIntegration } from '../reactnavigation';\nimport { SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN } from '../semanticAttributes';\nimport { SPAN_THREAD_NAME, SPAN_THREAD_NAME_JAVASCRIPT } from '../span';\nimport { getTimeToInitialDisplayFallback } from '../timeToDisplayFallback';\nimport { createSpanJSON } from '../utils';\n\nexport const INTEGRATION_NAME = 'TimeToDisplay';\n\nconst TIME_TO_DISPLAY_TIMEOUT_MS = 30_000;\nconst isDeadlineExceeded = (durationMs: number): boolean => durationMs > TIME_TO_DISPLAY_TIMEOUT_MS;\n\nexport const timeToDisplayIntegration = (): Integration => {\n let enableTimeToInitialDisplayForPreloadedRoutes = false;\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup(client) {\n enableTimeToInitialDisplayForPreloadedRoutes =\n getReactNavigationIntegration(client)?.options.enableTimeToInitialDisplayForPreloadedRoutes ?? false;\n },\n // eslint-disable-next-line complexity\n processEvent: async event => {\n if (event.type !== 'transaction') {\n // TimeToDisplay data is only relevant for transactions\n return event;\n }\n\n const rootSpanId = event.contexts?.trace?.span_id;\n if (!rootSpanId) {\n debug.warn(`[${INTEGRATION_NAME}] No root span id found in transaction.`);\n return event;\n }\n\n const transactionStartTimestampSeconds = event.start_timestamp;\n if (!transactionStartTimestampSeconds) {\n // This should never happen\n debug.warn(`[${INTEGRATION_NAME}] No transaction start timestamp found in transaction.`);\n return event;\n }\n\n event.spans = event.spans || [];\n event.measurements = event.measurements || {};\n\n const ttidSpan = await addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n const ttfdSpan = await addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan });\n\n if (ttidSpan?.start_timestamp && ttidSpan?.timestamp) {\n event.measurements['time_to_initial_display'] = {\n value: (ttidSpan.timestamp - ttidSpan.start_timestamp) * 1000,\n unit: 'millisecond',\n };\n }\n\n if (ttfdSpan?.start_timestamp && ttfdSpan?.timestamp) {\n const durationMs = (ttfdSpan.timestamp - ttfdSpan.start_timestamp) * 1000;\n if (isDeadlineExceeded(durationMs)) {\n if (event.measurements['time_to_initial_display']) {\n event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display'];\n }\n } else {\n event.measurements['time_to_full_display'] = {\n value: durationMs,\n unit: 'millisecond',\n };\n }\n }\n\n const newTransactionEndTimestampSeconds = Math.max(\n ttidSpan?.timestamp ?? -1,\n ttfdSpan?.timestamp ?? -1,\n event.timestamp ?? -1,\n );\n if (newTransactionEndTimestampSeconds !== -1) {\n event.timestamp = newTransactionEndTimestampSeconds;\n }\n\n return event;\n },\n };\n};\n\nasync function addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-${rootSpanId}`);\n\n event.spans = event.spans || [];\n\n let ttidSpan: SpanJSON | undefined = event.spans?.find(span => span.op === UI_LOAD_INITIAL_DISPLAY);\n\n if (ttidSpan && (ttidSpan.status === undefined || ttidSpan.status === 'ok') && !ttidEndTimestampSeconds) {\n debug.log(`[${INTEGRATION_NAME}] Ttid span already exists and is ok.`, ttidSpan);\n return ttidSpan;\n }\n\n if (!ttidEndTimestampSeconds) {\n debug.log(`[${INTEGRATION_NAME}] No manual ttid end timestamp found for span ${rootSpanId}.`);\n return addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n }\n\n if (ttidSpan?.status && ttidSpan.status !== 'ok') {\n ttidSpan.status = 'ok';\n ttidSpan.timestamp = ttidEndTimestampSeconds;\n debug.log(`[${INTEGRATION_NAME}] Updated existing ttid span.`, ttidSpan);\n return ttidSpan;\n }\n\n ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n debug.log(`[${INTEGRATION_NAME}] Added ttid span to transaction.`, ttidSpan);\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidNativeTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-navigation-${rootSpanId}`);\n const ttidFallbackTimestampSeconds = await getTimeToInitialDisplayFallback(rootSpanId);\n\n const hasBeenSeen = event.contexts?.trace?.data?.[SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN];\n if (hasBeenSeen && !enableTimeToInitialDisplayForPreloadedRoutes) {\n debug.log(\n `[${INTEGRATION_NAME}] Route has been seen and time to initial display is disabled for preloaded routes.`,\n );\n return undefined;\n }\n\n const ttidTimestampSeconds = ttidNativeTimestampSeconds ?? ttidFallbackTimestampSeconds;\n if (!ttidTimestampSeconds) {\n debug.log(`[${INTEGRATION_NAME}] No automatic ttid end timestamp found for span ${rootSpanId}.`);\n return undefined;\n }\n\n const viewNames = event.contexts?.app?.view_names;\n const screenName = Array.isArray(viewNames) ? viewNames[0] : viewNames;\n\n const ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: screenName ? `${screenName} initial display` : 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidTimestampSeconds,\n origin: SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n event.spans = event.spans ?? [];\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addTimeToFullDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n ttidSpan,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n ttidSpan: SpanJSON | undefined;\n}): Promise<SpanJSON | undefined> {\n const ttfdEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttfd-${rootSpanId}`);\n\n if (!ttidSpan || !ttfdEndTimestampSeconds) {\n return undefined;\n }\n\n event.spans = event.spans || [];\n\n let ttfdSpan = event.spans?.find(span => span.op === UI_LOAD_FULL_DISPLAY);\n\n let ttfdAdjustedEndTimestampSeconds = ttfdEndTimestampSeconds;\n const ttfdIsBeforeTtid = ttidSpan.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp;\n if (ttfdIsBeforeTtid && ttidSpan.timestamp) {\n ttfdAdjustedEndTimestampSeconds = ttidSpan.timestamp;\n }\n\n const durationMs = (ttfdAdjustedEndTimestampSeconds - transactionStartTimestampSeconds) * 1000;\n\n if (ttfdSpan?.status && ttfdSpan.status !== 'ok') {\n ttfdSpan.status = 'ok';\n ttfdSpan.timestamp = ttfdAdjustedEndTimestampSeconds;\n debug.log(`[${INTEGRATION_NAME}] Updated existing ttfd span.`, ttfdSpan);\n return ttfdSpan;\n }\n\n ttfdSpan = createSpanJSON({\n status: isDeadlineExceeded(durationMs) ? 'deadline_exceeded' : 'ok',\n op: UI_LOAD_FULL_DISPLAY,\n description: 'Time To Full Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttfdAdjustedEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n debug.log(`[${INTEGRATION_NAME}] Added ttfd span to transaction.`, ttfdSpan);\n event.spans.push(ttfdSpan);\n return ttfdSpan;\n}\n"]}
1
+ {"version":3,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AR,QAAQ,CAAE,MAAM,KAAI,QAAQ,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACjD,QAAQ,CAAC,MAAM,GAAG,IAAI,CAAC;YACvB,QAAQ,CAAC,SAAS,GAAG,+BAA+B,CAAC;YACrD,KAAK,CAAC,GAAG,CAAC,IAAI,gBAAgB,+BAA+B,EAAE,QAAQ,CAAC,CAAC;YACzE,OAAO,QAAQ,CAAC;QAClB,CAAC;QAED,QAAQ,GAAG,cAAc,CAAC;YACxB,MAAM,EAAE,kBAAkB,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI;YACnE,EAAE,EAAE,oBAAoB;YACxB,WAAW,EAAE,sBAAsB;YACnC,eAAe,EAAE,gCAAgC;YACjD,SAAS,EAAE,+BAA+B;YAC1C,MAAM,EAAE,qCAAqC;YAC7C,cAAc,EAAE,UAAU;YAC1B,IAAI,EAAE;gBACJ,CAAC,gBAAgB,CAAC,EAAE,2BAA2B;aAChD;SACF,CAAC,CAAC;QACH,KAAK,CAAC,GAAG,CAAC,IAAI,gBAAgB,mCAAmC,EAAE,QAAQ,CAAC,CAAC;QAC7E,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;IAClB,CAAC;CAAA","sourcesContent":["import type { Event, Integration, SpanJSON } from '@sentry/core';\n\nimport { debug } from '@sentry/core';\n\nimport { NATIVE } from '../../wrapper';\nimport { UI_LOAD_FULL_DISPLAY, UI_LOAD_INITIAL_DISPLAY } from '../ops';\nimport { SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY, SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY } from '../origin';\nimport { getReactNavigationIntegration } from '../reactnavigation';\nimport { SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN } from '../semanticAttributes';\nimport { SPAN_THREAD_NAME, SPAN_THREAD_NAME_JAVASCRIPT } from '../span';\nimport { getTimeToInitialDisplayFallback } from '../timeToDisplayFallback';\nimport { createSpanJSON } from '../utils';\n\nexport const INTEGRATION_NAME = 'TimeToDisplay';\n\nconst TIME_TO_DISPLAY_TIMEOUT_MS = 30_000;\nconst isDeadlineExceeded = (durationMs: number): boolean => durationMs > TIME_TO_DISPLAY_TIMEOUT_MS;\n\nexport const timeToDisplayIntegration = (): Integration => {\n let enableTimeToInitialDisplayForPreloadedRoutes = false;\n\n return {\n name: INTEGRATION_NAME,\n afterAllSetup(client) {\n enableTimeToInitialDisplayForPreloadedRoutes =\n getReactNavigationIntegration(client)?.options.enableTimeToInitialDisplayForPreloadedRoutes ?? false;\n },\n // oxlint-disable-next-line eslint(complexity)\n processEvent: async event => {\n if (event.type !== 'transaction') {\n // TimeToDisplay data is only relevant for transactions\n return event;\n }\n\n const rootSpanId = event.contexts?.trace?.span_id;\n if (!rootSpanId) {\n debug.warn(`[${INTEGRATION_NAME}] No root span id found in transaction.`);\n return event;\n }\n\n const transactionStartTimestampSeconds = event.start_timestamp;\n if (!transactionStartTimestampSeconds) {\n // This should never happen\n debug.warn(`[${INTEGRATION_NAME}] No transaction start timestamp found in transaction.`);\n return event;\n }\n\n event.spans = event.spans || [];\n event.measurements = event.measurements || {};\n\n const ttidSpan = await addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n const ttfdSpan = await addTimeToFullDisplay({ event, rootSpanId, transactionStartTimestampSeconds, ttidSpan });\n\n if (ttidSpan?.start_timestamp && ttidSpan?.timestamp) {\n event.measurements['time_to_initial_display'] = {\n value: (ttidSpan.timestamp - ttidSpan.start_timestamp) * 1000,\n unit: 'millisecond',\n };\n }\n\n if (ttfdSpan?.start_timestamp && ttfdSpan?.timestamp) {\n const durationMs = (ttfdSpan.timestamp - ttfdSpan.start_timestamp) * 1000;\n if (isDeadlineExceeded(durationMs)) {\n if (event.measurements['time_to_initial_display']) {\n event.measurements['time_to_full_display'] = event.measurements['time_to_initial_display'];\n }\n } else {\n event.measurements['time_to_full_display'] = {\n value: durationMs,\n unit: 'millisecond',\n };\n }\n }\n\n const newTransactionEndTimestampSeconds = Math.max(\n ttidSpan?.timestamp ?? -1,\n ttfdSpan?.timestamp ?? -1,\n event.timestamp ?? -1,\n );\n if (newTransactionEndTimestampSeconds !== -1) {\n event.timestamp = newTransactionEndTimestampSeconds;\n }\n\n return event;\n },\n };\n};\n\nasync function addTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-${rootSpanId}`);\n\n event.spans = event.spans || [];\n\n let ttidSpan: SpanJSON | undefined = event.spans?.find(span => span.op === UI_LOAD_INITIAL_DISPLAY);\n\n if (ttidSpan && (ttidSpan.status === undefined || ttidSpan.status === 'ok') && !ttidEndTimestampSeconds) {\n debug.log(`[${INTEGRATION_NAME}] Ttid span already exists and is ok.`, ttidSpan);\n return ttidSpan;\n }\n\n if (!ttidEndTimestampSeconds) {\n debug.log(`[${INTEGRATION_NAME}] No manual ttid end timestamp found for span ${rootSpanId}.`);\n return addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n });\n }\n\n if (ttidSpan?.status && ttidSpan.status !== 'ok') {\n ttidSpan.status = 'ok';\n ttidSpan.timestamp = ttidEndTimestampSeconds;\n debug.log(`[${INTEGRATION_NAME}] Updated existing ttid span.`, ttidSpan);\n return ttidSpan;\n }\n\n ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n debug.log(`[${INTEGRATION_NAME}] Added ttid span to transaction.`, ttidSpan);\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addAutomaticTimeToInitialDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n enableTimeToInitialDisplayForPreloadedRoutes,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n enableTimeToInitialDisplayForPreloadedRoutes: boolean;\n}): Promise<SpanJSON | undefined> {\n const ttidNativeTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttid-navigation-${rootSpanId}`);\n const ttidFallbackTimestampSeconds = await getTimeToInitialDisplayFallback(rootSpanId);\n\n const hasBeenSeen = event.contexts?.trace?.data?.[SEMANTIC_ATTRIBUTE_ROUTE_HAS_BEEN_SEEN];\n if (hasBeenSeen && !enableTimeToInitialDisplayForPreloadedRoutes) {\n debug.log(\n `[${INTEGRATION_NAME}] Route has been seen and time to initial display is disabled for preloaded routes.`,\n );\n return undefined;\n }\n\n const ttidTimestampSeconds = ttidNativeTimestampSeconds ?? ttidFallbackTimestampSeconds;\n if (!ttidTimestampSeconds) {\n debug.log(`[${INTEGRATION_NAME}] No automatic ttid end timestamp found for span ${rootSpanId}.`);\n return undefined;\n }\n\n const viewNames = event.contexts?.app?.view_names;\n const screenName = Array.isArray(viewNames) ? viewNames[0] : viewNames;\n\n const ttidSpan = createSpanJSON({\n op: UI_LOAD_INITIAL_DISPLAY,\n description: screenName ? `${screenName} initial display` : 'Time To Initial Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttidTimestampSeconds,\n origin: SPAN_ORIGIN_AUTO_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n event.spans = event.spans ?? [];\n event.spans.push(ttidSpan);\n return ttidSpan;\n}\n\nasync function addTimeToFullDisplay({\n event,\n rootSpanId,\n transactionStartTimestampSeconds,\n ttidSpan,\n}: {\n event: Event;\n rootSpanId: string;\n transactionStartTimestampSeconds: number;\n ttidSpan: SpanJSON | undefined;\n}): Promise<SpanJSON | undefined> {\n const ttfdEndTimestampSeconds = await NATIVE.popTimeToDisplayFor(`ttfd-${rootSpanId}`);\n\n if (!ttidSpan || !ttfdEndTimestampSeconds) {\n return undefined;\n }\n\n event.spans = event.spans || [];\n\n let ttfdSpan = event.spans?.find(span => span.op === UI_LOAD_FULL_DISPLAY);\n\n let ttfdAdjustedEndTimestampSeconds = ttfdEndTimestampSeconds;\n const ttfdIsBeforeTtid = ttidSpan.timestamp && ttfdEndTimestampSeconds < ttidSpan.timestamp;\n if (ttfdIsBeforeTtid && ttidSpan.timestamp) {\n ttfdAdjustedEndTimestampSeconds = ttidSpan.timestamp;\n }\n\n const durationMs = (ttfdAdjustedEndTimestampSeconds - transactionStartTimestampSeconds) * 1000;\n\n if (ttfdSpan?.status && ttfdSpan.status !== 'ok') {\n ttfdSpan.status = 'ok';\n ttfdSpan.timestamp = ttfdAdjustedEndTimestampSeconds;\n debug.log(`[${INTEGRATION_NAME}] Updated existing ttfd span.`, ttfdSpan);\n return ttfdSpan;\n }\n\n ttfdSpan = createSpanJSON({\n status: isDeadlineExceeded(durationMs) ? 'deadline_exceeded' : 'ok',\n op: UI_LOAD_FULL_DISPLAY,\n description: 'Time To Full Display',\n start_timestamp: transactionStartTimestampSeconds,\n timestamp: ttfdAdjustedEndTimestampSeconds,\n origin: SPAN_ORIGIN_MANUAL_UI_TIME_TO_DISPLAY,\n parent_span_id: rootSpanId,\n data: {\n [SPAN_THREAD_NAME]: SPAN_THREAD_NAME_JAVASCRIPT,\n },\n });\n debug.log(`[${INTEGRATION_NAME}] Added ttfd span to transaction.`, ttfdSpan);\n event.spans.push(ttfdSpan);\n return ttfdSpan;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"userInteraction.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAC;AAiBxE,eAAO,MAAM,0BAA0B,QAAO,WAI7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sBAAuB;IAC1D,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;CACZ,KAAG,IAAI,GAAG,SAmEV,CAAC"}
1
+ {"version":3,"file":"userInteraction.d.ts","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,IAAI,EAAoB,MAAM,cAAc,CAAC;AAoBxE,eAAO,MAAM,0BAA0B,QAAO,WAI7C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GAAI,mBAAmB;IAC1D,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IAC9B,EAAE,EAAE,MAAM,CAAC;CACZ,KAAG,IAAI,GAAG,SAmEV,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"userInteraction.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,gCAAgC,EAChC,UAAU,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3F,MAA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,IAAI,gBAAgB,oBAAoB,EAAE,2CACxC,UAAU,CAAC,iBAAiB,CAAC,CAAC,WAChC,uBAAuB,CACxB,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,IAAI,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,YAAY,IAAI,SAAS,EAAE,CAAC;IAC1D,IACE,iBAAiB;QACjB,UAAU,CAAC,iBAAiB,CAAC,CAAC,WAAW,KAAK,IAAI;QAClD,UAAU,CAAC,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,EACvC;QACA,KAAK,CAAC,IAAI,CACR,IAAI,gBAAgB,oBAAoB,EAAE,gDACxC,UAAU,CAAC,iBAAiB,CAAC,CAAC,WAChC,+BAA+B,CAChC,CAAC;QACF,OAAO,SAAS,CAAC;KAClB;IAED,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,OAAO,GAAqB;QAChC,IAAI;QACJ,EAAE;QACF,KAAK;KACN,CAAC;IACF,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE;QACrC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa;QAC1C,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc;KAC7C,CAAC,CAAC;IACH,OAAO,CAAC,YAAY,CAAC,gCAAgC,EAAE,8BAA8B,CAAC,CAAC;IACvF,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,KAAK,CAAC,GAAG,CAAC,IAAI,gBAAgB,sCAAsC,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import type { Integration, Span, StartSpanOptions } from '@sentry/core';\nimport {\n debug,\n getActiveSpan,\n getClient,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\nimport type { ReactNativeClientOptions } from '../../options';\nimport { onlySampleIfChildSpans } from '../onSpanEndUtils';\nimport { SPAN_ORIGIN_MANUAL_INTERACTION } from '../origin';\nimport { getCurrentReactNativeTracingIntegration } from '../reactnativetracing';\nimport { clearActiveSpanFromScope, isSentryInteractionSpan, startIdleSpan } from '../span';\n\nconst INTEGRATION_NAME = 'UserInteraction';\n\nexport const userInteractionIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n };\n};\n\n/**\n * Starts a new transaction for a user interaction.\n * @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.\n */\nexport const startUserInteractionSpan = (userInteractionId: {\n elementId: string | undefined;\n op: string;\n}): Span | undefined => {\n const client = getClient();\n if (!client) {\n return undefined;\n }\n\n const tracing = getCurrentReactNativeTracingIntegration();\n if (!tracing) {\n debug.log(`[${INTEGRATION_NAME}] Tracing integration is not available. Can not start user interaction span.`);\n return undefined;\n }\n\n const options = client.getOptions() as ReactNativeClientOptions;\n const { elementId, op } = userInteractionId;\n if (!options.enableUserInteractionTracing) {\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing is disabled.`);\n return undefined;\n }\n if (!elementId) {\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction with undefined elementId.`);\n return undefined;\n }\n if (!tracing.state.currentRoute) {\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction without a current route.`);\n return undefined;\n }\n\n const activeTransaction = getActiveSpan();\n const activeTransactionIsNotInteraction = activeTransaction && !isSentryInteractionSpan(activeTransaction);\n if (activeTransaction && activeTransactionIsNotInteraction) {\n debug.warn(\n `[${INTEGRATION_NAME}] Did not create ${op} transaction because active transaction ${\n spanToJSON(activeTransaction).description\n } exists on the scope.`,\n );\n return undefined;\n }\n\n const name = `${tracing.state.currentRoute}.${elementId}`;\n if (\n activeTransaction &&\n spanToJSON(activeTransaction).description === name &&\n spanToJSON(activeTransaction).op === op\n ) {\n debug.warn(\n `[${INTEGRATION_NAME}] Did not create ${op} transaction because it the same transaction ${\n spanToJSON(activeTransaction).description\n } already exists on the scope.`,\n );\n return undefined;\n }\n\n const scope = getCurrentScope();\n const context: StartSpanOptions = {\n name,\n op,\n scope,\n };\n clearActiveSpanFromScope(scope);\n const newSpan = startIdleSpan(context, {\n idleTimeout: tracing.options.idleTimeoutMs,\n finalTimeout: tracing.options.finalTimeoutMs,\n });\n newSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_INTERACTION);\n onlySampleIfChildSpans(client, newSpan);\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing Created ${op} transaction ${name}.`);\n return newSpan;\n};\n"]}
1
+ {"version":3,"file":"userInteraction.js","sourceRoot":"","sources":["../../../../src/js/tracing/integrations/userInteraction.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,KAAK,EACL,aAAa,EACb,SAAS,EACT,eAAe,EACf,gCAAgC,EAChC,UAAU,GACX,MAAM,cAAc,CAAC;AAItB,OAAO,EAAE,sBAAsB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,uCAAuC,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,EAAE,wBAAwB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAE3F,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAE3C,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAgB,EAAE;IAC1D,OAAO;QACL,IAAI,EAAE,gBAAgB;KACvB,CAAC;AACJ,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,iBAGxC,EAAoB,EAAE;IACrB,MAAM,MAAM,GAAG,SAAS,EAAE,CAAC;IAC3B,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,OAAO,GAAG,uC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C,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,EACvC,CAAC;QACD,KAAK,CAAC,IAAI,CACR,IAAI,gBAAgB,oBAAoB,EAAE,gDACxC,UAAU,CAAC,iBAAiB,CAAC,CAAC,WAChC,+BAA+B,CAChC,CAAC;QACF,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;IAChC,MAAM,OAAO,GAAqB;QAChC,IAAI;QACJ,EAAE;QACF,KAAK;KACN,CAAC;IACF,wBAAwB,CAAC,KAAK,CAAC,CAAC;IAChC,MAAM,OAAO,GAAG,aAAa,CAAC,OAAO,EAAE;QACrC,WAAW,EAAE,OAAO,CAAC,OAAO,CAAC,aAAa;QAC1C,YAAY,EAAE,OAAO,CAAC,OAAO,CAAC,cAAc;KAC7C,CAAC,CAAC;IACH,OAAO,CAAC,YAAY,CAAC,gCAAgC,EAAE,8BAA8B,CAAC,CAAC;IACvF,sBAAsB,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,KAAK,CAAC,GAAG,CAAC,IAAI,gBAAgB,sCAAsC,EAAE,gBAAgB,IAAI,GAAG,CAAC,CAAC;IAC/F,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC","sourcesContent":["import type { Integration, Span, StartSpanOptions } from '@sentry/core';\n\nimport {\n debug,\n getActiveSpan,\n getClient,\n getCurrentScope,\n SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN,\n spanToJSON,\n} from '@sentry/core';\n\nimport type { ReactNativeClientOptions } from '../../options';\n\nimport { onlySampleIfChildSpans } from '../onSpanEndUtils';\nimport { SPAN_ORIGIN_MANUAL_INTERACTION } from '../origin';\nimport { getCurrentReactNativeTracingIntegration } from '../reactnativetracing';\nimport { clearActiveSpanFromScope, isSentryInteractionSpan, startIdleSpan } from '../span';\n\nconst INTEGRATION_NAME = 'UserInteraction';\n\nexport const userInteractionIntegration = (): Integration => {\n return {\n name: INTEGRATION_NAME,\n };\n};\n\n/**\n * Starts a new transaction for a user interaction.\n * @param userInteractionId Consists of `op` representation UI Event and `elementId` unique element identifier on current screen.\n */\nexport const startUserInteractionSpan = (userInteractionId: {\n elementId: string | undefined;\n op: string;\n}): Span | undefined => {\n const client = getClient();\n if (!client) {\n return undefined;\n }\n\n const tracing = getCurrentReactNativeTracingIntegration();\n if (!tracing) {\n debug.log(`[${INTEGRATION_NAME}] Tracing integration is not available. Can not start user interaction span.`);\n return undefined;\n }\n\n const options = client.getOptions() as ReactNativeClientOptions;\n const { elementId, op } = userInteractionId;\n if (!options.enableUserInteractionTracing) {\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing is disabled.`);\n return undefined;\n }\n if (!elementId) {\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction with undefined elementId.`);\n return undefined;\n }\n if (!tracing.state.currentRoute) {\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing can not create transaction without a current route.`);\n return undefined;\n }\n\n const activeTransaction = getActiveSpan();\n const activeTransactionIsNotInteraction = activeTransaction && !isSentryInteractionSpan(activeTransaction);\n if (activeTransaction && activeTransactionIsNotInteraction) {\n debug.warn(\n `[${INTEGRATION_NAME}] Did not create ${op} transaction because active transaction ${\n spanToJSON(activeTransaction).description\n } exists on the scope.`,\n );\n return undefined;\n }\n\n const name = `${tracing.state.currentRoute}.${elementId}`;\n if (\n activeTransaction &&\n spanToJSON(activeTransaction).description === name &&\n spanToJSON(activeTransaction).op === op\n ) {\n debug.warn(\n `[${INTEGRATION_NAME}] Did not create ${op} transaction because it the same transaction ${\n spanToJSON(activeTransaction).description\n } already exists on the scope.`,\n );\n return undefined;\n }\n\n const scope = getCurrentScope();\n const context: StartSpanOptions = {\n name,\n op,\n scope,\n };\n clearActiveSpanFromScope(scope);\n const newSpan = startIdleSpan(context, {\n idleTimeout: tracing.options.idleTimeoutMs,\n finalTimeout: tracing.options.finalTimeoutMs,\n });\n newSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN, SPAN_ORIGIN_MANUAL_INTERACTION);\n onlySampleIfChildSpans(client, newSpan);\n debug.log(`[${INTEGRATION_NAME}] User Interaction Tracing Created ${op} transaction ${name}.`);\n return newSpan;\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"onSpanEndUtils.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/onSpanEndUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAYjD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI,CAO9F;AAED,eAAO,MAAM,yBAAyB,WAAY,MAAM,QAAQ,IAAI,iBAAiB,MAAM,KAAG,IA0B7F,CAAC;AAwDF,eAAO,MAAM,yBAAyB,WAAY,MAAM,GAAG,SAAS,QAAQ,IAAI,GAAG,SAAS,KAAG,IAa9F,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,WACrC,MAAM,GAAG,SAAS,QACpB,IAAI,GAAG,SAAS,6BACK,MAAM,sBACb,MAAM,OAAO,KAChC,IAoBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,WAAY,MAAM,QAAQ,IAAI,KAAG,IAmBnE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,WAAY,MAAM,QAAQ,IAAI,KAAG,IA2C/D,CAAC"}
1
+ {"version":3,"file":"onSpanEndUtils.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/onSpanEndUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAcjD;;GAEG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,KAAK,IAAI,GAAG,IAAI,CAQ9F;AAED,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,EAAE,MAAM,IAAI,EAAE,eAAe,MAAM,KAAG,IA2B7F,CAAC;AAyDF,eAAO,MAAM,yBAAyB,GAAI,QAAQ,MAAM,GAAG,SAAS,EAAE,MAAM,IAAI,GAAG,SAAS,KAAG,IAa9F,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,GAAG,SAAS,EAC1B,MAAM,IAAI,GAAG,SAAS,EACtB,2BAA2B,MAAM,EACjC,oBAAoB,MAAM,OAAO,KAChC,IAoBF,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,QAAQ,MAAM,EAAE,MAAM,IAAI,KAAG,IAoBnE,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,kBAAkB,GAAI,QAAQ,MAAM,EAAE,MAAM,IAAI,KAAG,IAuE/D,CAAC"}
@@ -1,4 +1,4 @@
1
- import { debug, getSpanDescendants, SPAN_STATUS_ERROR, spanToJSON } from '@sentry/core';
1
+ import { debug, getSpanDescendants, SPAN_STATUS_ERROR, spanToJSON, timestampInSeconds } from '@sentry/core';
2
2
  import { AppState, Platform } from 'react-native';
3
3
  import { isRootSpan, isSentrySpan } from '../utils/span';
4
4
  /**
@@ -10,10 +10,11 @@ const IOS_INACTIVE_CANCEL_DELAY_MS = 5000;
10
10
  * Hooks on span end event to execute a callback when the span ends.
11
11
  */
12
12
  export function onThisSpanEnd(client, span, callback) {
13
- client.on('spanEnd', (endedSpan) => {
13
+ const unsubscribe = client.on('spanEnd', (endedSpan) => {
14
14
  if (span !== endedSpan) {
15
15
  return;
16
16
  }
17
+ unsubscribe();
17
18
  callback(endedSpan);
18
19
  });
19
20
  }
@@ -22,10 +23,11 @@ export const adjustTransactionDuration = (client, span, maxDurationMs) => {
22
23
  debug.warn('Not sampling empty back spans only works for Sentry Transactions (Root Spans).');
23
24
  return;
24
25
  }
25
- client.on('spanEnd', (endedSpan) => {
26
+ const unsubscribe = client.on('spanEnd', (endedSpan) => {
26
27
  if (endedSpan !== span) {
27
28
  return;
28
29
  }
30
+ unsubscribe();
29
31
  const endTimestamp = spanToJSON(span).timestamp;
30
32
  const startTimestamp = spanToJSON(span).start_timestamp;
31
33
  if (!endTimestamp || !startTimestamp) {
@@ -65,10 +67,11 @@ function discardEmptyNavigationSpan(client, span, shouldDiscardFn, onDiscardFn)
65
67
  debug.warn('Not sampling empty navigation spans only works for Sentry Transactions (Root Spans).');
66
68
  return;
67
69
  }
68
- client.on('spanEnd', (endedSpan) => {
70
+ const unsubscribe = client.on('spanEnd', (endedSpan) => {
69
71
  if (endedSpan !== span) {
70
72
  return;
71
73
  }
74
+ unsubscribe();
72
75
  if (!shouldDiscardFn(span)) {
73
76
  return;
74
77
  }
@@ -122,10 +125,11 @@ export const onlySampleIfChildSpans = (client, span) => {
122
125
  debug.warn('Not sampling childless spans only works for Sentry Transactions (Root Spans).');
123
126
  return;
124
127
  }
125
- client.on('spanEnd', (endedSpan) => {
128
+ const unsubscribe = client.on('spanEnd', (endedSpan) => {
126
129
  if (endedSpan !== span) {
127
130
  return;
128
131
  }
132
+ unsubscribe();
129
133
  const children = getSpanDescendants(span);
130
134
  if (children.length <= 1) {
131
135
  // Span always has at lest one child, itself
@@ -146,20 +150,41 @@ export const onlySampleIfChildSpans = (client, span) => {
146
150
  */
147
151
  export const cancelInBackground = (client, span) => {
148
152
  let inactiveTimeout;
153
+ // The timestamp when the app actually left the foreground. Used to end
154
+ // http.client child spans at the right time instead of whenever the
155
+ // deferred cancellation timer fires (which can be much later if the JS
156
+ // thread was suspended on iOS).
157
+ let leftForegroundTimestamp;
149
158
  const cancelSpan = () => {
150
159
  if (inactiveTimeout !== undefined) {
151
160
  clearTimeout(inactiveTimeout);
152
161
  inactiveTimeout = undefined;
153
162
  }
154
163
  debug.log(`Setting ${spanToJSON(span).op} transaction to cancelled because the app is in the background.`);
164
+ // End still-recording http.client children at the time the app left
165
+ // the foreground, not when the deferred timer fires. On iOS, the JS
166
+ // thread can be suspended after the `inactive` event, so the 5-second
167
+ // timer may fire long after the app backgrounded. Using the original
168
+ // timestamp prevents inflated span durations.
169
+ const childEndTimestamp = leftForegroundTimestamp !== null && leftForegroundTimestamp !== void 0 ? leftForegroundTimestamp : timestampInSeconds();
170
+ const children = getSpanDescendants(span);
171
+ for (const child of children) {
172
+ if (child !== span && child.isRecording() && spanToJSON(child).op === 'http.client') {
173
+ child.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });
174
+ child.end(childEndTimestamp);
175
+ }
176
+ }
155
177
  span.setStatus({ code: SPAN_STATUS_ERROR, message: 'cancelled' });
156
178
  span.end();
157
179
  };
158
180
  const subscription = AppState.addEventListener('change', (newState) => {
159
181
  if (newState === 'background') {
182
+ leftForegroundTimestamp = leftForegroundTimestamp !== null && leftForegroundTimestamp !== void 0 ? leftForegroundTimestamp : timestampInSeconds();
160
183
  cancelSpan();
161
184
  }
162
185
  else if (Platform.OS === 'ios' && newState === 'inactive') {
186
+ // Record when the app actually left the foreground.
187
+ leftForegroundTimestamp = timestampInSeconds();
163
188
  // Schedule a deferred cancellation — if the JS thread is suspended
164
189
  // before the 'background' event fires, this timer will execute when
165
190
  // the app is eventually resumed and end the span.
@@ -169,23 +194,27 @@ export const cancelInBackground = (client, span) => {
169
194
  }
170
195
  else if (newState === 'active') {
171
196
  // App returned to foreground — clear any pending inactive cancellation.
197
+ leftForegroundTimestamp = undefined;
172
198
  if (inactiveTimeout !== undefined) {
173
199
  clearTimeout(inactiveTimeout);
174
200
  inactiveTimeout = undefined;
175
201
  }
176
202
  }
177
203
  });
178
- subscription &&
179
- client.on('spanEnd', (endedSpan) => {
204
+ if (subscription) {
205
+ const unsubscribe = client.on('spanEnd', (endedSpan) => {
180
206
  var _a;
181
- if (endedSpan === span) {
182
- debug.log(`Removing AppState listener for ${spanToJSON(span).op} transaction.`);
183
- if (inactiveTimeout !== undefined) {
184
- clearTimeout(inactiveTimeout);
185
- inactiveTimeout = undefined;
186
- }
187
- (_a = subscription === null || subscription === void 0 ? void 0 : subscription.remove) === null || _a === void 0 ? void 0 : _a.call(subscription);
207
+ if (endedSpan !== span) {
208
+ return;
209
+ }
210
+ unsubscribe();
211
+ debug.log(`Removing AppState listener for ${spanToJSON(span).op} transaction.`);
212
+ if (inactiveTimeout !== undefined) {
213
+ clearTimeout(inactiveTimeout);
214
+ inactiveTimeout = undefined;
188
215
  }
216
+ (_a = subscription.remove) === null || _a === void 0 ? void 0 : _a.call(subscription);
189
217
  });
218
+ }
190
219
  };
191
220
  //# sourceMappingURL=onSpanEndUtils.js.map