@scalebun/react-native 1.0.3 → 1.1.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 (244) hide show
  1. package/android/src/main/java/com/scalebun/core/crash/CrashStorage.kt +115 -1
  2. package/android/src/main/java/com/scalebun/core/crash/NativeCrashHandler.kt +14 -0
  3. package/android/src/main/java/com/scalebun/replaysdk/ReplaySdkModule.kt +25 -9
  4. package/android/src/main/java/com/scalebun/replaysdk/voice/VoiceTranscriber.kt +68 -2
  5. package/android/src/main/java/com/scalebun/rn/crash/ScaleBunCrashModule.kt +66 -2
  6. package/android/src/main/java/com/scalebun/rn/ota/SlotManager.kt +70 -4
  7. package/ios/Crash/ScaleBunCrashBridge.mm +6 -0
  8. package/ios/Crash/ScaleBunCrashHandler.swift +14 -1
  9. package/ios/Crash/ScaleBunCrashModule.swift +14 -0
  10. package/ios/Crash/ScaleBunCrashSignalBridge.h +32 -1
  11. package/ios/Crash/ScaleBunCrashSignalBridge.m +172 -7
  12. package/ios/Crash/ScaleBunCrashSignalStress.c +137 -0
  13. package/ios/Crash/ScaleBunCrashStorage.swift +75 -0
  14. package/lib/commonjs/analytics/EventTracker.js +30 -2
  15. package/lib/commonjs/analytics/EventTracker.js.map +1 -1
  16. package/lib/commonjs/bootstrap/SDKBootstrapper.js +31 -23
  17. package/lib/commonjs/bootstrap/SDKBootstrapper.js.map +1 -1
  18. package/lib/commonjs/compat/codepush.js +78 -15
  19. package/lib/commonjs/compat/codepush.js.map +1 -1
  20. package/lib/commonjs/core/config/schema.js +26 -5
  21. package/lib/commonjs/core/config/schema.js.map +1 -1
  22. package/lib/commonjs/core/constants/endpoints.js +9 -6
  23. package/lib/commonjs/core/constants/endpoints.js.map +1 -1
  24. package/lib/commonjs/core/context/device.js +130 -0
  25. package/lib/commonjs/core/context/device.js.map +1 -1
  26. package/lib/commonjs/debug/replayWiring.js +2 -1
  27. package/lib/commonjs/debug/replayWiring.js.map +1 -1
  28. package/lib/commonjs/features/bugreport/BugReportFeature.js +112 -0
  29. package/lib/commonjs/features/bugreport/BugReportFeature.js.map +1 -0
  30. package/lib/commonjs/features/bugreport/buildPayload.js +97 -0
  31. package/lib/commonjs/features/bugreport/buildPayload.js.map +1 -0
  32. package/lib/commonjs/features/crash/CrashReporter.js +25 -1
  33. package/lib/commonjs/features/crash/CrashReporter.js.map +1 -1
  34. package/lib/commonjs/features/crash/capture.js +27 -9
  35. package/lib/commonjs/features/crash/capture.js.map +1 -1
  36. package/lib/commonjs/features/crash/nativeCrashBridge.js +163 -28
  37. package/lib/commonjs/features/crash/nativeCrashBridge.js.map +1 -1
  38. package/lib/commonjs/features/engage/EngagePromptProvider.js +36 -2
  39. package/lib/commonjs/features/engage/EngagePromptProvider.js.map +1 -1
  40. package/lib/commonjs/features/engage/EngagePromptView.js +47 -14
  41. package/lib/commonjs/features/engage/EngagePromptView.js.map +1 -1
  42. package/lib/commonjs/features/engage/engageTriggerEngine.js +10 -0
  43. package/lib/commonjs/features/engage/engageTriggerEngine.js.map +1 -1
  44. package/lib/commonjs/features/engage/engageTypes.js.map +1 -1
  45. package/lib/commonjs/features/journey/ScaleBunDebugRoot.js +2 -1
  46. package/lib/commonjs/features/journey/ScaleBunDebugRoot.js.map +1 -1
  47. package/lib/commonjs/features/ota/OtaOrchestrator.js +72 -5
  48. package/lib/commonjs/features/ota/OtaOrchestrator.js.map +1 -1
  49. package/lib/commonjs/features/ota/deviceAttributes.js +48 -0
  50. package/lib/commonjs/features/ota/deviceAttributes.js.map +1 -0
  51. package/lib/commonjs/features/ota/geoCountry.js +93 -0
  52. package/lib/commonjs/features/ota/geoCountry.js.map +1 -0
  53. package/lib/commonjs/features/ota/useOtaUpdate.js +4 -1
  54. package/lib/commonjs/features/ota/useOtaUpdate.js.map +1 -1
  55. package/lib/commonjs/features/performance/PerformanceFeature.js +23 -9
  56. package/lib/commonjs/features/performance/PerformanceFeature.js.map +1 -1
  57. package/lib/commonjs/features/performance/collectors/FrameMetricsCollector.js +69 -9
  58. package/lib/commonjs/features/performance/collectors/FrameMetricsCollector.js.map +1 -1
  59. package/lib/commonjs/features/performance/transport/PerformanceTransport.js +25 -0
  60. package/lib/commonjs/features/performance/transport/PerformanceTransport.js.map +1 -1
  61. package/lib/commonjs/features/session/BackendSessionAdapter.js +128 -11
  62. package/lib/commonjs/features/session/BackendSessionAdapter.js.map +1 -1
  63. package/lib/commonjs/features/session/JourneyEventPipeline.js +1 -0
  64. package/lib/commonjs/features/session/JourneyEventPipeline.js.map +1 -1
  65. package/lib/commonjs/features/session/ReplayCaptureManager.js +46 -0
  66. package/lib/commonjs/features/session/ReplayCaptureManager.js.map +1 -1
  67. package/lib/commonjs/features/session/SessionManager.js +42 -12
  68. package/lib/commonjs/features/session/SessionManager.js.map +1 -1
  69. package/lib/commonjs/features/session/nativeCapture.js +4 -4
  70. package/lib/commonjs/features/session/nativeCapture.js.map +1 -1
  71. package/lib/commonjs/features/session/outboxFrameCapture.js +3 -2
  72. package/lib/commonjs/features/session/outboxFrameCapture.js.map +1 -1
  73. package/lib/commonjs/features/session/sessionTypes.js.map +1 -1
  74. package/lib/commonjs/index.js +13 -0
  75. package/lib/commonjs/index.js.map +1 -1
  76. package/lib/commonjs/public/ScaleBunFacade.js +199 -2
  77. package/lib/commonjs/public/ScaleBunFacade.js.map +1 -1
  78. package/lib/commonjs/specs/NativeScaleBunCrash.js.map +1 -1
  79. package/lib/module/analytics/EventTracker.js +29 -1
  80. package/lib/module/analytics/EventTracker.js.map +1 -1
  81. package/lib/module/bootstrap/SDKBootstrapper.js +29 -21
  82. package/lib/module/bootstrap/SDKBootstrapper.js.map +1 -1
  83. package/lib/module/compat/codepush.js +77 -14
  84. package/lib/module/compat/codepush.js.map +1 -1
  85. package/lib/module/core/config/schema.js +26 -5
  86. package/lib/module/core/config/schema.js.map +1 -1
  87. package/lib/module/core/constants/endpoints.js +9 -6
  88. package/lib/module/core/constants/endpoints.js.map +1 -1
  89. package/lib/module/core/context/device.js +119 -0
  90. package/lib/module/core/context/device.js.map +1 -1
  91. package/lib/module/debug/replayWiring.js +2 -1
  92. package/lib/module/debug/replayWiring.js.map +1 -1
  93. package/lib/module/features/bugreport/BugReportFeature.js +105 -0
  94. package/lib/module/features/bugreport/BugReportFeature.js.map +1 -0
  95. package/lib/module/features/bugreport/buildPayload.js +91 -0
  96. package/lib/module/features/bugreport/buildPayload.js.map +1 -0
  97. package/lib/module/features/crash/CrashReporter.js +25 -1
  98. package/lib/module/features/crash/CrashReporter.js.map +1 -1
  99. package/lib/module/features/crash/capture.js +28 -9
  100. package/lib/module/features/crash/capture.js.map +1 -1
  101. package/lib/module/features/crash/nativeCrashBridge.js +161 -28
  102. package/lib/module/features/crash/nativeCrashBridge.js.map +1 -1
  103. package/lib/module/features/engage/EngagePromptProvider.js +36 -2
  104. package/lib/module/features/engage/EngagePromptProvider.js.map +1 -1
  105. package/lib/module/features/engage/EngagePromptView.js +47 -14
  106. package/lib/module/features/engage/EngagePromptView.js.map +1 -1
  107. package/lib/module/features/engage/engageTriggerEngine.js +10 -0
  108. package/lib/module/features/engage/engageTriggerEngine.js.map +1 -1
  109. package/lib/module/features/engage/engageTypes.js.map +1 -1
  110. package/lib/module/features/journey/ScaleBunDebugRoot.js +2 -1
  111. package/lib/module/features/journey/ScaleBunDebugRoot.js.map +1 -1
  112. package/lib/module/features/ota/OtaOrchestrator.js +72 -5
  113. package/lib/module/features/ota/OtaOrchestrator.js.map +1 -1
  114. package/lib/module/features/ota/deviceAttributes.js +43 -0
  115. package/lib/module/features/ota/deviceAttributes.js.map +1 -0
  116. package/lib/module/features/ota/geoCountry.js +86 -0
  117. package/lib/module/features/ota/geoCountry.js.map +1 -0
  118. package/lib/module/features/ota/useOtaUpdate.js +4 -1
  119. package/lib/module/features/ota/useOtaUpdate.js.map +1 -1
  120. package/lib/module/features/performance/PerformanceFeature.js +23 -9
  121. package/lib/module/features/performance/PerformanceFeature.js.map +1 -1
  122. package/lib/module/features/performance/collectors/FrameMetricsCollector.js +70 -10
  123. package/lib/module/features/performance/collectors/FrameMetricsCollector.js.map +1 -1
  124. package/lib/module/features/performance/transport/PerformanceTransport.js +25 -0
  125. package/lib/module/features/performance/transport/PerformanceTransport.js.map +1 -1
  126. package/lib/module/features/session/BackendSessionAdapter.js +128 -11
  127. package/lib/module/features/session/BackendSessionAdapter.js.map +1 -1
  128. package/lib/module/features/session/JourneyEventPipeline.js +1 -0
  129. package/lib/module/features/session/JourneyEventPipeline.js.map +1 -1
  130. package/lib/module/features/session/ReplayCaptureManager.js +46 -0
  131. package/lib/module/features/session/ReplayCaptureManager.js.map +1 -1
  132. package/lib/module/features/session/SessionManager.js +42 -12
  133. package/lib/module/features/session/SessionManager.js.map +1 -1
  134. package/lib/module/features/session/nativeCapture.js +4 -5
  135. package/lib/module/features/session/nativeCapture.js.map +1 -1
  136. package/lib/module/features/session/outboxFrameCapture.js +3 -2
  137. package/lib/module/features/session/outboxFrameCapture.js.map +1 -1
  138. package/lib/module/features/session/sessionTypes.js.map +1 -1
  139. package/lib/module/index.js +4 -1
  140. package/lib/module/index.js.map +1 -1
  141. package/lib/module/public/ScaleBunFacade.js +199 -2
  142. package/lib/module/public/ScaleBunFacade.js.map +1 -1
  143. package/lib/module/specs/NativeScaleBunCrash.js.map +1 -1
  144. package/lib/typescript/analytics/EventTracker.d.ts +20 -0
  145. package/lib/typescript/analytics/EventTracker.d.ts.map +1 -1
  146. package/lib/typescript/bootstrap/SDKBootstrapper.d.ts.map +1 -1
  147. package/lib/typescript/compat/codepush.d.ts +27 -4
  148. package/lib/typescript/compat/codepush.d.ts.map +1 -1
  149. package/lib/typescript/core/config/schema.d.ts +4 -1
  150. package/lib/typescript/core/config/schema.d.ts.map +1 -1
  151. package/lib/typescript/core/constants/endpoints.d.ts +9 -6
  152. package/lib/typescript/core/constants/endpoints.d.ts.map +1 -1
  153. package/lib/typescript/core/context/device.d.ts +46 -0
  154. package/lib/typescript/core/context/device.d.ts.map +1 -1
  155. package/lib/typescript/debug/replayWiring.d.ts.map +1 -1
  156. package/lib/typescript/features/bugreport/BugReportFeature.d.ts +59 -0
  157. package/lib/typescript/features/bugreport/BugReportFeature.d.ts.map +1 -0
  158. package/lib/typescript/features/bugreport/buildPayload.d.ts +51 -0
  159. package/lib/typescript/features/bugreport/buildPayload.d.ts.map +1 -0
  160. package/lib/typescript/features/crash/CrashReporter.d.ts +20 -1
  161. package/lib/typescript/features/crash/CrashReporter.d.ts.map +1 -1
  162. package/lib/typescript/features/crash/capture.d.ts +21 -2
  163. package/lib/typescript/features/crash/capture.d.ts.map +1 -1
  164. package/lib/typescript/features/crash/nativeCrashBridge.d.ts +16 -3
  165. package/lib/typescript/features/crash/nativeCrashBridge.d.ts.map +1 -1
  166. package/lib/typescript/features/engage/EngagePromptProvider.d.ts.map +1 -1
  167. package/lib/typescript/features/engage/EngagePromptView.d.ts.map +1 -1
  168. package/lib/typescript/features/engage/EngageTransport.d.ts +1 -1
  169. package/lib/typescript/features/engage/EngageTransport.d.ts.map +1 -1
  170. package/lib/typescript/features/engage/engageTriggerEngine.d.ts.map +1 -1
  171. package/lib/typescript/features/engage/engageTypes.d.ts +15 -0
  172. package/lib/typescript/features/engage/engageTypes.d.ts.map +1 -1
  173. package/lib/typescript/features/journey/ScaleBunDebugRoot.d.ts.map +1 -1
  174. package/lib/typescript/features/ota/OtaOrchestrator.d.ts +14 -2
  175. package/lib/typescript/features/ota/OtaOrchestrator.d.ts.map +1 -1
  176. package/lib/typescript/features/ota/deviceAttributes.d.ts +18 -0
  177. package/lib/typescript/features/ota/deviceAttributes.d.ts.map +1 -0
  178. package/lib/typescript/features/ota/geoCountry.d.ts +14 -0
  179. package/lib/typescript/features/ota/geoCountry.d.ts.map +1 -0
  180. package/lib/typescript/features/ota/useOtaUpdate.d.ts +20 -2
  181. package/lib/typescript/features/ota/useOtaUpdate.d.ts.map +1 -1
  182. package/lib/typescript/features/performance/PerformanceFeature.d.ts +0 -1
  183. package/lib/typescript/features/performance/PerformanceFeature.d.ts.map +1 -1
  184. package/lib/typescript/features/performance/collectors/FrameMetricsCollector.d.ts +33 -0
  185. package/lib/typescript/features/performance/collectors/FrameMetricsCollector.d.ts.map +1 -1
  186. package/lib/typescript/features/performance/transport/PerformanceTransport.d.ts.map +1 -1
  187. package/lib/typescript/features/session/BackendSessionAdapter.d.ts +42 -2
  188. package/lib/typescript/features/session/BackendSessionAdapter.d.ts.map +1 -1
  189. package/lib/typescript/features/session/JourneyEventPipeline.d.ts +2 -0
  190. package/lib/typescript/features/session/JourneyEventPipeline.d.ts.map +1 -1
  191. package/lib/typescript/features/session/ReplayCaptureManager.d.ts +38 -1
  192. package/lib/typescript/features/session/ReplayCaptureManager.d.ts.map +1 -1
  193. package/lib/typescript/features/session/SessionManager.d.ts.map +1 -1
  194. package/lib/typescript/features/session/nativeCapture.d.ts +2 -1
  195. package/lib/typescript/features/session/nativeCapture.d.ts.map +1 -1
  196. package/lib/typescript/features/session/outboxFrameCapture.d.ts.map +1 -1
  197. package/lib/typescript/features/session/sessionTypes.d.ts +20 -3
  198. package/lib/typescript/features/session/sessionTypes.d.ts.map +1 -1
  199. package/lib/typescript/index.d.ts +1 -0
  200. package/lib/typescript/index.d.ts.map +1 -1
  201. package/lib/typescript/public/ScaleBunFacade.d.ts +69 -0
  202. package/lib/typescript/public/ScaleBunFacade.d.ts.map +1 -1
  203. package/lib/typescript/public/types.d.ts +34 -8
  204. package/lib/typescript/public/types.d.ts.map +1 -1
  205. package/lib/typescript/specs/NativeScaleBunCrash.d.ts +14 -0
  206. package/lib/typescript/specs/NativeScaleBunCrash.d.ts.map +1 -1
  207. package/lib/typescript/vendor/protocol/index.d.ts +17 -17
  208. package/package.json +1 -1
  209. package/src/analytics/EventTracker.ts +28 -1
  210. package/src/bootstrap/SDKBootstrapper.ts +27 -23
  211. package/src/compat/codepush.ts +87 -16
  212. package/src/core/config/schema.ts +26 -5
  213. package/src/core/constants/endpoints.ts +9 -6
  214. package/src/core/context/device.ts +146 -0
  215. package/src/debug/replayWiring.ts +2 -1
  216. package/src/features/bugreport/BugReportFeature.ts +128 -0
  217. package/src/features/bugreport/buildPayload.ts +116 -0
  218. package/src/features/crash/CrashReporter.ts +40 -1
  219. package/src/features/crash/capture.ts +36 -9
  220. package/src/features/crash/nativeCrashBridge.ts +156 -22
  221. package/src/features/engage/EngagePromptProvider.tsx +48 -2
  222. package/src/features/engage/EngagePromptView.tsx +51 -15
  223. package/src/features/engage/EngageTransport.ts +1 -1
  224. package/src/features/engage/engageTriggerEngine.ts +15 -0
  225. package/src/features/engage/engageTypes.ts +15 -0
  226. package/src/features/journey/ScaleBunDebugRoot.tsx +2 -1
  227. package/src/features/ota/OtaOrchestrator.ts +84 -6
  228. package/src/features/ota/deviceAttributes.ts +46 -0
  229. package/src/features/ota/geoCountry.ts +85 -0
  230. package/src/features/ota/useOtaUpdate.ts +20 -2
  231. package/src/features/performance/PerformanceFeature.ts +22 -9
  232. package/src/features/performance/collectors/FrameMetricsCollector.ts +72 -10
  233. package/src/features/performance/transport/PerformanceTransport.ts +18 -0
  234. package/src/features/session/BackendSessionAdapter.ts +137 -10
  235. package/src/features/session/JourneyEventPipeline.ts +3 -0
  236. package/src/features/session/ReplayCaptureManager.ts +53 -1
  237. package/src/features/session/SessionManager.ts +46 -7
  238. package/src/features/session/nativeCapture.ts +3 -2
  239. package/src/features/session/outboxFrameCapture.ts +3 -2
  240. package/src/features/session/sessionTypes.ts +26 -3
  241. package/src/index.ts +4 -1
  242. package/src/public/ScaleBunFacade.ts +198 -2
  243. package/src/public/types.ts +35 -8
  244. package/src/specs/NativeScaleBunCrash.ts +16 -0
