@sentry/react-native 5.28.0 → 6.0.0-alpha.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 (294) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/android/build.gradle +1 -1
  3. package/dist/js/client.d.ts +5 -9
  4. package/dist/js/client.d.ts.map +1 -1
  5. package/dist/js/client.js +11 -42
  6. package/dist/js/client.js.map +1 -1
  7. package/dist/js/index.d.ts +5 -10
  8. package/dist/js/index.d.ts.map +1 -1
  9. package/dist/js/index.js +4 -21
  10. package/dist/js/index.js.map +1 -1
  11. package/dist/js/integrations/debugsymbolicator.d.ts +2 -8
  12. package/dist/js/integrations/debugsymbolicator.d.ts.map +1 -1
  13. package/dist/js/integrations/debugsymbolicator.js +1 -9
  14. package/dist/js/integrations/debugsymbolicator.js.map +1 -1
  15. package/dist/js/integrations/default.d.ts.map +1 -1
  16. package/dist/js/integrations/default.js +18 -7
  17. package/dist/js/integrations/default.js.map +1 -1
  18. package/dist/js/integrations/devicecontext.d.ts +2 -8
  19. package/dist/js/integrations/devicecontext.d.ts.map +1 -1
  20. package/dist/js/integrations/devicecontext.js +0 -9
  21. package/dist/js/integrations/devicecontext.js.map +1 -1
  22. package/dist/js/integrations/eventorigin.d.ts +2 -8
  23. package/dist/js/integrations/eventorigin.d.ts.map +1 -1
  24. package/dist/js/integrations/eventorigin.js +0 -8
  25. package/dist/js/integrations/eventorigin.js.map +1 -1
  26. package/dist/js/integrations/expocontext.d.ts +2 -8
  27. package/dist/js/integrations/expocontext.d.ts.map +1 -1
  28. package/dist/js/integrations/expocontext.js +0 -8
  29. package/dist/js/integrations/expocontext.js.map +1 -1
  30. package/dist/js/integrations/exports.d.ts +4 -0
  31. package/dist/js/integrations/exports.d.ts.map +1 -1
  32. package/dist/js/integrations/exports.js +4 -0
  33. package/dist/js/integrations/exports.js.map +1 -1
  34. package/dist/js/integrations/modulesloader.d.ts +2 -8
  35. package/dist/js/integrations/modulesloader.d.ts.map +1 -1
  36. package/dist/js/integrations/modulesloader.js +0 -8
  37. package/dist/js/integrations/modulesloader.js.map +1 -1
  38. package/dist/js/integrations/nativelinkederrors.d.ts +2 -8
  39. package/dist/js/integrations/nativelinkederrors.d.ts.map +1 -1
  40. package/dist/js/integrations/nativelinkederrors.js +0 -8
  41. package/dist/js/integrations/nativelinkederrors.js.map +1 -1
  42. package/dist/js/integrations/reactnativeerrorhandlers.d.ts +2 -8
  43. package/dist/js/integrations/reactnativeerrorhandlers.d.ts.map +1 -1
  44. package/dist/js/integrations/reactnativeerrorhandlers.js +1 -8
  45. package/dist/js/integrations/reactnativeerrorhandlers.js.map +1 -1
  46. package/dist/js/integrations/reactnativeinfo.d.ts +2 -8
  47. package/dist/js/integrations/reactnativeinfo.d.ts.map +1 -1
  48. package/dist/js/integrations/reactnativeinfo.js +0 -8
  49. package/dist/js/integrations/reactnativeinfo.js.map +1 -1
  50. package/dist/js/integrations/release.d.ts +2 -8
  51. package/dist/js/integrations/release.d.ts.map +1 -1
  52. package/dist/js/integrations/release.js +0 -8
  53. package/dist/js/integrations/release.js.map +1 -1
  54. package/dist/js/integrations/rewriteframes.js +1 -1
  55. package/dist/js/integrations/rewriteframes.js.map +1 -1
  56. package/dist/js/integrations/screenshot.d.ts +2 -8
  57. package/dist/js/integrations/screenshot.d.ts.map +1 -1
  58. package/dist/js/integrations/screenshot.js +2 -11
  59. package/dist/js/integrations/screenshot.js.map +1 -1
  60. package/dist/js/integrations/sdkinfo.d.ts +2 -8
  61. package/dist/js/integrations/sdkinfo.d.ts.map +1 -1
  62. package/dist/js/integrations/sdkinfo.js +0 -8
  63. package/dist/js/integrations/sdkinfo.js.map +1 -1
  64. package/dist/js/integrations/spotlight.d.ts +2 -10
  65. package/dist/js/integrations/spotlight.d.ts.map +1 -1
  66. package/dist/js/integrations/spotlight.js +1 -10
  67. package/dist/js/integrations/spotlight.js.map +1 -1
  68. package/dist/js/integrations/viewhierarchy.d.ts +2 -8
  69. package/dist/js/integrations/viewhierarchy.d.ts.map +1 -1
  70. package/dist/js/integrations/viewhierarchy.js +0 -8
  71. package/dist/js/integrations/viewhierarchy.js.map +1 -1
  72. package/dist/js/options.d.ts +43 -0
  73. package/dist/js/options.d.ts.map +1 -1
  74. package/dist/js/options.js.map +1 -1
  75. package/dist/js/profiling/cache.d.ts +1 -1
  76. package/dist/js/profiling/hermes.d.ts +1 -1
  77. package/dist/js/profiling/hermes.d.ts.map +1 -1
  78. package/dist/js/profiling/integration.d.ts +1 -7
  79. package/dist/js/profiling/integration.d.ts.map +1 -1
  80. package/dist/js/profiling/integration.js +39 -25
  81. package/dist/js/profiling/integration.js.map +1 -1
  82. package/dist/js/profiling/utils.js +2 -1
  83. package/dist/js/profiling/utils.js.map +1 -1
  84. package/dist/js/replay/mobilereplay.d.ts +2 -2
  85. package/dist/js/replay/mobilereplay.d.ts.map +1 -1
  86. package/dist/js/replay/mobilereplay.js.map +1 -1
  87. package/dist/js/scopeSync.d.ts +6 -0
  88. package/dist/js/scopeSync.d.ts.map +1 -0
  89. package/dist/js/scopeSync.js +60 -0
  90. package/dist/js/scopeSync.js.map +1 -0
  91. package/dist/js/sdk.d.ts +1 -20
  92. package/dist/js/sdk.d.ts.map +1 -1
  93. package/dist/js/sdk.js +20 -53
  94. package/dist/js/sdk.js.map +1 -1
  95. package/dist/js/tools/sentryMetroSerializer.js.map +1 -1
  96. package/dist/js/touchevents.d.ts +0 -1
  97. package/dist/js/touchevents.d.ts.map +1 -1
  98. package/dist/js/touchevents.js +5 -9
  99. package/dist/js/touchevents.js.map +1 -1
  100. package/dist/js/tracing/gesturetracing.d.ts +1 -6
  101. package/dist/js/tracing/gesturetracing.d.ts.map +1 -1
  102. package/dist/js/tracing/gesturetracing.js +8 -12
  103. package/dist/js/tracing/gesturetracing.js.map +1 -1
  104. package/dist/js/tracing/index.d.ts +6 -7
  105. package/dist/js/tracing/index.d.ts.map +1 -1
  106. package/dist/js/tracing/index.js +4 -7
  107. package/dist/js/tracing/index.js.map +1 -1
  108. package/dist/js/tracing/integrations/appStart.d.ts +39 -0
  109. package/dist/js/tracing/integrations/appStart.d.ts.map +1 -0
  110. package/dist/js/tracing/integrations/appStart.js +301 -0
  111. package/dist/js/tracing/integrations/appStart.js.map +1 -0
  112. package/dist/js/tracing/integrations/nativeFrames.d.ts +20 -0
  113. package/dist/js/tracing/integrations/nativeFrames.d.ts.map +1 -0
  114. package/dist/js/tracing/integrations/nativeFrames.js +256 -0
  115. package/dist/js/tracing/integrations/nativeFrames.js.map +1 -0
  116. package/dist/js/tracing/integrations/stalltracking.d.ts +31 -0
  117. package/dist/js/tracing/integrations/stalltracking.d.ts.map +1 -0
  118. package/dist/js/tracing/integrations/stalltracking.js +236 -0
  119. package/dist/js/tracing/integrations/stalltracking.js.map +1 -0
  120. package/dist/js/tracing/integrations/userInteraction.d.ts +11 -0
  121. package/dist/js/tracing/integrations/userInteraction.d.ts.map +1 -0
  122. package/dist/js/tracing/integrations/userInteraction.js +70 -0
  123. package/dist/js/tracing/integrations/userInteraction.js.map +1 -0
  124. package/dist/js/tracing/onSpanEndUtils.d.ts +17 -0
  125. package/dist/js/tracing/onSpanEndUtils.d.ts.map +1 -0
  126. package/dist/js/tracing/onSpanEndUtils.js +112 -0
  127. package/dist/js/tracing/onSpanEndUtils.js.map +1 -0
  128. package/dist/js/tracing/origin.d.ts +2 -0
  129. package/dist/js/tracing/origin.d.ts.map +1 -0
  130. package/dist/js/tracing/origin.js +2 -0
  131. package/dist/js/tracing/origin.js.map +1 -0
  132. package/dist/js/tracing/reactnativenavigation.d.ts +21 -39
  133. package/dist/js/tracing/reactnativenavigation.d.ts.map +1 -1
  134. package/dist/js/tracing/reactnativenavigation.js +98 -87
  135. package/dist/js/tracing/reactnativenavigation.js.map +1 -1
  136. package/dist/js/tracing/reactnativeprofiler.d.ts.map +1 -1
  137. package/dist/js/tracing/reactnativeprofiler.js +6 -13
  138. package/dist/js/tracing/reactnativeprofiler.js.map +1 -1
  139. package/dist/js/tracing/reactnativetracing.d.ts +44 -160
  140. package/dist/js/tracing/reactnativetracing.d.ts.map +1 -1
  141. package/dist/js/tracing/reactnativetracing.js +51 -481
  142. package/dist/js/tracing/reactnativetracing.js.map +1 -1
  143. package/dist/js/tracing/reactnavigation.d.ts +18 -63
  144. package/dist/js/tracing/reactnavigation.d.ts.map +1 -1
  145. package/dist/js/tracing/reactnavigation.js +197 -218
  146. package/dist/js/tracing/reactnavigation.js.map +1 -1
  147. package/dist/js/tracing/semanticAttributes.d.ts +12 -0
  148. package/dist/js/tracing/semanticAttributes.d.ts.map +1 -0
  149. package/dist/js/tracing/semanticAttributes.js +12 -0
  150. package/dist/js/tracing/semanticAttributes.js.map +1 -0
  151. package/dist/js/tracing/span.d.ts +52 -0
  152. package/dist/js/tracing/span.d.ts.map +1 -0
  153. package/dist/js/tracing/span.js +82 -0
  154. package/dist/js/tracing/span.js.map +1 -0
  155. package/dist/js/tracing/timetodisplay.d.ts.map +1 -1
  156. package/dist/js/tracing/timetodisplay.js +16 -29
  157. package/dist/js/tracing/timetodisplay.js.map +1 -1
  158. package/dist/js/tracing/timetodisplaynative.d.ts.map +1 -1
  159. package/dist/js/tracing/timetodisplaynative.js +5 -3
  160. package/dist/js/tracing/timetodisplaynative.js.map +1 -1
  161. package/dist/js/tracing/types.d.ts +2 -9
  162. package/dist/js/tracing/types.d.ts.map +1 -1
  163. package/dist/js/tracing/types.js.map +1 -1
  164. package/dist/js/tracing/utils.d.ts +23 -12
  165. package/dist/js/tracing/utils.d.ts.map +1 -1
  166. package/dist/js/tracing/utils.js +48 -52
  167. package/dist/js/tracing/utils.js.map +1 -1
  168. package/dist/js/transports/encodePolyfill.d.ts +3 -0
  169. package/dist/js/transports/encodePolyfill.d.ts.map +1 -0
  170. package/dist/js/transports/encodePolyfill.js +13 -0
  171. package/dist/js/transports/encodePolyfill.js.map +1 -0
  172. package/dist/js/transports/native.d.ts +2 -2
  173. package/dist/js/transports/native.d.ts.map +1 -1
  174. package/dist/js/transports/native.js +2 -1
  175. package/dist/js/transports/native.js.map +1 -1
  176. package/dist/js/utils/fill.d.ts +7 -0
  177. package/dist/js/utils/fill.d.ts.map +1 -0
  178. package/dist/js/utils/fill.js +9 -0
  179. package/dist/js/utils/fill.js.map +1 -0
  180. package/dist/js/utils/normalize.d.ts.map +1 -1
  181. package/dist/js/utils/normalize.js +8 -5
  182. package/dist/js/utils/normalize.js.map +1 -1
  183. package/dist/js/utils/rnlibraries.d.ts.map +1 -1
  184. package/dist/js/utils/rnlibraries.js +6 -0
  185. package/dist/js/utils/rnlibraries.js.map +1 -1
  186. package/dist/js/utils/rnlibrariesinterface.d.ts +3 -0
  187. package/dist/js/utils/rnlibrariesinterface.d.ts.map +1 -1
  188. package/dist/js/utils/rnlibrariesinterface.js.map +1 -1
  189. package/dist/js/utils/span.d.ts +19 -0
  190. package/dist/js/utils/span.d.ts.map +1 -0
  191. package/dist/js/utils/span.js +29 -0
  192. package/dist/js/utils/span.js.map +1 -0
  193. package/dist/js/vendor/react-native/index.d.ts +5 -1
  194. package/dist/js/vendor/react-native/index.d.ts.map +1 -1
  195. package/dist/js/vendor/react-native/index.js.map +1 -1
  196. package/dist/js/version.d.ts +1 -1
  197. package/dist/js/version.d.ts.map +1 -1
  198. package/dist/js/version.js +1 -1
  199. package/dist/js/version.js.map +1 -1
  200. package/dist/js/wrapper.d.ts.map +1 -1
  201. package/dist/js/wrapper.js +1 -0
  202. package/dist/js/wrapper.js.map +1 -1
  203. package/package.json +12 -13
  204. package/ts3.8/dist/js/client.d.ts +5 -9
  205. package/ts3.8/dist/js/index.d.ts +5 -10
  206. package/ts3.8/dist/js/integrations/debugsymbolicator.d.ts +2 -8
  207. package/ts3.8/dist/js/integrations/devicecontext.d.ts +2 -8
  208. package/ts3.8/dist/js/integrations/eventorigin.d.ts +2 -8
  209. package/ts3.8/dist/js/integrations/expocontext.d.ts +2 -8
  210. package/ts3.8/dist/js/integrations/exports.d.ts +4 -0
  211. package/ts3.8/dist/js/integrations/modulesloader.d.ts +2 -8
  212. package/ts3.8/dist/js/integrations/nativelinkederrors.d.ts +2 -8
  213. package/ts3.8/dist/js/integrations/reactnativeerrorhandlers.d.ts +2 -8
  214. package/ts3.8/dist/js/integrations/reactnativeinfo.d.ts +2 -8
  215. package/ts3.8/dist/js/integrations/release.d.ts +2 -8
  216. package/ts3.8/dist/js/integrations/screenshot.d.ts +2 -8
  217. package/ts3.8/dist/js/integrations/sdkinfo.d.ts +2 -8
  218. package/ts3.8/dist/js/integrations/spotlight.d.ts +2 -10
  219. package/ts3.8/dist/js/integrations/viewhierarchy.d.ts +2 -8
  220. package/ts3.8/dist/js/options.d.ts +43 -0
  221. package/ts3.8/dist/js/profiling/cache.d.ts +1 -1
  222. package/ts3.8/dist/js/profiling/hermes.d.ts +1 -1
  223. package/ts3.8/dist/js/profiling/integration.d.ts +1 -7
  224. package/ts3.8/dist/js/replay/mobilereplay.d.ts +2 -2
  225. package/ts3.8/dist/js/scopeSync.d.ts +6 -0
  226. package/ts3.8/dist/js/sdk.d.ts +1 -20
  227. package/ts3.8/dist/js/touchevents.d.ts +0 -1
  228. package/ts3.8/dist/js/tracing/gesturetracing.d.ts +1 -6
  229. package/ts3.8/dist/js/tracing/index.d.ts +6 -7
  230. package/ts3.8/dist/js/tracing/integrations/appStart.d.ts +39 -0
  231. package/ts3.8/dist/js/tracing/integrations/nativeFrames.d.ts +20 -0
  232. package/ts3.8/dist/js/tracing/integrations/stalltracking.d.ts +31 -0
  233. package/ts3.8/dist/js/tracing/integrations/userInteraction.d.ts +11 -0
  234. package/ts3.8/dist/js/tracing/onSpanEndUtils.d.ts +17 -0
  235. package/ts3.8/dist/js/tracing/origin.d.ts +2 -0
  236. package/ts3.8/dist/js/tracing/reactnativenavigation.d.ts +21 -39
  237. package/ts3.8/dist/js/tracing/reactnativetracing.d.ts +44 -160
  238. package/ts3.8/dist/js/tracing/reactnavigation.d.ts +18 -63
  239. package/ts3.8/dist/js/tracing/semanticAttributes.d.ts +12 -0
  240. package/ts3.8/dist/js/tracing/span.d.ts +52 -0
  241. package/ts3.8/dist/js/tracing/types.d.ts +2 -9
  242. package/ts3.8/dist/js/tracing/utils.d.ts +23 -12
  243. package/ts3.8/dist/js/transports/encodePolyfill.d.ts +3 -0
  244. package/ts3.8/dist/js/transports/native.d.ts +2 -2
  245. package/ts3.8/dist/js/utils/fill.d.ts +7 -0
  246. package/ts3.8/dist/js/utils/rnlibrariesinterface.d.ts +3 -0
  247. package/ts3.8/dist/js/utils/span.d.ts +19 -0
  248. package/ts3.8/dist/js/vendor/react-native/index.d.ts +5 -1
  249. package/ts3.8/dist/js/version.d.ts +1 -1
  250. package/dist/js/integrations/index.d.ts +0 -16
  251. package/dist/js/integrations/index.d.ts.map +0 -1
  252. package/dist/js/integrations/index.js +0 -17
  253. package/dist/js/integrations/index.js.map +0 -1
  254. package/dist/js/scope.d.ts +0 -54
  255. package/dist/js/scope.d.ts.map +0 -1
  256. package/dist/js/scope.js +0 -89
  257. package/dist/js/scope.js.map +0 -1
  258. package/dist/js/tracing/addTracingExtensions.d.ts +0 -8
  259. package/dist/js/tracing/addTracingExtensions.d.ts.map +0 -1
  260. package/dist/js/tracing/addTracingExtensions.js +0 -66
  261. package/dist/js/tracing/addTracingExtensions.js.map +0 -1
  262. package/dist/js/tracing/nativeframes.d.ts +0 -60
  263. package/dist/js/tracing/nativeframes.d.ts.map +0 -1
  264. package/dist/js/tracing/nativeframes.js +0 -210
  265. package/dist/js/tracing/nativeframes.js.map +0 -1
  266. package/dist/js/tracing/reactnavigationv4.d.ts +0 -92
  267. package/dist/js/tracing/reactnavigationv4.d.ts.map +0 -1
  268. package/dist/js/tracing/reactnavigationv4.js +0 -229
  269. package/dist/js/tracing/reactnavigationv4.js.map +0 -1
  270. package/dist/js/tracing/routingInstrumentation.d.ts +0 -52
  271. package/dist/js/tracing/routingInstrumentation.d.ts.map +0 -1
  272. package/dist/js/tracing/routingInstrumentation.js +0 -36
  273. package/dist/js/tracing/routingInstrumentation.js.map +0 -1
  274. package/dist/js/tracing/stalltracking.d.ts +0 -99
  275. package/dist/js/tracing/stalltracking.d.ts.map +0 -1
  276. package/dist/js/tracing/stalltracking.js +0 -286
  277. package/dist/js/tracing/stalltracking.js.map +0 -1
  278. package/dist/js/tracing/transaction.d.ts +0 -11
  279. package/dist/js/tracing/transaction.d.ts.map +0 -1
  280. package/dist/js/tracing/transaction.js +0 -37
  281. package/dist/js/tracing/transaction.js.map +0 -1
  282. package/dist/js/transports/TextEncoder.d.ts +0 -3
  283. package/dist/js/transports/TextEncoder.d.ts.map +0 -1
  284. package/dist/js/transports/TextEncoder.js +0 -12
  285. package/dist/js/transports/TextEncoder.js.map +0 -1
  286. package/ts3.8/dist/js/integrations/index.d.ts +0 -16
  287. package/ts3.8/dist/js/scope.d.ts +0 -54
  288. package/ts3.8/dist/js/tracing/addTracingExtensions.d.ts +0 -8
  289. package/ts3.8/dist/js/tracing/nativeframes.d.ts +0 -60
  290. package/ts3.8/dist/js/tracing/reactnavigationv4.d.ts +0 -92
  291. package/ts3.8/dist/js/tracing/routingInstrumentation.d.ts +0 -52
  292. package/ts3.8/dist/js/tracing/stalltracking.d.ts +0 -99
  293. package/ts3.8/dist/js/tracing/transaction.d.ts +0 -11
  294. package/ts3.8/dist/js/transports/TextEncoder.d.ts +0 -3