@@ -11,6 +11,7 @@ exports.teardownReplay = teardownReplay;
11
11
  exports.wireNativeCaptureDeferred = wireNativeCaptureDeferred;
12
12
  var _api = require("../features/replay/public/api");
13
13
  var _internalLogger = require("../core/logger/internalLogger");
14
+ var _device = require("../core/context/device");
14
15
  /**
15
16
  * ScaleBun Debug — Replay Wiring
16
17
  *
@@ -95,7 +96,7 @@ function wireNativeCaptureDeferred(getSessionManager) {
95
96
  byteSize: result.sizeBytes || Math.round(result.base64.length * 0.75),
96
97
  format: result.format ?? 'jpeg',
97
98
  frameHash: result.frameHash,
98
- platform: Platform.OS === 'ios' ? 'ios' : 'android'
99
+ platform: (0, _device.resolvePlatformOS)()
99
100
  };
100
101
  } catch {
101
102
  return null;
@@ -1 +1 @@
1
- {"version":3,"names":["_api","require","_internalLogger","_replaySdkInitialized","_nativeCaptureWired","initReplaySdk","replayConfig","transport","undefined","logger","debug","ReplaySdk","init","debugTransport","then","info","catch","err","warn","message","recErr","wireNativeCaptureDeferred","getSessionManager","attempt","retryCount","sessionManager","setTimeout","bridgeAdapter","Dimensions","Platform","isAvailable","nativeBridgeCapture","_sessionId","_reason","_quality","result","captureScreenshot","base64","width","height","get","Math","round","byteSize","sizeBytes","length","format","frameHash","platform","OS","setNativeCapture","isReplaySdkInitialized","getReplaySdk","teardownReplay","destroy","resetReplayState"],"sourceRoot":"../../../src","sources":["debug/replayWiring.ts"],"mappings":";;;;;;;;;;;AAOA,IAAAA,IAAA,GAAAC,OAAA;AAIA,IAAAC,eAAA,GAAAD,OAAA;AAXA;AACA;AACA;AACA;AACA;AACA;;AAQA;;AAEA,IAAIE,qBAAqB,GAAG,KAAK;AACjC,IAAIC,mBAAmB,GAAG,KAAK;;AAE/B;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CACzBC,YAA+C,EAC/CC,SAAyB,EACrB;EACJ,IAAID,YAAY,KAAKE,SAAS,EAAE;IAC5BC,sBAAM,CAACC,KAAK,CAAC,oDAAoD,CAAC;IAClE;EACJ;EACA,IAAI;IACAC,cAAS,CAACC,IAAI,CAACN,YAAY,EAAE;MAAEO,cAAc,EAAEN;IAAU,CAAC,CAAC,CAACO,IAAI,CAAC,MAAM;MACnEX,qBAAqB,GAAG,IAAI;MAC5BM,sBAAM,CAACM,IAAI,CAAC,+CAA+C,CAAC;IAChE,CAAC,CAAC,CAACC,KAAK,CAAE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O,SAAS4B,sBAAsBA,CAAA,EAAY;EAC9C,OAAOhD,qBAAqB;AAChC;AAEO,SAASiD,YAAYA,CAAA,EAAqB;EAC7C,OAAOzC,cAAS;AACpB;;AAEA;;AAEO,SAAS0C,cAAcA,CAAA,EAAS;EACnC,IAAIlD,qBAAqB,EAAE;IACvBQ,cAAS,CAAC2C,OAAO,CAAC,CAAC,CAACtC,KAAK,CAAC,MAAM,CAAE,eAAgB,CAAC;EACvD;AACJ;AAEO,SAASuC,gBAAgBA,CAAA,EAAS;EACrCpD,qBAAqB,GAAG,KAAK;EAC7BC,mBAAmB,GAAG,KAAK;AAC/B","ignoreList":[]}
1
+ {"version":3,"names":["_api","require","_internalLogger","_device","_replaySdkInitialized","_nativeCaptureWired","initReplaySdk","replayConfig","transport","undefined","logger","debug","ReplaySdk","init","debugTransport","then","info","catch","err","warn","message","recErr","wireNativeCaptureDeferred","getSessionManager","attempt","retryCount","sessionManager","setTimeout","bridgeAdapter","Dimensions","Platform","isAvailable","nativeBridgeCapture","_sessionId","_reason","_quality","result","captureScreenshot","base64","width","height","get","Math","round","byteSize","sizeBytes","length","format","frameHash","platform","resolvePlatformOS","setNativeCapture","isReplaySdkInitialized","getReplaySdk","teardownReplay","destroy","resetReplayState"],"sourceRoot":"../../../src","sources":["debug/replayWiring.ts"],"mappings":";;;;;;;;;;;AAOA,IAAAA,IAAA,GAAAC,OAAA;AAIA,IAAAC,eAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAZA;AACA;AACA;AACA;AACA;AACA;;AASA;;AAEA,IAAIG,qBAAqB,GAAG,KAAK;AACjC,IAAIC,mBAAmB,GAAG,KAAK;;AAE/B;;AAEA;AACA;AACA;AACA;AACO,SAASC,aAAaA,CACzBC,YAA+C,EAC/CC,SAAyB,EACrB;EACJ,IAAID,YAAY,KAAKE,SAAS,EAAE;IAC5BC,sBAAM,CAACC,KAAK,CAAC,oDAAoD,CAAC;IAClE;EACJ;EACA,IAAI;IACAC,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AAC,MAAMH,OAAO,CAACC,UAAU,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC;MACnD;IACJ;EACJ,CAAC;EAEDE,UAAU,CAAC,MAAMH,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC;AACrC;;AAEA;;AAEO,SAAS4B,sBAAsBA,CAAA,EAAY;EAC9C,OAAOhD,qBAAqB;AAChC;AAEO,SAASiD,YAAYA,CAAA,EAAqB;EAC7C,OAAOzC,cAAS;AACpB;;AAEA;;AAEO,SAAS0C,cAAcA,CAAA,EAAS;EACnC,IAAIlD,qBAAqB,EAAE;IACvBQ,cAAS,CAAC2C,OAAO,CAAC,CAAC,CAACtC,KAAK,CAAC,MAAM,CAAE,eAAgB,CAAC;EACvD;AACJ;AAEO,SAASuC,gBAAgBA,CAAA,EAAS;EACrCpD,qBAAqB,GAAG,KAAK;EAC7BC,mBAAmB,GAAG,KAAK;AAC/B","ignoreList":[]}
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.BugReportFeature = void 0;
7
+ var _internalLogger = require("../../core/logger/internalLogger");
8
+ /**
9
+ * F-BUG (React Native) — bug-report feature.
10
+ *
11
+ * Ported from the web SDK's `features/bugreport/BugReportFeature.ts`, deliberately keeping its
12
+ * split: this class is THIN. It raises the capture signal and holds a `submitFn` injected by the
13
+ * facade, which owns session + transport and therefore owns the HTTP. Duplicating the submit here
14
+ * would give the two SDKs two contracts to drift apart.
15
+ *
16
+ * WHAT DOES NOT PORT
17
+ * The web feature lazy-imports a DOM launcher widget (`widget.ts`, 185 lines of document/CSS). RN
18
+ * has no DOM: the form is rendered by `EngagePromptView`, which already exists, already handles the
19
+ * native modal/keyboard behaviour, and is already what `shake_device` puts on screen. Building a
20
+ * second prompt system for this would be the same mistake in a different repo.
21
+ *
22
+ * TRIGGERING
23
+ * `shake_device` is already wired end to end — native CoreMotion/SensorManager →
24
+ * `engageShakeBridge` → `gestureTriggerDetector.reportShake()` → the `$gesture` signal lane → the
25
+ * engage trigger engine. This feature is a submit target for that flow, not a second detector.
26
+ */
27
+
28
+ /** Why a submit did not produce a report id. Mirrors the web SDK's discriminated failure union. */
29
+
30
+ /** Resolves to the report id, or to `{ e }` naming WHICH branch failed. */
31
+
32
+ class BugReportFeature {
33
+ name = 'bugReport';
34
+ active = false;
35
+ submitFn = null;
36
+ /** Raises the 'report' capture signal so replay flushes its buffer into the current session. */
37
+ signalFn = null;
38
+ get isActive() {
39
+ return this.active;
40
+ }
41
+ setup(hooks = {}) {
42
+ this.signalFn = hooks.signal ?? null;
43
+ this.active = true;
44
+ }
45
+
46
+ /**
47
+ * Flush replay into the session so the report has its visual context.
48
+ *
49
+ * Fail-soft: replay may be disabled, paused, or unsupported on this build. A report without a
50
+ * replay anchor is still a useful report, so this must never block a submit.
51
+ */
52
+ signalReport() {
53
+ try {
54
+ this.signalFn?.();
55
+ } catch {
56
+ /* never let a capture-signal failure break a bug report */
57
+ }
58
+ }
59
+
60
+ /** Wired by the facade after init — the full submit path (transport + session + context). */
61
+ setSubmit(fn) {
62
+ this.submitFn = fn;
63
+ }
64
+
65
+ /**
66
+ * Submit a report.
67
+ *
68
+ * Returns rather than throws, always. This is called from a UI the host app renders, often from a
69
+ * user gesture; an exception escaping into a React Native render tree is a redbox for the
70
+ * customer's user, over a bug report they were trying to send us.
71
+ */
72
+ async submit(input) {
73
+ if (!input || !input.message || input.message.trim().length === 0) {
74
+ _internalLogger.logger.warn('[scalebun] reportBug: a message is required');
75
+ return {
76
+ e: 'empty'
77
+ };
78
+ }
79
+ // No submitFn means the facade never finished wiring. That is 'init', not a send failure —
80
+ // the distinction is what tells an integrator to check their setup rather than their network.
81
+ if (!this.submitFn) return {
82
+ e: 'init'
83
+ };
84
+ if (input.voice && !input.voice.transcriptApproved) {
85
+ // Refused rather than silently stripped: dropping the attachment would send a report the user
86
+ // believes contains their voice note, and they would never learn it did not.
87
+ _internalLogger.logger.warn('[scalebun] reportBug: voice note has no approved transcript — not sending');
88
+ return {
89
+ e: 'empty'
90
+ };
91
+ }
92
+ try {
93
+ // Order matters and mirrors the web path: signal BEFORE submit so the replay bytes are already
94
+ // in flight, and so the report's replay coordinate refers to a frame that exists. A flush
95
+ // cannot retroactively manufacture a frame, so a missing anchor must stay missing rather than
96
+ // become a misleading "start of session" link in the dashboard.
97
+ this.signalReport();
98
+ return await this.submitFn(input);
99
+ } catch {
100
+ return {
101
+ e: 'send'
102
+ };
103
+ }
104
+ }
105
+ teardown() {
106
+ this.submitFn = null;
107
+ this.signalFn = null;
108
+ this.active = false;
109
+ }
110
+ }
111
+ exports.BugReportFeature = BugReportFeature;
112
+ //# sourceMappingURL=BugReportFeature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_internalLogger","require","BugReportFeature","name","active","submitFn","signalFn","isActive","setup","hooks","signal","signalReport","setSubmit","fn","submit","input","message","trim","length","logger","warn","e","voice","transcriptApproved","teardown","exports"],"sourceRoot":"../../../../src","sources":["features/bugreport/BugReportFeature.ts"],"mappings":";;;;;;AAmBA,IAAAA,eAAA,GAAAC,OAAA;AAnBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAIA;;AAGA;;AA0BO,MAAMC,gBAAgB,CAAC;EACnBC,IAAI,GAAG,WAAW;EAEnBC,MAAM,GAAG,KAAK;EACdC,QAAQ,GAAoB,IAAI;EACxC;EACQC,QAAQ,GAAwB,IAAI;EAE5C,IAAIC,QAAQA,CAAA,EAAY;IACtB,OAAO,IAAI,CAACH,MAAM;EACpB;EAEAI,KAAKA,CAACC,KAA8B,GAAG,CAAC,CAAC,EAAQ;IAC/C,IAAI,CAACH,QAAQ,GAAGG,KAAK,CAACC,MAAM,IAAI,IAAI;IACpC,IAAI,CAACN,MAAM,GAAG,IAAI;EACpB;;EAEA;AACF;AACA;AACA;AACA;AACA;EACEO,YAAYA,CAAA,EAAS;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4
+ value: true
5
+ });
6
+ exports.buildBugReportPayload = buildBugReportPayload;
7
+ /**
8
+ * Builds the body for POST /ingestion/sessions/:sessionId/bug-reports.
9
+ *
10
+ * Kept as a PURE function with no transport, no bridge and no clock of its own, because the wire
11
+ * shape is a cross-repo contract and the only way to keep it honest is to be able to assert it
12
+ * directly. Every bound below is copied from the server DTO
13
+ * (wzb-dashboard-backend/src/features/bug-reports/dto/submit-bug-report.dto.ts) rather than guessed:
14
+ *
15
+ * clientReportId? string idempotency key -> BugReport.clientReportId (@unique)
16
+ * title? string <= 300
17
+ * message string <= 20000 -> BugReport.description (REQUIRED)
18
+ * email? string <= 320
19
+ * url? string <= 2000
20
+ * console? unknown[] recent breadcrumbs
21
+ * screenshotKey? string <= 512, [A-Za-z0-9._/-] and no ".."
22
+ * timestamp? number 2000-01-01 .. 2100-01-01 in epoch MILLIS
23
+ * replaySeq? int 0 .. 2147483647
24
+ * replaySegmentId? string <= 256
25
+ *
26
+ * Truncating here rather than letting the server 400 is deliberate: a 20,001-character description
27
+ * is a real report from a real annoyed user, and losing it to a validation error helps nobody. The
28
+ * ceiling is theirs, so we respect it at the edge. Nothing is silently REWRITTEN — only cut, and
29
+ * only at bounds the server would otherwise reject outright.
30
+ */
31
+
32
+ /** Mirrors SubmitBugReportDto. Optional keys are omitted entirely rather than sent as undefined. */
33
+
34
+ const MAX_TITLE = 300;
35
+ const MAX_MESSAGE = 20_000;
36
+ const MAX_EMAIL = 320;
37
+ const MAX_SEGMENT_ID = 256;
38
+ /** The server rejects outside these; a drifted device clock must not cost us the whole report. */
39
+ const TS_MIN = 946684800000; // 2000-01-01
40
+ const TS_MAX = 4102444800000; // 2100-01-01
41
+ const MAX_BREADCRUMBS = 50;
42
+ function clip(v, max) {
43
+ if (typeof v !== 'string') return undefined;
44
+ const t = v.trim();
45
+ return t.length === 0 ? undefined : t.slice(0, max);
46
+ }
47
+ function buildBugReportPayload(input, breadcrumbs = [], ctx = {}) {
48
+ const message = (input.message ?? '').trim().slice(0, MAX_MESSAGE);
49
+ const payload = {
50
+ message
51
+ };
52
+ const title = clip(input.title, MAX_TITLE);
53
+ if (title) payload.title = title;
54
+ const email = clip(input.email, MAX_EMAIL);
55
+ if (email) payload.email = email;
56
+ const clientReportId = clip(input.clientReportId, 200);
57
+ if (clientReportId) payload.clientReportId = clientReportId;
58
+ if (breadcrumbs.length > 0) payload.console = breadcrumbs.slice(-MAX_BREADCRUMBS);
59
+
60
+ /**
61
+ * An out-of-range clock is DROPPED, not clamped.
62
+ *
63
+ * Clamping would invent a `reportedAt` the device never observed, and the server keeps that column
64
+ * separate from `createdAt` precisely so the two can be compared. A missing client time is honest;
65
+ * a fabricated one silently corrupts that comparison.
66
+ */
67
+ const ts = ctx.timestamp;
68
+ if (typeof ts === 'number' && Number.isFinite(ts) && ts >= TS_MIN && ts <= TS_MAX) {
69
+ payload.timestamp = ts;
70
+ }
71
+
72
+ /**
73
+ * The replay anchor is included ONLY when a frame actually existed at submit time.
74
+ *
75
+ * Defaulting `replaySeq` to 0 would point every anchor-less report at the start of the session,
76
+ * which reads in the dashboard exactly like a real anchor and is wrong. Replay may be disabled,
77
+ * paused, or yet to produce a frame; absent must stay absent.
78
+ */
79
+ const seq = ctx.replayCoord?.seq;
80
+ if (typeof seq === 'number' && Number.isInteger(seq) && seq >= 0 && seq <= 2147483647) {
81
+ payload.replaySeq = seq;
82
+ const segmentId = clip(ctx.replayCoord?.segmentId ?? undefined, MAX_SEGMENT_ID);
83
+ if (segmentId) payload.replaySegmentId = segmentId;
84
+ }
85
+
86
+ /**
87
+ * `url` is intentionally NEVER set on React Native.
88
+ *
89
+ * The field means a page URL. The nearest mobile concept is the current screen name, and putting
90
+ * a screen name in a column called `url` is exactly the field-misuse that makes a dashboard show
91
+ * one thing and mean another. Screen context already reaches the report through the session it is
92
+ * attached to. If mobile needs its own field, that is a schema change, not a reused column.
93
+ */
94
+
95
+ return payload;
96
+ }
97
+ //# sourceMappingURL=buildPayload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["MAX_TITLE","MAX_MESSAGE","MAX_EMAIL","MAX_SEGMENT_ID","TS_MIN","TS_MAX","MAX_BREADCRUMBS","clip","v","max","undefined","t","trim","length","slice","buildBugReportPayload","input","breadcrumbs","ctx","message","payload","title","email","clientReportId","console","ts","timestamp","Number","isFinite","seq","replayCoord","isInteger","replaySeq","segmentId","replaySegmentId"],"sourceRoot":"../../../../src","sources":["features/bugreport/buildPayload.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;;AAmBA,MAAMA,SAAS,GAAG,GAAG;AACrB,MAAMC,WAAW,GAAG,MAAM;AAC1B,MAAMC,SAAS,GAAG,GAAG;AACrB,MAAMC,cAAc,GAAG,GAAG;AAC1B;AACA,MAAMC,MAAM,GAAG,YAAY,CAAC,CAAC;AAC7B,MAAMC,MAAM,GAAG,aAAa,CAAC,CAAC;AAC9B,MAAMC,eAAe,GAAG,EAAE;AAE1B,SAASC,IAAIA,CAACC,CAA4B,EAAEC,GAAW,EAAsB;EAC3E,IAAI,OAAOD,CAAC,KAAK,QAAQ,EAAE,OAAOE,SAAS;EAC3C,MAAMC,CAAC,GAAGH,CAAC,CAACI,IAAI,CAAC,CAAC;EAClB,OAAOD,CAAC,CAACE,MAAM,KAAK,CAAC,GAAGH,SAAS,GAAGC,CAAC,CAACG,KAAK,CAAC,CAAC,EAAEL,GAAG,CAAC;AACrD;AAEO,SAASM,qBAAqBA,CACnCC,KAAmF,EACnFC,WAA+B,GAAG,EAAE,EACpCC,GAA6D,GAAG,CAAC,CAAC,EAChD;EAClB,MAAMC,OAAO,GAAG,CAACH,KAAK,CAACG,OAAO,IAAI,EAAE,EAAEP,IAAI,CAAC,CAAC,CAACE,KAAK,CAAC,CAAC,EAAEb,WAAW,CAAC;EAElE,MAAMmB,OAAyB,GAAG;IAA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AAe,GAAGD,SAAS;EACpD;;EAEA;AACF;AACA;AACA;AACA;AACA;AACA;AACA;;EAEE,OAAOb,OAAO;AAChB","ignoreList":[]}
@@ -93,11 +93,35 @@ class BackendErrorsSink {
93
93
  deliver(report) {
94
94
  const transport = _SessionManager.SessionManager.getExistingInstance()?.getBackendTransport();
95
95
  if (!transport) return;
96
+ // D12: this used to forward four fields and drop the rest — so a native
97
+ // crash's signal/thread/exception-type were captured on device and
98
+ // discarded one call before the wire, every RN error row had a NULL
99
+ // platform (making Issue.primaryPlatform mean "web-only"), and fatality
100
+ // was indistinguishable from a handled error. The receiver has always
101
+ // accepted all of these.
96
102
  transport.queueError({
97
103
  type: report.type,
98
104
  message: report.message,
99
105
  stack: report.stack,
100
- screenName: report.screenName
106
+ screenName: report.screenName,
107
+ platform: report.platform,
108
+ isFatal: report.isFatal,
109
+ metadata: report.metadata,
110
+ /**
111
+ * Carried through so the transport can address the ORIGINAL session.
112
+ *
113
+ * Set only on a recovered native crash, whose session died with its process. Omitted
114
+ * for every live report, where the current session is the right answer — so this
115
+ * changes nothing about normal error delivery.
116
+ */
117
+ ...(report.sessionId ? {
118
+ sessionId: report.sessionId
119
+ } : {}),
120
+ // Becomes SessionError.clientId, which is @unique — that constraint is what turns a
121
+ // retried crash into one record instead of a duplicate.
122
+ ...(report.crashId ? {
123
+ clientId: report.crashId
124
+ } : {})
101
125
  });
102
126
  // Best-effort immediate delivery so the crash surfaces quickly.
103
127
  transport.flushErrors().catch(() => {});
@@ -1 +1 @@
1
- {"version":3,"names":["_crashSafe","require","_SessionManager","CrashReporter","sinks","registerSink","sink","push","i","indexOf","splice","report","noThrow","deliver","exports","DesktopEventSink","name","constructor","trackFn","message","stack","isFatal","type","source","screenName","platform","metadata","BackendErrorsSink","transport","SessionManager","getExistingInstance","getBackendTransport","queueError","flushErrors","catch","_reporter","getCrashReporter","resetCrashReporter"],"sourceRoot":"../../../../src","sources":["features/crash/CrashReporter.ts"],"mappings":";;;;;;;;AAgBA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UAAU;MAC7BC,QAAQ,EAAEd,MAAM,CAACc,QAAQ;MACzB,IAAId,MAAM,CAACe,QAAQ,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC;EACN;AACJ;;AAEA;AACA;AACA;AACA;AACA;AAJAZ,OAAA,CAAAC,gBAAA,GAAAA,gBAAA;AAKO,MAAMY,iBAAiB,CAAsB;EACvCX,IAAI,GAAG,SAAS;EAEzBH,OAAOA,CAACF,MAAmB,EAAQ;IAC/B,MAAMiB,SAAS,GAAGC,8BAAc,CAACC,mBAAmB,CAAC,CAAC,EAAEC,mBAAmB,CAAC,CAAC;IAC7E,IAAI,CAACH,SAAS,EAAE;IAChBA,SAAS,CAACI,UAAU,CAAC;MACjBV,IAAI,EAAEX,MAAM,CAACW,IAAI;MACjBH,OAAO,EAAER,MAAM,CAACQ,OAAO;MACvBC,KAAK,EAAET,MAAM,CAACS,KAAK;MACnBI,UAAU,EAAEb,MAAM,CAACa;IACvB,CAAC,CAAC;IACF;IACAI,SAAS,CAACK,WAAW,CAAC,CAAC,CAACC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;EAC3C;AACJ;;AAEA;AACA;AACA;AAAApB,OAAA,CAAAa,iBAAA,GAAAA,iBAAA;AAEA,IAAIQ,SAA+B,GAAG,IAAI;;AAE1C;AACO,SAASC,gBAAgBA,CAAA,EAAkB;EAC9C,IAAI,CAACD,SAAS,EAAEA,SAAS,GAAG,IAAIhC,aAAa,CAAC,CAAC;EAC/C,OAAOgC,SAAS;AACpB;;AAEA;AACO,SAASE,kBAAkBA,CAAA,EAAS;EACvCF,SAAS,GAAG,IAAI;AACpB","ignoreList":[]}
1
+ {"version":3,"names":["_crashSafe","require","_SessionManager","CrashReporter","sinks","registerSink","sink","push","i","indexOf","splice","report","noThrow","deliver","exports","DesktopEventSink","name","constructor","trackFn","message","stack","isFatal","type","source","screenName","platform","metadata","BackendErrorsSink","transport","SessionManager","getExistingInstance","getBackendTransport","queueError","sessionId","crashId","clientId","flushErrors","catch","_reporter","getCrashReporter","resetCrashReporter"],"sourceRoot":"../../../../src","sources":["features/crash/CrashReporter.ts"],"mappings":";;;;;;;;AAgBA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,eAAA,GAAAD,OAAA;AAjBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAKA;;AAGA;;AAyCA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACO,MAAME,aAAa,CAAC;EACNC,KAAK,GAAgB,EAAE;;EAExC;EACAC,YAAYA,CAACC,IAAe,EAAc;IACtC,IAAI,CAACF,KAAK,CAACG,IAAI,CAACD,IAAI,CAAC;IACrB,OAAO,MAAM;MACT,MAAME,CAAC,GAAG,IAAI,CAACJ,KAAK,CAACK,OAAO,CAACH,IAAI,CAAC;MAClC,IAAIE,CAAC,IAAI,CAAC,EAAE,IAAI,CAACJ,KAAK,CAACM,MAAM,CAACF,CAAC,EAAE,CAAC,CAAC;IACvC,CAAC;EACL;;EAEA;EACAG,MAAMA,CAACA,MAAmB,EAAQ;IAC9B,KAAK,MAAML,IAAI,IAAI,IAAI,CAACF,KAAK,EAAE;MAC3B,IAAAQ,kBAAO,EAAC,MAAMN,IAAI,CAACO,OAAO,CAACF,MAAM,CAAC,CAAC;IACvC;EACJ;AACJ;;AAEA;AACA;AACA;AACA;AACA;AAJAG,OAAA,CAAAX,aAAA,GAAAA,aAAA;AAKO,MAAMY,gBAAgB,CAAsB;EACtCC,IAAI,GAAG,SAAS;EACzBC,WAAWA,CACUC,OAAkE,EACrF;IAAA,KADmBA,OAAkE,GAAlEA,OAAkE;EACpF;EAEHL,OAAOA,CAACF,MAAmB,EAAQ;IAC/B,IAAI,CAACO,OAAO,CAAC,QAAQ,EAAE;MACnBC,OAAO,EAAER,MAAM,CAACQ,OAAO;MACvBC,KAAK,EAAET,MAAM,CAACS,KAAK;MACnBC,OAAO,EAAEV,MAAM,CAACU,OAAO;MACvBC,IAAI,EA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;AAAAvB,OAAA,CAAAa,iBAAA,GAAAA,iBAAA;AAEA,IAAIW,SAA+B,GAAG,IAAI;;AAE1C;AACO,SAASC,gBAAgBA,CAAA,EAAkB;EAC9C,IAAI,CAACD,SAAS,EAAEA,SAAS,GAAG,IAAInC,aAAa,CAAC,CAAC;EAC/C,OAAOmC,SAAS;AACpB;;AAEA;AACO,SAASE,kBAAkBA,CAAA,EAAS;EACvCF,SAAS,GAAG,IAAI;AACpB","ignoreList":[]}
@@ -5,26 +5,44 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.captureException = captureException;
7
7
  exports.captureMessage = captureMessage;
8
- var _envelope = require("../../pipeline/envelope/envelope");
9
- var _memoryQueue = require("../../pipeline/queue/memoryQueue");
10
8
  var _crashSafe = require("../../core/lifecycle/crashSafe");
9
+ var _CrashReporter = require("./CrashReporter");
10
+ /**
11
+ * Manual error/message capture — the `Sentry.captureException` equivalent.
12
+ *
13
+ * D3: these used to write envelopes into `memoryQueue`, a queue whose only
14
+ * drain (`Dispatcher.flush`) was registered in the DI container and never
15
+ * resolved by anything — every capture was accumulated and discarded. They
16
+ * were also never exported, so the two entry points were reachable by nobody
17
+ * and delivered to nowhere.
18
+ *
19
+ * Now they ride the SAME pipeline as automatic crash capture (CrashReporter →
20
+ * BackendErrorsSink → `/ingestion/sessions/:id/errors`) — the one path in this
21
+ * SDK that is proven to land rows.
22
+ */
11
23
  function captureException(error, extra) {
12
24
  (0, _crashSafe.noThrow)(() => {
13
- const envelope = (0, _envelope.createEnvelope)('crash', {
25
+ (0, _CrashReporter.getCrashReporter)().report({
26
+ type: 'handled',
14
27
  message: error.message,
15
28
  stack: error.stack,
16
- ...extra
29
+ isFatal: false,
30
+ source: 'manual',
31
+ screenName: extra?.screenName,
32
+ metadata: extra?.metadata
17
33
  });
18
- _memoryQueue.memoryQueue.add(envelope);
19
34
  });
20
35
  }
21
- function captureMessage(message) {
36
+ function captureMessage(message, extra) {
22
37
  (0, _crashSafe.noThrow)(() => {
23
- const envelope = (0, _envelope.createEnvelope)('log', {
38
+ (0, _CrashReporter.getCrashReporter)().report({
39
+ type: 'handled',
24
40
  message,
25
- level: 'info'
41
+ isFatal: false,
42
+ source: 'manual',
43
+ screenName: extra?.screenName,
44
+ metadata: extra?.metadata
26
45
  });
27
- _memoryQueue.memoryQueue.add(envelope);
28
46
  });
29
47
  }
30
48
  //# sourceMappingURL=capture.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_envelope","require","_memoryQueue","_crashSafe","captureException","error","extra","noThrow","envelope","createEnvelope","message","stack","memoryQueue","add","captureMessage","level"],"sourceRoot":"../../../../src","sources":["features/crash/capture.ts"],"mappings":";;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,UAAA,GAAAF,OAAA;AAEO,SAASG,gBAAgBA,CAACC,KAAY,EAAEC,KAAW,EAAE;EACxD,IAAAC,kBAAO,EAAC,MAAM;IACV,MAAMC,QAAQ,GAAG,IAAAC,wBAAc,EAAC,OAAO,EAAE;MACrCC,OAAO,EAAEL,KAAK,CAACK,OAAO;MACtBC,KAAK,EAAEN,KAAK,CAACM,KAAK;MAClB,GAAGL;IACP,CAAC,CAAC;IACFM,wBAAW,CAACC,GAAG,CAACL,QAAQ,CAAC;EAC7B,CAAC,CAAC;AACN;AAEO,SAASM,cAAcA,CAACJ,OAAe,EAAE;EAC5C,IAAAH,kBAAO,EAAC,MAAM;IACV,MAAMC,QAAQ,GAAG,IAAAC,wBAAc,EAAC,KAAK,EAAE;MAAEC,OAAO;MAAEK,KAAK,EAAE;IAAO,CAAC,CAAC;IAClEH,wBAAW,CAACC,GAAG,CAACL,QAAQ,CAAC;EAC7B,CAAC,CAAC;AACN","ignoreList":[]}
1
+ {"version":3,"names":["_crashSafe","require","_CrashReporter","captureException","error","extra","noThrow","getCrashReporter","report","type","message","stack","isFatal","source","screenName","metadata","captureMessage"],"sourceRoot":"../../../../src","sources":["features/crash/capture.ts"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,cAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,gBAAgBA,CAC5BC,KAAY,EACZC,KAAmE,EAC/D;EACJ,IAAAC,kBAAO,EAAC,MAAM;IACV,IAAAC,+BAAgB,EAAC,CAAC,CAACC,MAAM,CAAC;MACtBC,IAAI,EAAE,SAAS;MACfC,OAAO,EAAEN,KAAK,CAACM,OAAO;MACtBC,KAAK,EAAEP,KAAK,CAACO,KAAK;MAClBC,OAAO,EAAE,KAAK;MACdC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAET,KAAK,EAAES,UAAU;MAC7BC,QAAQ,EAAEV,KAAK,EAAEU;IACrB,CAAC,CAAC;EACN,CAAC,CAAC;AACN;AAEO,SAASC,cAAcA,CAC1BN,OAAe,EACfL,KAAmE,EAC/D;EACJ,IAAAC,kBAAO,EAAC,MAAM;IACV,IAAAC,+BAAgB,EAAC,CAAC,CAACC,MAAM,CAAC;MACtBC,IAAI,EAAE,SAAS;MACfC,OAAO;MACPE,OAAO,EAAE,KAAK;MACdC,MAAM,EAAE,QAAQ;MAChBC,UAAU,EAAET,KAAK,EAAES,UAAU;MAC7BC,QAAQ,EAAEV,KAAK,EAAEU;IACrB,CAAC,CAAC;EACN,CAAC,CAAC;AACN","ignoreList":[]}
@@ -5,13 +5,13 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.drainNativeCrash = drainNativeCrash;
7
7
  exports.installNativeCrashHandler = installNativeCrashHandler;
8
+ exports.setNativeActiveSession = setNativeActiveSession;
8
9
  exports.triggerNativeCrash = triggerNativeCrash;
9
10
  var _reactNative = require("react-native");
10
11
  var _architecture = require("../../core/architecture");
11
- var _envelope = require("../../pipeline/envelope/envelope");
12
- var _memoryQueue = require("../../pipeline/queue/memoryQueue");
13
12
  var _internalLogger = require("../../core/logger/internalLogger");
14
13
  var _CrashReporter = require("./CrashReporter");
14
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
15
15
  /**
16
16
  * Wraps the ScaleBunCrash native module (Android/iOS).
17
17
  * Call installNativeCrashHandler() once at SDK init to register handlers.
@@ -55,6 +55,26 @@ function getCrashModule() {
55
55
  * NSSetUncaughtExceptionHandler + signal handlers on iOS).
56
56
  * Safe to call multiple times — native side is idempotent.
57
57
  */
58
+ /**
59
+ * Tell native which session is live, so a crash that happens next can name it.
60
+ *
61
+ * Called once per session — never per event. Native writes it to crash-safe storage immediately,
62
+ * because a fatal handler cannot call back into JS to ask, and by the time it runs the JS thread may
63
+ * already be gone.
64
+ *
65
+ * Fire-and-forget and no-throw: losing this degrades a recovered crash to unattributed, which is the
66
+ * old behaviour. It must never be able to fail a session start.
67
+ */
68
+ async function setNativeActiveSession(sessionId) {
69
+ try {
70
+ const mod = getCrashModule();
71
+ if (!mod?.setActiveSessionId || !sessionId) return;
72
+ await mod.setActiveSessionId(sessionId);
73
+ _internalLogger.logger.debug(`[NativeCrash] Active session → ${sessionId}`);
74
+ } catch {
75
+ // No-throw
76
+ }
77
+ }
58
78
  async function installNativeCrashHandler() {
59
79
  try {
60
80
  const mod = getCrashModule();
@@ -70,38 +90,66 @@ async function installNativeCrashHandler() {
70
90
  }
71
91
 
72
92
  /**
73
- * Drain a crash record left from the previous process run.
74
- * If found, enqueues a crash.native envelope and returns true.
75
- * Returns false when no pending crash is found.
93
+ * How many pending crashes one launch will deliver.
94
+ *
95
+ * The native spool holds three (a device that crashes, restarts offline, and crashes again), but
96
+ * `drainPendingCrash` hands back the OLDEST ONE ONLY. Draining once per launch therefore needed three
97
+ * launches to clear three crashes — and a fourth crash evicts the oldest, so on a device crashing in a
98
+ * loop the spool loses faster than a one-per-launch drain empties it.
99
+ *
100
+ * Bounded, not `while (true)`: this loop is driven by native state and stops the moment delivery
101
+ * fails, but the bound is what makes it impossible for a native bug — a clear that silently does
102
+ * nothing — to spin the drain forever at startup.
103
+ */
104
+ const MAX_DRAIN_PER_LAUNCH = 4;
105
+
106
+ /**
107
+ * Drain the crash records left from previous process runs.
108
+ * Returns true if at least one pending crash was found.
109
+ *
110
+ * Stops early the first time delivery fails: if the network is down for one crash it is down for the
111
+ * next, and every extra attempt is a request that cannot succeed made during app startup.
76
112
  */
77
113
  async function drainNativeCrash() {
114
+ let found = false;
115
+ const seen = new Set();
116
+ for (let i = 0; i < MAX_DRAIN_PER_LAUNCH; i++) {
117
+ const outcome = await drainOne(seen);
118
+ if (outcome === 'none') break;
119
+ found = true;
120
+ // 'kept' means the backend did not take it. The rest of the spool is behind the same
121
+ // network, so stop rather than fail three more times.
122
+ if (outcome === 'kept') break;
123
+ }
124
+ return found;
125
+ }
126
+
127
+ /** One record: read → report → clear if the backend took it. */
128
+ async function drainOne(seen) {
78
129
  try {
79
130
  const mod = getCrashModule();
80
- if (!mod?.drainPendingCrash) return false;
131
+ if (!mod?.drainPendingCrash) return 'none';
81
132
  const crash = await mod.drainPendingCrash();
82
- if (!crash) return false;
133
+ if (!crash) return 'none';
134
+
135
+ /*
136
+ * The same record twice means the previous clear did not take effect — a native failure we
137
+ * cannot fix from here. Reporting it again would deliver a duplicate on every iteration, so
138
+ * treat it as the end of the spool.
139
+ */
140
+ const seenKey = typeof crash.crashId === 'string' ? crash.crashId : '';
141
+ // `''` is a deliberate sentinel for the single legacy record, which has no id. Tracking it
142
+ // too means a legacy clear that silently fails stops the loop instead of redelivering the
143
+ // same crash on every one of the remaining iterations.
144
+ if (seen.has(seenKey)) return 'none';
145
+ seen.add(seenKey);
83
146
  const stackArr = Array.isArray(crash.stackTrace) ? crash.stackTrace : [];
84
147
 
85
148
  // 1) Desktop debug stream — keep the rich native-crash envelope.
86
- const envelope = (0, _envelope.createEnvelope)('crash', {
87
- name: crash.name ?? 'crash.native',
88
- exceptionType: crash.exceptionType,
89
- message: crash.message,
90
- stackTrace: stackArr,
91
- threadName: crash.threadName,
92
- timestamp: crash.timestamp,
93
- platform: crash.platform,
94
- ...(crash.signal !== undefined ? {
95
- signal: crash.signal
96
- } : {}),
97
- ...(crash.cause !== undefined ? {
98
- cause: crash.cause
99
- } : {}),
100
- ...(crash.userInfo !== undefined ? {
101
- userInfo: crash.userInfo
102
- } : {})
103
- });
104
- _memoryQueue.memoryQueue.add(envelope);
149
+ // D2: a rich envelope used to be written here into memoryQueue — a queue
150
+ // whose drain was never wired, so the native crash's forensic detail was
151
+ // captured and then discarded. The flattened report below now carries the
152
+ // same fields in `metadata` (D12), through the pipeline that actually lands.
105
153
 
106
154
  // 2) SaaS backend errors endpoint (dashboard Crashes view) — route the
107
155
  // same normalized report through the central reporter. This is what
@@ -113,6 +161,30 @@ async function drainNativeCrash() {
113
161
  message: crash.message ?? crash.exceptionType ?? 'Native crash',
114
162
  stack: stackArr.length ? stackArr.join('\n') : undefined,
115
163
  platform: crash.platform,
164
+ /**
165
+ * THE ORIGINAL SESSION — the entire point of the recovery path.
166
+ *
167
+ * This crash happened in a process that no longer exists, so it does NOT belong to the
168
+ * session running now. Passing it explicitly is what stops the reporter routing it
169
+ * through the current SessionManager and attributing it to the session created after
170
+ * the restart.
171
+ *
172
+ * Undefined on records written before this shipped, and on a crash that beat the first
173
+ * session. The sink then keeps the legacy behaviour rather than guessing an owner.
174
+ */
175
+ ...(crash.sessionId ? {
176
+ sessionId: String(crash.sessionId)
177
+ } : {}),
178
+ /**
179
+ * The stable id, carried through so it becomes the backend's dedupe key.
180
+ *
181
+ * Written once when the crash was first persisted — never regenerated here. If this were
182
+ * minted per attempt, every retry would arrive as a brand-new crash and at-least-once
183
+ * delivery would turn into duplicate-every-time.
184
+ */
185
+ ...(crash.crashId ? {
186
+ crashId: String(crash.crashId)
187
+ } : {}),
116
188
  metadata: {
117
189
  exceptionType: crash.exceptionType,
118
190
  threadName: crash.threadName,
@@ -121,8 +193,71 @@ async function drainNativeCrash() {
121
193
  } : {})
122
194
  }
123
195
  });
124
- _internalLogger.logger.info('[NativeCrash] Previous crash drained → desktop + backend');
125
- return true;
196
+
197
+ /**
198
+ * DELETE ONLY AFTER THE BACKEND HAS IT.
199
+ *
200
+ * The read above is non-destructive, so the crash is still on disk right now. It is removed
201
+ * only once delivery has actually succeeded — previously the record was destroyed at read
202
+ * time, so a failed upload lost the crash permanently: the app had proof of a crash, deleted
203
+ * it, and then failed to send it.
204
+ *
205
+ * On failure we simply do NOT clear. The crash stays pending and is retried on the next
206
+ * launch, which is what makes this at-least-once. Duplicate delivery is safe because the
207
+ * crash carries a stable `crashId` that the backend dedupes on — a retry produces no second
208
+ * record.
209
+ *
210
+ * A record with no `crashId` is legacy: it predates stable ids, so it cannot be safely
211
+ * retried (a redelivery WOULD duplicate) and is cleared immediately, preserving exactly the
212
+ * old at-most-once behaviour for old data rather than silently changing it.
213
+ */
214
+ const crashId = seenKey;
215
+ if (!crashId) {
216
+ await mod.clearPendingCrash?.('');
217
+ _internalLogger.logger.info('[NativeCrash] Legacy crash (no id) drained and cleared');
218
+ return 'cleared';
219
+ }
220
+ const delivered = await confirmDelivery();
221
+ if (delivered) {
222
+ await mod.clearPendingCrash?.(crashId);
223
+ _internalLogger.logger.info(`[NativeCrash] Crash ${crashId} delivered → cleared`);
224
+ return 'cleared';
225
+ }
226
+ _internalLogger.logger.info(`[NativeCrash] Crash ${crashId} not yet delivered → kept for retry`);
227
+ return 'kept';
228
+ } catch {
229
+ // Unknown state — stop the loop rather than risk spinning on a failure we cannot diagnose.
230
+ return 'none';
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Has the crash actually reached the backend?
236
+ *
237
+ * The reporter's sinks are fire-and-forget by design (a crash report must never block or throw), so
238
+ * "delivered" is asked of the transport rather than inferred from `report()` returning. If the
239
+ * transport is not up yet — the drain can win the race against SessionManager — the answer is NO and
240
+ * the crash stays on disk for the next launch. That is strictly better than the old behaviour, where
241
+ * exactly that race deleted the record and dropped the crash silently.
242
+ */
243
+ async function confirmDelivery() {
244
+ try {
245
+ const {
246
+ SessionManager
247
+ } = await Promise.resolve().then(() => _interopRequireWildcard(require('../session/SessionManager')));
248
+ const transport = SessionManager.getExistingInstance()?.getBackendTransport();
249
+ // No transport yet — the drain can win the startup race. That is a delivery FAILURE, not a
250
+ // reason to give up: the record stays on disk and the next launch retries it. This exact
251
+ // path used to delete the crash and send nothing.
252
+ if (!transport) return false;
253
+ /**
254
+ * The BOOLEAN, not merely "it resolved".
255
+ *
256
+ * flushErrors used to return void and swallow its own errors, so awaiting it proved only
257
+ * that the call finished. Deleting a crash on that basis would have thrown away crashes
258
+ * that never reached the backend — the failure this whole change exists to prevent.
259
+ */
260
+ return (await transport.flushErrors()) === true;
126
261
  } catch {
127
262
  return false;
128
263
  }