@@ -1,52 +0,0 @@
1
- import type { Hub } from '@sentry/core';
2
- import type { Transaction, TransactionContext } from '@sentry/types';
3
- import type { BeforeNavigate } from './types';
4
- export type TransactionCreator = (context: TransactionContext) => Transaction | undefined;
5
- export type OnConfirmRoute = (context: TransactionContext) => void;
6
- export interface RoutingInstrumentationInstance {
7
- /**
8
- * Name of the routing instrumentation
9
- */
10
- readonly name: string;
11
- /**
12
- * Registers a listener that's called on every route change with a `TransactionContext`.
13
- *
14
- * Do not overwrite this unless you know what you are doing.
15
- *
16
- * @param listener A `RouteListener`
17
- * @param beforeNavigate BeforeNavigate
18
- * @param inConfirmRoute OnConfirmRoute
19
- */
20
- registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
21
- /**
22
- * To be called when the route changes, BEFORE the new route mounts.
23
- * If this is called after a route mounts the child spans will not be correctly attached.
24
- *
25
- * @param context A `TransactionContext` used to initialize the transaction.
26
- */
27
- onRouteWillChange(context: TransactionContext): Transaction | undefined;
28
- }
29
- /**
30
- * Base Routing Instrumentation. Can be used by users to manually instrument custom routers.
31
- * Pass this to the tracing integration, and call `onRouteWillChange` every time before a route changes.
32
- */
33
- export declare class RoutingInstrumentation implements RoutingInstrumentationInstance {
34
- static instrumentationName: string;
35
- readonly name: string;
36
- protected _getCurrentHub?: () => Hub;
37
- protected _beforeNavigate?: BeforeNavigate;
38
- protected _onConfirmRoute?: OnConfirmRoute;
39
- protected _tracingListener?: TransactionCreator;
40
- /** @inheritdoc */
41
- registerRoutingInstrumentation(listener: TransactionCreator, beforeNavigate: BeforeNavigate, onConfirmRoute: OnConfirmRoute): void;
42
- /** @inheritdoc */
43
- onRouteWillChange(context: TransactionContext): Transaction | undefined;
44
- }
45
- /**
46
- * Internal base routing instrumentation where `_onConfirmRoute` is not called in onRouteWillChange
47
- */
48
- export declare class InternalRoutingInstrumentation extends RoutingInstrumentation {
49
- /** @inheritdoc */
50
- onRouteWillChange(context: TransactionContext): Transaction | undefined;
51
- }
52
- //# sourceMappingURL=routingInstrumentation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routingInstrumentation.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/routingInstrumentation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAErE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAE9C,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,WAAW,GAAG,SAAS,CAAC;AAE1F,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,kBAAkB,KAAK,IAAI,CAAC;AAEnE,MAAM,WAAW,8BAA8B;IAC7C;;OAEG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB;;;;;;;;OAQG;IACH,8BAA8B,CAC5B,QAAQ,EAAE,kBAAkB,EAC5B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,GAC7B,IAAI,CAAC;IACR;;;;;OAKG;IACH,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS,CAAC;CACzE;AAED;;;GAGG;AACH,qBAAa,sBAAuB,YAAW,8BAA8B;IAC3E,OAAc,mBAAmB,EAAE,MAAM,CAAkC;IAE3E,SAAgB,IAAI,EAAE,MAAM,CAA8C;IAE1E,SAAS,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,CAAC;IACrC,SAAS,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC;IAC3C,SAAS,CAAC,eAAe,CAAC,EAAE,cAAc,CAAC;IAC3C,SAAS,CAAC,gBAAgB,CAAC,EAAE,kBAAkB,CAAC;IAEhD,kBAAkB;IACX,8BAA8B,CACnC,QAAQ,EAAE,kBAAkB,EAC5B,cAAc,EAAE,cAAc,EAC9B,cAAc,EAAE,cAAc,GAC7B,IAAI;IAMP,kBAAkB;IACX,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS;CAS/E;AAED;;GAEG;AACH,qBAAa,8BAA+B,SAAQ,sBAAsB;IACxE,kBAAkB;IACX,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,GAAG,SAAS;CAG/E"}
@@ -1,36 +0,0 @@
1
- /**
2
- * Base Routing Instrumentation. Can be used by users to manually instrument custom routers.
3
- * Pass this to the tracing integration, and call `onRouteWillChange` every time before a route changes.
4
- */
5
- export class RoutingInstrumentation {
6
- constructor() {
7
- this.name = RoutingInstrumentation.instrumentationName;
8
- }
9
- /** @inheritdoc */
10
- registerRoutingInstrumentation(listener, beforeNavigate, onConfirmRoute) {
11
- this._tracingListener = listener;
12
- this._beforeNavigate = beforeNavigate;
13
- this._onConfirmRoute = onConfirmRoute;
14
- }
15
- /** @inheritdoc */
16
- onRouteWillChange(context) {
17
- var _a, _b;
18
- const transaction = (_a = this._tracingListener) === null || _a === void 0 ? void 0 : _a.call(this, context);
19
- if (transaction) {
20
- (_b = this._onConfirmRoute) === null || _b === void 0 ? void 0 : _b.call(this, context);
21
- }
22
- return transaction;
23
- }
24
- }
25
- RoutingInstrumentation.instrumentationName = 'base-routing-instrumentation';
26
- /**
27
- * Internal base routing instrumentation where `_onConfirmRoute` is not called in onRouteWillChange
28
- */
29
- export class InternalRoutingInstrumentation extends RoutingInstrumentation {
30
- /** @inheritdoc */
31
- onRouteWillChange(context) {
32
- var _a;
33
- return (_a = this._tracingListener) === null || _a === void 0 ? void 0 : _a.call(this, context);
34
- }
35
- }
36
- //# sourceMappingURL=routingInstrumentation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"routingInstrumentation.js","sourceRoot":"","sources":["../../../src/js/tracing/routingInstrumentation.ts"],"names":[],"mappings":"AAqCA;;;GAGG;AACH,MAAM,OAAO,sBAAsB;IAAnC;QAGkB,SAAI,GAAW,sBAAsB,CAAC,mBAAmB,CAAC;IA4B5E,CAAC;IArBC,kBAAkB;IACX,8BAA8B,CACnC,QAA4B,EAC5B,cAA8B,EAC9B,cAA8B;QAE9B,IAAI,CAAC,gBAAgB,GAAG,QAAQ,CAAC;QACjC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;QACtC,IAAI,CAAC,eAAe,GAAG,cAAc,CAAC;IACxC,CAAC;IAED,kBAAkB;IACX,iBAAiB,CAAC,OAA2B;;QAClD,MAAM,WAAW,GAAG,MAAA,IAAI,CAAC,gBAAgB,qDAAG,OAAO,CAAC,CAAC;QAErD,IAAI,WAAW,EAAE;YACf,MAAA,IAAI,CAAC,eAAe,qDAAG,OAAO,CAAC,CAAC;SACjC;QAED,OAAO,WAAW,CAAC;IACrB,CAAC;;AA7Ba,0CAAmB,GAAW,8BAA8B,CAAC;AAgC7E;;GAEG;AACH,MAAM,OAAO,8BAA+B,SAAQ,sBAAsB;IACxE,kBAAkB;IACX,iBAAiB,CAAC,OAA2B;;QAClD,OAAO,MAAA,IAAI,CAAC,gBAAgB,qDAAG,OAAO,CAAC,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { Hub } from '@sentry/core';\nimport type { Transaction, TransactionContext } from '@sentry/types';\n\nimport type { BeforeNavigate } from './types';\n\nexport type TransactionCreator = (context: TransactionContext) => Transaction | undefined;\n\nexport type OnConfirmRoute = (context: TransactionContext) => void;\n\nexport interface RoutingInstrumentationInstance {\n /**\n * Name of the routing instrumentation\n */\n readonly name: string;\n /**\n * Registers a listener that's called on every route change with a `TransactionContext`.\n *\n * Do not overwrite this unless you know what you are doing.\n *\n * @param listener A `RouteListener`\n * @param beforeNavigate BeforeNavigate\n * @param inConfirmRoute OnConfirmRoute\n */\n registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute,\n ): void;\n /**\n * To be called when the route changes, BEFORE the new route mounts.\n * If this is called after a route mounts the child spans will not be correctly attached.\n *\n * @param context A `TransactionContext` used to initialize the transaction.\n */\n onRouteWillChange(context: TransactionContext): Transaction | undefined;\n}\n\n/**\n * Base Routing Instrumentation. Can be used by users to manually instrument custom routers.\n * Pass this to the tracing integration, and call `onRouteWillChange` every time before a route changes.\n */\nexport class RoutingInstrumentation implements RoutingInstrumentationInstance {\n public static instrumentationName: string = 'base-routing-instrumentation';\n\n public readonly name: string = RoutingInstrumentation.instrumentationName;\n\n protected _getCurrentHub?: () => Hub;\n protected _beforeNavigate?: BeforeNavigate;\n protected _onConfirmRoute?: OnConfirmRoute;\n protected _tracingListener?: TransactionCreator;\n\n /** @inheritdoc */\n public registerRoutingInstrumentation(\n listener: TransactionCreator,\n beforeNavigate: BeforeNavigate,\n onConfirmRoute: OnConfirmRoute,\n ): void {\n this._tracingListener = listener;\n this._beforeNavigate = beforeNavigate;\n this._onConfirmRoute = onConfirmRoute;\n }\n\n /** @inheritdoc */\n public onRouteWillChange(context: TransactionContext): Transaction | undefined {\n const transaction = this._tracingListener?.(context);\n\n if (transaction) {\n this._onConfirmRoute?.(context);\n }\n\n return transaction;\n }\n}\n\n/**\n * Internal base routing instrumentation where `_onConfirmRoute` is not called in onRouteWillChange\n */\nexport class InternalRoutingInstrumentation extends RoutingInstrumentation {\n /** @inheritdoc */\n public onRouteWillChange(context: TransactionContext): Transaction | undefined {\n return this._tracingListener?.(context);\n }\n}\n"]}
@@ -1,99 +0,0 @@
1
- import type { IdleTransaction, Transaction } from '@sentry/core';
2
- import type { Measurements, MeasurementUnit } from '@sentry/types';
3
- import { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';
4
- export interface StallMeasurements extends Measurements {
5
- [STALL_COUNT]: {
6
- value: number;
7
- unit: MeasurementUnit;
8
- };
9
- [STALL_TOTAL_TIME]: {
10
- value: number;
11
- unit: MeasurementUnit;
12
- };
13
- [STALL_LONGEST_TIME]: {
14
- value: number;
15
- unit: MeasurementUnit;
16
- };
17
- }
18
- export type StallTrackingOptions = {
19
- /**
20
- * How long in milliseconds an event loop iteration can be delayed for before being considered a "stall."
21
- * @default 100
22
- */
23
- minimumStallThreshold: number;
24
- };
25
- /**
26
- * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:
27
- * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js
28
- *
29
- * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.
30
- * 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`
31
- */
32
- export declare class StallTrackingInstrumentation {
33
- isTracking: boolean;
34
- private _minimumStallThreshold;
35
- /** Total amount of time of all stalls that occurred during the current tracking session */
36
- private _totalStallTime;
37
- /** Total number of stalls that occurred during the current tracking session */
38
- private _stallCount;
39
- /** The last timestamp the iteration ran in milliseconds */
40
- private _lastIntervalMs;
41
- private _timeout;
42
- private _isBackground;
43
- private _statsByTransaction;
44
- constructor(options?: StallTrackingOptions);
45
- /**
46
- * @inheritDoc
47
- * Not used for this integration. Instead call `registerTransactionStart` to start tracking.
48
- */
49
- setupOnce(): void;
50
- /**
51
- * Register a transaction as started. Starts stall tracking if not already running.
52
- * @returns A finish method that returns the stall measurements.
53
- */
54
- onTransactionStart(transaction: Transaction): void;
55
- /**
56
- * Logs a transaction as finished.
57
- * Stops stall tracking if no more transactions are running.
58
- * @returns The stall measurements
59
- */
60
- onTransactionFinish(transaction: Transaction | IdleTransaction, passedEndTimestamp?: number): void;
61
- /**
62
- * Switch that enables the iteraction once app moves from background to foreground.
63
- */
64
- private _backgroundEventListener;
65
- /**
66
- * Logs the finish time of the span for use in `trimEnd: true` transactions.
67
- */
68
- private _markSpanFinish;
69
- /**
70
- * Get the current stats for a transaction at a given time.
71
- */
72
- private _getCurrentStats;
73
- /**
74
- * Start tracking stalls
75
- */
76
- private _startTracking;
77
- /**
78
- * Stops the stall tracking interval and calls reset().
79
- */
80
- private _stopTracking;
81
- /**
82
- * Will stop tracking if there are no more transactions.
83
- */
84
- private _shouldStopTracking;
85
- /**
86
- * Clears all the collected stats
87
- */
88
- private _reset;
89
- /**
90
- * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how
91
- * long the stall is for.
92
- */
93
- private _iteration;
94
- /**
95
- * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)
96
- */
97
- private _flushLeakedTransactions;
98
- }
99
- //# sourceMappingURL=stalltracking.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stalltrac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,WAAW,EAAE,WAAW,GAAG,eAAe,EAAE,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI;IA+FzG;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAahC;;OAEG;IACH,OAAO,CAAC,eAAe;IA2BvB;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAWxB;;OAEG;IACH,OAAO,CAAC,cAAc;IAStB;;OAEG;IACH,OAAO,CAAC,aAAa;IAWrB;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAM3B;;OAEG;IACH,OAAO,CAAC,MAAM;IAOd;;;OAGG;IACH,OAAO,CAAC,UAAU;IA0BlB;;OAEG;IACH,OAAO,CAAC,wBAAwB;CAYjC"}
@@ -1,286 +0,0 @@
1
- import { logger, timestampInSeconds } from '@sentry/utils';
2
- import { AppState } from 'react-native';
3
- import { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';
4
- /** Margin of error of 20ms */
5
- const MARGIN_OF_ERROR_SECONDS = 0.02;
6
- /** How long between each iteration in the event loop tracker timeout */
7
- const LOOP_TIMEOUT_INTERVAL_MS = 50;
8
- /** Limit for how many transactions the stall tracker will track at a time to prevent leaks due to transactions not being finished */
9
- const MAX_RUNNING_TRANSACTIONS = 10;
10
- /**
11
- * Stall measurement tracker inspired by the `JSEventLoopWatchdog` used internally in React Native:
12
- * https://github.com/facebook/react-native/blob/006f5afe120c290a37cf6ff896748fbc062bf7ed/Libraries/Interaction/JSEventLoopWatchdog.js
13
- *
14
- * However, we modified the interval implementation to instead have a fixed loop timeout interval of `LOOP_TIMEOUT_INTERVAL_MS`.
15
- * 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`
16
- */
17
- export class StallTrackingInstrumentation {
18
- constructor(options = { minimumStallThreshold: 50 }) {
19
- this.isTracking = false;
20
- /** Total amount of time of all stalls that occurred during the current tracking session */
21
- this._totalStallTime = 0;
22
- /** Total number of stalls that occurred during the current tracking session */
23
- this._stallCount = 0;
24
- /** The last timestamp the iteration ran in milliseconds */
25
- this._lastIntervalMs = 0;
26
- this._timeout = null;
27
- this._isBackground = false;
28
- this._statsByTransaction = new Map();
29
- this._minimumStallThreshold = options.minimumStallThreshold;
30
- this._backgroundEventListener = this._backgroundEventListener.bind(this);
31
- // Avoids throwing any error if using React Native on a environment that doesn't implement AppState.
32
- if (AppState === null || AppState === void 0 ? void 0 : AppState.isAvailable) {
33
- // eslint-disable-next-line @typescript-eslint/unbound-method
34
- AppState.addEventListener('change', this._backgroundEventListener);
35
- }
36
- }
37
- /**
38
- * @inheritDoc
39
- * Not used for this integration. Instead call `registerTransactionStart` to start tracking.
40
- */
41
- setupOnce() {
42
- // Do nothing.
43
- }
44
- /**
45
- * Register a transaction as started. Starts stall tracking if not already running.
46
- * @returns A finish method that returns the stall measurements.
47
- */
48
- onTransactionStart(transaction) {
49
- if (this._statsByTransaction.has(transaction)) {
50
- logger.error('[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.');
51
- return;
52
- }
53
- this._startTracking();
54
- this._statsByTransaction.set(transaction, {
55
- longestStallTime: 0,
56
- atTimestamp: null,
57
- atStart: this._getCurrentStats(transaction),
58
- });
59
- this._flushLeakedTransactions();
60
- if (transaction.spanRecorder) {
61
- // eslint-disable-next-line @typescript-eslint/unbound-method
62
- const originalAdd = transaction.spanRecorder.add;
63
- transaction.spanRecorder.add = (span) => {
64
- originalAdd.apply(transaction.spanRecorder, [span]);
65
- // eslint-disable-next-line @typescript-eslint/unbound-method
66
- const originalSpanFinish = span.finish;
67
- span.finish = (endTimestamp) => {
68
- // We let the span determine its own end timestamp as well in case anything gets changed upstream
69
- originalSpanFinish.apply(span, [endTimestamp]);
70
- // The span should set a timestamp, so this would be defined.
71
- if (span.endTimestamp) {
72
- this._markSpanFinish(transaction, span.endTimestamp);
73
- }
74
- };
75
- // eslint-disable-next-line @typescript-eslint/unbound-method
76
- const originalSpanEnd = span.end;
77
- span.end = (endTimestamp) => {
78
- // We let the span determine its own end timestamp as well in case anything gets changed upstream
79
- originalSpanEnd.apply(span, [endTimestamp]);
80
- // The span should set a timestamp, so this would be defined.
81
- if (span.endTimestamp) {
82
- this._markSpanFinish(transaction, span.endTimestamp);
83
- }
84
- };
85
- };
86
- }
87
- }
88
- /**
89
- * Logs a transaction as finished.
90
- * Stops stall tracking if no more transactions are running.
91
- * @returns The stall measurements
92
- */
93
- onTransactionFinish(transaction, passedEndTimestamp) {
94
- const transactionStats = this._statsByTransaction.get(transaction);
95
- if (!transactionStats) {
96
- // Transaction has been flushed out somehow, we return null.
97
- logger.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');
98
- this._statsByTransaction.delete(transaction);
99
- this._shouldStopTracking();
100
- return;
101
- }
102
- const endTimestamp = passedEndTimestamp !== null && passedEndTimestamp !== void 0 ? passedEndTimestamp : transaction.endTimestamp;
103
- const spans = transaction.spanRecorder ? transaction.spanRecorder.spans : [];
104
- const finishedSpanCount = spans.reduce((count, s) => (s !== transaction && s.endTimestamp ? count + 1 : count), 0);
105
- const trimEnd = transaction.toContext().trimEnd;
106
- const endWillBeTrimmed = trimEnd && finishedSpanCount > 0;
107
- /*
108
- This is not safe in the case that something changes upstream, but if we're planning to move this over to @sentry/javascript anyways,
109
- we can have this temporarily for now.
110
- */
111
- const isIdleTransaction = 'activities' in transaction;
112
- let statsOnFinish;
113
- if (endTimestamp && isIdleTransaction) {
114
- /*
115
- There is different behavior regarding child spans in a normal transaction and an idle transaction. In normal transactions,
116
- the child spans that aren't finished will be dumped, while in an idle transaction they're cancelled and finished.
117
-
118
- Note: `endTimestamp` will always be defined if this is called on an idle transaction finish. This is because we only instrument
119
- idle transactions inside `ReactNativeTracing`, which will pass an `endTimestamp`.
120
- */
121
- // There will be cancelled spans, which means that the end won't be trimmed
122
- const spansWillBeCancelled = spans.some(s => s !== transaction && s.startTimestamp < endTimestamp && !s.endTimestamp);
123
- if (endWillBeTrimmed && !spansWillBeCancelled) {
124
- // the last span's timestamp will be used.
125
- if (transactionStats.atTimestamp) {
126
- statsOnFinish = transactionStats.atTimestamp.stats;
127
- }
128
- }
129
- else {
130
- // this endTimestamp will be used.
131
- statsOnFinish = this._getCurrentStats(transaction);
132
- }
133
- }
134
- else if (endWillBeTrimmed) {
135
- // If `trimEnd` is used, and there is a span to trim to. If there isn't, then the transaction should use `endTimestamp` or generate one.
136
- if (transactionStats.atTimestamp) {
137
- statsOnFinish = transactionStats.atTimestamp.stats;
138
- }
139
- }
140
- else if (!endTimestamp) {
141
- statsOnFinish = this._getCurrentStats(transaction);
142
- }
143
- this._statsByTransaction.delete(transaction);
144
- this._shouldStopTracking();
145
- if (!statsOnFinish) {
146
- if (typeof endTimestamp !== 'undefined') {
147
- logger.log('[StallTracking] Stall measurements not added due to `endTimestamp` being set.');
148
- }
149
- else if (trimEnd) {
150
- logger.log('[StallTracking] Stall measurements not added due to `trimEnd` being set but we could not determine the stall measurements at that time.');
151
- }
152
- return;
153
- }
154
- transaction.setMeasurement(STALL_COUNT, statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value, transactionStats.atStart.stall_count.unit);
155
- transaction.setMeasurement(STALL_TOTAL_TIME, statsOnFinish.stall_total_time.value - transactionStats.atStart.stall_total_time.value, transactionStats.atStart.stall_total_time.unit);
156
- transaction.setMeasurement(STALL_LONGEST_TIME, statsOnFinish.stall_longest_time.value, statsOnFinish.stall_longest_time.unit);
157
- }
158
- /**
159
- * Switch that enables the iteraction once app moves from background to foreground.
160
- */
161
- _backgroundEventListener(state) {
162
- if (state === 'active') {
163
- this._isBackground = false;
164
- if (this._timeout != null) {
165
- this._lastIntervalMs = timestampInSeconds() * 1000;
166
- this._iteration();
167
- }
168
- }
169
- else {
170
- this._isBackground = true;
171
- this._timeout !== null && clearTimeout(this._timeout);
172
- }
173
- }
174
- /**
175
- * Logs the finish time of the span for use in `trimEnd: true` transactions.
176
- */
177
- _markSpanFinish(transaction, spanEndTimestamp) {
178
- const previousStats = this._statsByTransaction.get(transaction);
179
- if (previousStats) {
180
- if (Math.abs(timestampInSeconds() - spanEndTimestamp) > MARGIN_OF_ERROR_SECONDS) {
181
- logger.log('[StallTracking] Span end not logged due to end timestamp being outside the margin of error from now.');
182
- if (previousStats.atTimestamp && previousStats.atTimestamp.timestamp < spanEndTimestamp) {
183
- // We also need to delete the stat for the last span, as the transaction would be trimmed to this span not the last one.
184
- this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, previousStats), { atTimestamp: null }));
185
- }
186
- }
187
- else {
188
- this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, previousStats), { atTimestamp: {
189
- timestamp: spanEndTimestamp,
190
- stats: this._getCurrentStats(transaction),
191
- } }));
192
- }
193
- }
194
- }
195
- /**
196
- * Get the current stats for a transaction at a given time.
197
- */
198
- _getCurrentStats(transaction) {
199
- var _a, _b;
200
- return {
201
- stall_count: { value: this._stallCount, unit: 'none' },
202
- stall_total_time: { value: this._totalStallTime, unit: 'millisecond' },
203
- stall_longest_time: {
204
- value: (_b = (_a = this._statsByTransaction.get(transaction)) === null || _a === void 0 ? void 0 : _a.longestStallTime) !== null && _b !== void 0 ? _b : 0,
205
- unit: 'millisecond',
206
- },
207
- };
208
- }
209
- /**
210
- * Start tracking stalls
211
- */
212
- _startTracking() {
213
- if (!this.isTracking) {
214
- this.isTracking = true;
215
- this._lastIntervalMs = Math.floor(timestampInSeconds() * 1000);
216
- this._iteration();
217
- }
218
- }
219
- /**
220
- * Stops the stall tracking interval and calls reset().
221
- */
222
- _stopTracking() {
223
- this.isTracking = false;
224
- if (this._timeout !== null) {
225
- clearTimeout(this._timeout);
226
- this._timeout = null;
227
- }
228
- this._reset();
229
- }
230
- /**
231
- * Will stop tracking if there are no more transactions.
232
- */
233
- _shouldStopTracking() {
234
- if (this._statsByTransaction.size === 0) {
235
- this._stopTracking();
236
- }
237
- }
238
- /**
239
- * Clears all the collected stats
240
- */
241
- _reset() {
242
- this._stallCount = 0;
243
- this._totalStallTime = 0;
244
- this._lastIntervalMs = 0;
245
- this._statsByTransaction.clear();
246
- }
247
- /**
248
- * Iteration of the stall tracking interval. Measures how long the timer strayed from its expected time of running, and how
249
- * long the stall is for.
250
- */
251
- _iteration() {
252
- var _a;
253
- const now = timestampInSeconds() * 1000;
254
- const totalTimeTaken = now - this._lastIntervalMs;
255
- if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + this._minimumStallThreshold) {
256
- const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;
257
- this._stallCount += 1;
258
- this._totalStallTime += stallTime;
259
- for (const [transaction, value] of this._statsByTransaction.entries()) {
260
- const longestStallTime = Math.max((_a = value.longestStallTime) !== null && _a !== void 0 ? _a : 0, stallTime);
261
- this._statsByTransaction.set(transaction, Object.assign(Object.assign({}, value), { longestStallTime }));
262
- }
263
- }
264
- this._lastIntervalMs = now;
265
- if (this.isTracking && !this._isBackground) {
266
- this._timeout = setTimeout(this._iteration.bind(this), LOOP_TIMEOUT_INTERVAL_MS);
267
- }
268
- }
269
- /**
270
- * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)
271
- */
272
- _flushLeakedTransactions() {
273
- if (this._statsByTransaction.size > MAX_RUNNING_TRANSACTIONS) {
274
- let counter = 0;
275
- const len = this._statsByTransaction.size - MAX_RUNNING_TRANSACTIONS;
276
- const transactions = this._statsByTransaction.keys();
277
- for (const t of transactions) {
278
- if (counter >= len)
279
- break;
280
- counter += 1;
281
- this._statsByTransaction.delete(t);
282
- }
283
- }
284
- }
285
- }
286
- //# sourceMappingURL=stalltracking.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stalltracking.js","sourceRoot":"","sources":["../../../src/js/tracing/stalltracking.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAE3D,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,WAAW,EAAE,kB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AI,GAAG,wBAAwB,CAAC;YACrE,MAAM,YAAY,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,EAAE,CAAC;YACrD,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE;gBAC5B,IAAI,OAAO,IAAI,GAAG;oBAAE,MAAM;gBAC1B,OAAO,IAAI,CAAC,CAAC;gBACb,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;aACpC;SACF;IACH,CAAC;CACF","sourcesContent":["/* eslint-disable max-lines */\nimport type { IdleTransaction, Span, Transaction } from '@sentry/core';\nimport type { Measurements, MeasurementUnit } from '@sentry/types';\nimport { logger, timestampInSeconds } from '@sentry/utils';\nimport type { AppStateStatus } from 'react-native';\nimport { AppState } from 'react-native';\n\nimport { STALL_COUNT, STALL_LONGEST_TIME, STALL_TOTAL_TIME } from '../measurements';\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\nexport type StallTrackingOptions = {\n /**\n * How long in milliseconds an event loop iteration can be delayed for before being considered a \"stall.\"\n * @default 100\n */\n minimumStallThreshold: number;\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 class StallTrackingInstrumentation {\n public isTracking: boolean = false;\n\n private _minimumStallThreshold: number;\n\n /** Total amount of time of all stalls that occurred during the current tracking session */\n private _totalStallTime: number = 0;\n /** Total number of stalls that occurred during the current tracking session */\n private _stallCount: number = 0;\n\n /** The last timestamp the iteration ran in milliseconds */\n private _lastIntervalMs: number = 0;\n private _timeout: ReturnType<typeof setTimeout> | null = null;\n\n private _isBackground: boolean = false;\n\n private _statsByTransaction: Map<\n Transaction,\n {\n longestStallTime: number;\n atStart: StallMeasurements;\n atTimestamp: {\n timestamp: number;\n stats: StallMeasurements;\n } | null;\n }\n > = new Map();\n\n public constructor(options: StallTrackingOptions = { minimumStallThreshold: 50 }) {\n this._minimumStallThreshold = options.minimumStallThreshold;\n\n this._backgroundEventListener = this._backgroundEventListener.bind(this);\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', this._backgroundEventListener);\n }\n }\n\n /**\n * @inheritDoc\n * Not used for this integration. Instead call `registerTransactionStart` to start tracking.\n */\n public setupOnce(): void {\n // Do nothing.\n }\n\n /**\n * Register a transaction as started. Starts stall tracking if not already running.\n * @returns A finish method that returns the stall measurements.\n */\n public onTransactionStart(transaction: Transaction): void {\n if (this._statsByTransaction.has(transaction)) {\n logger.error(\n '[StallTracking] Tried to start stall tracking on a transaction already being tracked. Measurements might be lost.',\n );\n\n return;\n }\n\n this._startTracking();\n this._statsByTransaction.set(transaction, {\n longestStallTime: 0,\n atTimestamp: null,\n atStart: this._getCurrentStats(transaction),\n });\n this._flushLeakedTransactions();\n\n if (transaction.spanRecorder) {\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalAdd = transaction.spanRecorder.add;\n\n transaction.spanRecorder.add = (span: Span): void => {\n originalAdd.apply(transaction.spanRecorder, [span]);\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalSpanFinish = span.finish;\n\n span.finish = (endTimestamp?: number) => {\n // We let the span determine its own end timestamp as well in case anything gets changed upstream\n originalSpanFinish.apply(span, [endTimestamp]);\n\n // The span should set a timestamp, so this would be defined.\n if (span.endTimestamp) {\n this._markSpanFinish(transaction, span.endTimestamp);\n }\n };\n\n // eslint-disable-next-line @typescript-eslint/unbound-method\n const originalSpanEnd = span.end;\n\n span.end = (endTimestamp?: number) => {\n // We let the span determine its own end timestamp as well in case anything gets changed upstream\n originalSpanEnd.apply(span, [endTimestamp]);\n\n // The span should set a timestamp, so this would be defined.\n if (span.endTimestamp) {\n this._markSpanFinish(transaction, span.endTimestamp);\n }\n };\n };\n }\n }\n\n /**\n * Logs a transaction as finished.\n * Stops stall tracking if no more transactions are running.\n * @returns The stall measurements\n */\n public onTransactionFinish(transaction: Transaction | IdleTransaction, passedEndTimestamp?: number): void {\n const transactionStats = this._statsByTransaction.get(transaction);\n\n if (!transactionStats) {\n // Transaction has been flushed out somehow, we return null.\n logger.log('[StallTracking] Stall measurements were not added to transaction due to exceeding the max count.');\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n return;\n }\n\n const endTimestamp = passedEndTimestamp ?? transaction.endTimestamp;\n\n const spans = transaction.spanRecorder ? transaction.spanRecorder.spans : [];\n const finishedSpanCount = spans.reduce((count, s) => (s !== transaction && s.endTimestamp ? count + 1 : count), 0);\n\n const trimEnd = transaction.toContext().trimEnd;\n const endWillBeTrimmed = trimEnd && finishedSpanCount > 0;\n\n /*\n This is not safe in the case that something changes upstream, but if we're planning to move this over to @sentry/javascript anyways,\n we can have this temporarily for now.\n */\n const isIdleTransaction = 'activities' in transaction;\n\n let statsOnFinish: StallMeasurements | undefined;\n if (endTimestamp && isIdleTransaction) {\n /*\n There is different behavior regarding child spans in a normal transaction and an idle transaction. In normal transactions,\n the child spans that aren't finished will be dumped, while in an idle transaction they're cancelled and finished.\n\n Note: `endTimestamp` will always be defined if this is called on an idle transaction finish. This is because we only instrument\n idle transactions inside `ReactNativeTracing`, which will pass an `endTimestamp`.\n */\n\n // There will be cancelled spans, which means that the end won't be trimmed\n const spansWillBeCancelled = spans.some(\n s => s !== transaction && s.startTimestamp < endTimestamp && !s.endTimestamp,\n );\n\n if (endWillBeTrimmed && !spansWillBeCancelled) {\n // the last span's timestamp will be used.\n\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else {\n // this endTimestamp will be used.\n statsOnFinish = this._getCurrentStats(transaction);\n }\n } else if (endWillBeTrimmed) {\n // If `trimEnd` is used, and there is a span to trim to. If there isn't, then the transaction should use `endTimestamp` or generate one.\n if (transactionStats.atTimestamp) {\n statsOnFinish = transactionStats.atTimestamp.stats;\n }\n } else if (!endTimestamp) {\n statsOnFinish = this._getCurrentStats(transaction);\n }\n\n this._statsByTransaction.delete(transaction);\n this._shouldStopTracking();\n\n if (!statsOnFinish) {\n if (typeof endTimestamp !== 'undefined') {\n logger.log('[StallTracking] Stall measurements not added due to `endTimestamp` being set.');\n } else if (trimEnd) {\n logger.log(\n '[StallTracking] Stall measurements not added due to `trimEnd` being set but we could not determine the stall measurements at that time.',\n );\n }\n\n return;\n }\n\n transaction.setMeasurement(\n STALL_COUNT,\n statsOnFinish.stall_count.value - transactionStats.atStart.stall_count.value,\n transactionStats.atStart.stall_count.unit,\n );\n\n transaction.setMeasurement(\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 transaction.setMeasurement(\n STALL_LONGEST_TIME,\n statsOnFinish.stall_longest_time.value,\n statsOnFinish.stall_longest_time.unit,\n );\n }\n\n /**\n * Switch that enables the iteraction once app moves from background to foreground.\n */\n private _backgroundEventListener(state: AppStateStatus): void {\n if (state === ('active' as AppStateStatus)) {\n this._isBackground = false;\n if (this._timeout != null) {\n this._lastIntervalMs = timestampInSeconds() * 1000;\n this._iteration();\n }\n } else {\n this._isBackground = true;\n this._timeout !== null && clearTimeout(this._timeout);\n }\n }\n\n /**\n * Logs the finish time of the span for use in `trimEnd: true` transactions.\n */\n private _markSpanFinish(transaction: Transaction, spanEndTimestamp: number): void {\n const previousStats = this._statsByTransaction.get(transaction);\n if (previousStats) {\n if (Math.abs(timestampInSeconds() - spanEndTimestamp) > MARGIN_OF_ERROR_SECONDS) {\n logger.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 < spanEndTimestamp) {\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 this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: null,\n });\n }\n } else {\n this._statsByTransaction.set(transaction, {\n ...previousStats,\n atTimestamp: {\n timestamp: spanEndTimestamp,\n stats: this._getCurrentStats(transaction),\n },\n });\n }\n }\n }\n\n /**\n * Get the current stats for a transaction at a given time.\n */\n private _getCurrentStats(transaction: Transaction): StallMeasurements {\n return {\n stall_count: { value: this._stallCount, unit: 'none' },\n stall_total_time: { value: this._totalStallTime, unit: 'millisecond' },\n stall_longest_time: {\n value: this._statsByTransaction.get(transaction)?.longestStallTime ?? 0,\n unit: 'millisecond',\n },\n };\n }\n\n /**\n * Start tracking stalls\n */\n private _startTracking(): void {\n if (!this.isTracking) {\n this.isTracking = true;\n this._lastIntervalMs = Math.floor(timestampInSeconds() * 1000);\n\n this._iteration();\n }\n }\n\n /**\n * Stops the stall tracking interval and calls reset().\n */\n private _stopTracking(): void {\n this.isTracking = false;\n\n if (this._timeout !== null) {\n clearTimeout(this._timeout);\n this._timeout = null;\n }\n\n this._reset();\n }\n\n /**\n * Will stop tracking if there are no more transactions.\n */\n private _shouldStopTracking(): void {\n if (this._statsByTransaction.size === 0) {\n this._stopTracking();\n }\n }\n\n /**\n * Clears all the collected stats\n */\n private _reset(): void {\n this._stallCount = 0;\n this._totalStallTime = 0;\n this._lastIntervalMs = 0;\n this._statsByTransaction.clear();\n }\n\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 private _iteration(): void {\n const now = timestampInSeconds() * 1000;\n const totalTimeTaken = now - this._lastIntervalMs;\n\n if (totalTimeTaken >= LOOP_TIMEOUT_INTERVAL_MS + this._minimumStallThreshold) {\n const stallTime = totalTimeTaken - LOOP_TIMEOUT_INTERVAL_MS;\n this._stallCount += 1;\n this._totalStallTime += stallTime;\n\n for (const [transaction, value] of this._statsByTransaction.entries()) {\n const longestStallTime = Math.max(value.longestStallTime ?? 0, stallTime);\n\n this._statsByTransaction.set(transaction, {\n ...value,\n longestStallTime,\n });\n }\n }\n\n this._lastIntervalMs = now;\n\n if (this.isTracking && !this._isBackground) {\n this._timeout = setTimeout(this._iteration.bind(this), LOOP_TIMEOUT_INTERVAL_MS);\n }\n }\n\n /**\n * Deletes leaked transactions (Earliest transactions when we have more than MAX_RUNNING_TRANSACTIONS transactions.)\n */\n private _flushLeakedTransactions(): void {\n if (this._statsByTransaction.size > MAX_RUNNING_TRANSACTIONS) {\n let counter = 0;\n const len = this._statsByTransaction.size - MAX_RUNNING_TRANSACTIONS;\n const transactions = this._statsByTransaction.keys();\n for (const t of transactions) {\n if (counter >= len) break;\n counter += 1;\n this._statsByTransaction.delete(t);\n }\n }\n }\n}\n"]}
@@ -1,11 +0,0 @@
1
- import { type BeforeFinishCallback, type IdleTransaction } from '@sentry/core';
2
- /**
3
- * Idle Transaction callback to only sample transactions with child spans.
4
- * To avoid side effects of other callbacks this should be hooked as the last callback.
5
- */
6
- export declare const onlySampleIfChildSpans: BeforeFinishCallback;
7
- /**
8
- * Hooks on AppState change to cancel the transaction if the app goes background.
9
- */
10
- export declare const cancelInBackground: (transaction: IdleTransaction) => void;
11
- //# sourceMappingURL=transaction.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.d.ts","sourceRoot":"","sources":["../../../src/js/tracing/transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAK/E;;;GAGG;AACH,eAAO,MAAM,sBAAsB,EAAE,oBASpC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,kBAAkB,gBAAiB,eAAe,KAAG,IAsBjE,CAAC"}
@@ -1,37 +0,0 @@
1
- import { logger } from '@sentry/utils';
2
- import { AppState } from 'react-native';
3
- /**
4
- * Idle Transaction callback to only sample transactions with child spans.
5
- * To avoid side effects of other callbacks this should be hooked as the last callback.
6
- */
7
- export const onlySampleIfChildSpans = (transaction) => {
8
- const spansCount = transaction.spanRecorder &&
9
- transaction.spanRecorder.spans.filter(span => span.spanId !== transaction.spanId).length;
10
- if (!spansCount || spansCount <= 0) {
11
- logger.log(`Not sampling as ${transaction.op} transaction has no child spans.`);
12
- transaction.sampled = false;
13
- }
14
- };
15
- /**
16
- * Hooks on AppState change to cancel the transaction if the app goes background.
17
- */
18
- export const cancelInBackground = (transaction) => {
19
- if (!AppState || !AppState.isAvailable) {
20
- logger.warn('AppState is not available, spans will not be canceled in background.');
21
- return;
22
- }
23
- // RN Web can return undefined, https://github.com/necolas/react-native-web/blob/8cf720f0e57c74a254bfa7bed0313e33a4b29c11/packages/react-native-web/src/exports/AppState/index.js#L55
24
- const subscription = AppState.addEventListener('change', (newState) => {
25
- if (newState === 'background') {
26
- logger.debug(`Setting ${transaction.op} transaction to cancelled because the app is in the background.`);
27
- transaction.setStatus('cancelled');
28
- transaction.finish();
29
- }
30
- });
31
- subscription &&
32
- transaction.registerBeforeFinishCallback(() => {
33
- logger.debug(`Removing AppState listener for ${transaction.op} transaction.`);
34
- subscription && subscription.remove && subscription.remove();
35
- });
36
- };
37
- //# sourceMappingURL=transaction.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/js/tracing/transaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;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AC,MAAM,EAAE,CAAC;QAC/D,CAAC,CAAC,CAAC;AACP,CAAC,CAAC","sourcesContent":["import { type BeforeFinishCallback, type IdleTransaction } from '@sentry/core';\nimport { logger } from '@sentry/utils';\nimport type { AppStateStatus, NativeEventSubscription } from 'react-native';\nimport { AppState } from 'react-native';\n\n/**\n * Idle Transaction callback to only sample transactions with child spans.\n * To avoid side effects of other callbacks this should be hooked as the last callback.\n */\nexport const onlySampleIfChildSpans: BeforeFinishCallback = (transaction: IdleTransaction): void => {\n const spansCount =\n transaction.spanRecorder &&\n transaction.spanRecorder.spans.filter(span => span.spanId !== transaction.spanId).length;\n\n if (!spansCount || spansCount <= 0) {\n logger.log(`Not sampling as ${transaction.op} transaction has no child spans.`);\n transaction.sampled = false;\n }\n};\n\n/**\n * Hooks on AppState change to cancel the transaction if the app goes background.\n */\nexport const cancelInBackground = (transaction: IdleTransaction): void => {\n if (!AppState || !AppState.isAvailable) {\n logger.warn('AppState is not available, spans will not be canceled in background.');\n return;\n }\n\n // RN Web can return undefined, https://github.com/necolas/react-native-web/blob/8cf720f0e57c74a254bfa7bed0313e33a4b29c11/packages/react-native-web/src/exports/AppState/index.js#L55\n const subscription: NativeEventSubscription | undefined = AppState.addEventListener(\n 'change',\n (newState: AppStateStatus) => {\n if (newState === 'background') {\n logger.debug(`Setting ${transaction.op} transaction to cancelled because the app is in the background.`);\n transaction.setStatus('cancelled');\n transaction.finish();\n }\n },\n );\n subscription &&\n transaction.registerBeforeFinishCallback(() => {\n logger.debug(`Removing AppState listener for ${transaction.op} transaction.`);\n subscription && subscription.remove && subscription.remove();\n });\n};\n"]}
@@ -1,3 +0,0 @@
1
- import type { TextEncoderInternal } from '@sentry/types';
2
- export declare const makeUtf8TextEncoder: () => TextEncoderInternal;
3
- //# sourceMappingURL=TextEncoder.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextEncoder.d.ts","sourceRoot":"","sources":["../../../src/js/transports/TextEncoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIzD,eAAO,MAAM,mBAAmB,QAAO,mBAStC,CAAC"}
@@ -1,12 +0,0 @@
1
- import { utf8ToBytes } from '../vendor';
2
- export const makeUtf8TextEncoder = () => {
3
- const textEncoder = {
4
- encode: (text) => {
5
- const bytes = new Uint8Array(utf8ToBytes(text));
6
- return bytes;
7
- },
8
- encoding: 'utf-8',
9
- };
10
- return textEncoder;
11
- };
12
- //# sourceMappingURL=TextEncoder.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"TextEncoder.js","sourceRoot":"","sources":["../../../src/js/transports/TextEncoder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,CAAC,MAAM,mBAAmB,GAAG,GAAwB,EAAE;IAC3D,MAAM,WAAW,GAAG;QAClB,MAAM,EAAE,CAAC,IAAY,EAAE,EAAE;YACvB,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAChD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,QAAQ,EAAE,OAAO;KAClB,CAAC;IACF,OAAO,WAAW,CAAC;AACrB,CAAC,CAAC","sourcesContent":["import type { TextEncoderInternal } from '@sentry/types';\n\nimport { utf8ToBytes } from '../vendor';\n\nexport const makeUtf8TextEncoder = (): TextEncoderInternal => {\n const textEncoder = {\n encode: (text: string) => {\n const bytes = new Uint8Array(utf8ToBytes(text));\n return bytes;\n },\n encoding: 'utf-8',\n };\n return textEncoder;\n};\n"]}