@scalebun/react-native 1.0.2 → 1.0.3

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 (1622) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +65 -65
  3. package/android/build.gradle +86 -86
  4. package/android/consumer-rules.pro +28 -28
  5. package/android/src/main/AndroidManifest.xml +14 -14
  6. package/android/src/main/java/com/scalebun/core/crash/CrashStorage.kt +41 -41
  7. package/android/src/main/java/com/scalebun/core/crash/NativeCrashHandler.kt +79 -79
  8. package/android/src/main/java/com/scalebun/core/performance/ANRWatchdog.kt +100 -100
  9. package/android/src/main/java/com/scalebun/core/performance/AppStartCollector.kt +132 -132
  10. package/android/src/main/java/com/scalebun/core/performance/FrameMetricsCollector.kt +230 -230
  11. package/android/src/main/java/com/scalebun/core/performance/PerformanceCore.kt +165 -165
  12. package/android/src/main/java/com/scalebun/profiler/ProfilerModule.kt +398 -398
  13. package/android/src/main/java/com/scalebun/profiler/ProfilerPackage.kt +24 -24
  14. package/android/src/main/java/com/scalebun/profiler/collectors/CpuCollector.kt +161 -161
  15. package/android/src/main/java/com/scalebun/profiler/collectors/IncidentDetector.kt +223 -223
  16. package/android/src/main/java/com/scalebun/profiler/collectors/MemoryCollector.kt +157 -157
  17. package/android/src/main/java/com/scalebun/profiler/collectors/RenderCollector.kt +194 -194
  18. package/android/src/main/java/com/scalebun/profiler/collectors/SamplerScheduler.kt +218 -218
  19. package/android/src/main/java/com/scalebun/profiler/collectors/ThreadCollector.kt +142 -142
  20. package/android/src/main/java/com/scalebun/replaysdk/ReplaySdkModule.kt +966 -966
  21. package/android/src/main/java/com/scalebun/replaysdk/ReplaySdkPackage.kt +24 -24
  22. package/android/src/main/java/com/scalebun/replaysdk/capture/CaptureReason.kt +47 -47
  23. package/android/src/main/java/com/scalebun/replaysdk/capture/FrameCaptureManager.kt +508 -508
  24. package/android/src/main/java/com/scalebun/replaysdk/capture/FrameCaptureScheduler.kt +187 -187
  25. package/android/src/main/java/com/scalebun/replaysdk/capture/UiStabilityDetector.kt +214 -214
  26. package/android/src/main/java/com/scalebun/replaysdk/core/ReplayConfig.kt +144 -144
  27. package/android/src/main/java/com/scalebun/replaysdk/core/ReplayLogger.kt +31 -31
  28. package/android/src/main/java/com/scalebun/replaysdk/core/SessionIdGenerator.kt +15 -15
  29. package/android/src/main/java/com/scalebun/replaysdk/models/ReplayModels.kt +88 -88
  30. package/android/src/main/java/com/scalebun/replaysdk/outbox/NativeOutbox.kt +541 -541
  31. package/android/src/main/java/com/scalebun/replaysdk/outbox/OutboxUploader.kt +407 -407
  32. package/android/src/main/java/com/scalebun/replaysdk/privacy/PrivacyMaskProcessor.kt +126 -126
  33. package/android/src/main/java/com/scalebun/replaysdk/session/SessionManager.kt +281 -281
  34. package/android/src/main/java/com/scalebun/replaysdk/storage/ReplayStorage.kt +136 -136
  35. package/android/src/main/java/com/scalebun/replaysdk/timeline/TimelineCollector.kt +28 -28
  36. package/android/src/main/java/com/scalebun/replaysdk/tracking/InteractionTracker.kt +419 -419
  37. package/android/src/main/java/com/scalebun/replaysdk/tracking/ScreenTracker.kt +20 -20
  38. package/android/src/main/java/com/scalebun/replaysdk/transport/ReplayTransport.kt +99 -99
  39. package/android/src/main/java/com/scalebun/replaysdk/voice/VoiceRecorder.kt +121 -121
  40. package/android/src/main/java/com/scalebun/replaysdk/voice/VoiceTranscriber.kt +104 -104
  41. package/android/src/main/java/com/scalebun/rn/ScaleBunPackage.kt +113 -113
  42. package/android/src/main/java/com/scalebun/rn/crash/ScaleBunCrashModule.kt +100 -100
  43. package/android/src/main/java/com/scalebun/rn/crash/ScaleBunCrashPackage.kt +22 -22
  44. package/android/src/main/java/com/scalebun/rn/engage/ScaleBunEngageModule.kt +579 -579
  45. package/android/src/main/java/com/scalebun/rn/engage/ScaleBunEngagePackage.kt +22 -22
  46. package/android/src/main/java/com/scalebun/rn/engage/ScaleBunNotificationPresenter.kt +110 -110
  47. package/android/src/main/java/com/scalebun/rn/ota/BundleDownloader.kt +170 -0
  48. package/android/src/main/java/com/scalebun/rn/ota/ScaleBunOtaModule.kt +284 -136
  49. package/android/src/main/java/com/scalebun/rn/ota/SlotManager.kt +311 -285
  50. package/android/src/main/java/com/scalebun/rn/performance/PerformanceModule.kt +206 -206
  51. package/android/src/main/java/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule.kt +77 -77
  52. package/android/src/main/java/com/scalebun/rn/storage/ScaleBunStorageModule.kt +68 -68
  53. package/android/src/main/java/com/scalebun/storage/KvFileStore.kt +174 -174
  54. package/android/src/newarch/java/com/scalebun/profiler/ProfilerSpec.kt +12 -12
  55. package/android/src/newarch/java/com/scalebun/replaysdk/ReplaySdkSpec.kt +12 -12
  56. package/android/src/newarch/java/com/scalebun/rn/crash/ScaleBunCrashSpec.kt +15 -15
  57. package/android/src/newarch/java/com/scalebun/rn/ota/ScaleBunOtaSpec.kt +16 -16
  58. package/android/src/newarch/java/com/scalebun/rn/performance/PerformanceSpec.kt +12 -12
  59. package/android/src/newarch/java/com/scalebun/rn/referrer/ScaleBunInstallReferrerSpec.kt +14 -14
  60. package/android/src/newarch/java/com/scalebun/rn/storage/ScaleBunStorageSpec.kt +16 -16
  61. package/android/src/oldarch/java/com/scalebun/profiler/ProfilerSpec.kt +34 -34
  62. package/android/src/oldarch/java/com/scalebun/replaysdk/ReplaySdkSpec.kt +76 -76
  63. package/android/src/oldarch/java/com/scalebun/rn/crash/ScaleBunCrashSpec.kt +21 -21
  64. package/android/src/oldarch/java/com/scalebun/rn/ota/ScaleBunOtaSpec.kt +31 -25
  65. package/android/src/oldarch/java/com/scalebun/rn/performance/PerformanceSpec.kt +27 -27
  66. package/android/src/oldarch/java/com/scalebun/rn/referrer/ScaleBunInstallReferrerSpec.kt +18 -18
  67. package/android/src/oldarch/java/com/scalebun/rn/storage/ScaleBunStorageSpec.kt +26 -26
  68. package/bin/lib/iosCodemod.js +266 -266
  69. package/bin/scalebun.js +640 -640
  70. package/ios/Capture/InteractionTracker.swift +191 -191
  71. package/ios/Capture/PrivacyMaskProcessor.swift +158 -158
  72. package/ios/Capture/ScreenshotCaptureManager.swift +315 -315
  73. package/ios/Capture/WindowResolver.swift +63 -63
  74. package/ios/Core/ReplayConfig.swift +100 -100
  75. package/ios/Core/ReplayLogger.swift +22 -22
  76. package/ios/Core/SessionIdGenerator.swift +18 -18
  77. package/ios/Crash/ScaleBunCrashBridge.mm +63 -63
  78. package/ios/Crash/ScaleBunCrashHandler.swift +67 -67
  79. package/ios/Crash/ScaleBunCrashModule.swift +69 -69
  80. package/ios/Crash/ScaleBunCrashSignalBridge.h +18 -18
  81. package/ios/Crash/ScaleBunCrashSignalBridge.m +131 -131
  82. package/ios/Crash/ScaleBunCrashStorage.swift +46 -46
  83. package/ios/Engage/ScaleBunEngageBridge.m +32 -32
  84. package/ios/Engage/ScaleBunEngageModule.swift +250 -250
  85. package/ios/Engage/ScaleBunPushNotificationCenter.swift +185 -185
  86. package/ios/Ota/BundleDownloader.swift +182 -0
  87. package/ios/Ota/OtaSlotManager.swift +290 -264
  88. package/ios/Ota/ScaleBunOtaBridge.mm +77 -68
  89. package/ios/Ota/ScaleBunOtaEventsModule.swift +61 -0
  90. package/ios/Ota/ScaleBunOtaModule.swift +176 -123
  91. package/ios/Outbox/NativeOutbox.swift +598 -598
  92. package/ios/Outbox/OutboxUploader.swift +431 -431
  93. package/ios/Performance/ScaleBunPerformanceBridge.m +32 -32
  94. package/ios/Performance/ScaleBunPerformanceModule.swift +290 -290
  95. package/ios/PrivacyInfo.xcprivacy +97 -97
  96. package/ios/Profiler/ScaleBunProfilerBridge.m +55 -55
  97. package/ios/Profiler/ScaleBunProfilerModule.swift +972 -972
  98. package/ios/ReplaySdk-Bridging-Header.h +2 -2
  99. package/ios/ReplaySdk.swift +608 -608
  100. package/ios/ReplaySdkBridge.m +94 -94
  101. package/ios/Session/SessionManager.swift +203 -203
  102. package/ios/Skan/ScaleBunSkanBridge.m +14 -14
  103. package/ios/Skan/ScaleBunSkanModule.swift +61 -61
  104. package/ios/Storage/ReplayStorage.swift +61 -61
  105. package/ios/Storage/ScaleBunKvFileStore.swift +125 -125
  106. package/ios/Storage/ScaleBunStorageBridge.mm +72 -72
  107. package/ios/Storage/ScaleBunStorageModule.swift +57 -57
  108. package/ios/Transport/ReplayTransport.swift +70 -70
  109. package/ios/VoiceRecorder.swift +145 -145
  110. package/lib/commonjs/analytics/EventTracker.js +34 -34
  111. package/lib/commonjs/analytics/EventTracker.js.map +1 -1
  112. package/lib/commonjs/analytics/automaticEvents.js +7 -7
  113. package/lib/commonjs/analytics/automaticEvents.js.map +1 -1
  114. package/lib/commonjs/analytics/batching.js +24 -24
  115. package/lib/commonjs/analytics/batching.js.map +1 -1
  116. package/lib/commonjs/analytics/eventLane.js +13 -13
  117. package/lib/commonjs/analytics/eventLane.js.map +1 -1
  118. package/lib/commonjs/bootstrap/FeatureRegistry.js +17 -17
  119. package/lib/commonjs/bootstrap/FeatureRegistry.js.map +1 -1
  120. package/lib/commonjs/bootstrap/SDKBootstrapper.js +64 -42
  121. package/lib/commonjs/bootstrap/SDKBootstrapper.js.map +1 -1
  122. package/lib/commonjs/bucketing/fnv1a32.js +10 -10
  123. package/lib/commonjs/bucketing/fnv1a32.js.map +1 -1
  124. package/lib/commonjs/compat/codepush.js +6 -6
  125. package/lib/commonjs/compat/codepush.js.map +1 -1
  126. package/lib/commonjs/config/ConfigManager.js +20 -20
  127. package/lib/commonjs/config/ConfigManager.js.map +1 -1
  128. package/lib/commonjs/config/configTypes.js.map +1 -1
  129. package/lib/commonjs/core/architecture.js +23 -23
  130. package/lib/commonjs/core/architecture.js.map +1 -1
  131. package/lib/commonjs/core/clock/now.js +2 -2
  132. package/lib/commonjs/core/clock/now.js.map +1 -1
  133. package/lib/commonjs/core/config/defaults.js.map +1 -1
  134. package/lib/commonjs/core/config/schema.js +102 -102
  135. package/lib/commonjs/core/config/schema.js.map +1 -1
  136. package/lib/commonjs/core/constants/endpoints.js +7 -7
  137. package/lib/commonjs/core/constants/endpoints.js.map +1 -1
  138. package/lib/commonjs/core/constants/timings.js +5 -5
  139. package/lib/commonjs/core/constants/timings.js.map +1 -1
  140. package/lib/commonjs/core/constants/version.js +4 -4
  141. package/lib/commonjs/core/constants/version.js.map +1 -1
  142. package/lib/commonjs/core/context/app.js.map +1 -1
  143. package/lib/commonjs/core/context/device.js.map +1 -1
  144. package/lib/commonjs/core/context/session.js.map +1 -1
  145. package/lib/commonjs/core/context/user.js.map +1 -1
  146. package/lib/commonjs/core/contracts/IFeature.js.map +1 -1
  147. package/lib/commonjs/core/di/container.js.map +1 -1
  148. package/lib/commonjs/core/encoding/base64.js +9 -9
  149. package/lib/commonjs/core/encoding/base64.js.map +1 -1
  150. package/lib/commonjs/core/id/deviceId.js +4 -4
  151. package/lib/commonjs/core/id/deviceId.js.map +1 -1
  152. package/lib/commonjs/core/id/sessionId.js.map +1 -1
  153. package/lib/commonjs/core/lifecycle/appLifecycle.js.map +1 -1
  154. package/lib/commonjs/core/lifecycle/crashSafe.js +3 -3
  155. package/lib/commonjs/core/lifecycle/crashSafe.js.map +1 -1
  156. package/lib/commonjs/core/logger/errorClassification.js +30 -30
  157. package/lib/commonjs/core/logger/errorClassification.js.map +1 -1
  158. package/lib/commonjs/core/logger/internalLogger.js.map +1 -1
  159. package/lib/commonjs/core/logger/levels.js.map +1 -1
  160. package/lib/commonjs/crypto/hmacSha256.js +6 -6
  161. package/lib/commonjs/crypto/hmacSha256.js.map +1 -1
  162. package/lib/commonjs/debug/bootstrap.js +26 -26
  163. package/lib/commonjs/debug/bootstrap.js.map +1 -1
  164. package/lib/commonjs/debug/commands.js +10 -10
  165. package/lib/commonjs/debug/commands.js.map +1 -1
  166. package/lib/commonjs/debug/configBuilder.js +6 -6
  167. package/lib/commonjs/debug/configBuilder.js.map +1 -1
  168. package/lib/commonjs/debug/exportBridge.js +17 -17
  169. package/lib/commonjs/debug/exportBridge.js.map +1 -1
  170. package/lib/commonjs/debug/hostResolver.js +10 -10
  171. package/lib/commonjs/debug/hostResolver.js.map +1 -1
  172. package/lib/commonjs/debug/index.js.map +1 -1
  173. package/lib/commonjs/debug/metrics.js.map +1 -1
  174. package/lib/commonjs/debug/perf.js +11 -11
  175. package/lib/commonjs/debug/perf.js.map +1 -1
  176. package/lib/commonjs/debug/perfWiring.js +10 -10
  177. package/lib/commonjs/debug/perfWiring.js.map +1 -1
  178. package/lib/commonjs/debug/protocol.js.map +1 -1
  179. package/lib/commonjs/debug/redaction.js +26 -26
  180. package/lib/commonjs/debug/redaction.js.map +1 -1
  181. package/lib/commonjs/debug/replayWiring.js +11 -11
  182. package/lib/commonjs/debug/replayWiring.js.map +1 -1
  183. package/lib/commonjs/debug/screenTracking.js +7 -7
  184. package/lib/commonjs/debug/screenTracking.js.map +1 -1
  185. package/lib/commonjs/debug/sessionWiring.js +8 -8
  186. package/lib/commonjs/debug/sessionWiring.js.map +1 -1
  187. package/lib/commonjs/debug/stream.js +26 -26
  188. package/lib/commonjs/debug/stream.js.map +1 -1
  189. package/lib/commonjs/debug/transport.js +24 -24
  190. package/lib/commonjs/debug/transport.js.map +1 -1
  191. package/lib/commonjs/features/bugreport/index.js.map +1 -1
  192. package/lib/commonjs/features/crash/CrashFeature.js +27 -9
  193. package/lib/commonjs/features/crash/CrashFeature.js.map +1 -1
  194. package/lib/commonjs/features/crash/CrashReporter.js +28 -28
  195. package/lib/commonjs/features/crash/CrashReporter.js.map +1 -1
  196. package/lib/commonjs/features/crash/NativeCrashFeature.js +7 -7
  197. package/lib/commonjs/features/crash/NativeCrashFeature.js.map +1 -1
  198. package/lib/commonjs/features/crash/capture.js.map +1 -1
  199. package/lib/commonjs/features/crash/globalHandler.js +11 -11
  200. package/lib/commonjs/features/crash/globalHandler.js.map +1 -1
  201. package/lib/commonjs/features/crash/index.js.map +1 -1
  202. package/lib/commonjs/features/crash/nativeCrashBridge.js +19 -19
  203. package/lib/commonjs/features/crash/nativeCrashBridge.js.map +1 -1
  204. package/lib/commonjs/features/crash/rejectionHandler.js +123 -0
  205. package/lib/commonjs/features/crash/rejectionHandler.js.map +1 -0
  206. package/lib/commonjs/features/engage/EngageAnchor.js +3 -3
  207. package/lib/commonjs/features/engage/EngageAnchor.js.map +1 -1
  208. package/lib/commonjs/features/engage/EngageArchetypeRenderers.js +19 -19
  209. package/lib/commonjs/features/engage/EngageArchetypeRenderers.js.map +1 -1
  210. package/lib/commonjs/features/engage/EngageInAppView.js +35 -35
  211. package/lib/commonjs/features/engage/EngageInAppView.js.map +1 -1
  212. package/lib/commonjs/features/engage/EngageInlinePlacement.js +7 -7
  213. package/lib/commonjs/features/engage/EngageInlinePlacement.js.map +1 -1
  214. package/lib/commonjs/features/engage/EngagePromptProvider.js +88 -86
  215. package/lib/commonjs/features/engage/EngagePromptProvider.js.map +1 -1
  216. package/lib/commonjs/features/engage/EngagePromptView.js +18 -18
  217. package/lib/commonjs/features/engage/EngagePromptView.js.map +1 -1
  218. package/lib/commonjs/features/engage/EngageTransport.js +79 -79
  219. package/lib/commonjs/features/engage/EngageTransport.js.map +1 -1
  220. package/lib/commonjs/features/engage/EngageVariantContent.js +10 -10
  221. package/lib/commonjs/features/engage/EngageVariantContent.js.map +1 -1
  222. package/lib/commonjs/features/engage/__test-support__/reactNativeStub.js +7 -7
  223. package/lib/commonjs/features/engage/__test-support__/reactNativeStub.js.map +1 -1
  224. package/lib/commonjs/features/engage/attachmentCapture.js +12 -12
  225. package/lib/commonjs/features/engage/attachmentCapture.js.map +1 -1
  226. package/lib/commonjs/features/engage/captureVoiceAttachment.js +20 -20
  227. package/lib/commonjs/features/engage/captureVoiceAttachment.js.map +1 -1
  228. package/lib/commonjs/features/engage/engageCoachmarkTour.js +4 -4
  229. package/lib/commonjs/features/engage/engageCoachmarkTour.js.map +1 -1
  230. package/lib/commonjs/features/engage/engageGameLogic.js.map +1 -1
  231. package/lib/commonjs/features/engage/engageMediaSizing.js +15 -15
  232. package/lib/commonjs/features/engage/engageMediaSizing.js.map +1 -1
  233. package/lib/commonjs/features/engage/engageMultiStepSheet.js +6 -6
  234. package/lib/commonjs/features/engage/engageMultiStepSheet.js.map +1 -1
  235. package/lib/commonjs/features/engage/engageOutcome.js +6 -6
  236. package/lib/commonjs/features/engage/engageOutcome.js.map +1 -1
  237. package/lib/commonjs/features/engage/engagePushTokenBridge.js +20 -20
  238. package/lib/commonjs/features/engage/engagePushTokenBridge.js.map +1 -1
  239. package/lib/commonjs/features/engage/engageShakeBridge.js +16 -16
  240. package/lib/commonjs/features/engage/engageShakeBridge.js.map +1 -1
  241. package/lib/commonjs/features/engage/engageSignals.js.map +1 -1
  242. package/lib/commonjs/features/engage/engageStoreReviewBridge.js +19 -19
  243. package/lib/commonjs/features/engage/engageStoreReviewBridge.js.map +1 -1
  244. package/lib/commonjs/features/engage/engageTestSeenStore.js +29 -29
  245. package/lib/commonjs/features/engage/engageTestSeenStore.js.map +1 -1
  246. package/lib/commonjs/features/engage/engageThrottle.js +117 -86
  247. package/lib/commonjs/features/engage/engageThrottle.js.map +1 -1
  248. package/lib/commonjs/features/engage/engageTriggerEngine.js +7 -7
  249. package/lib/commonjs/features/engage/engageTriggerEngine.js.map +1 -1
  250. package/lib/commonjs/features/engage/engageTypes.js +33 -33
  251. package/lib/commonjs/features/engage/engageTypes.js.map +1 -1
  252. package/lib/commonjs/features/engage/engageVariantResolver.js +13 -13
  253. package/lib/commonjs/features/engage/engageVariantResolver.js.map +1 -1
  254. package/lib/commonjs/features/engage/engageWindowInsets.js +10 -10
  255. package/lib/commonjs/features/engage/engageWindowInsets.js.map +1 -1
  256. package/lib/commonjs/features/engage/gestureTriggerDetector.js.map +1 -1
  257. package/lib/commonjs/features/engage/transcription/TranscriptionProvider.js +16 -16
  258. package/lib/commonjs/features/engage/transcription/TranscriptionProvider.js.map +1 -1
  259. package/lib/commonjs/features/install-referrer/installReferrer.js +26 -26
  260. package/lib/commonjs/features/install-referrer/installReferrer.js.map +1 -1
  261. package/lib/commonjs/features/journey/ScaleBunDebugRoot.js +28 -28
  262. package/lib/commonjs/features/journey/ScaleBunDebugRoot.js.map +1 -1
  263. package/lib/commonjs/features/journey/ScaleBunFlatList.js +15 -15
  264. package/lib/commonjs/features/journey/ScaleBunFlatList.js.map +1 -1
  265. package/lib/commonjs/features/journey/ScaleBunImpression.js +22 -22
  266. package/lib/commonjs/features/journey/ScaleBunImpression.js.map +1 -1
  267. package/lib/commonjs/features/journey/ScaleBunScrollView.js +20 -20
  268. package/lib/commonjs/features/journey/ScaleBunScrollView.js.map +1 -1
  269. package/lib/commonjs/features/journey/ScaleBunSectionList.js +15 -15
  270. package/lib/commonjs/features/journey/ScaleBunSectionList.js.map +1 -1
  271. package/lib/commonjs/features/journey/calibrationContext.js +12 -12
  272. package/lib/commonjs/features/journey/calibrationContext.js.map +1 -1
  273. package/lib/commonjs/features/journey/gestureBuffer.js +9 -9
  274. package/lib/commonjs/features/journey/gestureBuffer.js.map +1 -1
  275. package/lib/commonjs/features/journey/gestureDetector.js +10 -10
  276. package/lib/commonjs/features/journey/gestureDetector.js.map +1 -1
  277. package/lib/commonjs/features/journey/impression.js +18 -18
  278. package/lib/commonjs/features/journey/impression.js.map +1 -1
  279. package/lib/commonjs/features/journey/journeyManager.js +6 -6
  280. package/lib/commonjs/features/journey/journeyManager.js.map +1 -1
  281. package/lib/commonjs/features/journey/journeyTypes.js +5 -5
  282. package/lib/commonjs/features/journey/journeyTypes.js.map +1 -1
  283. package/lib/commonjs/features/journey/navDetector.js +7 -7
  284. package/lib/commonjs/features/journey/navDetector.js.map +1 -1
  285. package/lib/commonjs/features/journey/screenshotHelper.js +7 -7
  286. package/lib/commonjs/features/journey/screenshotHelper.js.map +1 -1
  287. package/lib/commonjs/features/journey/targetRegistry.js +17 -17
  288. package/lib/commonjs/features/journey/targetRegistry.js.map +1 -1
  289. package/lib/commonjs/features/journey/touchTarget.js +29 -29
  290. package/lib/commonjs/features/journey/touchTarget.js.map +1 -1
  291. package/lib/commonjs/features/navigation/AutoScreenDetector.js +114 -71
  292. package/lib/commonjs/features/navigation/AutoScreenDetector.js.map +1 -1
  293. package/lib/commonjs/features/network/NetworkFeature.js +23 -23
  294. package/lib/commonjs/features/network/NetworkFeature.js.map +1 -1
  295. package/lib/commonjs/features/network/index.js +5 -5
  296. package/lib/commonjs/features/network/index.js.map +1 -1
  297. package/lib/commonjs/features/ota/OtaEventEmitter.js +21 -21
  298. package/lib/commonjs/features/ota/OtaEventEmitter.js.map +1 -1
  299. package/lib/commonjs/features/ota/OtaOrchestrator.js +535 -40
  300. package/lib/commonjs/features/ota/OtaOrchestrator.js.map +1 -1
  301. package/lib/commonjs/features/ota/OtaTypes.js.map +1 -1
  302. package/lib/commonjs/features/ota/environment.js +172 -0
  303. package/lib/commonjs/features/ota/environment.js.map +1 -0
  304. package/lib/commonjs/features/ota/retry.js +96 -0
  305. package/lib/commonjs/features/ota/retry.js.map +1 -0
  306. package/lib/commonjs/features/ota/signature.js +115 -0
  307. package/lib/commonjs/features/ota/signature.js.map +1 -0
  308. package/lib/commonjs/features/ota/useOtaUpdate.js +15 -15
  309. package/lib/commonjs/features/ota/useOtaUpdate.js.map +1 -1
  310. package/lib/commonjs/features/performance/PerformanceFeature.js +26 -26
  311. package/lib/commonjs/features/performance/PerformanceFeature.js.map +1 -1
  312. package/lib/commonjs/features/performance/collectors/AppLaunchCollector.js +13 -13
  313. package/lib/commonjs/features/performance/collectors/AppLaunchCollector.js.map +1 -1
  314. package/lib/commonjs/features/performance/collectors/AutoScreenLoadCollector.js +32 -32
  315. package/lib/commonjs/features/performance/collectors/AutoScreenLoadCollector.js.map +1 -1
  316. package/lib/commonjs/features/performance/collectors/CustomTraceCollector.js +13 -13
  317. package/lib/commonjs/features/performance/collectors/CustomTraceCollector.js.map +1 -1
  318. package/lib/commonjs/features/performance/collectors/FrameMetricsCollector.js +11 -11
  319. package/lib/commonjs/features/performance/collectors/FrameMetricsCollector.js.map +1 -1
  320. package/lib/commonjs/features/performance/collectors/JsStallCollector.js +12 -12
  321. package/lib/commonjs/features/performance/collectors/JsStallCollector.js.map +1 -1
  322. package/lib/commonjs/features/performance/collectors/NetworkPerfCollector.js +10 -10
  323. package/lib/commonjs/features/performance/collectors/NetworkPerfCollector.js.map +1 -1
  324. package/lib/commonjs/features/performance/collectors/ScreenLoadCollector.js +11 -11
  325. package/lib/commonjs/features/performance/collectors/ScreenLoadCollector.js.map +1 -1
  326. package/lib/commonjs/features/performance/collectors/UiHangCollector.js +5 -5
  327. package/lib/commonjs/features/performance/collectors/UiHangCollector.js.map +1 -1
  328. package/lib/commonjs/features/performance/config.js +11 -11
  329. package/lib/commonjs/features/performance/config.js.map +1 -1
  330. package/lib/commonjs/features/performance/getNativePerformanceModule.js +11 -11
  331. package/lib/commonjs/features/performance/getNativePerformanceModule.js.map +1 -1
  332. package/lib/commonjs/features/performance/index.js.map +1 -1
  333. package/lib/commonjs/features/performance/metrics/MetricsEngine.js +13 -13
  334. package/lib/commonjs/features/performance/metrics/MetricsEngine.js.map +1 -1
  335. package/lib/commonjs/features/performance/models.js +8 -8
  336. package/lib/commonjs/features/performance/models.js.map +1 -1
  337. package/lib/commonjs/features/performance/transport/PerformanceTransport.js +6 -6
  338. package/lib/commonjs/features/performance/transport/PerformanceTransport.js.map +1 -1
  339. package/lib/commonjs/features/profiler/ProfilerFeature.js +53 -53
  340. package/lib/commonjs/features/profiler/ProfilerFeature.js.map +1 -1
  341. package/lib/commonjs/features/profiler/config.js +15 -15
  342. package/lib/commonjs/features/profiler/config.js.map +1 -1
  343. package/lib/commonjs/features/profiler/contracts.js +22 -22
  344. package/lib/commonjs/features/profiler/contracts.js.map +1 -1
  345. package/lib/commonjs/features/profiler/index.js.map +1 -1
  346. package/lib/commonjs/features/profiler/models.js +44 -44
  347. package/lib/commonjs/features/profiler/models.js.map +1 -1
  348. package/lib/commonjs/features/profiler/transport/ProfilerTransport.js +9 -9
  349. package/lib/commonjs/features/profiler/transport/ProfilerTransport.js.map +1 -1
  350. package/lib/commonjs/features/replay/bridge/adapters/bridgeAdapter.js +17 -17
  351. package/lib/commonjs/features/replay/bridge/adapters/bridgeAdapter.js.map +1 -1
  352. package/lib/commonjs/features/replay/bridge/eventEmitter.js +8 -8
  353. package/lib/commonjs/features/replay/bridge/eventEmitter.js.map +1 -1
  354. package/lib/commonjs/features/replay/bridge/nativeModule.js +20 -20
  355. package/lib/commonjs/features/replay/bridge/nativeModule.js.map +1 -1
  356. package/lib/commonjs/features/replay/core/clock/clock.js +6 -6
  357. package/lib/commonjs/features/replay/core/clock/clock.js.map +1 -1
  358. package/lib/commonjs/features/replay/core/config/defaults.js +2 -2
  359. package/lib/commonjs/features/replay/core/config/defaults.js.map +1 -1
  360. package/lib/commonjs/features/replay/core/config/validator.js +5 -5
  361. package/lib/commonjs/features/replay/core/config/validator.js.map +1 -1
  362. package/lib/commonjs/features/replay/core/env/environmentDetector.js +10 -10
  363. package/lib/commonjs/features/replay/core/env/environmentDetector.js.map +1 -1
  364. package/lib/commonjs/features/replay/core/errors/safeCall.js +4 -4
  365. package/lib/commonjs/features/replay/core/errors/safeCall.js.map +1 -1
  366. package/lib/commonjs/features/replay/core/ids/sessionId.js +5 -5
  367. package/lib/commonjs/features/replay/core/ids/sessionId.js.map +1 -1
  368. package/lib/commonjs/features/replay/core/logger/logger.js +5 -5
  369. package/lib/commonjs/features/replay/core/logger/logger.js.map +1 -1
  370. package/lib/commonjs/features/replay/core/privacy/privacyTypes.js +4 -4
  371. package/lib/commonjs/features/replay/core/privacy/privacyTypes.js.map +1 -1
  372. package/lib/commonjs/features/replay/core/queue/boundedQueue.js +5 -5
  373. package/lib/commonjs/features/replay/core/queue/boundedQueue.js.map +1 -1
  374. package/lib/commonjs/features/replay/integrations/alert/alertInstrumentation.js +59 -59
  375. package/lib/commonjs/features/replay/integrations/alert/alertInstrumentation.js.map +1 -1
  376. package/lib/commonjs/features/replay/integrations/logs/consoleIntegration.js +19 -19
  377. package/lib/commonjs/features/replay/integrations/logs/consoleIntegration.js.map +1 -1
  378. package/lib/commonjs/features/replay/integrations/network/networkAdapter.js +30 -30
  379. package/lib/commonjs/features/replay/integrations/network/networkAdapter.js.map +1 -1
  380. package/lib/commonjs/features/replay/integrations/react-navigation/navigationIntegration.js +19 -19
  381. package/lib/commonjs/features/replay/integrations/react-navigation/navigationIntegration.js.map +1 -1
  382. package/lib/commonjs/features/replay/integrations/touch/ReplayRoot.js +16 -16
  383. package/lib/commonjs/features/replay/integrations/touch/ReplayRoot.js.map +1 -1
  384. package/lib/commonjs/features/replay/pipeline/batching/batchManager.js +5 -5
  385. package/lib/commonjs/features/replay/pipeline/batching/batchManager.js.map +1 -1
  386. package/lib/commonjs/features/replay/pipeline/envelope/envelopeBuilder.js +5 -5
  387. package/lib/commonjs/features/replay/pipeline/envelope/envelopeBuilder.js.map +1 -1
  388. package/lib/commonjs/features/replay/pipeline/retry/retryPolicy.js +4 -4
  389. package/lib/commonjs/features/replay/pipeline/retry/retryPolicy.js.map +1 -1
  390. package/lib/commonjs/features/replay/pipeline/transport/transportTypes.js +7 -7
  391. package/lib/commonjs/features/replay/pipeline/transport/transportTypes.js.map +1 -1
  392. package/lib/commonjs/features/replay/public/api.js +21 -21
  393. package/lib/commonjs/features/replay/public/api.js.map +1 -1
  394. package/lib/commonjs/features/replay/public/enums.js +5 -5
  395. package/lib/commonjs/features/replay/public/enums.js.map +1 -1
  396. package/lib/commonjs/features/replay/public/types.js.map +1 -1
  397. package/lib/commonjs/features/replay/replay/breadcrumbs/breadcrumbCollector.js +5 -5
  398. package/lib/commonjs/features/replay/replay/breadcrumbs/breadcrumbCollector.js.map +1 -1
  399. package/lib/commonjs/features/replay/replay/frames/frameModels.js +4 -4
  400. package/lib/commonjs/features/replay/replay/frames/frameModels.js.map +1 -1
  401. package/lib/commonjs/features/replay/replay/session/sessionOrchestrator.js +10 -10
  402. package/lib/commonjs/features/replay/replay/session/sessionOrchestrator.js.map +1 -1
  403. package/lib/commonjs/features/replay/replay/timeline/timelineModels.js +4 -4
  404. package/lib/commonjs/features/replay/replay/timeline/timelineModels.js.map +1 -1
  405. package/lib/commonjs/features/replay/transport/BackendReplayTransport.js +13 -13
  406. package/lib/commonjs/features/replay/transport/BackendReplayTransport.js.map +1 -1
  407. package/lib/commonjs/features/replay/transport/CompositeReplayTransport.js +8 -8
  408. package/lib/commonjs/features/replay/transport/CompositeReplayTransport.js.map +1 -1
  409. package/lib/commonjs/features/replay/transport/DesktopReplayTransport.js +14 -14
  410. package/lib/commonjs/features/replay/transport/DesktopReplayTransport.js.map +1 -1
  411. package/lib/commonjs/features/replay/transport/ReplayTransport.js.map +1 -1
  412. package/lib/commonjs/features/session/BackendSessionAdapter.js +358 -153
  413. package/lib/commonjs/features/session/BackendSessionAdapter.js.map +1 -1
  414. package/lib/commonjs/features/session/DesktopSessionTransport.js +14 -14
  415. package/lib/commonjs/features/session/DesktopSessionTransport.js.map +1 -1
  416. package/lib/commonjs/features/session/JourneyEventPipeline.js +19 -19
  417. package/lib/commonjs/features/session/JourneyEventPipeline.js.map +1 -1
  418. package/lib/commonjs/features/session/ReplayCaptureManager.js +123 -123
  419. package/lib/commonjs/features/session/ReplayCaptureManager.js.map +1 -1
  420. package/lib/commonjs/features/session/ScrollTracker.js +17 -17
  421. package/lib/commonjs/features/session/ScrollTracker.js.map +1 -1
  422. package/lib/commonjs/features/session/SessionManager.js +143 -143
  423. package/lib/commonjs/features/session/SessionManager.js.map +1 -1
  424. package/lib/commonjs/features/session/SyncDecisionEngine.js +23 -23
  425. package/lib/commonjs/features/session/SyncDecisionEngine.js.map +1 -1
  426. package/lib/commonjs/features/session/index.js.map +1 -1
  427. package/lib/commonjs/features/session/nativeCapture.js +5 -5
  428. package/lib/commonjs/features/session/nativeCapture.js.map +1 -1
  429. package/lib/commonjs/features/session/outboxFrameCapture.js +15 -15
  430. package/lib/commonjs/features/session/outboxFrameCapture.js.map +1 -1
  431. package/lib/commonjs/features/session/sessionTypes.js +44 -44
  432. package/lib/commonjs/features/session/sessionTypes.js.map +1 -1
  433. package/lib/commonjs/features/skan/skanBridge.js +11 -11
  434. package/lib/commonjs/features/skan/skanBridge.js.map +1 -1
  435. package/lib/commonjs/features/skan/skanConversionManager.js +23 -23
  436. package/lib/commonjs/features/skan/skanConversionManager.js.map +1 -1
  437. package/lib/commonjs/index.js +7 -0
  438. package/lib/commonjs/index.js.map +1 -1
  439. package/lib/commonjs/integrations/fetch/fetchInterceptor.js +21 -21
  440. package/lib/commonjs/integrations/fetch/fetchInterceptor.js.map +1 -1
  441. package/lib/commonjs/integrations/navigation/screenTracker.js.map +1 -1
  442. package/lib/commonjs/integrations/network/bodyCapture.js +69 -69
  443. package/lib/commonjs/integrations/network/bodyCapture.js.map +1 -1
  444. package/lib/commonjs/integrations/xhr/xhrInterceptor.js +24 -24
  445. package/lib/commonjs/integrations/xhr/xhrInterceptor.js.map +1 -1
  446. package/lib/commonjs/metro/index.js +37 -37
  447. package/lib/commonjs/metro/index.js.map +1 -1
  448. package/lib/commonjs/metro/optionalDependencyStub.js.map +1 -1
  449. package/lib/commonjs/metro/optionalModules.js +16 -16
  450. package/lib/commonjs/metro/optionalModules.js.map +1 -1
  451. package/lib/commonjs/pipeline/dispatcher/dispatcher.js.map +1 -1
  452. package/lib/commonjs/pipeline/envelope/envelope.js.map +1 -1
  453. package/lib/commonjs/pipeline/envelope/serializer.js.map +1 -1
  454. package/lib/commonjs/pipeline/processors/dedupe.js.map +1 -1
  455. package/lib/commonjs/pipeline/processors/enrich.js.map +1 -1
  456. package/lib/commonjs/pipeline/processors/sampling.js.map +1 -1
  457. package/lib/commonjs/pipeline/processors/sanitize.js.map +1 -1
  458. package/lib/commonjs/pipeline/queue/flushQueue.js +4 -4
  459. package/lib/commonjs/pipeline/queue/flushQueue.js.map +1 -1
  460. package/lib/commonjs/pipeline/queue/memoryQueue.js.map +1 -1
  461. package/lib/commonjs/pipeline/queue/persistentQueue.js +80 -80
  462. package/lib/commonjs/pipeline/queue/persistentQueue.js.map +1 -1
  463. package/lib/commonjs/pipeline/queue/queuePolicy.js.map +1 -1
  464. package/lib/commonjs/pipeline/scheduler/flushScheduler.js.map +1 -1
  465. package/lib/commonjs/pipeline/scheduler/retryPolicy.js +2 -2
  466. package/lib/commonjs/pipeline/scheduler/retryPolicy.js.map +1 -1
  467. package/lib/commonjs/public/ScaleBunErrorBoundary.js +79 -0
  468. package/lib/commonjs/public/ScaleBunErrorBoundary.js.map +1 -0
  469. package/lib/commonjs/public/ScaleBunFacade.js +274 -274
  470. package/lib/commonjs/public/ScaleBunFacade.js.map +1 -1
  471. package/lib/commonjs/public/ScaleBunProvider.js +3 -3
  472. package/lib/commonjs/public/ScaleBunProvider.js.map +1 -1
  473. package/lib/commonjs/public/typedTracker.js +36 -36
  474. package/lib/commonjs/public/typedTracker.js.map +1 -1
  475. package/lib/commonjs/public/types.js.map +1 -1
  476. package/lib/commonjs/push/PushManager.js +21 -21
  477. package/lib/commonjs/push/PushManager.js.map +1 -1
  478. package/lib/commonjs/push/adapters/ManualAdapter.js +14 -14
  479. package/lib/commonjs/push/adapters/ManualAdapter.js.map +1 -1
  480. package/lib/commonjs/push/adapters/NativeBridgeAdapter.js +17 -17
  481. package/lib/commonjs/push/adapters/NativeBridgeAdapter.js.map +1 -1
  482. package/lib/commonjs/push/adapters/NoopAdapter.js +5 -5
  483. package/lib/commonjs/push/adapters/NoopAdapter.js.map +1 -1
  484. package/lib/commonjs/push/adapters/RNFirebaseMessagingAdapter.js +17 -17
  485. package/lib/commonjs/push/adapters/RNFirebaseMessagingAdapter.js.map +1 -1
  486. package/lib/commonjs/push/adapters/loadMessaging.js +12 -12
  487. package/lib/commonjs/push/adapters/loadMessaging.js.map +1 -1
  488. package/lib/commonjs/push/adapters/loadNotifee.js +12 -12
  489. package/lib/commonjs/push/adapters/loadNotifee.js.map +1 -1
  490. package/lib/commonjs/push/adapters/selectAdapter.js +14 -14
  491. package/lib/commonjs/push/adapters/selectAdapter.js.map +1 -1
  492. package/lib/commonjs/push/detect/capabilities.js +19 -19
  493. package/lib/commonjs/push/detect/capabilities.js.map +1 -1
  494. package/lib/commonjs/push/index.js.map +1 -1
  495. package/lib/commonjs/push/native/nativeNotifications.js +32 -32
  496. package/lib/commonjs/push/native/nativeNotifications.js.map +1 -1
  497. package/lib/commonjs/push/types.js.map +1 -1
  498. package/lib/commonjs/specs/NativeReplaySdk.js +18 -18
  499. package/lib/commonjs/specs/NativeReplaySdk.js.map +1 -1
  500. package/lib/commonjs/specs/NativeScaleBunCrash.js +19 -19
  501. package/lib/commonjs/specs/NativeScaleBunCrash.js.map +1 -1
  502. package/lib/commonjs/specs/NativeScaleBunInstallReferrer.js +14 -14
  503. package/lib/commonjs/specs/NativeScaleBunInstallReferrer.js.map +1 -1
  504. package/lib/commonjs/specs/NativeScaleBunOta.js +21 -21
  505. package/lib/commonjs/specs/NativeScaleBunOta.js.map +1 -1
  506. package/lib/commonjs/specs/NativeScaleBunPerformance.js +15 -15
  507. package/lib/commonjs/specs/NativeScaleBunPerformance.js.map +1 -1
  508. package/lib/commonjs/specs/NativeScaleBunProfiler.js +16 -16
  509. package/lib/commonjs/specs/NativeScaleBunProfiler.js.map +1 -1
  510. package/lib/commonjs/specs/NativeScaleBunStorage.js +29 -29
  511. package/lib/commonjs/specs/NativeScaleBunStorage.js.map +1 -1
  512. package/lib/commonjs/storage/StorageBackend.js +83 -83
  513. package/lib/commonjs/storage/StorageBackend.js.map +1 -1
  514. package/lib/commonjs/storage/db/sqlite.js.map +1 -1
  515. package/lib/commonjs/storage/files/fileStore.js.map +1 -1
  516. package/lib/commonjs/transport/auth/sdkSession.js.map +1 -1
  517. package/lib/commonjs/transport/backoff/exponentialJitter.js +2 -2
  518. package/lib/commonjs/transport/backoff/exponentialJitter.js.map +1 -1
  519. package/lib/commonjs/transport/http/endpoints.js.map +1 -1
  520. package/lib/commonjs/transport/http/httpClient.js +3 -3
  521. package/lib/commonjs/transport/http/httpClient.js.map +1 -1
  522. package/lib/commonjs/transport/rateLimit/retryAfter.js.map +1 -1
  523. package/lib/commonjs/transport/signing/requestSigner.js.map +1 -1
  524. package/lib/commonjs/vendor/protocol/index.js +74 -74
  525. package/lib/commonjs/vendor/protocol/index.js.map +1 -1
  526. package/lib/commonjs/vendor/protocol/internal/validation.js +23 -23
  527. package/lib/commonjs/vendor/protocol/internal/validation.js.map +1 -1
  528. package/lib/commonjs/vendor/sdk-contracts/bridge.js.map +1 -1
  529. package/lib/commonjs/vendor/sdk-contracts/config.js.map +1 -1
  530. package/lib/commonjs/vendor/sdk-contracts/events.js.map +1 -1
  531. package/lib/commonjs/vendor/sdk-contracts/features.js.map +1 -1
  532. package/lib/commonjs/vendor/sdk-contracts/index.js.map +1 -1
  533. package/lib/commonjs/vendor/sdk-contracts/platform.js.map +1 -1
  534. package/lib/commonjs/vendor/sdk-contracts/session-boundary.js.map +1 -1
  535. package/lib/commonjs/vendor/sdk-contracts/session.js.map +1 -1
  536. package/lib/commonjs/vendor/vendor.manifest +10 -10
  537. package/lib/module/analytics/EventTracker.js +34 -34
  538. package/lib/module/analytics/EventTracker.js.map +1 -1
  539. package/lib/module/analytics/automaticEvents.js +7 -7
  540. package/lib/module/analytics/automaticEvents.js.map +1 -1
  541. package/lib/module/analytics/batching.js +24 -24
  542. package/lib/module/analytics/batching.js.map +1 -1
  543. package/lib/module/analytics/eventLane.js +13 -13
  544. package/lib/module/analytics/eventLane.js.map +1 -1
  545. package/lib/module/bootstrap/FeatureRegistry.js +17 -17
  546. package/lib/module/bootstrap/FeatureRegistry.js.map +1 -1
  547. package/lib/module/bootstrap/SDKBootstrapper.js +64 -42
  548. package/lib/module/bootstrap/SDKBootstrapper.js.map +1 -1
  549. package/lib/module/bucketing/fnv1a32.js +10 -10
  550. package/lib/module/bucketing/fnv1a32.js.map +1 -1
  551. package/lib/module/compat/codepush.js +6 -6
  552. package/lib/module/compat/codepush.js.map +1 -1
  553. package/lib/module/config/ConfigManager.js +20 -20
  554. package/lib/module/config/ConfigManager.js.map +1 -1
  555. package/lib/module/config/configTypes.js.map +1 -1
  556. package/lib/module/core/architecture.js +23 -23
  557. package/lib/module/core/architecture.js.map +1 -1
  558. package/lib/module/core/clock/now.js +2 -2
  559. package/lib/module/core/clock/now.js.map +1 -1
  560. package/lib/module/core/config/defaults.js.map +1 -1
  561. package/lib/module/core/config/schema.js +102 -102
  562. package/lib/module/core/config/schema.js.map +1 -1
  563. package/lib/module/core/constants/endpoints.js +7 -7
  564. package/lib/module/core/constants/endpoints.js.map +1 -1
  565. package/lib/module/core/constants/timings.js +5 -5
  566. package/lib/module/core/constants/timings.js.map +1 -1
  567. package/lib/module/core/constants/version.js +4 -4
  568. package/lib/module/core/constants/version.js.map +1 -1
  569. package/lib/module/core/context/app.js.map +1 -1
  570. package/lib/module/core/context/device.js.map +1 -1
  571. package/lib/module/core/context/session.js.map +1 -1
  572. package/lib/module/core/context/user.js.map +1 -1
  573. package/lib/module/core/contracts/IFeature.js.map +1 -1
  574. package/lib/module/core/di/container.js.map +1 -1
  575. package/lib/module/core/encoding/base64.js +9 -9
  576. package/lib/module/core/encoding/base64.js.map +1 -1
  577. package/lib/module/core/id/deviceId.js +4 -4
  578. package/lib/module/core/id/deviceId.js.map +1 -1
  579. package/lib/module/core/id/sessionId.js.map +1 -1
  580. package/lib/module/core/lifecycle/appLifecycle.js.map +1 -1
  581. package/lib/module/core/lifecycle/crashSafe.js +3 -3
  582. package/lib/module/core/lifecycle/crashSafe.js.map +1 -1
  583. package/lib/module/core/logger/errorClassification.js +30 -30
  584. package/lib/module/core/logger/errorClassification.js.map +1 -1
  585. package/lib/module/core/logger/internalLogger.js.map +1 -1
  586. package/lib/module/core/logger/levels.js.map +1 -1
  587. package/lib/module/crypto/hmacSha256.js +6 -6
  588. package/lib/module/crypto/hmacSha256.js.map +1 -1
  589. package/lib/module/debug/bootstrap.js +26 -26
  590. package/lib/module/debug/bootstrap.js.map +1 -1
  591. package/lib/module/debug/commands.js +10 -10
  592. package/lib/module/debug/commands.js.map +1 -1
  593. package/lib/module/debug/configBuilder.js +6 -6
  594. package/lib/module/debug/configBuilder.js.map +1 -1
  595. package/lib/module/debug/exportBridge.js +17 -17
  596. package/lib/module/debug/exportBridge.js.map +1 -1
  597. package/lib/module/debug/hostResolver.js +10 -10
  598. package/lib/module/debug/hostResolver.js.map +1 -1
  599. package/lib/module/debug/index.js +5 -5
  600. package/lib/module/debug/index.js.map +1 -1
  601. package/lib/module/debug/metrics.js.map +1 -1
  602. package/lib/module/debug/perf.js +11 -11
  603. package/lib/module/debug/perf.js.map +1 -1
  604. package/lib/module/debug/perfWiring.js +10 -10
  605. package/lib/module/debug/perfWiring.js.map +1 -1
  606. package/lib/module/debug/protocol.js +11 -11
  607. package/lib/module/debug/protocol.js.map +1 -1
  608. package/lib/module/debug/redaction.js +26 -26
  609. package/lib/module/debug/redaction.js.map +1 -1
  610. package/lib/module/debug/replayWiring.js +11 -11
  611. package/lib/module/debug/replayWiring.js.map +1 -1
  612. package/lib/module/debug/screenTracking.js +7 -7
  613. package/lib/module/debug/screenTracking.js.map +1 -1
  614. package/lib/module/debug/sessionWiring.js +8 -8
  615. package/lib/module/debug/sessionWiring.js.map +1 -1
  616. package/lib/module/debug/stream.js +26 -26
  617. package/lib/module/debug/stream.js.map +1 -1
  618. package/lib/module/debug/transport.js +24 -24
  619. package/lib/module/debug/transport.js.map +1 -1
  620. package/lib/module/features/bugreport/index.js.map +1 -1
  621. package/lib/module/features/crash/CrashFeature.js +27 -9
  622. package/lib/module/features/crash/CrashFeature.js.map +1 -1
  623. package/lib/module/features/crash/CrashReporter.js +28 -28
  624. package/lib/module/features/crash/CrashReporter.js.map +1 -1
  625. package/lib/module/features/crash/NativeCrashFeature.js +7 -7
  626. package/lib/module/features/crash/NativeCrashFeature.js.map +1 -1
  627. package/lib/module/features/crash/capture.js.map +1 -1
  628. package/lib/module/features/crash/globalHandler.js +11 -11
  629. package/lib/module/features/crash/globalHandler.js.map +1 -1
  630. package/lib/module/features/crash/index.js.map +1 -1
  631. package/lib/module/features/crash/nativeCrashBridge.js +19 -19
  632. package/lib/module/features/crash/nativeCrashBridge.js.map +1 -1
  633. package/lib/module/features/crash/rejectionHandler.js +116 -0
  634. package/lib/module/features/crash/rejectionHandler.js.map +1 -0
  635. package/lib/module/features/engage/EngageAnchor.js +3 -3
  636. package/lib/module/features/engage/EngageAnchor.js.map +1 -1
  637. package/lib/module/features/engage/EngageArchetypeRenderers.js +19 -19
  638. package/lib/module/features/engage/EngageArchetypeRenderers.js.map +1 -1
  639. package/lib/module/features/engage/EngageInAppView.js +35 -35
  640. package/lib/module/features/engage/EngageInAppView.js.map +1 -1
  641. package/lib/module/features/engage/EngageInlinePlacement.js +7 -7
  642. package/lib/module/features/engage/EngageInlinePlacement.js.map +1 -1
  643. package/lib/module/features/engage/EngagePromptProvider.js +88 -86
  644. package/lib/module/features/engage/EngagePromptProvider.js.map +1 -1
  645. package/lib/module/features/engage/EngagePromptView.js +18 -18
  646. package/lib/module/features/engage/EngagePromptView.js.map +1 -1
  647. package/lib/module/features/engage/EngageTransport.js +79 -79
  648. package/lib/module/features/engage/EngageTransport.js.map +1 -1
  649. package/lib/module/features/engage/EngageVariantContent.js +10 -10
  650. package/lib/module/features/engage/EngageVariantContent.js.map +1 -1
  651. package/lib/module/features/engage/__test-support__/reactNativeStub.js +7 -7
  652. package/lib/module/features/engage/__test-support__/reactNativeStub.js.map +1 -1
  653. package/lib/module/features/engage/attachmentCapture.js +12 -12
  654. package/lib/module/features/engage/attachmentCapture.js.map +1 -1
  655. package/lib/module/features/engage/captureVoiceAttachment.js +20 -20
  656. package/lib/module/features/engage/captureVoiceAttachment.js.map +1 -1
  657. package/lib/module/features/engage/engageCoachmarkTour.js +4 -4
  658. package/lib/module/features/engage/engageCoachmarkTour.js.map +1 -1
  659. package/lib/module/features/engage/engageGameLogic.js.map +1 -1
  660. package/lib/module/features/engage/engageMediaSizing.js +15 -15
  661. package/lib/module/features/engage/engageMediaSizing.js.map +1 -1
  662. package/lib/module/features/engage/engageMultiStepSheet.js +6 -6
  663. package/lib/module/features/engage/engageMultiStepSheet.js.map +1 -1
  664. package/lib/module/features/engage/engageOutcome.js +6 -6
  665. package/lib/module/features/engage/engageOutcome.js.map +1 -1
  666. package/lib/module/features/engage/engagePushTokenBridge.js +20 -20
  667. package/lib/module/features/engage/engagePushTokenBridge.js.map +1 -1
  668. package/lib/module/features/engage/engageShakeBridge.js +16 -16
  669. package/lib/module/features/engage/engageShakeBridge.js.map +1 -1
  670. package/lib/module/features/engage/engageSignals.js.map +1 -1
  671. package/lib/module/features/engage/engageStoreReviewBridge.js +19 -19
  672. package/lib/module/features/engage/engageStoreReviewBridge.js.map +1 -1
  673. package/lib/module/features/engage/engageTestSeenStore.js +29 -29
  674. package/lib/module/features/engage/engageTestSeenStore.js.map +1 -1
  675. package/lib/module/features/engage/engageThrottle.js +117 -86
  676. package/lib/module/features/engage/engageThrottle.js.map +1 -1
  677. package/lib/module/features/engage/engageTriggerEngine.js +7 -7
  678. package/lib/module/features/engage/engageTriggerEngine.js.map +1 -1
  679. package/lib/module/features/engage/engageTypes.js +33 -33
  680. package/lib/module/features/engage/engageTypes.js.map +1 -1
  681. package/lib/module/features/engage/engageVariantResolver.js +13 -13
  682. package/lib/module/features/engage/engageVariantResolver.js.map +1 -1
  683. package/lib/module/features/engage/engageWindowInsets.js +10 -10
  684. package/lib/module/features/engage/engageWindowInsets.js.map +1 -1
  685. package/lib/module/features/engage/gestureTriggerDetector.js.map +1 -1
  686. package/lib/module/features/engage/transcription/TranscriptionProvider.js +16 -16
  687. package/lib/module/features/engage/transcription/TranscriptionProvider.js.map +1 -1
  688. package/lib/module/features/install-referrer/installReferrer.js +26 -26
  689. package/lib/module/features/install-referrer/installReferrer.js.map +1 -1
  690. package/lib/module/features/journey/ScaleBunDebugRoot.js +28 -28
  691. package/lib/module/features/journey/ScaleBunDebugRoot.js.map +1 -1
  692. package/lib/module/features/journey/ScaleBunFlatList.js +15 -15
  693. package/lib/module/features/journey/ScaleBunFlatList.js.map +1 -1
  694. package/lib/module/features/journey/ScaleBunImpression.js +22 -22
  695. package/lib/module/features/journey/ScaleBunImpression.js.map +1 -1
  696. package/lib/module/features/journey/ScaleBunScrollView.js +20 -20
  697. package/lib/module/features/journey/ScaleBunScrollView.js.map +1 -1
  698. package/lib/module/features/journey/ScaleBunSectionList.js +15 -15
  699. package/lib/module/features/journey/ScaleBunSectionList.js.map +1 -1
  700. package/lib/module/features/journey/calibrationContext.js +12 -12
  701. package/lib/module/features/journey/calibrationContext.js.map +1 -1
  702. package/lib/module/features/journey/gestureBuffer.js +9 -9
  703. package/lib/module/features/journey/gestureBuffer.js.map +1 -1
  704. package/lib/module/features/journey/gestureDetector.js +10 -10
  705. package/lib/module/features/journey/gestureDetector.js.map +1 -1
  706. package/lib/module/features/journey/impression.js +18 -18
  707. package/lib/module/features/journey/impression.js.map +1 -1
  708. package/lib/module/features/journey/journeyManager.js +6 -6
  709. package/lib/module/features/journey/journeyManager.js.map +1 -1
  710. package/lib/module/features/journey/journeyTypes.js +5 -5
  711. package/lib/module/features/journey/journeyTypes.js.map +1 -1
  712. package/lib/module/features/journey/navDetector.js +7 -7
  713. package/lib/module/features/journey/navDetector.js.map +1 -1
  714. package/lib/module/features/journey/screenshotHelper.js +7 -7
  715. package/lib/module/features/journey/screenshotHelper.js.map +1 -1
  716. package/lib/module/features/journey/targetRegistry.js +17 -17
  717. package/lib/module/features/journey/targetRegistry.js.map +1 -1
  718. package/lib/module/features/journey/touchTarget.js +29 -29
  719. package/lib/module/features/journey/touchTarget.js.map +1 -1
  720. package/lib/module/features/navigation/AutoScreenDetector.js +114 -71
  721. package/lib/module/features/navigation/AutoScreenDetector.js.map +1 -1
  722. package/lib/module/features/network/NetworkFeature.js +23 -23
  723. package/lib/module/features/network/NetworkFeature.js.map +1 -1
  724. package/lib/module/features/network/index.js +5 -5
  725. package/lib/module/features/network/index.js.map +1 -1
  726. package/lib/module/features/ota/OtaEventEmitter.js +21 -21
  727. package/lib/module/features/ota/OtaEventEmitter.js.map +1 -1
  728. package/lib/module/features/ota/OtaOrchestrator.js +536 -41
  729. package/lib/module/features/ota/OtaOrchestrator.js.map +1 -1
  730. package/lib/module/features/ota/OtaTypes.js.map +1 -1
  731. package/lib/module/features/ota/environment.js +165 -0
  732. package/lib/module/features/ota/environment.js.map +1 -0
  733. package/lib/module/features/ota/retry.js +87 -0
  734. package/lib/module/features/ota/retry.js.map +1 -0
  735. package/lib/module/features/ota/signature.js +109 -0
  736. package/lib/module/features/ota/signature.js.map +1 -0
  737. package/lib/module/features/ota/useOtaUpdate.js +15 -15
  738. package/lib/module/features/ota/useOtaUpdate.js.map +1 -1
  739. package/lib/module/features/performance/PerformanceFeature.js +26 -26
  740. package/lib/module/features/performance/PerformanceFeature.js.map +1 -1
  741. package/lib/module/features/performance/collectors/AppLaunchCollector.js +13 -13
  742. package/lib/module/features/performance/collectors/AppLaunchCollector.js.map +1 -1
  743. package/lib/module/features/performance/collectors/AutoScreenLoadCollector.js +32 -32
  744. package/lib/module/features/performance/collectors/AutoScreenLoadCollector.js.map +1 -1
  745. package/lib/module/features/performance/collectors/CustomTraceCollector.js +13 -13
  746. package/lib/module/features/performance/collectors/CustomTraceCollector.js.map +1 -1
  747. package/lib/module/features/performance/collectors/FrameMetricsCollector.js +11 -11
  748. package/lib/module/features/performance/collectors/FrameMetricsCollector.js.map +1 -1
  749. package/lib/module/features/performance/collectors/JsStallCollector.js +12 -12
  750. package/lib/module/features/performance/collectors/JsStallCollector.js.map +1 -1
  751. package/lib/module/features/performance/collectors/NetworkPerfCollector.js +10 -10
  752. package/lib/module/features/performance/collectors/NetworkPerfCollector.js.map +1 -1
  753. package/lib/module/features/performance/collectors/ScreenLoadCollector.js +11 -11
  754. package/lib/module/features/performance/collectors/ScreenLoadCollector.js.map +1 -1
  755. package/lib/module/features/performance/collectors/UiHangCollector.js +5 -5
  756. package/lib/module/features/performance/collectors/UiHangCollector.js.map +1 -1
  757. package/lib/module/features/performance/config.js +11 -11
  758. package/lib/module/features/performance/config.js.map +1 -1
  759. package/lib/module/features/performance/getNativePerformanceModule.js +11 -11
  760. package/lib/module/features/performance/getNativePerformanceModule.js.map +1 -1
  761. package/lib/module/features/performance/index.js +2 -2
  762. package/lib/module/features/performance/index.js.map +1 -1
  763. package/lib/module/features/performance/metrics/MetricsEngine.js +13 -13
  764. package/lib/module/features/performance/metrics/MetricsEngine.js.map +1 -1
  765. package/lib/module/features/performance/models.js +8 -8
  766. package/lib/module/features/performance/models.js.map +1 -1
  767. package/lib/module/features/performance/transport/PerformanceTransport.js +6 -6
  768. package/lib/module/features/performance/transport/PerformanceTransport.js.map +1 -1
  769. package/lib/module/features/profiler/ProfilerFeature.js +53 -53
  770. package/lib/module/features/profiler/ProfilerFeature.js.map +1 -1
  771. package/lib/module/features/profiler/config.js +15 -15
  772. package/lib/module/features/profiler/config.js.map +1 -1
  773. package/lib/module/features/profiler/contracts.js +22 -22
  774. package/lib/module/features/profiler/contracts.js.map +1 -1
  775. package/lib/module/features/profiler/index.js +4 -4
  776. package/lib/module/features/profiler/index.js.map +1 -1
  777. package/lib/module/features/profiler/models.js +44 -44
  778. package/lib/module/features/profiler/models.js.map +1 -1
  779. package/lib/module/features/profiler/transport/ProfilerTransport.js +9 -9
  780. package/lib/module/features/profiler/transport/ProfilerTransport.js.map +1 -1
  781. package/lib/module/features/replay/bridge/adapters/bridgeAdapter.js +17 -17
  782. package/lib/module/features/replay/bridge/adapters/bridgeAdapter.js.map +1 -1
  783. package/lib/module/features/replay/bridge/eventEmitter.js +8 -8
  784. package/lib/module/features/replay/bridge/eventEmitter.js.map +1 -1
  785. package/lib/module/features/replay/bridge/nativeModule.js +20 -20
  786. package/lib/module/features/replay/bridge/nativeModule.js.map +1 -1
  787. package/lib/module/features/replay/core/clock/clock.js +6 -6
  788. package/lib/module/features/replay/core/clock/clock.js.map +1 -1
  789. package/lib/module/features/replay/core/config/defaults.js +2 -2
  790. package/lib/module/features/replay/core/config/defaults.js.map +1 -1
  791. package/lib/module/features/replay/core/config/validator.js +5 -5
  792. package/lib/module/features/replay/core/config/validator.js.map +1 -1
  793. package/lib/module/features/replay/core/env/environmentDetector.js +10 -10
  794. package/lib/module/features/replay/core/env/environmentDetector.js.map +1 -1
  795. package/lib/module/features/replay/core/errors/safeCall.js +4 -4
  796. package/lib/module/features/replay/core/errors/safeCall.js.map +1 -1
  797. package/lib/module/features/replay/core/ids/sessionId.js +5 -5
  798. package/lib/module/features/replay/core/ids/sessionId.js.map +1 -1
  799. package/lib/module/features/replay/core/logger/logger.js +5 -5
  800. package/lib/module/features/replay/core/logger/logger.js.map +1 -1
  801. package/lib/module/features/replay/core/privacy/privacyTypes.js +4 -4
  802. package/lib/module/features/replay/core/privacy/privacyTypes.js.map +1 -1
  803. package/lib/module/features/replay/core/queue/boundedQueue.js +5 -5
  804. package/lib/module/features/replay/core/queue/boundedQueue.js.map +1 -1
  805. package/lib/module/features/replay/integrations/alert/alertInstrumentation.js +59 -59
  806. package/lib/module/features/replay/integrations/alert/alertInstrumentation.js.map +1 -1
  807. package/lib/module/features/replay/integrations/logs/consoleIntegration.js +19 -19
  808. package/lib/module/features/replay/integrations/logs/consoleIntegration.js.map +1 -1
  809. package/lib/module/features/replay/integrations/network/networkAdapter.js +30 -30
  810. package/lib/module/features/replay/integrations/network/networkAdapter.js.map +1 -1
  811. package/lib/module/features/replay/integrations/react-navigation/navigationIntegration.js +19 -19
  812. package/lib/module/features/replay/integrations/react-navigation/navigationIntegration.js.map +1 -1
  813. package/lib/module/features/replay/integrations/touch/ReplayRoot.js +16 -16
  814. package/lib/module/features/replay/integrations/touch/ReplayRoot.js.map +1 -1
  815. package/lib/module/features/replay/pipeline/batching/batchManager.js +5 -5
  816. package/lib/module/features/replay/pipeline/batching/batchManager.js.map +1 -1
  817. package/lib/module/features/replay/pipeline/envelope/envelopeBuilder.js +5 -5
  818. package/lib/module/features/replay/pipeline/envelope/envelopeBuilder.js.map +1 -1
  819. package/lib/module/features/replay/pipeline/retry/retryPolicy.js +4 -4
  820. package/lib/module/features/replay/pipeline/retry/retryPolicy.js.map +1 -1
  821. package/lib/module/features/replay/pipeline/transport/transportTypes.js +7 -7
  822. package/lib/module/features/replay/pipeline/transport/transportTypes.js.map +1 -1
  823. package/lib/module/features/replay/public/api.js +21 -21
  824. package/lib/module/features/replay/public/api.js.map +1 -1
  825. package/lib/module/features/replay/public/enums.js +5 -5
  826. package/lib/module/features/replay/public/enums.js.map +1 -1
  827. package/lib/module/features/replay/public/types.js.map +1 -1
  828. package/lib/module/features/replay/replay/breadcrumbs/breadcrumbCollector.js +5 -5
  829. package/lib/module/features/replay/replay/breadcrumbs/breadcrumbCollector.js.map +1 -1
  830. package/lib/module/features/replay/replay/frames/frameModels.js +4 -4
  831. package/lib/module/features/replay/replay/frames/frameModels.js.map +1 -1
  832. package/lib/module/features/replay/replay/session/sessionOrchestrator.js +10 -10
  833. package/lib/module/features/replay/replay/session/sessionOrchestrator.js.map +1 -1
  834. package/lib/module/features/replay/replay/timeline/timelineModels.js +4 -4
  835. package/lib/module/features/replay/replay/timeline/timelineModels.js.map +1 -1
  836. package/lib/module/features/replay/transport/BackendReplayTransport.js +13 -13
  837. package/lib/module/features/replay/transport/BackendReplayTransport.js.map +1 -1
  838. package/lib/module/features/replay/transport/CompositeReplayTransport.js +8 -8
  839. package/lib/module/features/replay/transport/CompositeReplayTransport.js.map +1 -1
  840. package/lib/module/features/replay/transport/DesktopReplayTransport.js +14 -14
  841. package/lib/module/features/replay/transport/DesktopReplayTransport.js.map +1 -1
  842. package/lib/module/features/replay/transport/ReplayTransport.js.map +1 -1
  843. package/lib/module/features/session/BackendSessionAdapter.js +357 -153
  844. package/lib/module/features/session/BackendSessionAdapter.js.map +1 -1
  845. package/lib/module/features/session/DesktopSessionTransport.js +14 -14
  846. package/lib/module/features/session/DesktopSessionTransport.js.map +1 -1
  847. package/lib/module/features/session/JourneyEventPipeline.js +19 -19
  848. package/lib/module/features/session/JourneyEventPipeline.js.map +1 -1
  849. package/lib/module/features/session/ReplayCaptureManager.js +123 -123
  850. package/lib/module/features/session/ReplayCaptureManager.js.map +1 -1
  851. package/lib/module/features/session/ScrollTracker.js +17 -17
  852. package/lib/module/features/session/ScrollTracker.js.map +1 -1
  853. package/lib/module/features/session/SessionManager.js +143 -143
  854. package/lib/module/features/session/SessionManager.js.map +1 -1
  855. package/lib/module/features/session/SyncDecisionEngine.js +23 -23
  856. package/lib/module/features/session/SyncDecisionEngine.js.map +1 -1
  857. package/lib/module/features/session/index.js +5 -5
  858. package/lib/module/features/session/index.js.map +1 -1
  859. package/lib/module/features/session/nativeCapture.js +5 -5
  860. package/lib/module/features/session/nativeCapture.js.map +1 -1
  861. package/lib/module/features/session/outboxFrameCapture.js +15 -15
  862. package/lib/module/features/session/outboxFrameCapture.js.map +1 -1
  863. package/lib/module/features/session/sessionTypes.js +44 -44
  864. package/lib/module/features/session/sessionTypes.js.map +1 -1
  865. package/lib/module/features/skan/skanBridge.js +11 -11
  866. package/lib/module/features/skan/skanBridge.js.map +1 -1
  867. package/lib/module/features/skan/skanConversionManager.js +23 -23
  868. package/lib/module/features/skan/skanConversionManager.js.map +1 -1
  869. package/lib/module/index.js +16 -10
  870. package/lib/module/index.js.map +1 -1
  871. package/lib/module/integrations/fetch/fetchInterceptor.js +21 -21
  872. package/lib/module/integrations/fetch/fetchInterceptor.js.map +1 -1
  873. package/lib/module/integrations/navigation/screenTracker.js.map +1 -1
  874. package/lib/module/integrations/network/bodyCapture.js +69 -69
  875. package/lib/module/integrations/network/bodyCapture.js.map +1 -1
  876. package/lib/module/integrations/xhr/xhrInterceptor.js +24 -24
  877. package/lib/module/integrations/xhr/xhrInterceptor.js.map +1 -1
  878. package/lib/module/metro/index.js +37 -37
  879. package/lib/module/metro/index.js.map +1 -1
  880. package/lib/module/metro/optionalDependencyStub.js +11 -11
  881. package/lib/module/metro/optionalDependencyStub.js.map +1 -1
  882. package/lib/module/metro/optionalModules.js +16 -16
  883. package/lib/module/metro/optionalModules.js.map +1 -1
  884. package/lib/module/pipeline/dispatcher/dispatcher.js.map +1 -1
  885. package/lib/module/pipeline/envelope/envelope.js.map +1 -1
  886. package/lib/module/pipeline/envelope/serializer.js.map +1 -1
  887. package/lib/module/pipeline/processors/dedupe.js.map +1 -1
  888. package/lib/module/pipeline/processors/enrich.js.map +1 -1
  889. package/lib/module/pipeline/processors/sampling.js.map +1 -1
  890. package/lib/module/pipeline/processors/sanitize.js.map +1 -1
  891. package/lib/module/pipeline/queue/flushQueue.js +4 -4
  892. package/lib/module/pipeline/queue/flushQueue.js.map +1 -1
  893. package/lib/module/pipeline/queue/memoryQueue.js.map +1 -1
  894. package/lib/module/pipeline/queue/persistentQueue.js +80 -80
  895. package/lib/module/pipeline/queue/persistentQueue.js.map +1 -1
  896. package/lib/module/pipeline/queue/queuePolicy.js.map +1 -1
  897. package/lib/module/pipeline/scheduler/flushScheduler.js.map +1 -1
  898. package/lib/module/pipeline/scheduler/retryPolicy.js +2 -2
  899. package/lib/module/pipeline/scheduler/retryPolicy.js.map +1 -1
  900. package/lib/module/public/ScaleBunErrorBoundary.js +70 -0
  901. package/lib/module/public/ScaleBunErrorBoundary.js.map +1 -0
  902. package/lib/module/public/ScaleBunFacade.js +274 -274
  903. package/lib/module/public/ScaleBunFacade.js.map +1 -1
  904. package/lib/module/public/ScaleBunProvider.js +3 -3
  905. package/lib/module/public/ScaleBunProvider.js.map +1 -1
  906. package/lib/module/public/typedTracker.js +36 -36
  907. package/lib/module/public/typedTracker.js.map +1 -1
  908. package/lib/module/public/types.js.map +1 -1
  909. package/lib/module/push/PushManager.js +21 -21
  910. package/lib/module/push/PushManager.js.map +1 -1
  911. package/lib/module/push/adapters/ManualAdapter.js +14 -14
  912. package/lib/module/push/adapters/ManualAdapter.js.map +1 -1
  913. package/lib/module/push/adapters/NativeBridgeAdapter.js +17 -17
  914. package/lib/module/push/adapters/NativeBridgeAdapter.js.map +1 -1
  915. package/lib/module/push/adapters/NoopAdapter.js +5 -5
  916. package/lib/module/push/adapters/NoopAdapter.js.map +1 -1
  917. package/lib/module/push/adapters/RNFirebaseMessagingAdapter.js +17 -17
  918. package/lib/module/push/adapters/RNFirebaseMessagingAdapter.js.map +1 -1
  919. package/lib/module/push/adapters/loadMessaging.js +12 -12
  920. package/lib/module/push/adapters/loadMessaging.js.map +1 -1
  921. package/lib/module/push/adapters/loadNotifee.js +12 -12
  922. package/lib/module/push/adapters/loadNotifee.js.map +1 -1
  923. package/lib/module/push/adapters/selectAdapter.js +14 -14
  924. package/lib/module/push/adapters/selectAdapter.js.map +1 -1
  925. package/lib/module/push/detect/capabilities.js +19 -19
  926. package/lib/module/push/detect/capabilities.js.map +1 -1
  927. package/lib/module/push/index.js +3 -3
  928. package/lib/module/push/index.js.map +1 -1
  929. package/lib/module/push/native/nativeNotifications.js +32 -32
  930. package/lib/module/push/native/nativeNotifications.js.map +1 -1
  931. package/lib/module/push/types.js.map +1 -1
  932. package/lib/module/specs/NativeReplaySdk.js +18 -18
  933. package/lib/module/specs/NativeReplaySdk.js.map +1 -1
  934. package/lib/module/specs/NativeScaleBunCrash.js +19 -19
  935. package/lib/module/specs/NativeScaleBunCrash.js.map +1 -1
  936. package/lib/module/specs/NativeScaleBunInstallReferrer.js +14 -14
  937. package/lib/module/specs/NativeScaleBunInstallReferrer.js.map +1 -1
  938. package/lib/module/specs/NativeScaleBunOta.js +21 -21
  939. package/lib/module/specs/NativeScaleBunOta.js.map +1 -1
  940. package/lib/module/specs/NativeScaleBunPerformance.js +15 -15
  941. package/lib/module/specs/NativeScaleBunPerformance.js.map +1 -1
  942. package/lib/module/specs/NativeScaleBunProfiler.js +16 -16
  943. package/lib/module/specs/NativeScaleBunProfiler.js.map +1 -1
  944. package/lib/module/specs/NativeScaleBunStorage.js +29 -29
  945. package/lib/module/specs/NativeScaleBunStorage.js.map +1 -1
  946. package/lib/module/storage/StorageBackend.js +83 -83
  947. package/lib/module/storage/StorageBackend.js.map +1 -1
  948. package/lib/module/storage/db/sqlite.js.map +1 -1
  949. package/lib/module/storage/files/fileStore.js.map +1 -1
  950. package/lib/module/transport/auth/sdkSession.js.map +1 -1
  951. package/lib/module/transport/backoff/exponentialJitter.js +2 -2
  952. package/lib/module/transport/backoff/exponentialJitter.js.map +1 -1
  953. package/lib/module/transport/http/endpoints.js.map +1 -1
  954. package/lib/module/transport/http/httpClient.js +3 -3
  955. package/lib/module/transport/http/httpClient.js.map +1 -1
  956. package/lib/module/transport/rateLimit/retryAfter.js.map +1 -1
  957. package/lib/module/transport/signing/requestSigner.js.map +1 -1
  958. package/lib/module/vendor/protocol/index.js +74 -74
  959. package/lib/module/vendor/protocol/index.js.map +1 -1
  960. package/lib/module/vendor/protocol/internal/validation.js +23 -23
  961. package/lib/module/vendor/protocol/internal/validation.js.map +1 -1
  962. package/lib/module/vendor/sdk-contracts/bridge.js.map +1 -1
  963. package/lib/module/vendor/sdk-contracts/config.js.map +1 -1
  964. package/lib/module/vendor/sdk-contracts/events.js.map +1 -1
  965. package/lib/module/vendor/sdk-contracts/features.js.map +1 -1
  966. package/lib/module/vendor/sdk-contracts/index.js.map +1 -1
  967. package/lib/module/vendor/sdk-contracts/platform.js.map +1 -1
  968. package/lib/module/vendor/sdk-contracts/session-boundary.js.map +1 -1
  969. package/lib/module/vendor/sdk-contracts/session.js.map +1 -1
  970. package/lib/module/vendor/vendor.manifest +10 -10
  971. package/lib/typescript/bootstrap/SDKBootstrapper.d.ts.map +1 -1
  972. package/lib/typescript/features/crash/CrashFeature.d.ts.map +1 -1
  973. package/lib/typescript/features/crash/rejectionHandler.d.ts +46 -0
  974. package/lib/typescript/features/crash/rejectionHandler.d.ts.map +1 -0
  975. package/lib/typescript/features/engage/EngagePromptProvider.d.ts.map +1 -1
  976. package/lib/typescript/features/engage/engageThrottle.d.ts +24 -4
  977. package/lib/typescript/features/engage/engageThrottle.d.ts.map +1 -1
  978. package/lib/typescript/features/engage/engageTypes.d.ts +6 -0
  979. package/lib/typescript/features/engage/engageTypes.d.ts.map +1 -1
  980. package/lib/typescript/features/navigation/AutoScreenDetector.d.ts +9 -0
  981. package/lib/typescript/features/navigation/AutoScreenDetector.d.ts.map +1 -1
  982. package/lib/typescript/features/ota/OtaOrchestrator.d.ts +67 -1
  983. package/lib/typescript/features/ota/OtaOrchestrator.d.ts.map +1 -1
  984. package/lib/typescript/features/ota/OtaTypes.d.ts +42 -0
  985. package/lib/typescript/features/ota/OtaTypes.d.ts.map +1 -1
  986. package/lib/typescript/features/ota/environment.d.ts +99 -0
  987. package/lib/typescript/features/ota/environment.d.ts.map +1 -0
  988. package/lib/typescript/features/ota/retry.d.ts +53 -0
  989. package/lib/typescript/features/ota/retry.d.ts.map +1 -0
  990. package/lib/typescript/features/ota/signature.d.ts +66 -0
  991. package/lib/typescript/features/ota/signature.d.ts.map +1 -0
  992. package/lib/typescript/features/session/BackendSessionAdapter.d.ts +93 -2
  993. package/lib/typescript/features/session/BackendSessionAdapter.d.ts.map +1 -1
  994. package/lib/typescript/index.d.ts +6 -0
  995. package/lib/typescript/index.d.ts.map +1 -1
  996. package/lib/typescript/public/ScaleBunErrorBoundary.d.ts +44 -0
  997. package/lib/typescript/public/ScaleBunErrorBoundary.d.ts.map +1 -0
  998. package/lib/typescript/specs/NativeScaleBunOta.d.ts +11 -0
  999. package/lib/typescript/specs/NativeScaleBunOta.d.ts.map +1 -1
  1000. package/package.json +12 -14
  1001. package/react-native.config.js +24 -24
  1002. package/scalebun-react-native.podspec +37 -37
  1003. package/src/analytics/EventTracker.ts +462 -462
  1004. package/src/analytics/automaticEvents.ts +105 -105
  1005. package/src/analytics/batching.ts +54 -54
  1006. package/src/analytics/eventLane.ts +26 -26
  1007. package/src/bootstrap/FeatureRegistry.ts +81 -81
  1008. package/src/bootstrap/SDKBootstrapper.ts +609 -585
  1009. package/src/bucketing/fnv1a32.ts +40 -40
  1010. package/src/compat/codepush.ts +118 -118
  1011. package/src/config/ConfigManager.ts +167 -167
  1012. package/src/config/configTypes.ts +32 -32
  1013. package/src/core/architecture.ts +39 -39
  1014. package/src/core/clock/now.ts +6 -6
  1015. package/src/core/config/schema.ts +231 -231
  1016. package/src/core/constants/endpoints.ts +9 -9
  1017. package/src/core/constants/timings.ts +23 -23
  1018. package/src/core/constants/version.ts +6 -6
  1019. package/src/core/context/user.ts +26 -26
  1020. package/src/core/contracts/IFeature.ts +53 -53
  1021. package/src/core/di/container.ts +26 -26
  1022. package/src/core/encoding/base64.ts +46 -46
  1023. package/src/core/id/deviceId.ts +51 -51
  1024. package/src/core/lifecycle/appLifecycle.ts +33 -33
  1025. package/src/core/lifecycle/crashSafe.ts +29 -29
  1026. package/src/core/logger/errorClassification.ts +108 -108
  1027. package/src/core/logger/internalLogger.ts +65 -65
  1028. package/src/crypto/hmacSha256.ts +106 -106
  1029. package/src/debug/bootstrap.ts +366 -366
  1030. package/src/debug/commands.ts +597 -597
  1031. package/src/debug/configBuilder.ts +56 -56
  1032. package/src/debug/exportBridge.ts +153 -153
  1033. package/src/debug/hostResolver.ts +34 -34
  1034. package/src/debug/index.ts +25 -25
  1035. package/src/debug/metrics.ts +29 -29
  1036. package/src/debug/perf.ts +212 -212
  1037. package/src/debug/perfWiring.ts +119 -119
  1038. package/src/debug/protocol.ts +58 -58
  1039. package/src/debug/redaction.ts +290 -290
  1040. package/src/debug/replayWiring.ts +147 -147
  1041. package/src/debug/screenTracking.ts +55 -55
  1042. package/src/debug/sessionWiring.ts +59 -59
  1043. package/src/debug/stream.ts +561 -561
  1044. package/src/debug/transport.ts +439 -439
  1045. package/src/features/crash/CrashFeature.ts +71 -52
  1046. package/src/features/crash/CrashReporter.ts +140 -140
  1047. package/src/features/crash/NativeCrashFeature.ts +42 -42
  1048. package/src/features/crash/capture.ts +21 -21
  1049. package/src/features/crash/globalHandler.ts +39 -39
  1050. package/src/features/crash/index.ts +8 -8
  1051. package/src/features/crash/nativeCrashBridge.ts +132 -132
  1052. package/src/features/crash/rejectionHandler.ts +134 -0
  1053. package/src/features/engage/EngageAnchor.tsx +159 -159
  1054. package/src/features/engage/EngageArchetypeRenderers.tsx +3716 -3716
  1055. package/src/features/engage/EngageInAppView.tsx +2678 -2678
  1056. package/src/features/engage/EngageInlinePlacement.tsx +169 -169
  1057. package/src/features/engage/EngagePromptProvider.tsx +1272 -1270
  1058. package/src/features/engage/EngagePromptView.tsx +1364 -1364
  1059. package/src/features/engage/EngageTransport.ts +668 -668
  1060. package/src/features/engage/EngageVariantContent.tsx +1483 -1483
  1061. package/src/features/engage/__test-support__/reactNativeStub.js +40 -40
  1062. package/src/features/engage/attachmentCapture.ts +45 -45
  1063. package/src/features/engage/captureVoiceAttachment.ts +81 -81
  1064. package/src/features/engage/engageCoachmarkTour.ts +120 -120
  1065. package/src/features/engage/engageGameLogic.ts +347 -347
  1066. package/src/features/engage/engageMediaSizing.ts +76 -76
  1067. package/src/features/engage/engageMultiStepSheet.ts +53 -53
  1068. package/src/features/engage/engageOutcome.ts +157 -157
  1069. package/src/features/engage/engagePushTokenBridge.ts +84 -84
  1070. package/src/features/engage/engageShakeBridge.ts +67 -67
  1071. package/src/features/engage/engageSignals.ts +40 -40
  1072. package/src/features/engage/engageStoreReviewBridge.ts +48 -48
  1073. package/src/features/engage/engageTestSeenStore.ts +95 -95
  1074. package/src/features/engage/engageThrottle.ts +478 -440
  1075. package/src/features/engage/engageTriggerEngine.ts +335 -335
  1076. package/src/features/engage/engageTypes.ts +697 -691
  1077. package/src/features/engage/engageVariantResolver.ts +364 -364
  1078. package/src/features/engage/engageWindowInsets.ts +108 -108
  1079. package/src/features/engage/gestureTriggerDetector.ts +83 -83
  1080. package/src/features/engage/transcription/TranscriptionProvider.ts +68 -68
  1081. package/src/features/install-referrer/installReferrer.ts +112 -112
  1082. package/src/features/journey/ScaleBunDebugRoot.tsx +726 -726
  1083. package/src/features/journey/ScaleBunFlatList.tsx +39 -39
  1084. package/src/features/journey/ScaleBunImpression.tsx +109 -109
  1085. package/src/features/journey/ScaleBunScrollView.tsx +72 -72
  1086. package/src/features/journey/ScaleBunSectionList.tsx +39 -39
  1087. package/src/features/journey/calibrationContext.ts +53 -53
  1088. package/src/features/journey/gestureBuffer.ts +59 -59
  1089. package/src/features/journey/gestureDetector.ts +162 -162
  1090. package/src/features/journey/impression.ts +92 -92
  1091. package/src/features/journey/journeyManager.ts +466 -466
  1092. package/src/features/journey/journeyTypes.ts +215 -215
  1093. package/src/features/journey/navDetector.ts +149 -149
  1094. package/src/features/journey/screenshotHelper.ts +137 -137
  1095. package/src/features/journey/targetRegistry.ts +43 -43
  1096. package/src/features/journey/touchTarget.ts +128 -128
  1097. package/src/features/navigation/AutoScreenDetector.ts +503 -448
  1098. package/src/features/network/NetworkFeature.ts +144 -144
  1099. package/src/features/network/index.ts +31 -31
  1100. package/src/features/ota/OtaEventEmitter.ts +128 -128
  1101. package/src/features/ota/OtaOrchestrator.ts +894 -323
  1102. package/src/features/ota/OtaTypes.ts +118 -62
  1103. package/src/features/ota/environment.ts +199 -0
  1104. package/src/features/ota/retry.ts +123 -0
  1105. package/src/features/ota/signature.ts +123 -0
  1106. package/src/features/ota/useOtaUpdate.ts +134 -134
  1107. package/src/features/performance/PerformanceFeature.ts +584 -584
  1108. package/src/features/performance/collectors/AppLaunchCollector.ts +117 -117
  1109. package/src/features/performance/collectors/AutoScreenLoadCollector.ts +258 -258
  1110. package/src/features/performance/collectors/CustomTraceCollector.ts +116 -116
  1111. package/src/features/performance/collectors/FrameMetricsCollector.ts +119 -119
  1112. package/src/features/performance/collectors/JsStallCollector.ts +165 -165
  1113. package/src/features/performance/collectors/NetworkPerfCollector.ts +69 -69
  1114. package/src/features/performance/collectors/ScreenLoadCollector.ts +95 -95
  1115. package/src/features/performance/collectors/UiHangCollector.ts +98 -98
  1116. package/src/features/performance/config.ts +136 -136
  1117. package/src/features/performance/getNativePerformanceModule.ts +38 -38
  1118. package/src/features/performance/index.ts +28 -28
  1119. package/src/features/performance/metrics/MetricsEngine.ts +152 -152
  1120. package/src/features/performance/models.ts +235 -235
  1121. package/src/features/performance/transport/PerformanceTransport.ts +143 -143
  1122. package/src/features/profiler/ProfilerFeature.ts +661 -661
  1123. package/src/features/profiler/config.ts +230 -230
  1124. package/src/features/profiler/contracts.ts +176 -176
  1125. package/src/features/profiler/index.ts +45 -45
  1126. package/src/features/profiler/models.ts +430 -430
  1127. package/src/features/profiler/transport/ProfilerTransport.ts +93 -93
  1128. package/src/features/replay/bridge/adapters/bridgeAdapter.ts +230 -230
  1129. package/src/features/replay/bridge/eventEmitter.ts +176 -176
  1130. package/src/features/replay/bridge/nativeModule.ts +241 -241
  1131. package/src/features/replay/core/clock/clock.ts +38 -38
  1132. package/src/features/replay/core/config/defaults.ts +66 -66
  1133. package/src/features/replay/core/config/validator.ts +113 -113
  1134. package/src/features/replay/core/env/environmentDetector.ts +21 -21
  1135. package/src/features/replay/core/errors/safeCall.ts +34 -34
  1136. package/src/features/replay/core/ids/sessionId.ts +44 -44
  1137. package/src/features/replay/core/logger/logger.ts +40 -40
  1138. package/src/features/replay/core/privacy/privacyTypes.ts +41 -41
  1139. package/src/features/replay/core/queue/boundedQueue.ts +71 -71
  1140. package/src/features/replay/integrations/alert/alertInstrumentation.ts +277 -277
  1141. package/src/features/replay/integrations/logs/consoleIntegration.ts +116 -116
  1142. package/src/features/replay/integrations/network/networkAdapter.ts +128 -128
  1143. package/src/features/replay/integrations/react-navigation/navigationIntegration.ts +89 -89
  1144. package/src/features/replay/integrations/touch/ReplayRoot.tsx +114 -114
  1145. package/src/features/replay/pipeline/batching/batchManager.ts +133 -133
  1146. package/src/features/replay/pipeline/envelope/envelopeBuilder.ts +66 -66
  1147. package/src/features/replay/pipeline/retry/retryPolicy.ts +62 -62
  1148. package/src/features/replay/pipeline/transport/transportTypes.ts +85 -85
  1149. package/src/features/replay/public/api.ts +364 -364
  1150. package/src/features/replay/public/enums.ts +78 -78
  1151. package/src/features/replay/public/types.ts +297 -297
  1152. package/src/features/replay/replay/breadcrumbs/breadcrumbCollector.ts +115 -115
  1153. package/src/features/replay/replay/frames/frameModels.ts +45 -45
  1154. package/src/features/replay/replay/session/sessionOrchestrator.ts +286 -286
  1155. package/src/features/replay/replay/timeline/timelineModels.ts +129 -129
  1156. package/src/features/replay/transport/BackendReplayTransport.ts +215 -215
  1157. package/src/features/replay/transport/CompositeReplayTransport.ts +82 -82
  1158. package/src/features/replay/transport/DesktopReplayTransport.ts +140 -140
  1159. package/src/features/replay/transport/ReplayTransport.ts +84 -84
  1160. package/src/features/session/BackendSessionAdapter.ts +1441 -1233
  1161. package/src/features/session/DesktopSessionTransport.ts +128 -128
  1162. package/src/features/session/JourneyEventPipeline.ts +273 -273
  1163. package/src/features/session/ReplayCaptureManager.ts +946 -946
  1164. package/src/features/session/ScrollTracker.ts +166 -166
  1165. package/src/features/session/SessionManager.ts +1209 -1209
  1166. package/src/features/session/SyncDecisionEngine.ts +117 -117
  1167. package/src/features/session/index.ts +88 -88
  1168. package/src/features/session/nativeCapture.ts +38 -38
  1169. package/src/features/session/outboxFrameCapture.ts +74 -74
  1170. package/src/features/session/sessionTypes.ts +491 -491
  1171. package/src/features/skan/skanBridge.ts +61 -61
  1172. package/src/features/skan/skanConversionManager.ts +173 -173
  1173. package/src/index.ts +197 -191
  1174. package/src/integrations/fetch/fetchInterceptor.ts +182 -182
  1175. package/src/integrations/network/bodyCapture.ts +328 -328
  1176. package/src/integrations/xhr/xhrInterceptor.ts +231 -231
  1177. package/src/metro/index.ts +164 -164
  1178. package/src/metro/optionalDependencyStub.ts +13 -13
  1179. package/src/metro/optionalModules.ts +27 -27
  1180. package/src/pipeline/dispatcher/dispatcher.ts +22 -22
  1181. package/src/pipeline/envelope/envelope.ts +31 -31
  1182. package/src/pipeline/envelope/serializer.ts +14 -14
  1183. package/src/pipeline/processors/enrich.ts +11 -11
  1184. package/src/pipeline/processors/sanitize.ts +23 -23
  1185. package/src/pipeline/queue/flushQueue.ts +144 -144
  1186. package/src/pipeline/queue/memoryQueue.ts +31 -31
  1187. package/src/pipeline/queue/persistentQueue.ts +414 -414
  1188. package/src/pipeline/scheduler/flushScheduler.ts +47 -47
  1189. package/src/pipeline/scheduler/retryPolicy.ts +8 -8
  1190. package/src/public/ScaleBunErrorBoundary.tsx +79 -0
  1191. package/src/public/ScaleBunFacade.ts +1479 -1479
  1192. package/src/public/ScaleBunProvider.tsx +91 -91
  1193. package/src/public/typedTracker.ts +123 -123
  1194. package/src/public/types.ts +312 -312
  1195. package/src/push/PushManager.ts +318 -318
  1196. package/src/push/adapters/ManualAdapter.ts +100 -100
  1197. package/src/push/adapters/NativeBridgeAdapter.ts +142 -142
  1198. package/src/push/adapters/NoopAdapter.ts +46 -46
  1199. package/src/push/adapters/RNFirebaseMessagingAdapter.ts +271 -271
  1200. package/src/push/adapters/loadMessaging.ts +24 -24
  1201. package/src/push/adapters/loadNotifee.ts +29 -29
  1202. package/src/push/adapters/selectAdapter.ts +176 -176
  1203. package/src/push/detect/capabilities.ts +124 -124
  1204. package/src/push/index.ts +22 -22
  1205. package/src/push/native/nativeNotifications.ts +216 -216
  1206. package/src/push/types.ts +159 -159
  1207. package/src/specs/NativeReplaySdk.ts +99 -99
  1208. package/src/specs/NativeScaleBunCrash.ts +36 -36
  1209. package/src/specs/NativeScaleBunInstallReferrer.ts +29 -29
  1210. package/src/specs/NativeScaleBunOta.ts +97 -85
  1211. package/src/specs/NativeScaleBunPerformance.ts +34 -34
  1212. package/src/specs/NativeScaleBunProfiler.ts +41 -41
  1213. package/src/specs/NativeScaleBunStorage.ts +59 -59
  1214. package/src/storage/StorageBackend.ts +272 -272
  1215. package/src/transport/auth/sdkSession.ts +27 -27
  1216. package/src/transport/backoff/exponentialJitter.ts +9 -9
  1217. package/src/transport/http/endpoints.ts +33 -33
  1218. package/src/transport/http/httpClient.ts +73 -73
  1219. package/src/vendor/protocol/index.ts +391 -391
  1220. package/src/vendor/protocol/internal/validation.ts +497 -497
  1221. package/src/vendor/sdk-contracts/bridge.ts +162 -162
  1222. package/src/vendor/sdk-contracts/config.ts +192 -192
  1223. package/src/vendor/sdk-contracts/events.ts +50 -50
  1224. package/src/vendor/sdk-contracts/features.ts +42 -42
  1225. package/src/vendor/sdk-contracts/index.ts +98 -98
  1226. package/src/vendor/sdk-contracts/platform.ts +42 -42
  1227. package/src/vendor/sdk-contracts/session-boundary.ts +55 -55
  1228. package/src/vendor/sdk-contracts/session.ts +225 -225
  1229. package/src/vendor/vendor.manifest +10 -10
  1230. package/android/build/generated/source/buildConfig/debug/com/scalebun/sdk/BuildConfig.java +0 -12
  1231. package/android/build/generated/source/codegen/java/com/scalebun/spec/NativeReplaySdkSpec.java +0 -208
  1232. package/android/build/generated/source/codegen/java/com/scalebun/spec/NativeScaleBunCrashSpec.java +0 -46
  1233. package/android/build/generated/source/codegen/java/com/scalebun/spec/NativeScaleBunInstallReferrerSpec.java +0 -38
  1234. package/android/build/generated/source/codegen/java/com/scalebun/spec/NativeScaleBunOtaSpec.java +0 -63
  1235. package/android/build/generated/source/codegen/java/com/scalebun/spec/NativeScaleBunPerformanceSpec.java +0 -70
  1236. package/android/build/generated/source/codegen/java/com/scalebun/spec/NativeScaleBunProfilerSpec.java +0 -96
  1237. package/android/build/generated/source/codegen/java/com/scalebun/spec/NativeScaleBunStorageSpec.java +0 -50
  1238. package/android/build/generated/source/codegen/jni/CMakeLists.txt +0 -28
  1239. package/android/build/generated/source/codegen/jni/ScaleBunSpec-generated.cpp +0 -554
  1240. package/android/build/generated/source/codegen/jni/ScaleBunSpec.h +0 -79
  1241. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/ComponentDescriptors.cpp +0 -22
  1242. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/ComponentDescriptors.h +0 -24
  1243. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/EventEmitters.cpp +0 -16
  1244. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/EventEmitters.h +0 -17
  1245. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/Props.cpp +0 -19
  1246. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/Props.h +0 -18
  1247. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/ScaleBunSpecJSI-generated.cpp +0 -595
  1248. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/ScaleBunSpecJSI.h +0 -1070
  1249. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/ShadowNodes.cpp +0 -17
  1250. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/ShadowNodes.h +0 -23
  1251. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/States.cpp +0 -16
  1252. package/android/build/generated/source/codegen/jni/react/renderer/components/ScaleBunSpec/States.h +0 -20
  1253. package/android/build/generated/source/codegen/schema.json +0 -1
  1254. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/AndroidManifest.xml +0 -20
  1255. package/android/build/intermediates/aapt_friendly_merged_manifests/debug/processDebugManifest/aapt/output-metadata.json +0 -18
  1256. package/android/build/intermediates/aar_metadata/debug/writeDebugAarMetadata/aar-metadata.properties +0 -6
  1257. package/android/build/intermediates/annotation_processor_list/debug/javaPreCompileDebug/annotationProcessors.json +0 -1
  1258. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  1259. package/android/build/intermediates/compile_r_class_jar/debug/generateDebugRFile/R.jar +0 -0
  1260. package/android/build/intermediates/compile_symbol_list/debug/generateDebugRFile/R.txt +0 -0
  1261. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +0 -1
  1262. package/android/build/intermediates/incremental/debug/packageDebugResources/merger.xml +0 -2
  1263. package/android/build/intermediates/incremental/mergeDebugAssets/merger.xml +0 -2
  1264. package/android/build/intermediates/incremental/mergeDebugJniLibFolders/merger.xml +0 -2
  1265. package/android/build/intermediates/incremental/mergeDebugShaders/merger.xml +0 -2
  1266. package/android/build/intermediates/java_res/debug/processDebugJavaRes/out/META-INF/scalebun_react-native_debug.kotlin_module +0 -0
  1267. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/sdk/BuildConfig.class +0 -0
  1268. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/spec/NativeReplaySdkSpec.class +0 -0
  1269. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/spec/NativeScaleBunCrashSpec.class +0 -0
  1270. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/spec/NativeScaleBunInstallReferrerSpec.class +0 -0
  1271. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/spec/NativeScaleBunOtaSpec.class +0 -0
  1272. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/spec/NativeScaleBunPerformanceSpec.class +0 -0
  1273. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/spec/NativeScaleBunProfilerSpec.class +0 -0
  1274. package/android/build/intermediates/javac/debug/compileDebugJavaWithJavac/classes/com/scalebun/spec/NativeScaleBunStorageSpec.class +0 -0
  1275. package/android/build/intermediates/local_only_symbol_list/debug/parseDebugLocalResources/R-def.txt +0 -2
  1276. package/android/build/intermediates/manifest_merge_blame_file/debug/processDebugManifest/manifest-merger-blame-debug-report.txt +0 -24
  1277. package/android/build/intermediates/merged_manifest/debug/processDebugManifest/AndroidManifest.xml +0 -20
  1278. package/android/build/intermediates/navigation_json/debug/extractDeepLinksDebug/navigation.json +0 -1
  1279. package/android/build/intermediates/nested_resources_validation_report/debug/generateDebugResources/nestedResourcesValidationReport.txt +0 -1
  1280. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/META-INF/scalebun_react-native_debug.kotlin_module +0 -0
  1281. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/crash/CrashStorage.class +0 -0
  1282. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/crash/NativeCrashHandler$Companion.class +0 -0
  1283. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/crash/NativeCrashHandler.class +0 -0
  1284. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/ANRWatchdog$HangInfo.class +0 -0
  1285. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/ANRWatchdog.class +0 -0
  1286. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/AppStartCollector$AppStartInfo.class +0 -0
  1287. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/AppStartCollector$Breakdown.class +0 -0
  1288. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/AppStartCollector$start$1.class +0 -0
  1289. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/AppStartCollector.class +0 -0
  1290. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/FrameMetricsCollector$Companion.class +0 -0
  1291. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/FrameMetricsCollector$FrameMetricsSnapshot.class +0 -0
  1292. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/FrameMetricsCollector$start$1.class +0 -0
  1293. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/FrameMetricsCollector$startChoreographerFallback$1.class +0 -0
  1294. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/FrameMetricsCollector.class +0 -0
  1295. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/PerformanceCore$Listener.class +0 -0
  1296. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/core/performance/PerformanceCore.class +0 -0
  1297. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/ProfilerModule$Companion.class +0 -0
  1298. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/ProfilerModule.class +0 -0
  1299. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/ProfilerPackage.class +0 -0
  1300. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/ProfilerSpec.class +0 -0
  1301. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/CpuCollector.class +0 -0
  1302. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/IncidentDetector.class +0 -0
  1303. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/MemoryCollector.class +0 -0
  1304. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/RenderCollector$frameCallback$1.class +0 -0
  1305. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/RenderCollector.class +0 -0
  1306. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/SamplerScheduler.class +0 -0
  1307. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/SamplerSchedulerKt.class +0 -0
  1308. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/ThreadCollector$WhenMappings.class +0 -0
  1309. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/profiler/collectors/ThreadCollector.class +0 -0
  1310. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/ReplaySdkModule$Companion.class +0 -0
  1311. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/ReplaySdkModule$registerConnectivity$cb$1.class +0 -0
  1312. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/ReplaySdkModule.class +0 -0
  1313. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/ReplaySdkPackage.class +0 -0
  1314. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/ReplaySdkSpec.class +0 -0
  1315. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/CaptureReason$Companion.class +0 -0
  1316. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/CaptureReason.class +0 -0
  1317. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/FrameCaptureManager$startFrequencyTimer$1.class +0 -0
  1318. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/FrameCaptureManager.class +0 -0
  1319. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/FrameCaptureScheduler$Companion.class +0 -0
  1320. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/FrameCaptureScheduler$FrameRequest.class +0 -0
  1321. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/FrameCaptureScheduler.class +0 -0
  1322. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/UiStabilityDetector$Companion.class +0 -0
  1323. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/UiStabilityDetector$SettleWatch.class +0 -0
  1324. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/UiStabilityDetector$StabilityWatch.class +0 -0
  1325. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/capture/UiStabilityDetector.class +0 -0
  1326. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/CaptureMode$Companion.class +0 -0
  1327. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/CaptureMode.class +0 -0
  1328. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/ReplayConfig$Companion.class +0 -0
  1329. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/ReplayConfig.class +0 -0
  1330. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/ReplayLogger.class +0 -0
  1331. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/ScreenshotQuality$Companion.class +0 -0
  1332. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/ScreenshotQuality.class +0 -0
  1333. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/SessionIdGenerator.class +0 -0
  1334. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/core/SessionState.class +0 -0
  1335. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/models/ReplayFrame.class +0 -0
  1336. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/models/ReplaySession.class +0 -0
  1337. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/models/TimelineEvent.class +0 -0
  1338. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/NativeOutbox$Companion.class +0 -0
  1339. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/NativeOutbox$enforceLimits$lambda$37$$inlined$sortedBy$1.class +0 -0
  1340. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/NativeOutbox.class +0 -0
  1341. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/OutboxUploader$NetResult$NetworkError.class +0 -0
  1342. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/OutboxUploader$NetResult$Response.class +0 -0
  1343. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/OutboxUploader$NetResult.class +0 -0
  1344. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/OutboxUploader$Outcome.class +0 -0
  1345. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/OutboxUploader$WhenMappings.class +0 -0
  1346. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/outbox/OutboxUploader.class +0 -0
  1347. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/privacy/PrivacyMaskProcessor.class +0 -0
  1348. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/session/SessionManager.class +0 -0
  1349. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/storage/ReplayStorage$enforceStorageLimit$$inlined$sortedBy$1.class +0 -0
  1350. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/storage/ReplayStorage.class +0 -0
  1351. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/timeline/TimelineCollector.class +0 -0
  1352. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/tracking/DialogTouchObserver$start$runnable$1.class +0 -0
  1353. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/tracking/DialogTouchObserver.class +0 -0
  1354. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/tracking/InteractionTracker.class +0 -0
  1355. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/tracking/NativeTouchInterceptor.class +0 -0
  1356. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/tracking/ScreenTracker.class +0 -0
  1357. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/transport/ReplayTransport$UploadResult.class +0 -0
  1358. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/transport/ReplayTransport$upload$2.class +0 -0
  1359. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/transport/ReplayTransport.class +0 -0
  1360. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/voice/VoiceRecorder$Companion.class +0 -0
  1361. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/voice/VoiceRecorder$Result.class +0 -0
  1362. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/voice/VoiceRecorder.class +0 -0
  1363. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/voice/VoiceTranscriber$TranscriptResult.class +0 -0
  1364. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/voice/VoiceTranscriber$listener$1.class +0 -0
  1365. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/replaysdk/voice/VoiceTranscriber.class +0 -0
  1366. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/ScaleBunPackage$Companion.class +0 -0
  1367. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/ScaleBunPackage.class +0 -0
  1368. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/crash/ScaleBunCrashModule$Companion.class +0 -0
  1369. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/crash/ScaleBunCrashModule.class +0 -0
  1370. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/crash/ScaleBunCrashPackage.class +0 -0
  1371. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/crash/ScaleBunCrashSpec.class +0 -0
  1372. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/engage/ScaleBunEngageModule$Companion.class +0 -0
  1373. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/engage/ScaleBunEngageModule$WindowInsetEdges.class +0 -0
  1374. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/engage/ScaleBunEngageModule$shakeListener$1.class +0 -0
  1375. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/engage/ScaleBunEngageModule.class +0 -0
  1376. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/engage/ScaleBunEngagePackage.class +0 -0
  1377. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/engage/ScaleBunNotificationPresenter.class +0 -0
  1378. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/ota/ScaleBunOtaModule$Companion.class +0 -0
  1379. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/ota/ScaleBunOtaModule.class +0 -0
  1380. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/ota/ScaleBunOtaSpec.class +0 -0
  1381. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/ota/SlotManager$Companion.class +0 -0
  1382. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/ota/SlotManager.class +0 -0
  1383. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/performance/PerformanceModule$Companion.class +0 -0
  1384. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/performance/PerformanceModule$coreListener$1.class +0 -0
  1385. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/performance/PerformanceModule.class +0 -0
  1386. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/performance/PerformanceSpec.class +0 -0
  1387. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule$Companion.class +0 -0
  1388. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule$getInstallReferrer$1.class +0 -0
  1389. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule.class +0 -0
  1390. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/referrer/ScaleBunInstallReferrerSpec.class +0 -0
  1391. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/storage/ScaleBunStorageModule$Companion.class +0 -0
  1392. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/storage/ScaleBunStorageModule.class +0 -0
  1393. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/rn/storage/ScaleBunStorageSpec.class +0 -0
  1394. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/sdk/BuildConfig.class +0 -0
  1395. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/spec/NativeReplaySdkSpec.class +0 -0
  1396. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/spec/NativeScaleBunCrashSpec.class +0 -0
  1397. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/spec/NativeScaleBunInstallReferrerSpec.class +0 -0
  1398. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/spec/NativeScaleBunOtaSpec.class +0 -0
  1399. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/spec/NativeScaleBunPerformanceSpec.class +0 -0
  1400. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/spec/NativeScaleBunProfilerSpec.class +0 -0
  1401. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/spec/NativeScaleBunStorageSpec.class +0 -0
  1402. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/storage/KvFileStore$Companion.class +0 -0
  1403. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/scalebun/storage/KvFileStore.class +0 -0
  1404. package/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar +0 -0
  1405. package/android/build/intermediates/symbol_list_with_package_name/debug/generateDebugRFile/package-aware-r.txt +0 -1
  1406. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab +0 -0
  1407. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream +0 -0
  1408. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.keystream.len +0 -0
  1409. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.len +0 -0
  1410. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at +0 -0
  1411. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i +0 -0
  1412. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab_i.len +0 -0
  1413. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab +0 -0
  1414. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream +0 -0
  1415. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.keystream.len +0 -0
  1416. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.len +0 -0
  1417. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at +0 -0
  1418. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i +0 -0
  1419. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab_i.len +0 -0
  1420. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab +0 -0
  1421. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream +0 -0
  1422. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.keystream.len +0 -0
  1423. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.len +0 -0
  1424. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at +0 -0
  1425. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i +0 -0
  1426. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab_i.len +0 -0
  1427. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
  1428. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream +0 -0
  1429. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.keystream.len +0 -0
  1430. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.len +0 -0
  1431. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
  1432. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i +0 -0
  1433. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab_i.len +0 -0
  1434. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab +0 -0
  1435. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream +0 -0
  1436. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len +0 -0
  1437. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len +0 -0
  1438. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at +0 -0
  1439. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i +0 -0
  1440. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i.len +0 -0
  1441. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab +0 -0
  1442. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream +0 -0
  1443. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.keystream.len +0 -0
  1444. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.len +0 -0
  1445. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab.values.at +0 -0
  1446. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i +0 -0
  1447. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/package-parts.tab_i.len +0 -0
  1448. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  1449. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream +0 -0
  1450. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.keystream.len +0 -0
  1451. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.len +0 -0
  1452. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values +0 -0
  1453. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  1454. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.s +0 -1
  1455. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i +0 -0
  1456. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab_i.len +0 -0
  1457. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab +0 -0
  1458. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream +0 -0
  1459. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.keystream.len +0 -0
  1460. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.len +0 -0
  1461. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at +0 -0
  1462. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i +0 -0
  1463. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab_i.len +0 -0
  1464. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab +0 -0
  1465. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream +0 -0
  1466. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.keystream.len +0 -0
  1467. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.len +0 -0
  1468. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at +0 -0
  1469. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i +0 -0
  1470. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab_i.len +0 -0
  1471. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab +0 -0
  1472. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream +0 -0
  1473. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.keystream.len +0 -0
  1474. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.len +0 -0
  1475. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at +0 -0
  1476. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i +0 -0
  1477. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab_i.len +0 -0
  1478. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +0 -2
  1479. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab +0 -0
  1480. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream +0 -0
  1481. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.keystream.len +0 -0
  1482. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.len +0 -0
  1483. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at +0 -0
  1484. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i +0 -0
  1485. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab_i.len +0 -0
  1486. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab +0 -0
  1487. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream +0 -0
  1488. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len +0 -0
  1489. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len +0 -0
  1490. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at +0 -0
  1491. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i +0 -0
  1492. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i.len +0 -0
  1493. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  1494. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  1495. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  1496. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  1497. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values +0 -0
  1498. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  1499. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.s +0 -1
  1500. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  1501. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i.len +0 -0
  1502. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  1503. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  1504. package/android/build/kotlin/compileDebugKotlin/local-state/build-history.bin +0 -0
  1505. package/android/build/outputs/logs/manifest-merger-debug-report.txt +0 -25
  1506. package/android/build/tmp/compileDebugJavaWithJavac/previous-compilation-data.bin +0 -0
  1507. package/android/build/tmp/kotlin-classes/debug/META-INF/scalebun_react-native_debug.kotlin_module +0 -0
  1508. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/crash/CrashStorage.class +0 -0
  1509. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/crash/NativeCrashHandler$Companion.class +0 -0
  1510. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/crash/NativeCrashHandler.class +0 -0
  1511. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/ANRWatchdog$HangInfo.class +0 -0
  1512. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/ANRWatchdog.class +0 -0
  1513. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/AppStartCollector$AppStartInfo.class +0 -0
  1514. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/AppStartCollector$Breakdown.class +0 -0
  1515. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/AppStartCollector$start$1.class +0 -0
  1516. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/AppStartCollector.class +0 -0
  1517. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/FrameMetricsCollector$Companion.class +0 -0
  1518. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/FrameMetricsCollector$FrameMetricsSnapshot.class +0 -0
  1519. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/FrameMetricsCollector$start$1.class +0 -0
  1520. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/FrameMetricsCollector$startChoreographerFallback$1.class +0 -0
  1521. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/FrameMetricsCollector.class +0 -0
  1522. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/PerformanceCore$Listener.class +0 -0
  1523. package/android/build/tmp/kotlin-classes/debug/com/scalebun/core/performance/PerformanceCore.class +0 -0
  1524. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/ProfilerModule$Companion.class +0 -0
  1525. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/ProfilerModule.class +0 -0
  1526. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/ProfilerPackage.class +0 -0
  1527. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/ProfilerSpec.class +0 -0
  1528. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/CpuCollector.class +0 -0
  1529. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/IncidentDetector.class +0 -0
  1530. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/MemoryCollector.class +0 -0
  1531. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/RenderCollector$frameCallback$1.class +0 -0
  1532. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/RenderCollector.class +0 -0
  1533. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/SamplerScheduler.class +0 -0
  1534. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/SamplerSchedulerKt.class +0 -0
  1535. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/ThreadCollector$WhenMappings.class +0 -0
  1536. package/android/build/tmp/kotlin-classes/debug/com/scalebun/profiler/collectors/ThreadCollector.class +0 -0
  1537. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/ReplaySdkModule$Companion.class +0 -0
  1538. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/ReplaySdkModule$registerConnectivity$cb$1.class +0 -0
  1539. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/ReplaySdkModule.class +0 -0
  1540. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/ReplaySdkPackage.class +0 -0
  1541. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/ReplaySdkSpec.class +0 -0
  1542. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/CaptureReason$Companion.class +0 -0
  1543. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/CaptureReason.class +0 -0
  1544. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/FrameCaptureManager$startFrequencyTimer$1.class +0 -0
  1545. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/FrameCaptureManager.class +0 -0
  1546. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/FrameCaptureScheduler$Companion.class +0 -0
  1547. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/FrameCaptureScheduler$FrameRequest.class +0 -0
  1548. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/FrameCaptureScheduler.class +0 -0
  1549. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/UiStabilityDetector$Companion.class +0 -0
  1550. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/UiStabilityDetector$SettleWatch.class +0 -0
  1551. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/UiStabilityDetector$StabilityWatch.class +0 -0
  1552. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/capture/UiStabilityDetector.class +0 -0
  1553. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/CaptureMode$Companion.class +0 -0
  1554. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/CaptureMode.class +0 -0
  1555. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/ReplayConfig$Companion.class +0 -0
  1556. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/ReplayConfig.class +0 -0
  1557. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/ReplayLogger.class +0 -0
  1558. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/ScreenshotQuality$Companion.class +0 -0
  1559. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/ScreenshotQuality.class +0 -0
  1560. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/SessionIdGenerator.class +0 -0
  1561. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/core/SessionState.class +0 -0
  1562. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/models/ReplayFrame.class +0 -0
  1563. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/models/ReplaySession.class +0 -0
  1564. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/models/TimelineEvent.class +0 -0
  1565. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/NativeOutbox$Companion.class +0 -0
  1566. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/NativeOutbox$enforceLimits$lambda$37$$inlined$sortedBy$1.class +0 -0
  1567. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/NativeOutbox.class +0 -0
  1568. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/OutboxUploader$NetResult$NetworkError.class +0 -0
  1569. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/OutboxUploader$NetResult$Response.class +0 -0
  1570. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/OutboxUploader$NetResult.class +0 -0
  1571. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/OutboxUploader$Outcome.class +0 -0
  1572. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/OutboxUploader$WhenMappings.class +0 -0
  1573. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/outbox/OutboxUploader.class +0 -0
  1574. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/privacy/PrivacyMaskProcessor.class +0 -0
  1575. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/session/SessionManager.class +0 -0
  1576. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/storage/ReplayStorage$enforceStorageLimit$$inlined$sortedBy$1.class +0 -0
  1577. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/storage/ReplayStorage.class +0 -0
  1578. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/timeline/TimelineCollector.class +0 -0
  1579. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/tracking/DialogTouchObserver$start$runnable$1.class +0 -0
  1580. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/tracking/DialogTouchObserver.class +0 -0
  1581. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/tracking/InteractionTracker.class +0 -0
  1582. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/tracking/NativeTouchInterceptor.class +0 -0
  1583. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/tracking/ScreenTracker.class +0 -0
  1584. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/transport/ReplayTransport$UploadResult.class +0 -0
  1585. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/transport/ReplayTransport$upload$2.class +0 -0
  1586. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/transport/ReplayTransport.class +0 -0
  1587. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/voice/VoiceRecorder$Companion.class +0 -0
  1588. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/voice/VoiceRecorder$Result.class +0 -0
  1589. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/voice/VoiceRecorder.class +0 -0
  1590. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/voice/VoiceTranscriber$TranscriptResult.class +0 -0
  1591. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/voice/VoiceTranscriber$listener$1.class +0 -0
  1592. package/android/build/tmp/kotlin-classes/debug/com/scalebun/replaysdk/voice/VoiceTranscriber.class +0 -0
  1593. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/ScaleBunPackage$Companion.class +0 -0
  1594. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/ScaleBunPackage.class +0 -0
  1595. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/crash/ScaleBunCrashModule$Companion.class +0 -0
  1596. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/crash/ScaleBunCrashModule.class +0 -0
  1597. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/crash/ScaleBunCrashPackage.class +0 -0
  1598. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/crash/ScaleBunCrashSpec.class +0 -0
  1599. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/engage/ScaleBunEngageModule$Companion.class +0 -0
  1600. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/engage/ScaleBunEngageModule$WindowInsetEdges.class +0 -0
  1601. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/engage/ScaleBunEngageModule$shakeListener$1.class +0 -0
  1602. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/engage/ScaleBunEngageModule.class +0 -0
  1603. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/engage/ScaleBunEngagePackage.class +0 -0
  1604. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/engage/ScaleBunNotificationPresenter.class +0 -0
  1605. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/ota/ScaleBunOtaModule$Companion.class +0 -0
  1606. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/ota/ScaleBunOtaModule.class +0 -0
  1607. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/ota/ScaleBunOtaSpec.class +0 -0
  1608. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/ota/SlotManager$Companion.class +0 -0
  1609. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/ota/SlotManager.class +0 -0
  1610. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/performance/PerformanceModule$Companion.class +0 -0
  1611. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/performance/PerformanceModule$coreListener$1.class +0 -0
  1612. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/performance/PerformanceModule.class +0 -0
  1613. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/performance/PerformanceSpec.class +0 -0
  1614. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule$Companion.class +0 -0
  1615. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule$getInstallReferrer$1.class +0 -0
  1616. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/referrer/ScaleBunInstallReferrerModule.class +0 -0
  1617. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/referrer/ScaleBunInstallReferrerSpec.class +0 -0
  1618. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/storage/ScaleBunStorageModule$Companion.class +0 -0
  1619. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/storage/ScaleBunStorageModule.class +0 -0
  1620. package/android/build/tmp/kotlin-classes/debug/com/scalebun/rn/storage/ScaleBunStorageSpec.class +0 -0
  1621. package/android/build/tmp/kotlin-classes/debug/com/scalebun/storage/KvFileStore$Companion.class +0 -0
  1622. package/android/build/tmp/kotlin-classes/debug/com/scalebun/storage/KvFileStore.class +0 -0
@@ -1,1233 +1,1441 @@
1
- /**
2
- * ScaleBun SDK — Backend Session Adapter
3
- *
4
- * Implements the SessionTransport interface (System A) and bridges
5
- * session/frame/event data to the backend API via HTTP.
6
- *
7
- * This is the ADAPTER that connects the existing SessionManager
8
- * (which only has DesktopSessionTransport) to the backend.
9
- *
10
- * Design:
11
- * - Uses the same endpoint contract as BackendReplayTransport
12
- * (POST /v1/replay/sessions, /frames, /events, /finalize)
13
- * - Batches frames and events with auto-flush
14
- * - Never throws — all errors are caught and logged
15
- * - Behind config flag: only constructed when backendUpload is enabled
16
- *
17
- * This does NOT duplicate the existing BackendReplayTransport.
18
- * It exists because SessionManager uses a different interface
19
- * (SessionTransport from sessionTypes.ts) than ReplayTransport
20
- * (from features/replay/transport/ReplayTransport.ts).
21
- * The payload shapes differ, so this adapter maps between them.
22
- *
23
- * MVP/dev-only: base64 frames are sent inline in JSON body.
24
- */
25
-
26
- import { logger } from '../../core/logger/internalLogger';
27
- import { base64ToBytes } from '../../core/encoding/base64';
28
- import { ENDPOINTS } from '../../transport/http/endpoints';
29
- import { SDK_VERSION } from '../../core/constants/version';
30
- import { bridgeAdapter } from '../replay/bridge/adapters/bridgeAdapter';
31
- import { getReplaySdkNative } from '../replay/bridge/nativeModule';
32
- import type { ReplaySdkNativeModule } from '../replay/bridge/nativeModule';
33
- import type { StorageBackend } from '../../storage/StorageBackend';
34
- import type {
35
- SessionTransport,
36
- Session,
37
- SessionMetadata,
38
- JourneyEvent,
39
- ReplayFrame,
40
- } from './sessionTypes';
41
-
42
- // ─── Config ─────────────────────────────────────────────────────────────────
43
-
44
- export interface BackendSessionConfig {
45
- /** Backend API base URL (e.g. http://localhost:3001/api) */
46
- endpoint: string;
47
- /** Batch size for frames before auto-flush. Default: 5 */
48
- batchSize?: number;
49
- /** Auto-flush interval in ms. Default: 3000 */
50
- flushIntervalMs?: number;
51
- /** Request timeout in ms. Default: 15000 */
52
- timeoutMs?: number;
53
- /** SaaS multi-tenant client key enables ingestion endpoints and x-scalebun-client-key header */
54
- clientKey?: string;
55
- /**
56
- * Upload frame bytes directly to object storage via presigned PUT instead of
57
- * inline base64 in the JSON body. Default false legacy inline path. Flip on
58
- * after the backend presign endpoint is deployed. Falls back to inline
59
- * automatically if the backend reports storage is not configured.
60
- */
61
- useObjectStorage?: boolean;
62
- /**
63
- * Route telemetry lanes (events/network/errors/performance/logs) through the
64
- * durable NATIVE file outbox instead of JS-side HTTP. Only takes effect when BOTH
65
- * this and `nativeOutboxUploadEnabled` are true AND the native module exposes the
66
- * outbox methods — otherwise the existing JS upload path is used unchanged. When
67
- * active, the native uploader owns delivery (no duplicate JS POST). Default false.
68
- */
69
- enableNativeFileOutbox?: boolean;
70
- /** Native outbox actually uploads (vs. capture/store-only). Gates telemetry routing. */
71
- nativeOutboxUploadEnabled?: boolean;
72
- /**
73
- * Additive native-outbox tuning flags (retry interval, attempt caps, Retry-After,
74
- * byte/age GC bounds, etc.) forwarded verbatim to the native `initOutbox` dict.
75
- * Native parses both `nativeOutbox*` and bare `outbox*` keys and applies its own
76
- * defaults for anything omitted — so an empty object changes nothing.
77
- */
78
- nativeOutboxTuning?: Record<string, unknown>;
79
- /** Idle-gap threshold (ms) the SDK recorded with; persisted on the session row. */
80
- idleThresholdMs?: number;
81
- /**
82
- * Durable key-value store used to persist the unflushed frame buffer across a
83
- * process kill. On background the in-flight frames are snapshotted here; on the
84
- * next launch they are re-uploaded and linked to the PRIOR session. Omitted →
85
- * frame-kill recovery is disabled (in-memory only, prior behavior).
86
- */
87
- storage?: StorageBackend;
88
- }
89
-
90
- /**
91
- * One platform-agnostic log line for the logs lane. The queue forwards whatever it is
92
- * given — `source`/`platform` are neutral string hints set by the PRODUCER (console
93
- * tags 'console'/'js'; a future native producer tags its own values onto this SAME
94
- * shape). `level` is free-text. Nothing here is JS-specific.
95
- */
96
- export interface LogQueueItem {
97
- level: string;
98
- message: string;
99
- source: string;
100
- platform: string;
101
- timestamp: string;
102
- metadata?: Record<string, unknown>;
103
- }
104
-
105
- // ─── Adapter ────────────────────────────────────────────────────────────────
106
-
107
- export class BackendSessionAdapter implements SessionTransport {
108
- private config: Required<Omit<BackendSessionConfig, 'clientKey' | 'storage'>> & { clientKey?: string; storage?: StorageBackend };
109
- /** Durable store for cross-kill frame recovery (null → recovery disabled). */
110
- private readonly _frameStore: StorageBackend | null;
111
- /** Storage key for the snapshotted unflushed frame buffer (see persistPendingFrames). */
112
- private static readonly PENDING_FRAMES_KEY = 'scalebun_replay_pending_frames';
113
- /** Cap on frames persisted per snapshot — bounds KV footprint (keeps the most recent). */
114
- private static readonly MAX_PERSIST_FRAMES = 10;
115
- // Per-session toggle: cleared to false if the backend reports storage disabled.
116
- private objectStorageActive: boolean;
117
- // True when telemetry should divert to the durable native outbox (both flags on).
118
- // Native module availability is re-checked per call so a missing/old binary falls
119
- // back to the JS path transparently.
120
- private readonly nativeOutboxEnabled: boolean;
121
- // Cached one-shot native-outbox bootstrap promise (see _ensureNativeOutbox).
122
- private _nativeOutboxReady: Promise<boolean> | null = null;
123
- private currentSessionId: string | null = null;
124
- // §11 session_start ordering: a recording sessionId is added here ONLY after its
125
- // INGESTION_START row is confirmed created on the backend (either via sendSessionStart's
126
- // own POST, or via startAnalyticsSession when recording adopts the analytics id).
127
- // Child telemetry lanes (frames/events/network/errors/perf/logs) refuse to flush until
128
- // the row exists — otherwise the backend 404s the child write. Data stays buffered and
129
- // the flush timer retries, so nothing is lost to a start/child race. The durable native
130
- // outbox path has its own ordering; this guards only the JS in-memory fallback.
131
- private readonly _startedSessionIds = new Set<string>();
132
- private pendingFrames: Array<{ frame: ReplayFrame; imageData: string }> = [];
133
- private pendingEvents: JourneyEvent[] = [];
134
- private pendingNetworkRequests: Array<Record<string, unknown>> = [];
135
- private pendingErrors: Array<Record<string, unknown>> = [];
136
- private pendingPerformanceMetrics: Array<Record<string, unknown>> = [];
137
- // Platform-agnostic logs lane. Neutral by constructionholds whatever LogQueueItems
138
- // it's handed (console today; native later) and forwards them untouched.
139
- private pendingLogs: LogQueueItem[] = [];
140
- private flushTimer: ReturnType<typeof setInterval> | null = null;
141
- private destroyed = false;
142
-
143
- // ── Analytics lane (always-on, foreground-scoped; isolated from recording) ──
144
- // Fully separate from currentSessionId/pendingEvents/_flushEvents, which serve
145
- // recording. This lane carries user track() events and never touches recording
146
- // state. One queue doubles as the pre-ready buffer (bounded, drop-oldest) and
147
- // the outgoing queue; sessionId is stamped at flush so endpoint id == body id.
148
- private static readonly ANALYTICS_BUFFER_CAP = 100;
149
- /** Logs lane: queue length that triggers an eager flush (mirrors the network lane). */
150
- private static readonly LOGS_BATCH_SIZE = 20;
151
- /** Logs lane: max rows posted per flush (server caps at 200/batch). */
152
- private static readonly LOGS_FLUSH_MAX = 50;
153
- private _analyticsSessionId: string | null = null;
154
- private pendingAnalyticsEvents: JourneyEvent[] = [];
155
- private analyticsFlushTimer: ReturnType<typeof setInterval> | null = null;
156
- // iOS finalize reconciliation: the id of a backgrounded analytics session whose
157
- // INGESTION_FINALIZE has NOT been confirmed delivered. Set synchronously in
158
- // finalizeAnalyticsSession before any await (so it survives an iOS suspension of
159
- // the awaited fetch), cleared only on a confirmed finalize ACK. On the next
160
- // foreground the listener calls reconcilePendingFinalize() to close it for real.
161
- // In-memory is sufficient: the JS context survives background→foreground; only a
162
- // true process kill drops it (covered by the server-side idle-close backstop).
163
- private _pendingFinalizeId: string | null = null;
164
-
165
- constructor(config: BackendSessionConfig) {
166
- this.config = {
167
- batchSize: 5,
168
- flushIntervalMs: 3000,
169
- timeoutMs: 15_000,
170
- useObjectStorage: false,
171
- enableNativeFileOutbox: false,
172
- nativeOutboxUploadEnabled: false,
173
- nativeOutboxTuning: {},
174
- idleThresholdMs: 60_000,
175
- ...config,
176
- clientKey: config.clientKey,
177
- };
178
- this._frameStore = config.storage ?? null;
179
- this.objectStorageActive = this.config.useObjectStorage;
180
- this.nativeOutboxEnabled =
181
- this.config.enableNativeFileOutbox && this.config.nativeOutboxUploadEnabled;
182
- logger.info(`[ScaleBun Replay] backendUpload enabled`);
183
- logger.info(`[ScaleBun Replay] backendBaseUrl: ${this.config.endpoint}`);
184
- logger.info(`[ScaleBun Replay] transport fan-out active: desktop yes, backend yes`);
185
- }
186
-
187
- // ─── SessionTransport Interface ─────────────────────────────────────
188
-
189
- /**
190
- * §11 gate: true only when the current recording session's INGESTION_START row is
191
- * confirmed on the backend. Child telemetry lanes consult this before flushing so they
192
- * never race ahead of session creation (which would 404). Null id → not ready.
193
- */
194
- private _sessionRowReady(): boolean {
195
- return !!this.currentSessionId && this._startedSessionIds.has(this.currentSessionId);
196
- }
197
-
198
- sendSessionStart(session: Session): void {
199
- this.currentSessionId = session.sessionId;
200
- this._startFlushTimer();
201
-
202
- logger.info(`[ScaleBun Replay] session start requested`);
203
- logger.info(`[ScaleBun Replay] sessionId: ${session.sessionId}`);
204
- logger.info(`[ScaleBun Replay] deviceId: ${session.deviceId}`);
205
- logger.info(`[ScaleBun Replay] recordingSessionId: ${session.sessionId}`);
206
-
207
- // One-row merge: when recording adopted the always-on analytics id
208
- // (SessionManager.startSession), the INGESTION_START row already exists.
209
- // Do NOT post a second one — just keep the flush timer running so frames/
210
- // journey/network/errors/perf flush to INGESTION_*(analyticsId). Legacy
211
- // mode (no clientKey, distinct minted id) still posts /replay/sessions.
212
- if (this.config.clientKey && session.sessionId === this._analyticsSessionId) {
213
- logger.info(`[ScaleBun Replay] recording attached to analytics session ${session.sessionId} (no new row)`);
214
- return;
215
- }
216
-
217
- logger.info(`[ScaleBun Replay] backend session upload started`);
218
-
219
- const startEndpoint = this.config.clientKey ? ENDPOINTS.INGESTION_START : '/replay/sessions';
220
-
221
- // Fetch native device info to enrich the session payload.
222
- // Falls back to metadata-only if bridge unavailable (old native binary).
223
- bridgeAdapter.getDeviceInfo()
224
- .then(nativeInfo => {
225
- const m = session.metadata;
226
- const payload = {
227
- sessionId: session.sessionId,
228
- deviceId: session.deviceId,
229
- startedAt: session.startedAt,
230
- // Link the recording row to the always-on analytics row so the
231
- // dashboard can join them. track() events land on the analytics
232
- // id; frames/journey land on this recording id. Without this
233
- // link the two appear as separate sessions (one looks "empty").
234
- // BACKEND DEPENDENCY: the dashboard must read/join on this field
235
- // (or treat the analytics row as canonical) to fully merge them.
236
- analyticsSessionId: this._analyticsSessionId,
237
- // Carry the idle threshold on the recording lane too: it may
238
- // create the row before the analytics lane does. Backend
239
- // upsert leaves it untouched if already set.
240
- idleThresholdMs: this.config.idleThresholdMs,
241
- device: {
242
- platform: nativeInfo?.platform ?? m?.platform,
243
- osVersion: nativeInfo?.osVersion ?? m?.osVersion,
244
- deviceModel: nativeInfo?.deviceModel ?? m?.deviceModel,
245
- screenWidth: m?.screenWidth,
246
- screenHeight: m?.screenHeight,
247
- appName: nativeInfo?.appName ?? m?.appName,
248
- appVersion: nativeInfo?.appVersion ?? m?.appVersion,
249
- bundleId: nativeInfo?.bundleId ?? m?.bundleId,
250
- sdkVersion: SDK_VERSION,
251
- releaseStage: m?.buildType,
252
- // Backend ingestion source not in this repo; field name
253
- // unconfirmed. Send both so whichever it reads is populated.
254
- environment: m?.buildType,
255
- },
256
- };
257
- logger.debug(`[BackendSessionAdapter] POST session start: ${session.sessionId}`);
258
- return this._post(startEndpoint, payload);
259
- })
260
- .then(() => {
261
- // §11: row now exists — release the child-lane flush gate for this id.
262
- this._startedSessionIds.add(session.sessionId);
263
- logger.info(`[ScaleBun Replay] backend session upload success`);
264
- })
265
- .catch(() => logger.info(`[ScaleBun Replay] backend session upload failure`));
266
- }
267
-
268
- sendSessionEnd(session: Session): void {
269
- logger.info(`[ScaleBun Replay] finalize started`);
270
- // Flush all pending data first, then finalize
271
- Promise.all([
272
- this._flushFrames(),
273
- this._flushEvents(),
274
- this._flushNetwork(),
275
- this._flushErrors(),
276
- this._flushPerformance(),
277
- ]).then(() => {
278
- // One-row merge: if this recording adopted the always-on analytics id,
279
- // the analytics lane owns the session's lifecycle and finalizes it on
280
- // background (finalizeAnalyticsSession). Finalizing here would close the
281
- // shared row mid-foreground and orphan later track() events — so flush
282
- // (above) but skip finalize. Legacy/distinct-id sessions finalize normally.
283
- if (this.config.clientKey && session.sessionId === this._analyticsSessionId) {
284
- logger.info(`[ScaleBun Replay] recording ended; analytics session ${session.sessionId} stays open`);
285
- return;
286
- }
287
- const finalizeEndpoint = this.config.clientKey
288
- ? ENDPOINTS.INGESTION_FINALIZE(session.sessionId)
289
- : `/replay/sessions/${session.sessionId}/finalize`;
290
- return this._post(
291
- finalizeEndpoint,
292
- {
293
- endedAt: session.endedAt ?? Date.now(),
294
- durationMs: session.endedAt
295
- ? session.endedAt - session.startedAt
296
- : Date.now() - session.startedAt,
297
- totalFrames: session.artifactIndex?.frameRefs?.length ?? 0,
298
- totalEvents: session.artifactIndex?.eventRefs?.length ?? 0,
299
- finalState: session.status === 'timeout' ? 'timeout' : 'completed',
300
- },
301
- );
302
- }).then(() => {
303
- logger.info(`[ScaleBun Replay] finalize success`);
304
- }).catch(() => {
305
- logger.info(`[ScaleBun Replay] finalize failure`);
306
- }).finally(() => {
307
- this._stopFlushTimer();
308
- // Keep the row-ready gate OPEN for a merged analytics session. The analytics
309
- // lane still owns it (not finalized on background — the session spans the
310
- // app-switch), so a foreground restart re-adopts the SAME id and must keep
311
- // flushing frames/events. Dropping the gate here would 404-buffer everything
312
- // after the first background cycle. Only clear it for a distinct/legacy
313
- // recording id that was actually finalized above.
314
- if (!(this.config.clientKey && session.sessionId === this._analyticsSessionId)) {
315
- this._startedSessionIds.delete(session.sessionId);
316
- }
317
- // Session end: drain any durably-stored telemetry from the native outbox.
318
- this._triggerNativeFlush();
319
- logger.debug(`[BackendSessionAdapter] Session finalized: ${session.sessionId}`);
320
- });
321
- }
322
-
323
- // ─── Analytics Lane (isolated from recording) ───────────────────────
324
-
325
- /** Public: the always-on analytics session id, or null before it opens. */
326
- get analyticsSessionId(): string | null {
327
- return this._analyticsSessionId;
328
- }
329
-
330
- /**
331
- * Open the always-on analytics ingestion session. Sets the analytics id,
332
- * starts the analytics flush timer, replays any pre-ready buffered events,
333
- * and POSTs INGESTION_START. Mirrors sendSessionStart's body builder but
334
- * never touches currentSessionId (recording lane).
335
- */
336
- async startAnalyticsSession(session: {
337
- sessionId: string;
338
- deviceId: string;
339
- startedAt: number;
340
- metadata?: SessionMetadata;
341
- /** Idle-gap threshold (ms) the SDK declares for this session; echoed by the
342
- * backend so the dashboard uses the same value to draw idle bands. */
343
- idleThresholdMs?: number;
344
- }): Promise<void> {
345
- if (this.destroyed) return;
346
- this._analyticsSessionId = session.sessionId;
347
- this._startAnalyticsFlushTimer();
348
-
349
- // Replay pre-ready buffered events now that the id exists. sessionId is
350
- // stamped at flush time, so buffered events need no rewrite.
351
- this._flushAnalyticsEvents().catch(() => { });
352
-
353
- const startEndpoint = this.config.clientKey ? ENDPOINTS.INGESTION_START : '/replay/sessions';
354
- try {
355
- const nativeInfo = await bridgeAdapter.getDeviceInfo();
356
- const m = session.metadata;
357
- const payload = {
358
- sessionId: session.sessionId,
359
- deviceId: session.deviceId,
360
- startedAt: session.startedAt,
361
- idleThresholdMs: session.idleThresholdMs,
362
- device: {
363
- platform: nativeInfo?.platform ?? m?.platform,
364
- osVersion: nativeInfo?.osVersion ?? m?.osVersion,
365
- deviceModel: nativeInfo?.deviceModel ?? m?.deviceModel,
366
- screenWidth: m?.screenWidth,
367
- screenHeight: m?.screenHeight,
368
- appName: nativeInfo?.appName ?? m?.appName,
369
- appVersion: nativeInfo?.appVersion ?? m?.appVersion,
370
- bundleId: nativeInfo?.bundleId ?? m?.bundleId,
371
- sdkVersion: SDK_VERSION,
372
- releaseStage: m?.buildType,
373
- environment: m?.buildType,
374
- },
375
- };
376
- await this._post(startEndpoint, payload);
377
- // §11: row exists. When recording adopts this analytics id (one-row merge),
378
- // this also releases the recording child-lane gate (_sessionRowReady).
379
- this._startedSessionIds.add(session.sessionId);
380
- // Row is confirmed — replay any events buffered while START was in flight.
381
- // The pre-ack flush at the top of this method is gated off until now, so
382
- // this is what actually drains the pre-ready buffer (no premature 404).
383
- this._flushAnalyticsEvents().catch(() => { });
384
- logger.info(`[ScaleBun Analytics] session start upload success: ${session.sessionId}`);
385
- } catch {
386
- logger.info(`[ScaleBun Analytics] session start upload failure`);
387
- }
388
- }
389
-
390
- /**
391
- * Enqueue a user track() event. Buffers (bounded, drop-oldest) when the
392
- * analytics session is not yet open; flushes at >=20 once it is.
393
- */
394
- trackEvent(event: JourneyEvent): void {
395
- if (this.destroyed) return;
396
- this.pendingAnalyticsEvents.push(event);
397
- const overflow = this.pendingAnalyticsEvents.length - BackendSessionAdapter.ANALYTICS_BUFFER_CAP;
398
- if (overflow > 0) {
399
- this.pendingAnalyticsEvents.splice(0, overflow); // drop oldest
400
- }
401
- if (this._analyticsSessionId && this.pendingAnalyticsEvents.length >= 20) {
402
- this._flushAnalyticsEvents().catch(() => { });
403
- }
404
- }
405
-
406
- /**
407
- * Emit an app-lifecycle boundary marker (APP_BACKGROUND / APP_FOREGROUND) onto
408
- * the analytics lane so the dashboard can shade the backgrounded span on the
409
- * replay timeline and exclude it from the active duration. Timestamp is captured
410
- * at the transition (accurate even if delivery is deferred until the next
411
- * foreground on iOS). No-op when no analytics session is open. The sessionId is
412
- * (re)stamped at flush time, so passing the current id here is only a placeholder.
413
- */
414
- emitLifecycleMarker(
415
- type: 'APP_BACKGROUND' | 'APP_FOREGROUND',
416
- payload?: Record<string, unknown>,
417
- ): void {
418
- if (this.destroyed || !this._analyticsSessionId) return;
419
- this.trackEvent({
420
- eventId: this._clientId(),
421
- sessionId: this._analyticsSessionId,
422
- ts: Date.now(),
423
- type,
424
- source: 'sdk',
425
- ...(payload ? { payload } : {}),
426
- });
427
- }
428
-
429
- /**
430
- * Public: force-flush queued analytics events immediately. Called on
431
- * APP_BACKGROUND so the lifecycle marker (and any buffered track events) reach
432
- * the backend before the OS suspends the flush timer. Best-effort on iOS, where
433
- * the POST may not resolve until the next foreground — the events stay buffered
434
- * with accurate timestamps and flush then.
435
- */
436
- flushAnalytics(): Promise<void> {
437
- return this._flushAnalyticsEvents();
438
- }
439
-
440
- /**
441
- * Flush queued analytics events. Mirrors _flushEvents (recording) byte for
442
- * byte on the wire map, but gates on _analyticsSessionId and STAMPS that id
443
- * into every event so endpoint id == body sessionId by construction.
444
- */
445
- private async _flushAnalyticsEvents(forSessionId?: string): Promise<void> {
446
- // finalize clears _analyticsSessionId synchronously, then passes the
447
- // captured id here so the final drain still targets the right session.
448
- const sessionId = forSessionId ?? this._analyticsSessionId;
449
- if (this.pendingAnalyticsEvents.length === 0 || !sessionId) return;
450
-
451
- // Row-confirmed gate (mirrors the recording lanes' _sessionRowReady). The
452
- // INGESTION_START create is async and can fail/lag; flushing events before
453
- // the row exists 404s the child write and re-buffers forever. Keep events
454
- // queued (bounded, drop-oldest via trackEvent) until START is acked.
455
- if (!this._startedSessionIds.has(sessionId)) return;
456
-
457
- const batch = this.pendingAnalyticsEvents.splice(0, 20);
458
- const events = batch.map(e => this._leanEvent(e, sessionId));
459
-
460
- try {
461
- const eventsEndpoint = this.config.clientKey
462
- ? ENDPOINTS.INGESTION_EVENTS(sessionId)
463
- : `/replay/sessions/${sessionId}/events`;
464
- await this._post(eventsEndpoint, { events });
465
- logger.debug(`[BackendSessionAdapter] Flushed ${batch.length} analytics event(s)`);
466
- } catch (err) {
467
- if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingAnalyticsEvents.unshift(...batch);
468
- }
469
- }
470
-
471
- /** Flush remaining analytics events, finalize the session, stop its timer. */
472
- async finalizeAnalyticsSession(): Promise<void> {
473
- const sessionId = this._analyticsSessionId;
474
- if (!sessionId) return;
475
-
476
- // Clear the id and stop the timer SYNCHRONOUSLY, before any await. On iOS
477
- // the app is suspended on background and the finalize fetch below never
478
- // resolves until the next foreground, so the old `finally` that nulled the
479
- // id never ran before the resume guard (SDKBootstrapper: `state==='active'
480
- // && !adapter.analyticsSessionId`) evaluated → guard stayed false → no new
481
- // session opened. Clearing up front makes the guard always see null after
482
- // background, so resume re-opens a fresh analytics session every cycle.
483
- this._analyticsSessionId = null;
484
- this._stopAnalyticsFlushTimer();
485
-
486
- // Mark as pending-finalize BEFORE any await. On iOS the app suspends right
487
- // after backgrounding, so the awaited _post below may never resolve. Setting
488
- // the marker synchronously guarantees the next foreground can reconcile-close
489
- // this id even though the background POST was suspended. Cleared only on a
490
- // confirmed ACK (below), so a suspended POST leaves the marker in place.
491
- this._pendingFinalizeId = sessionId;
492
-
493
- try {
494
- // Pass the captured id explicitly the field is already cleared.
495
- await this._flushAnalyticsEvents(sessionId);
496
- const finalizeEndpoint = this.config.clientKey
497
- ? ENDPOINTS.INGESTION_FINALIZE(sessionId)
498
- : `/replay/sessions/${sessionId}/finalize`;
499
- await this._post(finalizeEndpoint, { endedAt: Date.now() });
500
- // Confirmed delivered → drop the marker so the foreground reconciler does
501
- // NOT re-finalize this id (first half of the no-double-finalize guard).
502
- if (this._pendingFinalizeId === sessionId) this._pendingFinalizeId = null;
503
- logger.debug(`[BackendSessionAdapter] Analytics session finalized: ${sessionId}`);
504
- } catch {
505
- // Leave the marker set — foreground reconciliation will retry the close.
506
- logger.info(`[ScaleBun Analytics] finalize failure (will reconcile on foreground): ${sessionId}`);
507
- }
508
- }
509
-
510
- /**
511
- * Close any analytics session left open by a suspended background finalize.
512
- * Called on the NEXT foreground (SDKBootstrapper app-state 'active') BEFORE a new
513
- * analytics session is opened. JS is live on foreground, so this POST completes.
514
- * No-op when there is no pending id. Idempotent with the background finalize: the
515
- * marker is cleared on a confirmed background ACK, so this only fires when the
516
- * background POST was NOT confirmed; if that suspended POST later also lands, the
517
- * server must treat a repeat INGESTION_FINALIZE for the same id as a no-op.
518
- */
519
- async reconcilePendingFinalize(): Promise<void> {
520
- const sessionId = this._pendingFinalizeId;
521
- if (!sessionId) return;
522
-
523
- try {
524
- const finalizeEndpoint = this.config.clientKey
525
- ? ENDPOINTS.INGESTION_FINALIZE(sessionId)
526
- : `/replay/sessions/${sessionId}/finalize`;
527
- await this._post(finalizeEndpoint, { endedAt: Date.now() });
528
- logger.info(`[ScaleBun Analytics] reconciled finalize on foreground: ${sessionId}`);
529
- } catch {
530
- logger.info(`[ScaleBun Analytics] foreground reconcile finalize failed: ${sessionId}`);
531
- } finally {
532
- // Clear after a foreground attempt regardless of outcome: JS is live here
533
- // so a transient network error is rare, and the server-side idle-close
534
- // backstop covers any still-orphaned row. Bounds total finalizes per id to
535
- // at most 2 (suspended-bg + foreground) — never a per-foreground loop.
536
- if (this._pendingFinalizeId === sessionId) this._pendingFinalizeId = null;
537
- }
538
- }
539
-
540
- private _startAnalyticsFlushTimer(): void {
541
- this._stopAnalyticsFlushTimer();
542
- this.analyticsFlushTimer = setInterval(() => {
543
- this._flushAnalyticsEvents().catch(() => { });
544
- }, this.config.flushIntervalMs);
545
- }
546
-
547
- private _stopAnalyticsFlushTimer(): void {
548
- if (this.analyticsFlushTimer) {
549
- clearInterval(this.analyticsFlushTimer);
550
- this.analyticsFlushTimer = null;
551
- }
552
- }
553
-
554
- sendEvent(event: JourneyEvent): void {
555
- if (this.destroyed) return;
556
-
557
- logger.info(`[ScaleBun Replay] event recorded`);
558
- logger.info(` eventId: ${event.eventId}`);
559
- logger.info(` type: ${event.type}`);
560
- logger.info(` timestamp: ${event.ts}`);
561
- logger.info(` sessionId: ${event.sessionId}`);
562
-
563
- this.pendingEvents.push(event);
564
-
565
- if (this.pendingEvents.length >= 20) {
566
- this._flushEvents().catch(() => { });
567
- }
568
- }
569
-
570
- sendFrame(frame: ReplayFrame, imageData: string): void {
571
- if (this.destroyed) return;
572
-
573
- logger.info(`[ScaleBun Replay] frame captured`);
574
- logger.info(` frameId: ${frame.frameId}`);
575
- logger.info(` timestamp: ${frame.ts}`);
576
- logger.info(` sessionId: ${frame.sessionId}`);
577
- logger.info(` width/height: ${frame.width}x${frame.height}`);
578
-
579
- this.pendingFrames.push({ frame, imageData });
580
-
581
- if (this.pendingFrames.length >= this.config.batchSize) {
582
- this._flushFrames().catch(() => { });
583
- }
584
- }
585
-
586
- // ─── SaaS Ingestion Queues ──────────────────────────────────────────
587
-
588
- queueNetworkRequest(data: {
589
- method: string; url: string; statusCode?: number; duration?: number;
590
- screenName?: string; error?: string; requestSize?: number; responseSize?: number;
591
- requestHeaders?: Record<string, string>; responseHeaders?: Record<string, string>;
592
- }): void {
593
- if (this.destroyed || !this.config.clientKey) return;
594
- // clientId: stable per-row idempotency key so a mobile retry of the same
595
- // batch upserts instead of inserting duplicates server-side.
596
- this.pendingNetworkRequests.push({ ...data, clientId: this._clientId(), timestamp: new Date().toISOString() });
597
- if (this.pendingNetworkRequests.length >= 20) {
598
- this._flushNetwork().catch(() => {});
599
- }
600
- }
601
-
602
- queueError(data: {
603
- type: string; message: string; stack?: string; screenName?: string;
604
- }): void {
605
- if (this.destroyed || !this.config.clientKey) return;
606
- this.pendingErrors.push({ ...data, clientId: this._clientId(), timestamp: new Date().toISOString() });
607
- if (this.pendingErrors.length >= 10) {
608
- this._flushErrors().catch(() => {});
609
- }
610
- }
611
-
612
- /** Public: force-flush queued errors immediately (handled-error delivery). */
613
- flushErrors(): Promise<void> {
614
- return this._flushErrors();
615
- }
616
-
617
- /**
618
- * Public: flush ALL recording-lane queues immediately. Called on APP_BACKGROUND
619
- * so the server-side reaper computes endedAt from the freshest data even when
620
- * the OS suspends the flush timer right after backgrounding.
621
- */
622
- async flushAll(): Promise<void> {
623
- await Promise.all([
624
- this._flushFrames(),
625
- this._flushEvents(),
626
- this._flushNetwork(),
627
- this._flushErrors(),
628
- this._flushPerformance(),
629
- this._flushLogs(),
630
- ]);
631
- // Background trigger: close native segments + drain the native uploader so a
632
- // suspended JS context doesn't strand durably-stored telemetry.
633
- this._triggerNativeFlush();
634
- }
635
-
636
- queuePerformanceMetric(data: {
637
- type: string; screenName?: string; duration?: number; value?: number;
638
- metadata?: Record<string, unknown>;
639
- }): void {
640
- if (this.destroyed || !this.config.clientKey) return;
641
- this.pendingPerformanceMetrics.push({ ...data, clientId: this._clientId(), timestamp: new Date().toISOString() });
642
- if (this.pendingPerformanceMetrics.length >= 20) {
643
- this._flushPerformance().catch(() => {});
644
- }
645
- }
646
-
647
- /**
648
- * Queue one log line onto the platform-agnostic logs lane. Mirrors
649
- * queueNetworkRequest: drop when not in SaaS mode (no clientKey) or destroyed,
650
- * batch-flush at LOGS_BATCH_SIZE. The producer supplies source/platform/level —
651
- * this method makes NO assumptions about them, so a native producer reuses it as-is.
652
- */
653
- queueLog(data: {
654
- level: string; message: string; source: string; platform: string;
655
- timestamp?: string; metadata?: Record<string, unknown>;
656
- }): void {
657
- if (this.destroyed || !this.config.clientKey) return;
658
- this.pendingLogs.push({
659
- level: data.level,
660
- message: data.message,
661
- source: data.source,
662
- platform: data.platform,
663
- timestamp: data.timestamp ?? new Date().toISOString(),
664
- ...(data.metadata ? { metadata: data.metadata } : {}),
665
- });
666
- if (this.pendingLogs.length >= BackendSessionAdapter.LOGS_BATCH_SIZE) {
667
- this._flushLogs().catch(() => {});
668
- }
669
- }
670
-
671
- /** Stable client-generated idempotency id (matches journeyManager id scheme). */
672
- private _clientId(): string {
673
- return `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 10)}`;
674
- }
675
-
676
- // ─── Native outbox routing ──────────────────────────────────────────
677
-
678
- /**
679
- * Hand a telemetry batch to the durable native outbox. Returns true if native
680
- * accepted it (native uploader now owns delivery — caller must NOT also POST).
681
- * Returns false on any miss (flag off, no session, old binary, native error) so
682
- * the caller falls back to the JS HTTP path with the batch intact.
683
- */
684
- private async _enqueueNative(
685
- lane: 'events' | 'network' | 'errors' | 'performance' | 'logs',
686
- records: Array<Record<string, unknown>>,
687
- ): Promise<boolean> {
688
- if (!this.nativeOutboxEnabled || !this.currentSessionId) return false;
689
- const native = getReplaySdkNative();
690
- if (!native?.enqueueOutboxRecords) return false;
691
- if (!(await this._ensureNativeOutbox(native))) return false;
692
- try {
693
- return await native.enqueueOutboxRecords(lane, this.currentSessionId, records);
694
- } catch {
695
- return false;
696
- }
697
- }
698
-
699
- /**
700
- * Bootstrap the native outbox once. In SaaS mode the native module's full
701
- * `initialize()` (which builds a SessionManager) is never called, so the
702
- * NativeOutbox/uploader would not exist. `initOutbox` constructs only the
703
- * durable outbox from clientKey/apiBaseUrl/flags. Idempotent + cached so it
704
- * runs at most once; resolves false on old binaries (caller falls back to JS).
705
- */
706
- private _ensureNativeOutbox(native: ReplaySdkNativeModule): Promise<boolean> {
707
- if (this._nativeOutboxReady) return this._nativeOutboxReady;
708
- if (!native.initOutbox) return Promise.resolve(false);
709
- this._nativeOutboxReady = native
710
- .initOutbox({
711
- ...this.config.nativeOutboxTuning,
712
- clientKey: this.config.clientKey,
713
- apiBaseUrl: this.config.endpoint,
714
- enableNativeFileOutbox: true,
715
- nativeOutboxUploadEnabled: true,
716
- useObjectStorageForFrames: this.config.useObjectStorage === true,
717
- })
718
- .catch(() => false);
719
- return this._nativeOutboxReady;
720
- }
721
-
722
- /**
723
- * Public readiness gate for the native frame outbox path (used by the frame
724
- * capture adapter). Resolves true only when both outbox flags are on, a session
725
- * exists, the native binary exposes the bridge, and `initOutbox` succeeded.
726
- * Resolves false otherwise so the frame pipeline falls back to `captureScreenshot`.
727
- */
728
- ensureNativeOutboxReady(): Promise<boolean> {
729
- if (!this.nativeOutboxEnabled || !this.currentSessionId) return Promise.resolve(false);
730
- const native = getReplaySdkNative();
731
- if (!native?.captureScreenshotToFile) return Promise.resolve(false);
732
- return this._ensureNativeOutbox(native);
733
- }
734
-
735
- /** Best-effort: close native segments and drain the native uploader. Never throws. */
736
- private _triggerNativeFlush(): void {
737
- if (!this.nativeOutboxEnabled) return;
738
- try {
739
- getReplaySdkNative()?.flushNativeOutbox?.().catch(() => { });
740
- } catch {
741
- /* old binary / unavailable ignore */
742
- }
743
- }
744
-
745
- // ─── Lifecycle ──────────────────────────────────────────────────────
746
-
747
- destroy(): void {
748
- this.destroyed = true;
749
- this._stopFlushTimer();
750
- this._stopAnalyticsFlushTimer();
751
- this.pendingFrames = [];
752
- this.pendingEvents = [];
753
- this.pendingAnalyticsEvents = [];
754
- this.pendingNetworkRequests = [];
755
- this.pendingErrors = [];
756
- this.pendingPerformanceMetrics = [];
757
- this.currentSessionId = null;
758
- this._analyticsSessionId = null;
759
- this._pendingFinalizeId = null;
760
- this._startedSessionIds.clear();
761
- }
762
-
763
- // ─── Internal: Flush ────────────────────────────────────────────────
764
-
765
- /** Wire metadata for a frame real format/sizeBytes from native (no hardcoded literals). */
766
- private _frameMeta(b: { frame: ReplayFrame; imageData: string }) {
767
- const f = b.frame;
768
- const format = f.format ?? 'jpeg';
769
- // P2-5: a JSON frame-delta carries an application content type, not an image MIME.
770
- const isJsonDelta = f.frameType === 'delta' && format === 'scalebun-framedelta';
771
- const contentType = isJsonDelta
772
- ? 'application/x-scalebun-framedelta+json'
773
- : `image/${format}`;
774
- return {
775
- frameId: f.frameId,
776
- sessionId: f.sessionId,
777
- timestamp: f.ts,
778
- // P2-0: real monotonic per-session sequence (was hardcoded 0 server-side).
779
- sequenceNumber: f.sequenceNumber,
780
- // P2-5: keyframe|delta + base reference for dashboard reconstruction.
781
- frameType: f.frameType,
782
- baseFrameId: f.baseFrameId,
783
- screenName: f.screen ?? '',
784
- trigger: f.captureReason ?? '',
785
- format,
786
- contentType,
787
- width: f.width,
788
- height: f.height,
789
- sizeBytes: f.byteSize ?? 0,
790
- masked: f.redactionState === 'full',
791
- };
792
- }
793
-
794
- /**
795
- * P2-4: build the lean (v2) wire payload for one event. Drops redundant/empty
796
- * fields at the source while NEVER dropping fields the dashboard/analytics depend
797
- * on (eventId, type, timestamp, sessionId). `label` is omitted when it equals
798
- * `type` (the server defaults it back). `screenName` omitted when empty. `data`
799
- * is pruned of null/''/undefined leaves (one level). The `v:2` marker lets the
800
- * backend/dashboard pick the lean decoder; legacy (v1/no-marker) events still
801
- * decode unchanged. See P2_CONTRACT.md §4.
802
- */
803
- private _leanEvent(e: JourneyEvent, sessionId: string): Record<string, unknown> {
804
- const out: Record<string, unknown> = {
805
- v: 2,
806
- eventId: e.eventId,
807
- sessionId,
808
- type: e.type,
809
- timestamp: e.ts,
810
- };
811
- const screen = e.screen ?? '';
812
- if (screen) out.screenName = screen;
813
- const label = e.subtype ?? e.type;
814
- if (label && label !== e.type) out.label = label;
815
- const data = this._pruneEmpty(e.payload);
816
- if (data && Object.keys(data).length > 0) out.data = data;
817
- return out;
818
- }
819
-
820
- /** Shallow-prune null/undefined/'' leaves from a payload object. */
821
- private _pruneEmpty(payload: unknown): Record<string, unknown> | undefined {
822
- if (!payload || typeof payload !== 'object') return undefined;
823
- const src = payload as Record<string, unknown>;
824
- const out: Record<string, unknown> = {};
825
- for (const k of Object.keys(src)) {
826
- const v = src[k];
827
- if (v === null || v === undefined || v === '') continue;
828
- out[k] = v;
829
- }
830
- return out;
831
- }
832
-
833
- private async _flushFrames(): Promise<void> {
834
- if (this.pendingFrames.length === 0 || !this.currentSessionId) return;
835
- // §11: hold frames until the session_start row is confirmed (else 404). Data stays
836
- // buffered; the flush timer retries once the row lands.
837
- if (!this._sessionRowReady()) return;
838
- const sessionId = this.currentSessionId;
839
-
840
- const batch = this.pendingFrames.splice(0, this.config.batchSize);
841
- try {
842
- await this._postFrameBatch(sessionId, batch);
843
- logger.debug(`[BackendSessionAdapter] Flushed ${batch.length} frame(s)`);
844
- // Delivered the durable snapshot (if any) is now redundant. Clear it once
845
- // the in-memory buffer is fully drained so a later kill can't replay
846
- // already-uploaded frames.
847
- if (this.pendingFrames.length === 0) this._clearPersistedFrames();
848
- } catch (err) {
849
- if (BackendSessionAdapter._isPermanentHttpError(err)) return;
850
- logger.warn(`[replay.sdk.error] backend frame upload failure`, { count: batch.length });
851
- // Re-queue on failure
852
- this.pendingFrames.unshift(...batch);
853
- }
854
- }
855
-
856
- /**
857
- * POST one frame batch under an EXPLICIT sessionId (object-storage path when
858
- * active, else legacy inline base64). Used by both the live flush and cross-kill
859
- * recovery — recovery passes the PRIOR session's id so orphaned frames relink to
860
- * it. Throws on transient error so the caller can re-queue; frame writes are
861
- * idempotent server-side (upsert by frameId), so a double-send is harmless.
862
- */
863
- private async _postFrameBatch(
864
- sessionId: string,
865
- batch: Array<{ frame: ReplayFrame; imageData: string }>,
866
- ): Promise<void> {
867
- if (batch.length === 0) return;
868
- logger.info(`[replay.sdk.frame] backend frame upload started`, { count: batch.length });
869
-
870
- // Object-storage path: presign → PUT bytes → post key-only metadata.
871
- if (this.objectStorageActive && this.config.clientKey) {
872
- const result = await this._uploadFramesViaStorage(sessionId, batch);
873
- if (result === 'sent') {
874
- logger.info(`[replay.sdk.frame] backend frame upload success (object storage)`);
875
- return;
876
- }
877
- // 'disabled' → storage not configured server-side; fall through to inline.
878
- }
879
-
880
- // Legacy inline path: base64 in JSON body.
881
- const frames = batch.map(b => ({ ...this._frameMeta(b), imageData: b.imageData }));
882
- const framesEndpoint = this.config.clientKey
883
- ? ENDPOINTS.INGESTION_FRAMES(sessionId)
884
- : `/replay/sessions/${sessionId}/frames`;
885
- await this._post(framesEndpoint, { frames });
886
- logger.info(`[replay.sdk.frame] backend frame upload success`);
887
- }
888
-
889
- // ─── Cross-kill frame recovery ──────────────────────────────────────
890
- //
891
- // Frames buffer in-memory (pendingFrames) and only reach the backend on flush.
892
- // A process kill (swipe-away, OOM) between captures loses the last frames the
893
- // user saw — the iOS/Android background flush may be suspended before its POST
894
- // resolves. To close that gap we snapshot the unflushed buffer to the durable
895
- // KV store on background (survives kill), then re-upload it on the NEXT launch
896
- // linked to the PRIOR session id. Best-effort and never throws.
897
-
898
- /**
899
- * Snapshot the current unflushed frame buffer to durable storage so it survives
900
- * a process kill. Called on APP_BACKGROUND before the (possibly-suspended)
901
- * network flush. Synchronous mirror write — reaches disk on the native store's
902
- * next coalesced flush. No-op if recovery storage is absent or nothing pending.
903
- */
904
- persistPendingFrames(): void {
905
- if (!this._frameStore || this.destroyed || !this.currentSessionId) return;
906
- if (this.pendingFrames.length === 0) return;
907
- try {
908
- const items = this.pendingFrames.slice(-BackendSessionAdapter.MAX_PERSIST_FRAMES);
909
- this._frameStore.set(
910
- BackendSessionAdapter.PENDING_FRAMES_KEY,
911
- JSON.stringify({ sessionId: this.currentSessionId, items }),
912
- );
913
- } catch {
914
- // Serialization/storage failure must never break backgrounding.
915
- }
916
- }
917
-
918
- /** Drop the persisted frame snapshot (after successful delivery). Never throws. */
919
- private _clearPersistedFrames(): void {
920
- if (!this._frameStore) return;
921
- try {
922
- this._frameStore.delete(BackendSessionAdapter.PENDING_FRAMES_KEY);
923
- } catch {
924
- /* non-fatal */
925
- }
926
- }
927
-
928
- /**
929
- * On cold launch: if a prior run left an unflushed frame snapshot, re-upload it
930
- * linked to that PRIOR session, then clear it. Runs independently of the new
931
- * session (uses the stored id + a direct POST, bypassing the row-ready gate —
932
- * the prior session row already exists server-side). Best-effort; on transient
933
- * failure the snapshot is kept for the next launch.
934
- */
935
- async recoverPersistedFrames(): Promise<void> {
936
- if (!this._frameStore) return;
937
- let raw: string | undefined;
938
- try {
939
- raw = this._frameStore.get(BackendSessionAdapter.PENDING_FRAMES_KEY);
940
- } catch {
941
- return;
942
- }
943
- if (!raw) return;
944
-
945
- let parsed: { sessionId?: string; items?: Array<{ frame: ReplayFrame; imageData: string }> };
946
- try {
947
- parsed = JSON.parse(raw);
948
- } catch {
949
- // Corrupt snapshot discard so it can't wedge every launch.
950
- this._clearPersistedFrames();
951
- return;
952
- }
953
-
954
- const sessionId = parsed.sessionId;
955
- const items = parsed.items;
956
- if (!sessionId || !Array.isArray(items) || items.length === 0) {
957
- this._clearPersistedFrames();
958
- return;
959
- }
960
-
961
- try {
962
- logger.info(`[replay.sdk.frame] recovering ${items.length} frame(s) for prior session ${sessionId}`);
963
- await this._postFrameBatch(sessionId, items);
964
- this._clearPersistedFrames();
965
- } catch (err) {
966
- if (BackendSessionAdapter._isPermanentHttpError(err)) {
967
- // Server rejected permanently (e.g. session gone) — don't retry forever.
968
- this._clearPersistedFrames();
969
- return;
970
- }
971
- // Transient — keep the snapshot for the next launch.
972
- logger.warn(`[replay.sdk.frame] prior-session frame recovery deferred (transient)`);
973
- }
974
- }
975
-
976
- /**
977
- * Upload a batch via object storage. Returns 'sent' on success, 'disabled' if
978
- * the backend reports storage is not configured (caller falls back to inline).
979
- * Throws on transient error so the caller re-queues the batch.
980
- */
981
- private async _uploadFramesViaStorage(
982
- sessionId: string,
983
- batch: Array<{ frame: ReplayFrame; imageData: string }>,
984
- ): Promise<'sent' | 'disabled'> {
985
- const presignReq = batch.map(b => {
986
- const m = this._frameMeta(b);
987
- return { frameId: m.frameId, contentType: m.contentType, format: m.format };
988
- });
989
- const resp = await this._postReturning<{ enabled: boolean; frames: Array<{ frameId: string; uploadUrl: string; storageKey: string; bucket: string; contentType: string }> }>(
990
- ENDPOINTS.INGESTION_FRAMES_PRESIGN(sessionId),
991
- { frames: presignReq },
992
- );
993
-
994
- if (!resp || resp.enabled === false) {
995
- // Latch off for the rest of the session so we don't presign every batch.
996
- this.objectStorageActive = false;
997
- return 'disabled';
998
- }
999
-
1000
- const byFrameId = new Map(resp.frames.map(p => [p.frameId, p]));
1001
-
1002
- // Upload bytes directly to storage (backend never sees image bytes here).
1003
- await Promise.all(batch.map(async b => {
1004
- const p = byFrameId.get(b.frame.frameId);
1005
- if (!p) throw new Error(`No presign URL for frame ${b.frame.frameId}`);
1006
- await this._putBytes(p.uploadUrl, b.imageData, p.contentType);
1007
- }));
1008
-
1009
- // Persist key-only metadata (no base64 in the body).
1010
- const frames = batch.map(b => {
1011
- const p = byFrameId.get(b.frame.frameId)!;
1012
- return { ...this._frameMeta(b), storageKey: p.storageKey, contentType: p.contentType };
1013
- });
1014
- await this._post(ENDPOINTS.INGESTION_FRAMES(sessionId), { frames });
1015
- return 'sent';
1016
- }
1017
-
1018
- private async _flushEvents(): Promise<void> {
1019
- if (this.pendingEvents.length === 0 || !this.currentSessionId) return;
1020
-
1021
- const batch = this.pendingEvents.splice(0, 20);
1022
- const events = batch.map(e => this._leanEvent(e, e.sessionId));
1023
-
1024
- try {
1025
- logger.info(`[replay.sdk.event] backend event upload started`, { count: batch.length });
1026
- // Durable native outbox owns delivery when active (no duplicate JS POST).
1027
- // The native enqueue is NOT gated on row-readiness: it writes to disk and its
1028
- // uploader handles ordering/retry, so it must accept data even while offline.
1029
- if (await this._enqueueNative('events', events)) return;
1030
- // §11: JS-direct POST only after the session_start row exists; else re-buffer.
1031
- if (!this._sessionRowReady()) { this.pendingEvents.unshift(...batch); return; }
1032
- const eventsEndpoint = this.config.clientKey
1033
- ? ENDPOINTS.INGESTION_EVENTS(this.currentSessionId)
1034
- : `/replay/sessions/${this.currentSessionId}/events`;
1035
- await this._post(
1036
- eventsEndpoint,
1037
- { events },
1038
- );
1039
- logger.info(`[replay.sdk.event] backend event upload success`);
1040
- logger.debug(`[BackendSessionAdapter] Flushed ${batch.length} event(s)`);
1041
- } catch (err) {
1042
- if (BackendSessionAdapter._isPermanentHttpError(err)) return;
1043
- logger.warn(`[replay.sdk.error] backend event upload failure`, { count: batch.length });
1044
- this.pendingEvents.unshift(...batch);
1045
- }
1046
- }
1047
-
1048
- private async _flushNetwork(): Promise<void> {
1049
- if (this.pendingNetworkRequests.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1050
- const batch = this.pendingNetworkRequests.splice(0, 50);
1051
- try {
1052
- if (await this._enqueueNative('network', batch)) return;
1053
- if (!this._sessionRowReady()) { this.pendingNetworkRequests.unshift(...batch); return; }
1054
- await this._post(ENDPOINTS.INGESTION_NETWORK(this.currentSessionId), { requests: batch });
1055
- } catch (err) {
1056
- if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingNetworkRequests.unshift(...batch);
1057
- }
1058
- }
1059
-
1060
- private async _flushErrors(): Promise<void> {
1061
- if (this.pendingErrors.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1062
- const batch = this.pendingErrors.splice(0, 20);
1063
- try {
1064
- if (await this._enqueueNative('errors', batch)) return;
1065
- if (!this._sessionRowReady()) { this.pendingErrors.unshift(...batch); return; }
1066
- await this._post(ENDPOINTS.INGESTION_ERRORS(this.currentSessionId), { errors: batch });
1067
- } catch (err) {
1068
- if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingErrors.unshift(...batch);
1069
- }
1070
- }
1071
-
1072
- private async _flushPerformance(): Promise<void> {
1073
- if (this.pendingPerformanceMetrics.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1074
- const batch = this.pendingPerformanceMetrics.splice(0, 50);
1075
- try {
1076
- if (await this._enqueueNative('performance', batch)) return;
1077
- if (!this._sessionRowReady()) { this.pendingPerformanceMetrics.unshift(...batch); return; }
1078
- await this._post(ENDPOINTS.INGESTION_PERFORMANCE(this.currentSessionId), { metrics: batch });
1079
- } catch (err) {
1080
- if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingPerformanceMetrics.unshift(...batch);
1081
- }
1082
- }
1083
-
1084
- private async _flushLogs(): Promise<void> {
1085
- if (this.pendingLogs.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1086
- const batch = this.pendingLogs.splice(0, BackendSessionAdapter.LOGS_FLUSH_MAX);
1087
- try {
1088
- if (await this._enqueueNative('logs', batch as unknown as Array<Record<string, unknown>>)) return;
1089
- if (!this._sessionRowReady()) { this.pendingLogs.unshift(...batch); return; }
1090
- await this._post(ENDPOINTS.INGESTION_LOGS(this.currentSessionId), { logs: batch });
1091
- } catch (err) {
1092
- if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingLogs.unshift(...batch);
1093
- }
1094
- }
1095
-
1096
- // ─── Internal: Timer ────────────────────────────────────────────────
1097
-
1098
- private _startFlushTimer(): void {
1099
- this._stopFlushTimer();
1100
- this.flushTimer = setInterval(() => {
1101
- this._flushFrames().catch(() => { });
1102
- this._flushEvents().catch(() => { });
1103
- this._flushNetwork().catch(() => { });
1104
- this._flushErrors().catch(() => { });
1105
- this._flushPerformance().catch(() => { });
1106
- this._flushLogs().catch(() => { });
1107
- this._triggerNativeFlush();
1108
- }, this.config.flushIntervalMs);
1109
- }
1110
-
1111
- private _stopFlushTimer(): void {
1112
- if (this.flushTimer) {
1113
- clearInterval(this.flushTimer);
1114
- this.flushTimer = null;
1115
- }
1116
- }
1117
-
1118
- // ─── Internal: HTTP ─────────────────────────────────────────────────
1119
-
1120
- // A 4xx (except 408 Request Timeout / 429 Too Many Requests) is permanent:
1121
- // the same payload will never succeed, so requeuing it retries forever and
1122
- // floods the logs (e.g. a rejected clientKey HTTP 403 on every flush tick).
1123
- // Drop the batch on these; keep retrying 5xx / timeouts / network errors.
1124
- private static _isPermanentHttpError(err: unknown): boolean {
1125
- const status = (err as { status?: number })?.status;
1126
- return typeof status === 'number' && status >= 400 && status < 500 && status !== 408 && status !== 429;
1127
- }
1128
-
1129
- private async _post(path: string, body: unknown): Promise<void> {
1130
- const url = `${this.config.endpoint}${path}`;
1131
-
1132
- try {
1133
- const controller = new AbortController();
1134
- const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs);
1135
-
1136
- try {
1137
- const headers: Record<string, string> = { 'Content-Type': 'application/json' };
1138
- if (this.config.clientKey) {
1139
- headers['x-scalebun-client-key'] = this.config.clientKey;
1140
- }
1141
- const response = await fetch(url, {
1142
- method: 'POST',
1143
- headers,
1144
- body: JSON.stringify(body),
1145
- signal: controller.signal,
1146
- });
1147
-
1148
- if (!response.ok) {
1149
- logger.warn(`[BackendSessionAdapter] HTTP ${response.status} from ${path}`);
1150
- const httpErr = new Error(`HTTP ${response.status}`) as Error & { status?: number };
1151
- httpErr.status = response.status;
1152
- throw httpErr;
1153
- }
1154
- } finally {
1155
- clearTimeout(timeout);
1156
- }
1157
- } catch (err: any) {
1158
- if (err?.name === 'AbortError') {
1159
- logger.warn(`[BackendSessionAdapter] Timeout on ${path}`);
1160
- } else {
1161
- logger.warn(`[BackendSessionAdapter] Failed ${path}: ${err?.message}`);
1162
- }
1163
- throw err;
1164
- }
1165
- }
1166
-
1167
- /**
1168
- * POST that parses and returns the JSON response body. Mirrors _post's headers
1169
- * and timeout handling; used by the object-storage presign request, which needs
1170
- * the returned upload URLs (the void _post discards the body).
1171
- */
1172
- private async _postReturning<T>(path: string, body: unknown): Promise<T> {
1173
- const url = `${this.config.endpoint}${path}`;
1174
-
1175
- const controller = new AbortController();
1176
- const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs);
1177
- try {
1178
- const headers: Record<string, string> = { 'Content-Type': 'application/json' };
1179
- if (this.config.clientKey) {
1180
- headers['x-scalebun-client-key'] = this.config.clientKey;
1181
- }
1182
- const response = await fetch(url, {
1183
- method: 'POST',
1184
- headers,
1185
- body: JSON.stringify(body),
1186
- signal: controller.signal,
1187
- });
1188
- if (!response.ok) {
1189
- logger.warn(`[BackendSessionAdapter] HTTP ${response.status} from ${path}`);
1190
- const httpErr = new Error(`HTTP ${response.status}`) as Error & { status?: number };
1191
- httpErr.status = response.status;
1192
- throw httpErr;
1193
- }
1194
- return (await response.json()) as T;
1195
- } finally {
1196
- clearTimeout(timeout);
1197
- }
1198
- }
1199
-
1200
- /**
1201
- * PUT raw image bytes directly to a presigned storage URL. Decodes the base64
1202
- * frame payload to a binary Blob so the wire body is bytes, not a base64 string.
1203
- * No client key header the presigned URL carries its own auth.
1204
- */
1205
- private async _putBytes(uploadUrl: string, base64: string, contentType: string): Promise<void> {
1206
- // RN-safe base64→binary: decode to a Uint8Array and send that as the body.
1207
- // The `fetch('data:…').blob()` round-trip fails under the new architecture
1208
- // ("Network request failed"); RN's XHR sends a typed array as real binary.
1209
- const bytes = base64ToBytes(this._stripDataUri(base64));
1210
-
1211
- const controller = new AbortController();
1212
- const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs);
1213
- try {
1214
- const response = await fetch(uploadUrl, {
1215
- method: 'PUT',
1216
- headers: { 'Content-Type': contentType },
1217
- body: bytes,
1218
- signal: controller.signal,
1219
- });
1220
- if (!response.ok) {
1221
- throw new Error(`HTTP ${response.status}`);
1222
- }
1223
- } finally {
1224
- clearTimeout(timeout);
1225
- }
1226
- }
1227
-
1228
- /** Strip a leading `data:<mime>;base64,` prefix if the native layer included one. */
1229
- private _stripDataUri(s: string): string {
1230
- const comma = s.indexOf(',');
1231
- return s.startsWith('data:') && comma !== -1 ? s.slice(comma + 1) : s;
1232
- }
1233
- }
1
+ /**
2
+ * ScaleBun SDK — Backend Session Adapter
3
+ *
4
+ * Implements the SessionTransport interface (System A) and bridges
5
+ * session/frame/event data to the backend API via HTTP.
6
+ *
7
+ * This is the ADAPTER that connects the existing SessionManager
8
+ * (which only has DesktopSessionTransport) to the backend.
9
+ *
10
+ * Design:
11
+ * - Uses the same endpoint contract as BackendReplayTransport
12
+ * (POST /v1/replay/sessions, /frames, /events, /finalize)
13
+ * - Batches frames and events with auto-flush
14
+ * - Never throws — all errors are caught and logged
15
+ * - Behind config flag: only constructed when backendUpload is enabled
16
+ *
17
+ * This does NOT duplicate the existing BackendReplayTransport.
18
+ * It exists because SessionManager uses a different interface
19
+ * (SessionTransport from sessionTypes.ts) than ReplayTransport
20
+ * (from features/replay/transport/ReplayTransport.ts).
21
+ * The payload shapes differ, so this adapter maps between them.
22
+ *
23
+ * MVP/dev-only: base64 frames are sent inline in JSON body.
24
+ */
25
+
26
+ import { logger } from '../../core/logger/internalLogger';
27
+ import { base64ToBytes } from '../../core/encoding/base64';
28
+ import { ENDPOINTS } from '../../transport/http/endpoints';
29
+ import { SDK_VERSION } from '../../core/constants/version';
30
+ import { bridgeAdapter } from '../replay/bridge/adapters/bridgeAdapter';
31
+ import { getReplaySdkNative } from '../replay/bridge/nativeModule';
32
+ import type { ReplaySdkNativeModule } from '../replay/bridge/nativeModule';
33
+ import type { StorageBackend } from '../../storage/StorageBackend';
34
+ // Reused rather than reimplemented: `chunkEvents` is generic, order-preserving, and already carries
35
+ // a contract test proving it drops and duplicates nothing (analytics/__tests__/batchChunking.test.ts).
36
+ // Its internal ceiling (MAX_BATCH_EVENTS = 500) is well above the 100-frame cap passed here.
37
+ import { chunkEvents } from '../../analytics/batching';
38
+ import type {
39
+ SessionTransport,
40
+ Session,
41
+ SessionMetadata,
42
+ JourneyEvent,
43
+ ReplayFrame,
44
+ } from './sessionTypes';
45
+
46
+ // ─── Config ─────────────────────────────────────────────────────────────────
47
+
48
+ export interface BackendSessionConfig {
49
+ /** Backend API base URL (e.g. http://localhost:3001/api) */
50
+ endpoint: string;
51
+ /** Batch size for frames before auto-flush. Default: 5 */
52
+ batchSize?: number;
53
+ /** Auto-flush interval in ms. Default: 3000 */
54
+ flushIntervalMs?: number;
55
+ /** Request timeout in ms. Default: 15000 */
56
+ timeoutMs?: number;
57
+ /** SaaS multi-tenant client key enables ingestion endpoints and x-scalebun-client-key header */
58
+ clientKey?: string;
59
+ /**
60
+ * Upload frame bytes directly to object storage via presigned PUT instead of
61
+ * inline base64 in the JSON body. Default false → legacy inline path. Flip on
62
+ * after the backend presign endpoint is deployed. Falls back to inline
63
+ * automatically if the backend reports storage is not configured.
64
+ */
65
+ useObjectStorage?: boolean;
66
+ /**
67
+ * Route telemetry lanes (events/network/errors/performance/logs) through the
68
+ * durable NATIVE file outbox instead of JS-side HTTP. Only takes effect when BOTH
69
+ * this and `nativeOutboxUploadEnabled` are true AND the native module exposes the
70
+ * outbox methods otherwise the existing JS upload path is used unchanged. When
71
+ * active, the native uploader owns delivery (no duplicate JS POST). Default false.
72
+ */
73
+ enableNativeFileOutbox?: boolean;
74
+ /** Native outbox actually uploads (vs. capture/store-only). Gates telemetry routing. */
75
+ nativeOutboxUploadEnabled?: boolean;
76
+ /**
77
+ * Additive native-outbox tuning flags (retry interval, attempt caps, Retry-After,
78
+ * byte/age GC bounds, etc.) forwarded verbatim to the native `initOutbox` dict.
79
+ * Native parses both `nativeOutbox*` and bare `outbox*` keys and applies its own
80
+ * defaults for anything omitted — so an empty object changes nothing.
81
+ */
82
+ nativeOutboxTuning?: Record<string, unknown>;
83
+ /** Idle-gap threshold (ms) the SDK recorded with; persisted on the session row. */
84
+ idleThresholdMs?: number;
85
+ /**
86
+ * Durable key-value store used to persist the unflushed frame buffer across a
87
+ * process kill. On background the in-flight frames are snapshotted here; on the
88
+ * next launch they are re-uploaded and linked to the PRIOR session. Omitted →
89
+ * frame-kill recovery is disabled (in-memory only, prior behavior).
90
+ */
91
+ storage?: StorageBackend;
92
+ }
93
+
94
+ /**
95
+ * One platform-agnostic log line for the logs lane. The queue forwards whatever it is
96
+ * given — `source`/`platform` are neutral string hints set by the PRODUCER (console
97
+ * tags 'console'/'js'; a future native producer tags its own values onto this SAME
98
+ * shape). `level` is free-text. Nothing here is JS-specific.
99
+ */
100
+ export interface LogQueueItem {
101
+ level: string;
102
+ message: string;
103
+ source: string;
104
+ platform: string;
105
+ timestamp: string;
106
+ metadata?: Record<string, unknown>;
107
+ }
108
+
109
+ // ─── Adapter ────────────────────────────────────────────────────────────────
110
+
111
+ export class BackendSessionAdapter implements SessionTransport {
112
+ private config: Required<Omit<BackendSessionConfig, 'clientKey' | 'storage'>> & { clientKey?: string; storage?: StorageBackend };
113
+ /** Durable store for cross-kill frame recovery (null recovery disabled). */
114
+ private readonly _frameStore: StorageBackend | null;
115
+ /** Storage key for the snapshotted unflushed frame buffer (see persistPendingFrames). */
116
+ private static readonly PENDING_FRAMES_KEY = 'scalebun_replay_pending_frames';
117
+ /**
118
+ * Byte budget for the cross-kill frame snapshot (see `_selectFramesToPersist`).
119
+ *
120
+ * Replaces a flat 10-frame cap. A count could not bound the KV write at all — these frames carry
121
+ * base64 screenshots, so ten of them is anywhere from ~200 KB to several MB depending on device
122
+ * resolution, and an oversized value is exactly what fails on the background transition where
123
+ * this write happens.
124
+ *
125
+ * 2 MB is deliberately modest: this is a last-resort snapshot for frames that never reached the
126
+ * network, not a mirror of the session. Enough for a keyframe plus a run of deltas on any device;
127
+ * small enough that writing it cannot itself be the reason backgrounding stalls.
128
+ */
129
+ private static readonly MAX_PERSIST_BYTES = 2 * 1024 * 1024;
130
+ /**
131
+ * Frames the backend accepts in ONE request — `'Max 100 frames per batch'`
132
+ * (`IngestionService.uploadFrames`). Exceeding it is a 4xx, which this SDK classifies as
133
+ * permanent.
134
+ *
135
+ * This has to exist alongside the byte budget, not instead of it. The budget alone cannot bound
136
+ * the COUNT, and the count is what the server checks: measured on real traffic, mobile keyframes
137
+ * average ~16 KB, so a 2 MB snapshot is around 128 frames over the cap by construction. The old
138
+ * flat 10-frame rule was under it by construction, which is why this failure could not happen
139
+ * before and can now.
140
+ */
141
+ private static readonly MAX_FRAMES_PER_BATCH = 100;
142
+ // Per-session toggle: cleared to false if the backend reports storage disabled.
143
+ private objectStorageActive: boolean;
144
+ // True when telemetry should divert to the durable native outbox (both flags on).
145
+ // Native module availability is re-checked per call so a missing/old binary falls
146
+ // back to the JS path transparently.
147
+ private readonly nativeOutboxEnabled: boolean;
148
+ // Cached one-shot native-outbox bootstrap promise (see _ensureNativeOutbox).
149
+ private _nativeOutboxReady: Promise<boolean> | null = null;
150
+ private currentSessionId: string | null = null;
151
+ // §11 session_start ordering: a recording sessionId is added here ONLY after its
152
+ // INGESTION_START row is confirmed created on the backend (either via sendSessionStart's
153
+ // own POST, or via startAnalyticsSession when recording adopts the analytics id).
154
+ // Child telemetry lanes (frames/events/network/errors/perf/logs) refuse to flush until
155
+ // the row exists otherwise the backend 404s the child write. Data stays buffered and
156
+ // the flush timer retries, so nothing is lost to a start/child race. The durable native
157
+ // outbox path has its own ordering; this guards only the JS in-memory fallback.
158
+ private readonly _startedSessionIds = new Set<string>();
159
+ private pendingFrames: Array<{ frame: ReplayFrame; imageData: string }> = [];
160
+ private pendingEvents: JourneyEvent[] = [];
161
+ private pendingNetworkRequests: Array<Record<string, unknown>> = [];
162
+ private pendingErrors: Array<Record<string, unknown>> = [];
163
+ private pendingPerformanceMetrics: Array<Record<string, unknown>> = [];
164
+ // Platform-agnostic logs lane. Neutral by construction — holds whatever LogQueueItems
165
+ // it's handed (console today; native later) and forwards them untouched.
166
+ private pendingLogs: LogQueueItem[] = [];
167
+ private flushTimer: ReturnType<typeof setInterval> | null = null;
168
+ private destroyed = false;
169
+ /**
170
+ * Latch for `sdk_replay_capture_failed` — reported once per adapter, not once per rejected batch.
171
+ *
172
+ * A session whose row was never created rejects EVERY frame batch, so an unlatched report would
173
+ * emit one analytics event per flush for as long as the app stays open, on the same lane it is
174
+ * trying to report through.
175
+ */
176
+ private _captureFailureReported = false;
177
+
178
+ // ── Analytics lane (always-on, foreground-scoped; isolated from recording) ──
179
+ // Fully separate from currentSessionId/pendingEvents/_flushEvents, which serve
180
+ // recording. This lane carries user track() events and never touches recording
181
+ // state. One queue doubles as the pre-ready buffer (bounded, drop-oldest) and
182
+ // the outgoing queue; sessionId is stamped at flush so endpoint id == body id.
183
+ private static readonly ANALYTICS_BUFFER_CAP = 100;
184
+ /** Logs lane: queue length that triggers an eager flush (mirrors the network lane). */
185
+ private static readonly LOGS_BATCH_SIZE = 20;
186
+ /** Logs lane: max rows posted per flush (server caps at 200/batch). */
187
+ private static readonly LOGS_FLUSH_MAX = 50;
188
+ private _analyticsSessionId: string | null = null;
189
+ private pendingAnalyticsEvents: JourneyEvent[] = [];
190
+ private analyticsFlushTimer: ReturnType<typeof setInterval> | null = null;
191
+ // iOS finalize reconciliation: the id of a backgrounded analytics session whose
192
+ // INGESTION_FINALIZE has NOT been confirmed delivered. Set synchronously in
193
+ // finalizeAnalyticsSession before any await (so it survives an iOS suspension of
194
+ // the awaited fetch), cleared only on a confirmed finalize ACK. On the next
195
+ // foreground the listener calls reconcilePendingFinalize() to close it for real.
196
+ // In-memory is sufficient: the JS context survives background→foreground; only a
197
+ // true process kill drops it (covered by the server-side idle-close backstop).
198
+ private _pendingFinalizeId: string | null = null;
199
+
200
+ constructor(config: BackendSessionConfig) {
201
+ this.config = {
202
+ batchSize: 5,
203
+ flushIntervalMs: 3000,
204
+ timeoutMs: 15_000,
205
+ useObjectStorage: false,
206
+ enableNativeFileOutbox: false,
207
+ nativeOutboxUploadEnabled: false,
208
+ nativeOutboxTuning: {},
209
+ idleThresholdMs: 60_000,
210
+ ...config,
211
+ clientKey: config.clientKey,
212
+ };
213
+ this._frameStore = config.storage ?? null;
214
+ this.objectStorageActive = this.config.useObjectStorage;
215
+ this.nativeOutboxEnabled =
216
+ this.config.enableNativeFileOutbox && this.config.nativeOutboxUploadEnabled;
217
+ logger.info(`[ScaleBun Replay] backendUpload enabled`);
218
+ logger.info(`[ScaleBun Replay] backendBaseUrl: ${this.config.endpoint}`);
219
+ logger.info(`[ScaleBun Replay] transport fan-out active: desktop yes, backend yes`);
220
+ }
221
+
222
+ // ─── SessionTransport Interface ─────────────────────────────────────
223
+
224
+ /**
225
+ * §11 gate: true only when the current recording session's INGESTION_START row is
226
+ * confirmed on the backend. Child telemetry lanes consult this before flushing so they
227
+ * never race ahead of session creation (which would 404). Null id → not ready.
228
+ */
229
+ private _sessionRowReady(): boolean {
230
+ return !!this.currentSessionId && this._startedSessionIds.has(this.currentSessionId);
231
+ }
232
+
233
+ sendSessionStart(session: Session): void {
234
+ this.currentSessionId = session.sessionId;
235
+ this._startFlushTimer();
236
+
237
+ logger.info(`[ScaleBun Replay] session start requested`);
238
+ logger.info(`[ScaleBun Replay] sessionId: ${session.sessionId}`);
239
+ logger.info(`[ScaleBun Replay] deviceId: ${session.deviceId}`);
240
+ logger.info(`[ScaleBun Replay] recordingSessionId: ${session.sessionId}`);
241
+
242
+ // One-row merge: when recording adopted the always-on analytics id
243
+ // (SessionManager.startSession), the INGESTION_START row already exists.
244
+ // Do NOT post a second one — just keep the flush timer running so frames/
245
+ // journey/network/errors/perf flush to INGESTION_*(analyticsId). Legacy
246
+ // mode (no clientKey, distinct minted id) still posts /replay/sessions.
247
+ if (this.config.clientKey && session.sessionId === this._analyticsSessionId) {
248
+ logger.info(`[ScaleBun Replay] recording attached to analytics session ${session.sessionId} (no new row)`);
249
+ return;
250
+ }
251
+
252
+ logger.info(`[ScaleBun Replay] backend session upload started`);
253
+
254
+ const startEndpoint = this.config.clientKey ? ENDPOINTS.INGESTION_START : '/replay/sessions';
255
+
256
+ // Fetch native device info to enrich the session payload.
257
+ // Falls back to metadata-only if bridge unavailable (old native binary).
258
+ bridgeAdapter.getDeviceInfo()
259
+ .then(nativeInfo => {
260
+ const m = session.metadata;
261
+ const payload = {
262
+ sessionId: session.sessionId,
263
+ deviceId: session.deviceId,
264
+ startedAt: session.startedAt,
265
+ // Link the recording row to the always-on analytics row so the
266
+ // dashboard can join them. track() events land on the analytics
267
+ // id; frames/journey land on this recording id. Without this
268
+ // link the two appear as separate sessions (one looks "empty").
269
+ // BACKEND DEPENDENCY: the dashboard must read/join on this field
270
+ // (or treat the analytics row as canonical) to fully merge them.
271
+ analyticsSessionId: this._analyticsSessionId,
272
+ // Carry the idle threshold on the recording lane too: it may
273
+ // create the row before the analytics lane does. Backend
274
+ // upsert leaves it untouched if already set.
275
+ idleThresholdMs: this.config.idleThresholdMs,
276
+ device: {
277
+ platform: nativeInfo?.platform ?? m?.platform,
278
+ osVersion: nativeInfo?.osVersion ?? m?.osVersion,
279
+ deviceModel: nativeInfo?.deviceModel ?? m?.deviceModel,
280
+ screenWidth: m?.screenWidth,
281
+ screenHeight: m?.screenHeight,
282
+ appName: nativeInfo?.appName ?? m?.appName,
283
+ appVersion: nativeInfo?.appVersion ?? m?.appVersion,
284
+ bundleId: nativeInfo?.bundleId ?? m?.bundleId,
285
+ sdkVersion: SDK_VERSION,
286
+ releaseStage: m?.buildType,
287
+ // Backend ingestion source not in this repo; field name
288
+ // unconfirmed. Send both so whichever it reads is populated.
289
+ environment: m?.buildType,
290
+ },
291
+ };
292
+ logger.debug(`[BackendSessionAdapter] POST session start: ${session.sessionId}`);
293
+ return this._post(startEndpoint, payload);
294
+ })
295
+ .then(() => {
296
+ // §11: row now exists — release the child-lane flush gate for this id.
297
+ this._startedSessionIds.add(session.sessionId);
298
+ logger.info(`[ScaleBun Replay] backend session upload success`);
299
+ })
300
+ .catch(() => logger.info(`[ScaleBun Replay] backend session upload failure`));
301
+ }
302
+
303
+ sendSessionEnd(session: Session): void {
304
+ logger.info(`[ScaleBun Replay] finalize started`);
305
+ // Flush all pending data first, then finalize
306
+ Promise.all([
307
+ this._flushFrames(),
308
+ this._flushEvents(),
309
+ this._flushNetwork(),
310
+ this._flushErrors(),
311
+ this._flushPerformance(),
312
+ ]).then(() => {
313
+ // One-row merge: if this recording adopted the always-on analytics id,
314
+ // the analytics lane owns the session's lifecycle and finalizes it on
315
+ // background (finalizeAnalyticsSession). Finalizing here would close the
316
+ // shared row mid-foreground and orphan later track() events — so flush
317
+ // (above) but skip finalize. Legacy/distinct-id sessions finalize normally.
318
+ if (this.config.clientKey && session.sessionId === this._analyticsSessionId) {
319
+ logger.info(`[ScaleBun Replay] recording ended; analytics session ${session.sessionId} stays open`);
320
+ return;
321
+ }
322
+ const finalizeEndpoint = this.config.clientKey
323
+ ? ENDPOINTS.INGESTION_FINALIZE(session.sessionId)
324
+ : `/replay/sessions/${session.sessionId}/finalize`;
325
+ return this._post(
326
+ finalizeEndpoint,
327
+ {
328
+ endedAt: session.endedAt ?? Date.now(),
329
+ durationMs: session.endedAt
330
+ ? session.endedAt - session.startedAt
331
+ : Date.now() - session.startedAt,
332
+ totalFrames: session.artifactIndex?.frameRefs?.length ?? 0,
333
+ totalEvents: session.artifactIndex?.eventRefs?.length ?? 0,
334
+ finalState: session.status === 'timeout' ? 'timeout' : 'completed',
335
+ },
336
+ );
337
+ }).then(() => {
338
+ logger.info(`[ScaleBun Replay] finalize success`);
339
+ }).catch(() => {
340
+ logger.info(`[ScaleBun Replay] finalize failure`);
341
+ }).finally(() => {
342
+ this._stopFlushTimer();
343
+ // Keep the row-ready gate OPEN for a merged analytics session. The analytics
344
+ // lane still owns it (not finalized on background — the session spans the
345
+ // app-switch), so a foreground restart re-adopts the SAME id and must keep
346
+ // flushing frames/events. Dropping the gate here would 404-buffer everything
347
+ // after the first background cycle. Only clear it for a distinct/legacy
348
+ // recording id that was actually finalized above.
349
+ if (!(this.config.clientKey && session.sessionId === this._analyticsSessionId)) {
350
+ this._startedSessionIds.delete(session.sessionId);
351
+ }
352
+ // Session end: drain any durably-stored telemetry from the native outbox.
353
+ this._triggerNativeFlush();
354
+ logger.debug(`[BackendSessionAdapter] Session finalized: ${session.sessionId}`);
355
+ });
356
+ }
357
+
358
+ // ─── Analytics Lane (isolated from recording) ───────────────────────
359
+
360
+ /** Public: the always-on analytics session id, or null before it opens. */
361
+ get analyticsSessionId(): string | null {
362
+ return this._analyticsSessionId;
363
+ }
364
+
365
+ /**
366
+ * Open the always-on analytics ingestion session. Sets the analytics id,
367
+ * starts the analytics flush timer, replays any pre-ready buffered events,
368
+ * and POSTs INGESTION_START. Mirrors sendSessionStart's body builder but
369
+ * never touches currentSessionId (recording lane).
370
+ */
371
+ async startAnalyticsSession(session: {
372
+ sessionId: string;
373
+ deviceId: string;
374
+ startedAt: number;
375
+ metadata?: SessionMetadata;
376
+ /** Idle-gap threshold (ms) the SDK declares for this session; echoed by the
377
+ * backend so the dashboard uses the same value to draw idle bands. */
378
+ idleThresholdMs?: number;
379
+ }): Promise<void> {
380
+ if (this.destroyed) return;
381
+ this._analyticsSessionId = session.sessionId;
382
+ // A new session gets its own capture-failure report. The latch bounds reports WITHIN a
383
+ // session; left standing across sessions it silenced every session after the first in the
384
+ // app process, which is the one place this differs from the web SDK — that pipeline is
385
+ // constructed per page and its session id is readonly, so its latch cannot outlive a session.
386
+ this._captureFailureReported = false;
387
+ this._startAnalyticsFlushTimer();
388
+
389
+ // Replay pre-ready buffered events now that the id exists. sessionId is
390
+ // stamped at flush time, so buffered events need no rewrite.
391
+ this._flushAnalyticsEvents().catch(() => { });
392
+
393
+ const startEndpoint = this.config.clientKey ? ENDPOINTS.INGESTION_START : '/replay/sessions';
394
+ try {
395
+ const nativeInfo = await bridgeAdapter.getDeviceInfo();
396
+ const m = session.metadata;
397
+ const payload = {
398
+ sessionId: session.sessionId,
399
+ deviceId: session.deviceId,
400
+ startedAt: session.startedAt,
401
+ idleThresholdMs: session.idleThresholdMs,
402
+ device: {
403
+ platform: nativeInfo?.platform ?? m?.platform,
404
+ osVersion: nativeInfo?.osVersion ?? m?.osVersion,
405
+ deviceModel: nativeInfo?.deviceModel ?? m?.deviceModel,
406
+ screenWidth: m?.screenWidth,
407
+ screenHeight: m?.screenHeight,
408
+ appName: nativeInfo?.appName ?? m?.appName,
409
+ appVersion: nativeInfo?.appVersion ?? m?.appVersion,
410
+ bundleId: nativeInfo?.bundleId ?? m?.bundleId,
411
+ sdkVersion: SDK_VERSION,
412
+ releaseStage: m?.buildType,
413
+ environment: m?.buildType,
414
+ },
415
+ };
416
+ await this._post(startEndpoint, payload);
417
+ // §11: row exists. When recording adopts this analytics id (one-row merge),
418
+ // this also releases the recording child-lane gate (_sessionRowReady).
419
+ this._startedSessionIds.add(session.sessionId);
420
+ // Row is confirmed — replay any events buffered while START was in flight.
421
+ // The pre-ack flush at the top of this method is gated off until now, so
422
+ // this is what actually drains the pre-ready buffer (no premature 404).
423
+ this._flushAnalyticsEvents().catch(() => { });
424
+ logger.info(`[ScaleBun Analytics] session start upload success: ${session.sessionId}`);
425
+ } catch {
426
+ logger.info(`[ScaleBun Analytics] session start upload failure`);
427
+ }
428
+ }
429
+
430
+ /**
431
+ * Enqueue a user track() event. Buffers (bounded, drop-oldest) when the
432
+ * analytics session is not yet open; flushes at >=20 once it is.
433
+ */
434
+ trackEvent(event: JourneyEvent): void {
435
+ if (this.destroyed) return;
436
+ this.pendingAnalyticsEvents.push(event);
437
+ const overflow = this.pendingAnalyticsEvents.length - BackendSessionAdapter.ANALYTICS_BUFFER_CAP;
438
+ if (overflow > 0) {
439
+ this.pendingAnalyticsEvents.splice(0, overflow); // drop oldest
440
+ }
441
+ if (this._analyticsSessionId && this.pendingAnalyticsEvents.length >= 20) {
442
+ this._flushAnalyticsEvents().catch(() => { });
443
+ }
444
+ }
445
+
446
+ /**
447
+ * Emit an app-lifecycle boundary marker (APP_BACKGROUND / APP_FOREGROUND) onto
448
+ * the analytics lane so the dashboard can shade the backgrounded span on the
449
+ * replay timeline and exclude it from the active duration. Timestamp is captured
450
+ * at the transition (accurate even if delivery is deferred until the next
451
+ * foreground on iOS). No-op when no analytics session is open. The sessionId is
452
+ * (re)stamped at flush time, so passing the current id here is only a placeholder.
453
+ */
454
+ emitLifecycleMarker(
455
+ type: 'APP_BACKGROUND' | 'APP_FOREGROUND',
456
+ payload?: Record<string, unknown>,
457
+ ): void {
458
+ if (this.destroyed || !this._analyticsSessionId) return;
459
+ this.trackEvent({
460
+ eventId: this._clientId(),
461
+ sessionId: this._analyticsSessionId,
462
+ ts: Date.now(),
463
+ type,
464
+ source: 'sdk',
465
+ ...(payload ? { payload } : {}),
466
+ });
467
+ }
468
+
469
+ /**
470
+ * Public: force-flush queued analytics events immediately. Called on
471
+ * APP_BACKGROUND so the lifecycle marker (and any buffered track events) reach
472
+ * the backend before the OS suspends the flush timer. Best-effort on iOS, where
473
+ * the POST may not resolve until the next foreground — the events stay buffered
474
+ * with accurate timestamps and flush then.
475
+ */
476
+ flushAnalytics(): Promise<void> {
477
+ return this._flushAnalyticsEvents();
478
+ }
479
+
480
+ /**
481
+ * Flush queued analytics events. Mirrors _flushEvents (recording) byte for
482
+ * byte on the wire map, but gates on _analyticsSessionId and STAMPS that id
483
+ * into every event so endpoint id == body sessionId by construction.
484
+ */
485
+ private async _flushAnalyticsEvents(forSessionId?: string): Promise<void> {
486
+ // finalize clears _analyticsSessionId synchronously, then passes the
487
+ // captured id here so the final drain still targets the right session.
488
+ const sessionId = forSessionId ?? this._analyticsSessionId;
489
+ if (this.pendingAnalyticsEvents.length === 0 || !sessionId) return;
490
+
491
+ // Row-confirmed gate (mirrors the recording lanes' _sessionRowReady). The
492
+ // INGESTION_START create is async and can fail/lag; flushing events before
493
+ // the row exists 404s the child write and re-buffers forever. Keep events
494
+ // queued (bounded, drop-oldest via trackEvent) until START is acked.
495
+ if (!this._startedSessionIds.has(sessionId)) return;
496
+
497
+ const batch = this.pendingAnalyticsEvents.splice(0, 20);
498
+ const events = batch.map(e => this._leanEvent(e, sessionId));
499
+
500
+ try {
501
+ const eventsEndpoint = this.config.clientKey
502
+ ? ENDPOINTS.INGESTION_EVENTS(sessionId)
503
+ : `/replay/sessions/${sessionId}/events`;
504
+ await this._post(eventsEndpoint, { events });
505
+ logger.debug(`[BackendSessionAdapter] Flushed ${batch.length} analytics event(s)`);
506
+ } catch (err) {
507
+ if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingAnalyticsEvents.unshift(...batch);
508
+ }
509
+ }
510
+
511
+ /** Flush remaining analytics events, finalize the session, stop its timer. */
512
+ async finalizeAnalyticsSession(): Promise<void> {
513
+ const sessionId = this._analyticsSessionId;
514
+ if (!sessionId) return;
515
+
516
+ // Clear the id and stop the timer SYNCHRONOUSLY, before any await. On iOS
517
+ // the app is suspended on background and the finalize fetch below never
518
+ // resolves until the next foreground, so the old `finally` that nulled the
519
+ // id never ran before the resume guard (SDKBootstrapper: `state==='active'
520
+ // && !adapter.analyticsSessionId`) evaluated → guard stayed false → no new
521
+ // session opened. Clearing up front makes the guard always see null after
522
+ // background, so resume re-opens a fresh analytics session every cycle.
523
+ this._analyticsSessionId = null;
524
+ this._stopAnalyticsFlushTimer();
525
+
526
+ // Mark as pending-finalize BEFORE any await. On iOS the app suspends right
527
+ // after backgrounding, so the awaited _post below may never resolve. Setting
528
+ // the marker synchronously guarantees the next foreground can reconcile-close
529
+ // this id even though the background POST was suspended. Cleared only on a
530
+ // confirmed ACK (below), so a suspended POST leaves the marker in place.
531
+ this._pendingFinalizeId = sessionId;
532
+
533
+ try {
534
+ // Pass the captured id explicitly the field is already cleared.
535
+ await this._flushAnalyticsEvents(sessionId);
536
+ const finalizeEndpoint = this.config.clientKey
537
+ ? ENDPOINTS.INGESTION_FINALIZE(sessionId)
538
+ : `/replay/sessions/${sessionId}/finalize`;
539
+ await this._post(finalizeEndpoint, { endedAt: Date.now() });
540
+ // Confirmed delivered → drop the marker so the foreground reconciler does
541
+ // NOT re-finalize this id (first half of the no-double-finalize guard).
542
+ if (this._pendingFinalizeId === sessionId) this._pendingFinalizeId = null;
543
+ logger.debug(`[BackendSessionAdapter] Analytics session finalized: ${sessionId}`);
544
+ } catch {
545
+ // Leave the marker set — foreground reconciliation will retry the close.
546
+ logger.info(`[ScaleBun Analytics] finalize failure (will reconcile on foreground): ${sessionId}`);
547
+ }
548
+ }
549
+
550
+ /**
551
+ * Close any analytics session left open by a suspended background finalize.
552
+ * Called on the NEXT foreground (SDKBootstrapper app-state 'active') BEFORE a new
553
+ * analytics session is opened. JS is live on foreground, so this POST completes.
554
+ * No-op when there is no pending id. Idempotent with the background finalize: the
555
+ * marker is cleared on a confirmed background ACK, so this only fires when the
556
+ * background POST was NOT confirmed; if that suspended POST later also lands, the
557
+ * server must treat a repeat INGESTION_FINALIZE for the same id as a no-op.
558
+ */
559
+ async reconcilePendingFinalize(): Promise<void> {
560
+ const sessionId = this._pendingFinalizeId;
561
+ if (!sessionId) return;
562
+
563
+ try {
564
+ const finalizeEndpoint = this.config.clientKey
565
+ ? ENDPOINTS.INGESTION_FINALIZE(sessionId)
566
+ : `/replay/sessions/${sessionId}/finalize`;
567
+ await this._post(finalizeEndpoint, { endedAt: Date.now() });
568
+ logger.info(`[ScaleBun Analytics] reconciled finalize on foreground: ${sessionId}`);
569
+ } catch {
570
+ logger.info(`[ScaleBun Analytics] foreground reconcile finalize failed: ${sessionId}`);
571
+ } finally {
572
+ // Clear after a foreground attempt regardless of outcome: JS is live here
573
+ // so a transient network error is rare, and the server-side idle-close
574
+ // backstop covers any still-orphaned row. Bounds total finalizes per id to
575
+ // at most 2 (suspended-bg + foreground) — never a per-foreground loop.
576
+ if (this._pendingFinalizeId === sessionId) this._pendingFinalizeId = null;
577
+ }
578
+ }
579
+
580
+ private _startAnalyticsFlushTimer(): void {
581
+ this._stopAnalyticsFlushTimer();
582
+ this.analyticsFlushTimer = setInterval(() => {
583
+ this._flushAnalyticsEvents().catch(() => { });
584
+ }, this.config.flushIntervalMs);
585
+ }
586
+
587
+ private _stopAnalyticsFlushTimer(): void {
588
+ if (this.analyticsFlushTimer) {
589
+ clearInterval(this.analyticsFlushTimer);
590
+ this.analyticsFlushTimer = null;
591
+ }
592
+ }
593
+
594
+ sendEvent(event: JourneyEvent): void {
595
+ if (this.destroyed) return;
596
+
597
+ logger.info(`[ScaleBun Replay] event recorded`);
598
+ logger.info(` eventId: ${event.eventId}`);
599
+ logger.info(` type: ${event.type}`);
600
+ logger.info(` timestamp: ${event.ts}`);
601
+ logger.info(` sessionId: ${event.sessionId}`);
602
+
603
+ this.pendingEvents.push(event);
604
+
605
+ if (this.pendingEvents.length >= 20) {
606
+ this._flushEvents().catch(() => { });
607
+ }
608
+ }
609
+
610
+ sendFrame(frame: ReplayFrame, imageData: string): void {
611
+ if (this.destroyed) return;
612
+
613
+ logger.info(`[ScaleBun Replay] frame captured`);
614
+ logger.info(` frameId: ${frame.frameId}`);
615
+ logger.info(` timestamp: ${frame.ts}`);
616
+ logger.info(` sessionId: ${frame.sessionId}`);
617
+ logger.info(` width/height: ${frame.width}x${frame.height}`);
618
+
619
+ this.pendingFrames.push({ frame, imageData });
620
+
621
+ if (this.pendingFrames.length >= this.config.batchSize) {
622
+ this._flushFrames().catch(() => { });
623
+ }
624
+ }
625
+
626
+ // ─── SaaS Ingestion Queues ──────────────────────────────────────────
627
+
628
+ queueNetworkRequest(data: {
629
+ method: string; url: string; statusCode?: number; duration?: number;
630
+ screenName?: string; error?: string; requestSize?: number; responseSize?: number;
631
+ requestHeaders?: Record<string, string>; responseHeaders?: Record<string, string>;
632
+ }): void {
633
+ if (this.destroyed || !this.config.clientKey) return;
634
+ // clientId: stable per-row idempotency key so a mobile retry of the same
635
+ // batch upserts instead of inserting duplicates server-side.
636
+ this.pendingNetworkRequests.push({ ...data, clientId: this._clientId(), timestamp: new Date().toISOString() });
637
+ if (this.pendingNetworkRequests.length >= 20) {
638
+ this._flushNetwork().catch(() => {});
639
+ }
640
+ }
641
+
642
+ queueError(data: {
643
+ type: string; message: string; stack?: string; screenName?: string;
644
+ }): void {
645
+ if (this.destroyed || !this.config.clientKey) return;
646
+ this.pendingErrors.push({ ...data, clientId: this._clientId(), timestamp: new Date().toISOString() });
647
+ if (this.pendingErrors.length >= 10) {
648
+ this._flushErrors().catch(() => {});
649
+ }
650
+ }
651
+
652
+ /** Public: force-flush queued errors immediately (handled-error delivery). */
653
+ flushErrors(): Promise<void> {
654
+ return this._flushErrors();
655
+ }
656
+
657
+ /**
658
+ * Public: flush ALL recording-lane queues immediately. Called on APP_BACKGROUND
659
+ * so the server-side reaper computes endedAt from the freshest data even when
660
+ * the OS suspends the flush timer right after backgrounding.
661
+ */
662
+ async flushAll(): Promise<void> {
663
+ await Promise.all([
664
+ this._flushFrames(),
665
+ this._flushEvents(),
666
+ this._flushNetwork(),
667
+ this._flushErrors(),
668
+ this._flushPerformance(),
669
+ this._flushLogs(),
670
+ ]);
671
+ // Background trigger: close native segments + drain the native uploader so a
672
+ // suspended JS context doesn't strand durably-stored telemetry.
673
+ this._triggerNativeFlush();
674
+ }
675
+
676
+ queuePerformanceMetric(data: {
677
+ type: string; screenName?: string; duration?: number; value?: number;
678
+ metadata?: Record<string, unknown>;
679
+ }): void {
680
+ if (this.destroyed || !this.config.clientKey) return;
681
+ this.pendingPerformanceMetrics.push({ ...data, clientId: this._clientId(), timestamp: new Date().toISOString() });
682
+ if (this.pendingPerformanceMetrics.length >= 20) {
683
+ this._flushPerformance().catch(() => {});
684
+ }
685
+ }
686
+
687
+ /**
688
+ * Queue one log line onto the platform-agnostic logs lane. Mirrors
689
+ * queueNetworkRequest: drop when not in SaaS mode (no clientKey) or destroyed,
690
+ * batch-flush at LOGS_BATCH_SIZE. The producer supplies source/platform/level —
691
+ * this method makes NO assumptions about them, so a native producer reuses it as-is.
692
+ */
693
+ queueLog(data: {
694
+ level: string; message: string; source: string; platform: string;
695
+ timestamp?: string; metadata?: Record<string, unknown>;
696
+ }): void {
697
+ if (this.destroyed || !this.config.clientKey) return;
698
+ this.pendingLogs.push({
699
+ level: data.level,
700
+ message: data.message,
701
+ source: data.source,
702
+ platform: data.platform,
703
+ timestamp: data.timestamp ?? new Date().toISOString(),
704
+ ...(data.metadata ? { metadata: data.metadata } : {}),
705
+ });
706
+ if (this.pendingLogs.length >= BackendSessionAdapter.LOGS_BATCH_SIZE) {
707
+ this._flushLogs().catch(() => {});
708
+ }
709
+ }
710
+
711
+ /** Stable client-generated idempotency id (matches journeyManager id scheme). */
712
+ private _clientId(): string {
713
+ return `${Date.now().toString(36)}-${Math.random().toString(36).substring(2, 10)}`;
714
+ }
715
+
716
+ // ─── Native outbox routing ──────────────────────────────────────────
717
+
718
+ /**
719
+ * Hand a telemetry batch to the durable native outbox. Returns true if native
720
+ * accepted it (native uploader now owns delivery — caller must NOT also POST).
721
+ * Returns false on any miss (flag off, no session, old binary, native error) so
722
+ * the caller falls back to the JS HTTP path with the batch intact.
723
+ */
724
+ private async _enqueueNative(
725
+ lane: 'events' | 'network' | 'errors' | 'performance' | 'logs',
726
+ records: Array<Record<string, unknown>>,
727
+ ): Promise<boolean> {
728
+ if (!this.nativeOutboxEnabled || !this.currentSessionId) return false;
729
+ const native = getReplaySdkNative();
730
+ if (!native?.enqueueOutboxRecords) return false;
731
+ if (!(await this._ensureNativeOutbox(native))) return false;
732
+ try {
733
+ return await native.enqueueOutboxRecords(lane, this.currentSessionId, records);
734
+ } catch {
735
+ return false;
736
+ }
737
+ }
738
+
739
+ /**
740
+ * Bootstrap the native outbox once. In SaaS mode the native module's full
741
+ * `initialize()` (which builds a SessionManager) is never called, so the
742
+ * NativeOutbox/uploader would not exist. `initOutbox` constructs only the
743
+ * durable outbox from clientKey/apiBaseUrl/flags. Idempotent + cached so it
744
+ * runs at most once; resolves false on old binaries (caller falls back to JS).
745
+ */
746
+ private _ensureNativeOutbox(native: ReplaySdkNativeModule): Promise<boolean> {
747
+ if (this._nativeOutboxReady) return this._nativeOutboxReady;
748
+ if (!native.initOutbox) return Promise.resolve(false);
749
+ this._nativeOutboxReady = native
750
+ .initOutbox({
751
+ ...this.config.nativeOutboxTuning,
752
+ clientKey: this.config.clientKey,
753
+ apiBaseUrl: this.config.endpoint,
754
+ enableNativeFileOutbox: true,
755
+ nativeOutboxUploadEnabled: true,
756
+ useObjectStorageForFrames: this.config.useObjectStorage === true,
757
+ })
758
+ .catch(() => false);
759
+ return this._nativeOutboxReady;
760
+ }
761
+
762
+ /**
763
+ * Public readiness gate for the native frame outbox path (used by the frame
764
+ * capture adapter). Resolves true only when both outbox flags are on, a session
765
+ * exists, the native binary exposes the bridge, and `initOutbox` succeeded.
766
+ * Resolves false otherwise so the frame pipeline falls back to `captureScreenshot`.
767
+ */
768
+ ensureNativeOutboxReady(): Promise<boolean> {
769
+ if (!this.nativeOutboxEnabled || !this.currentSessionId) return Promise.resolve(false);
770
+ const native = getReplaySdkNative();
771
+ if (!native?.captureScreenshotToFile) return Promise.resolve(false);
772
+ return this._ensureNativeOutbox(native);
773
+ }
774
+
775
+ /** Best-effort: close native segments and drain the native uploader. Never throws. */
776
+ private _triggerNativeFlush(): void {
777
+ if (!this.nativeOutboxEnabled) return;
778
+ try {
779
+ getReplaySdkNative()?.flushNativeOutbox?.().catch(() => { });
780
+ } catch {
781
+ /* old binary / unavailable — ignore */
782
+ }
783
+ }
784
+
785
+ // ─── Lifecycle ──────────────────────────────────────────────────────
786
+
787
+ destroy(): void {
788
+ this.destroyed = true;
789
+ this._stopFlushTimer();
790
+ this._stopAnalyticsFlushTimer();
791
+ this.pendingFrames = [];
792
+ this.pendingEvents = [];
793
+ this.pendingAnalyticsEvents = [];
794
+ this.pendingNetworkRequests = [];
795
+ this.pendingErrors = [];
796
+ this.pendingPerformanceMetrics = [];
797
+ this.currentSessionId = null;
798
+ this._analyticsSessionId = null;
799
+ this._pendingFinalizeId = null;
800
+ this._startedSessionIds.clear();
801
+ }
802
+
803
+ // ─── Internal: Flush ────────────────────────────────────────────────
804
+
805
+ /** Wire metadata for a frame — real format/sizeBytes from native (no hardcoded literals). */
806
+ private _frameMeta(b: { frame: ReplayFrame; imageData: string }) {
807
+ const f = b.frame;
808
+ const format = f.format ?? 'jpeg';
809
+ // P2-5: a JSON frame-delta carries an application content type, not an image MIME.
810
+ const isJsonDelta = f.frameType === 'delta' && format === 'scalebun-framedelta';
811
+ const contentType = isJsonDelta
812
+ ? 'application/x-scalebun-framedelta+json'
813
+ : `image/${format}`;
814
+ return {
815
+ frameId: f.frameId,
816
+ sessionId: f.sessionId,
817
+ timestamp: f.ts,
818
+ // P2-0: real monotonic per-session sequence (was hardcoded 0 server-side).
819
+ sequenceNumber: f.sequenceNumber,
820
+ // P2-5: keyframe|delta + base reference for dashboard reconstruction.
821
+ frameType: f.frameType,
822
+ baseFrameId: f.baseFrameId,
823
+ screenName: f.screen ?? '',
824
+ trigger: f.captureReason ?? '',
825
+ format,
826
+ contentType,
827
+ width: f.width,
828
+ height: f.height,
829
+ sizeBytes: f.byteSize ?? 0,
830
+ masked: f.redactionState === 'full',
831
+ };
832
+ }
833
+
834
+ /**
835
+ * P2-4: build the lean (v2) wire payload for one event. Drops redundant/empty
836
+ * fields at the source while NEVER dropping fields the dashboard/analytics depend
837
+ * on (eventId, type, timestamp, sessionId). `label` is omitted when it equals
838
+ * `type` (the server defaults it back). `screenName` omitted when empty. `data`
839
+ * is pruned of null/''/undefined leaves (one level). The `v:2` marker lets the
840
+ * backend/dashboard pick the lean decoder; legacy (v1/no-marker) events still
841
+ * decode unchanged. See P2_CONTRACT.md §4.
842
+ */
843
+ private _leanEvent(e: JourneyEvent, sessionId: string): Record<string, unknown> {
844
+ const out: Record<string, unknown> = {
845
+ v: 2,
846
+ eventId: e.eventId,
847
+ sessionId,
848
+ type: e.type,
849
+ timestamp: e.ts,
850
+ };
851
+ const screen = e.screen ?? '';
852
+ if (screen) out.screenName = screen;
853
+ const label = e.subtype ?? e.type;
854
+ if (label && label !== e.type) out.label = label;
855
+ const data = this._pruneEmpty(e.payload);
856
+ if (data && Object.keys(data).length > 0) out.data = data;
857
+ return out;
858
+ }
859
+
860
+ /** Shallow-prune null/undefined/'' leaves from a payload object. */
861
+ private _pruneEmpty(payload: unknown): Record<string, unknown> | undefined {
862
+ if (!payload || typeof payload !== 'object') return undefined;
863
+ const src = payload as Record<string, unknown>;
864
+ const out: Record<string, unknown> = {};
865
+ for (const k of Object.keys(src)) {
866
+ const v = src[k];
867
+ if (v === null || v === undefined || v === '') continue;
868
+ out[k] = v;
869
+ }
870
+ return out;
871
+ }
872
+
873
+ private async _flushFrames(): Promise<void> {
874
+ if (this.pendingFrames.length === 0 || !this.currentSessionId) return;
875
+ // §11: hold frames until the session_start row is confirmed (else 404). Data stays
876
+ // buffered; the flush timer retries once the row lands.
877
+ if (!this._sessionRowReady()) return;
878
+ const sessionId = this.currentSessionId;
879
+
880
+ const batch = this.pendingFrames.splice(0, this.config.batchSize);
881
+ /**
882
+ * Chunked, because `config.batchSize` is HOST-CONFIGURABLE and the server's 100-frame cap is
883
+ * not. A host raising it past 100 previously turned every frame flush into a permanent 4xx —
884
+ * silent, total replay loss for that app, from a config value that looks like a tuning knob.
885
+ *
886
+ * A permanent rejection is reported and abandoned inside `_postFramesChunked`; what comes
887
+ * back is only what is still worth another attempt.
888
+ */
889
+ const remaining = await this._postFramesChunked(sessionId, batch);
890
+ if (remaining.length) {
891
+ logger.warn(`[replay.sdk.error] backend frame upload failure`, { count: remaining.length });
892
+ this.pendingFrames.unshift(...remaining);
893
+ return;
894
+ }
895
+ logger.debug(`[BackendSessionAdapter] Flushed ${batch.length} frame(s)`);
896
+ // Delivered the durable snapshot (if any) is now redundant. Clear it once
897
+ // the in-memory buffer is fully drained so a later kill can't replay
898
+ // already-uploaded frames.
899
+ if (this.pendingFrames.length === 0) this._clearPersistedFrames();
900
+ }
901
+
902
+ /**
903
+ * Report frames the SDK gave up on, on the analytics lane.
904
+ *
905
+ * SAME EVENT NAME AS THE WEB SDK (`sdk_replay_capture_failed`) with platform-specific `reason`
906
+ * values, so one dashboard breakdown reads both platforms without a concept-map alias — the two
907
+ * SDKs share no event vocabulary otherwise (`$pageview` vs `screen_viewed`), and adding a second
908
+ * name here would need an entry in `event-concepts.ts` for no benefit.
909
+ *
910
+ * Latched to once per session: a session whose row was never created rejects every batch, and an
911
+ * unlatched report would emit one event per flush for as long as the app is open.
912
+ *
913
+ * Best-effort and never throws — a diagnostic must not be able to break the capture path it
914
+ * describes.
915
+ */
916
+ private _reportCaptureFailure(stage: string, err: unknown, frameCount: number): void {
917
+ if (this._captureFailureReported) return;
918
+ this._captureFailureReported = true;
919
+ try {
920
+ if (!this._analyticsSessionId) return; // no lane open — nothing to attach it to
921
+ const status = (err as { status?: number })?.status;
922
+ this.trackEvent({
923
+ eventId: this._clientId(),
924
+ sessionId: this._analyticsSessionId,
925
+ ts: Date.now(),
926
+ type: 'sdk_replay_capture_failed',
927
+ source: 'sdk',
928
+ payload: {
929
+ stage,
930
+ // Platform-specific vocabulary. The HTTP status is the honest reason on this path:
931
+ // RN posts to the per-lane endpoints, which surface a real status unlike the web
932
+ // batch fan-out, whose 200 says nothing about what it stored.
933
+ reason: status ? `http_${status}` : 'upload_failed',
934
+ frames: frameCount,
935
+ platform: 'react-native',
936
+ },
937
+ } as unknown as JourneyEvent);
938
+ } catch {
939
+ // Diagnostics must never break the capture path.
940
+ }
941
+ }
942
+
943
+ /**
944
+ * Post frames in BACKEND-SAFE CHUNKS, and return the ones that were not durably accepted.
945
+ *
946
+ * WHY THIS EXISTS. `_postFrameBatch` issues exactly one request for whatever array it is handed,
947
+ * and both callers could hand it more than the server's 100-frame cap — the live flush via
948
+ * `config.batchSize`, and cross-kill recovery via the 2 MB persistence budget (~128 frames at the
949
+ * measured 16 KB average). The result was a 4xx, classified permanent, and on the recovery path
950
+ * that meant `_clearPersistedFrames()` — the ENTIRE cross-kill snapshot deleted because it was
951
+ * one frame too big to send in a single request it never needed to be sent in.
952
+ *
953
+ * THE RETURN VALUE IS THE POINT. The caller must be able to delete exactly what landed and keep
954
+ * exactly what did not, so this reports the survivors rather than throwing:
955
+ * - chunk accepted → dropped from the result (it is durably stored)
956
+ * - chunk PERMANENTLY refused dropped, and reported once. Re-sending identical bytes cannot
957
+ * succeed, and holding it would wedge every future launch on the
958
+ * same poison chunk. Only that chunk is abandoned; the rest still
959
+ * gets its chance, which is the whole difference from before.
960
+ * - chunk TRANSIENTLY failed → that chunk AND every chunk after it are kept, in order. We stop
961
+ * on the first transient failure rather than pressing on, because
962
+ * the usual cause is the network being gone and the rest would
963
+ * fail identically.
964
+ */
965
+ private async _postFramesChunked(
966
+ sessionId: string,
967
+ items: Array<{ frame: ReplayFrame; imageData: string }>,
968
+ ): Promise<Array<{ frame: ReplayFrame; imageData: string }>> {
969
+ const chunks = chunkEvents(items, BackendSessionAdapter.MAX_FRAMES_PER_BATCH);
970
+ for (let i = 0; i < chunks.length; i++) {
971
+ try {
972
+ await this._postFrameBatch(sessionId, chunks[i]);
973
+ } catch (err) {
974
+ if (BackendSessionAdapter._isPermanentHttpError(err)) {
975
+ this._reportCaptureFailure('upload-rejected', err, chunks[i].length);
976
+ continue;
977
+ }
978
+ return chunks.slice(i).flat();
979
+ }
980
+ }
981
+ return [];
982
+ }
983
+
984
+ /**
985
+ * POST one frame batch under an EXPLICIT sessionId (object-storage path when
986
+ * active, else legacy inline base64). Used by both the live flush and cross-kill
987
+ * recovery recovery passes the PRIOR session's id so orphaned frames relink to
988
+ * it. Throws on transient error so the caller can re-queue; frame writes are
989
+ * idempotent server-side (upsert by frameId), so a double-send is harmless.
990
+ */
991
+ private async _postFrameBatch(
992
+ sessionId: string,
993
+ batch: Array<{ frame: ReplayFrame; imageData: string }>,
994
+ ): Promise<void> {
995
+ if (batch.length === 0) return;
996
+ logger.info(`[replay.sdk.frame] backend frame upload started`, { count: batch.length });
997
+
998
+ // Object-storage path: presign → PUT bytes → post key-only metadata.
999
+ if (this.objectStorageActive && this.config.clientKey) {
1000
+ const result = await this._uploadFramesViaStorage(sessionId, batch);
1001
+ if (result === 'sent') {
1002
+ logger.info(`[replay.sdk.frame] backend frame upload success (object storage)`);
1003
+ return;
1004
+ }
1005
+ // 'disabled' storage not configured server-side; fall through to inline.
1006
+ }
1007
+
1008
+ // Legacy inline path: base64 in JSON body.
1009
+ const frames = batch.map(b => ({ ...this._frameMeta(b), imageData: b.imageData }));
1010
+ const framesEndpoint = this.config.clientKey
1011
+ ? ENDPOINTS.INGESTION_FRAMES(sessionId)
1012
+ : `/replay/sessions/${sessionId}/frames`;
1013
+ await this._post(framesEndpoint, { frames });
1014
+ logger.info(`[replay.sdk.frame] backend frame upload success`);
1015
+ }
1016
+
1017
+ // ─── Cross-kill frame recovery ──────────────────────────────────────
1018
+ //
1019
+ // Frames buffer in-memory (pendingFrames) and only reach the backend on flush.
1020
+ // A process kill (swipe-away, OOM) between captures loses the last frames the
1021
+ // user saw the iOS/Android background flush may be suspended before its POST
1022
+ // resolves. To close that gap we snapshot the unflushed buffer to the durable
1023
+ // KV store on background (survives kill), then re-upload it on the NEXT launch
1024
+ // linked to the PRIOR session id. Best-effort and never throws.
1025
+
1026
+ /**
1027
+ * Snapshot the current unflushed frame buffer to durable storage so it survives
1028
+ * a process kill. Called on APP_BACKGROUND before the (possibly-suspended)
1029
+ * network flush. Synchronous mirror write — reaches disk on the native store's
1030
+ * next coalesced flush. No-op if recovery storage is absent or nothing pending.
1031
+ */
1032
+ persistPendingFrames(): void {
1033
+ if (!this._frameStore || this.destroyed || !this.currentSessionId) return;
1034
+ if (this.pendingFrames.length === 0) return;
1035
+ try {
1036
+ const items = BackendSessionAdapter._selectFramesToPersist(this.pendingFrames);
1037
+ if (items.length === 0) return;
1038
+ this._frameStore.set(
1039
+ BackendSessionAdapter.PENDING_FRAMES_KEY,
1040
+ JSON.stringify({ sessionId: this.currentSessionId, items }),
1041
+ );
1042
+ } catch {
1043
+ // Serialization/storage failure must never break backgrounding.
1044
+ }
1045
+ }
1046
+
1047
+ /**
1048
+ * Choose which unflushed frames survive a process kill.
1049
+ *
1050
+ * WHY THIS IS NOT `slice(-10)`.
1051
+ *
1052
+ * The old rule kept the ten most RECENT frames, which is the wrong end of the buffer for replay.
1053
+ * A delta reconstructs against its base keyframe, so ten trailing deltas whose keyframe was
1054
+ * dropped are unplayable on their own — they arrive as `orphaned`, the state the dashboard flags
1055
+ * as a capture defect. Keeping the keyframe and fewer deltas yields a SHORTER replay; keeping the
1056
+ * deltas and no keyframe yields NO replay. That asymmetry is the whole decision.
1057
+ *
1058
+ * So: every keyframe is kept, then the most recent deltas fill whatever byte budget is left. This
1059
+ * mirrors the web SDK's `capBytes` policy (which sheds deltas first and never the keyframe), so
1060
+ * the two platforms lose the same thing under pressure instead of two different things.
1061
+ *
1062
+ * BYTES, not a frame count. A count is a poor proxy here: these carry base64 screenshots, so ten
1063
+ * frames may be 200 KB or 4 MB depending on device resolution — and this write goes to a KV store
1064
+ * on the background transition, where an oversized value is the thing most likely to fail and
1065
+ * lose the snapshot entirely. `imageData.length` is the base64 length, which is within ~1% of the
1066
+ * serialized cost and needs no extra pass.
1067
+ */
1068
+ private static _selectFramesToPersist(
1069
+ pending: Array<{ frame: ReplayFrame; imageData: string }>,
1070
+ ): Array<{ frame: ReplayFrame; imageData: string }> {
1071
+ const isKeyframe = (b: { frame: ReplayFrame }) => b.frame.frameType !== 'delta';
1072
+ const size = (b: { imageData: string }) => b.imageData?.length ?? 0;
1073
+
1074
+ const keep: Array<{ frame: ReplayFrame; imageData: string }> = [];
1075
+ let budget = BackendSessionAdapter.MAX_PERSIST_BYTES;
1076
+ /**
1077
+ * A COUNT cap as well as a byte budget.
1078
+ *
1079
+ * The byte budget is the right bound for the KV write; it is the wrong bound for the upload,
1080
+ * because the server checks a count. Recovery now chunks, so exceeding this is no longer
1081
+ * destructive — but persisting more than can ever be sent in one pass just guarantees leftover
1082
+ * work on every launch, and the frames past this point are the least valuable ones anyway.
1083
+ */
1084
+ const maxCount = BackendSessionAdapter.MAX_FRAMES_PER_BATCH;
1085
+
1086
+ // Keyframes first, newest back to oldest — a later keyframe supersedes an earlier one, so if
1087
+ // only one fits it should be the one closest to what the user last saw.
1088
+ for (let i = pending.length - 1; i >= 0; i--) {
1089
+ const b = pending[i];
1090
+ if (!isKeyframe(b)) continue;
1091
+ const cost = size(b);
1092
+ if (cost > budget || keep.length >= maxCount) continue;
1093
+ budget -= cost;
1094
+ keep.push(b);
1095
+ }
1096
+ // Then the most recent deltas with what remains.
1097
+ for (let i = pending.length - 1; i >= 0; i--) {
1098
+ const b = pending[i];
1099
+ if (isKeyframe(b)) continue;
1100
+ const cost = size(b);
1101
+ if (cost > budget || keep.length >= maxCount) continue;
1102
+ budget -= cost;
1103
+ keep.push(b);
1104
+ }
1105
+
1106
+ // Restore capture order: the backend orders frames by `sequenceNumber`, and the recovery POST
1107
+ // re-sends this array as-is.
1108
+ return keep.sort((a, b) => (a.frame.sequenceNumber ?? 0) - (b.frame.sequenceNumber ?? 0));
1109
+ }
1110
+
1111
+ /** Drop the persisted frame snapshot (after successful delivery). Never throws. */
1112
+ private _clearPersistedFrames(): void {
1113
+ if (!this._frameStore) return;
1114
+ try {
1115
+ this._frameStore.delete(BackendSessionAdapter.PENDING_FRAMES_KEY);
1116
+ } catch {
1117
+ /* non-fatal */
1118
+ }
1119
+ }
1120
+
1121
+ /**
1122
+ * On cold launch: if a prior run left an unflushed frame snapshot, re-upload it
1123
+ * linked to that PRIOR session, then clear it. Runs independently of the new
1124
+ * session (uses the stored id + a direct POST, bypassing the row-ready gate —
1125
+ * the prior session row already exists server-side). Best-effort; on transient
1126
+ * failure the snapshot is kept for the next launch.
1127
+ */
1128
+ async recoverPersistedFrames(): Promise<void> {
1129
+ if (!this._frameStore) return;
1130
+ let raw: string | undefined;
1131
+ try {
1132
+ raw = this._frameStore.get(BackendSessionAdapter.PENDING_FRAMES_KEY);
1133
+ } catch {
1134
+ return;
1135
+ }
1136
+ if (!raw) return;
1137
+
1138
+ let parsed: { sessionId?: string; items?: Array<{ frame: ReplayFrame; imageData: string }> };
1139
+ try {
1140
+ parsed = JSON.parse(raw);
1141
+ } catch {
1142
+ // Corrupt snapshot — discard so it can't wedge every launch.
1143
+ this._clearPersistedFrames();
1144
+ return;
1145
+ }
1146
+
1147
+ const sessionId = parsed.sessionId;
1148
+ const items = parsed.items;
1149
+ if (!sessionId || !Array.isArray(items) || items.length === 0) {
1150
+ this._clearPersistedFrames();
1151
+ return;
1152
+ }
1153
+
1154
+ logger.info(`[replay.sdk.frame] recovering ${items.length} frame(s) for prior session ${sessionId}`);
1155
+ /**
1156
+ * DELETE ONLY WHAT WAS ACCEPTED.
1157
+ *
1158
+ * This posted every recovered frame in ONE request and, on any permanent rejection, deleted
1159
+ * the whole snapshot. Since the persistence budget is 2 MB of ~16 KB frames, that request was
1160
+ * routinely over the server's 100-frame cap — so the common outcome was a 4xx followed by the
1161
+ * deletion of a cross-kill recovery snapshot in which every frame was individually fine. The
1162
+ * one thing a recovery buffer must never do.
1163
+ *
1164
+ * Now the send is chunked and only the unaccepted remainder survives. A chunk the server will
1165
+ * never take is abandoned inside `_postFramesChunked` (and reported), so a single poison chunk
1166
+ * cannot wedge every future launch — but a transient failure keeps its frames for next time.
1167
+ */
1168
+ const remaining = await this._postFramesChunked(sessionId, items);
1169
+ if (remaining.length === 0) {
1170
+ this._clearPersistedFrames();
1171
+ return;
1172
+ }
1173
+ logger.warn(`[replay.sdk.frame] prior-session frame recovery deferred`, { kept: remaining.length });
1174
+ try {
1175
+ this._frameStore.set(
1176
+ BackendSessionAdapter.PENDING_FRAMES_KEY,
1177
+ JSON.stringify({ sessionId, items: remaining }),
1178
+ );
1179
+ } catch {
1180
+ // Re-writing the trimmed snapshot is best-effort; the original is still on disk.
1181
+ }
1182
+ }
1183
+
1184
+ /**
1185
+ * Upload a batch via object storage. Returns 'sent' on success, 'disabled' if
1186
+ * the backend reports storage is not configured (caller falls back to inline).
1187
+ * Throws on transient error so the caller re-queues the batch.
1188
+ */
1189
+ private async _uploadFramesViaStorage(
1190
+ sessionId: string,
1191
+ batch: Array<{ frame: ReplayFrame; imageData: string }>,
1192
+ ): Promise<'sent' | 'disabled'> {
1193
+ const presignReq = batch.map(b => {
1194
+ const m = this._frameMeta(b);
1195
+ return { frameId: m.frameId, contentType: m.contentType, format: m.format };
1196
+ });
1197
+ const resp = await this._postReturning<{ enabled: boolean; frames: Array<{ frameId: string; uploadUrl: string; storageKey: string; bucket: string; contentType: string }> }>(
1198
+ ENDPOINTS.INGESTION_FRAMES_PRESIGN(sessionId),
1199
+ { frames: presignReq },
1200
+ );
1201
+
1202
+ if (!resp || resp.enabled === false) {
1203
+ // Latch off for the rest of the session so we don't presign every batch.
1204
+ this.objectStorageActive = false;
1205
+ return 'disabled';
1206
+ }
1207
+
1208
+ const byFrameId = new Map(resp.frames.map(p => [p.frameId, p]));
1209
+
1210
+ // Upload bytes directly to storage (backend never sees image bytes here).
1211
+ await Promise.all(batch.map(async b => {
1212
+ const p = byFrameId.get(b.frame.frameId);
1213
+ if (!p) throw new Error(`No presign URL for frame ${b.frame.frameId}`);
1214
+ await this._putBytes(p.uploadUrl, b.imageData, p.contentType);
1215
+ }));
1216
+
1217
+ // Persist key-only metadata (no base64 in the body).
1218
+ const frames = batch.map(b => {
1219
+ const p = byFrameId.get(b.frame.frameId)!;
1220
+ return { ...this._frameMeta(b), storageKey: p.storageKey, contentType: p.contentType };
1221
+ });
1222
+ await this._post(ENDPOINTS.INGESTION_FRAMES(sessionId), { frames });
1223
+ return 'sent';
1224
+ }
1225
+
1226
+ private async _flushEvents(): Promise<void> {
1227
+ if (this.pendingEvents.length === 0 || !this.currentSessionId) return;
1228
+
1229
+ const batch = this.pendingEvents.splice(0, 20);
1230
+ const events = batch.map(e => this._leanEvent(e, e.sessionId));
1231
+
1232
+ try {
1233
+ logger.info(`[replay.sdk.event] backend event upload started`, { count: batch.length });
1234
+ // Durable native outbox owns delivery when active (no duplicate JS POST).
1235
+ // The native enqueue is NOT gated on row-readiness: it writes to disk and its
1236
+ // uploader handles ordering/retry, so it must accept data even while offline.
1237
+ if (await this._enqueueNative('events', events)) return;
1238
+ // §11: JS-direct POST only after the session_start row exists; else re-buffer.
1239
+ if (!this._sessionRowReady()) { this.pendingEvents.unshift(...batch); return; }
1240
+ const eventsEndpoint = this.config.clientKey
1241
+ ? ENDPOINTS.INGESTION_EVENTS(this.currentSessionId)
1242
+ : `/replay/sessions/${this.currentSessionId}/events`;
1243
+ await this._post(
1244
+ eventsEndpoint,
1245
+ { events },
1246
+ );
1247
+ logger.info(`[replay.sdk.event] backend event upload success`);
1248
+ logger.debug(`[BackendSessionAdapter] Flushed ${batch.length} event(s)`);
1249
+ } catch (err) {
1250
+ if (BackendSessionAdapter._isPermanentHttpError(err)) return;
1251
+ logger.warn(`[replay.sdk.error] backend event upload failure`, { count: batch.length });
1252
+ this.pendingEvents.unshift(...batch);
1253
+ }
1254
+ }
1255
+
1256
+ private async _flushNetwork(): Promise<void> {
1257
+ if (this.pendingNetworkRequests.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1258
+ const batch = this.pendingNetworkRequests.splice(0, 50);
1259
+ try {
1260
+ if (await this._enqueueNative('network', batch)) return;
1261
+ if (!this._sessionRowReady()) { this.pendingNetworkRequests.unshift(...batch); return; }
1262
+ await this._post(ENDPOINTS.INGESTION_NETWORK(this.currentSessionId), { requests: batch });
1263
+ } catch (err) {
1264
+ if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingNetworkRequests.unshift(...batch);
1265
+ }
1266
+ }
1267
+
1268
+ private async _flushErrors(): Promise<void> {
1269
+ if (this.pendingErrors.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1270
+ const batch = this.pendingErrors.splice(0, 20);
1271
+ try {
1272
+ if (await this._enqueueNative('errors', batch)) return;
1273
+ if (!this._sessionRowReady()) { this.pendingErrors.unshift(...batch); return; }
1274
+ await this._post(ENDPOINTS.INGESTION_ERRORS(this.currentSessionId), { errors: batch });
1275
+ } catch (err) {
1276
+ if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingErrors.unshift(...batch);
1277
+ }
1278
+ }
1279
+
1280
+ private async _flushPerformance(): Promise<void> {
1281
+ if (this.pendingPerformanceMetrics.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1282
+ const batch = this.pendingPerformanceMetrics.splice(0, 50);
1283
+ try {
1284
+ if (await this._enqueueNative('performance', batch)) return;
1285
+ if (!this._sessionRowReady()) { this.pendingPerformanceMetrics.unshift(...batch); return; }
1286
+ await this._post(ENDPOINTS.INGESTION_PERFORMANCE(this.currentSessionId), { metrics: batch });
1287
+ } catch (err) {
1288
+ if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingPerformanceMetrics.unshift(...batch);
1289
+ }
1290
+ }
1291
+
1292
+ private async _flushLogs(): Promise<void> {
1293
+ if (this.pendingLogs.length === 0 || !this.currentSessionId || !this.config.clientKey) return;
1294
+ const batch = this.pendingLogs.splice(0, BackendSessionAdapter.LOGS_FLUSH_MAX);
1295
+ try {
1296
+ if (await this._enqueueNative('logs', batch as unknown as Array<Record<string, unknown>>)) return;
1297
+ if (!this._sessionRowReady()) { this.pendingLogs.unshift(...batch); return; }
1298
+ await this._post(ENDPOINTS.INGESTION_LOGS(this.currentSessionId), { logs: batch });
1299
+ } catch (err) {
1300
+ if (!BackendSessionAdapter._isPermanentHttpError(err)) this.pendingLogs.unshift(...batch);
1301
+ }
1302
+ }
1303
+
1304
+ // ─── Internal: Timer ────────────────────────────────────────────────
1305
+
1306
+ private _startFlushTimer(): void {
1307
+ this._stopFlushTimer();
1308
+ this.flushTimer = setInterval(() => {
1309
+ this._flushFrames().catch(() => { });
1310
+ this._flushEvents().catch(() => { });
1311
+ this._flushNetwork().catch(() => { });
1312
+ this._flushErrors().catch(() => { });
1313
+ this._flushPerformance().catch(() => { });
1314
+ this._flushLogs().catch(() => { });
1315
+ this._triggerNativeFlush();
1316
+ }, this.config.flushIntervalMs);
1317
+ }
1318
+
1319
+ private _stopFlushTimer(): void {
1320
+ if (this.flushTimer) {
1321
+ clearInterval(this.flushTimer);
1322
+ this.flushTimer = null;
1323
+ }
1324
+ }
1325
+
1326
+ // ─── Internal: HTTP ─────────────────────────────────────────────────
1327
+
1328
+ // A 4xx (except 408 Request Timeout / 429 Too Many Requests) is permanent:
1329
+ // the same payload will never succeed, so requeuing it retries forever and
1330
+ // floods the logs (e.g. a rejected clientKey → HTTP 403 on every flush tick).
1331
+ // Drop the batch on these; keep retrying 5xx / timeouts / network errors.
1332
+ private static _isPermanentHttpError(err: unknown): boolean {
1333
+ const status = (err as { status?: number })?.status;
1334
+ return typeof status === 'number' && status >= 400 && status < 500 && status !== 408 && status !== 429;
1335
+ }
1336
+
1337
+ private async _post(path: string, body: unknown): Promise<void> {
1338
+ const url = `${this.config.endpoint}${path}`;
1339
+
1340
+ try {
1341
+ const controller = new AbortController();
1342
+ const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs);
1343
+
1344
+ try {
1345
+ const headers: Record<string, string> = { 'Content-Type': 'application/json' };
1346
+ if (this.config.clientKey) {
1347
+ headers['x-scalebun-client-key'] = this.config.clientKey;
1348
+ }
1349
+ const response = await fetch(url, {
1350
+ method: 'POST',
1351
+ headers,
1352
+ body: JSON.stringify(body),
1353
+ signal: controller.signal,
1354
+ });
1355
+
1356
+ if (!response.ok) {
1357
+ logger.warn(`[BackendSessionAdapter] HTTP ${response.status} from ${path}`);
1358
+ const httpErr = new Error(`HTTP ${response.status}`) as Error & { status?: number };
1359
+ httpErr.status = response.status;
1360
+ throw httpErr;
1361
+ }
1362
+ } finally {
1363
+ clearTimeout(timeout);
1364
+ }
1365
+ } catch (err: any) {
1366
+ if (err?.name === 'AbortError') {
1367
+ logger.warn(`[BackendSessionAdapter] Timeout on ${path}`);
1368
+ } else {
1369
+ logger.warn(`[BackendSessionAdapter] Failed ${path}: ${err?.message}`);
1370
+ }
1371
+ throw err;
1372
+ }
1373
+ }
1374
+
1375
+ /**
1376
+ * POST that parses and returns the JSON response body. Mirrors _post's headers
1377
+ * and timeout handling; used by the object-storage presign request, which needs
1378
+ * the returned upload URLs (the void _post discards the body).
1379
+ */
1380
+ private async _postReturning<T>(path: string, body: unknown): Promise<T> {
1381
+ const url = `${this.config.endpoint}${path}`;
1382
+
1383
+ const controller = new AbortController();
1384
+ const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs);
1385
+ try {
1386
+ const headers: Record<string, string> = { 'Content-Type': 'application/json' };
1387
+ if (this.config.clientKey) {
1388
+ headers['x-scalebun-client-key'] = this.config.clientKey;
1389
+ }
1390
+ const response = await fetch(url, {
1391
+ method: 'POST',
1392
+ headers,
1393
+ body: JSON.stringify(body),
1394
+ signal: controller.signal,
1395
+ });
1396
+ if (!response.ok) {
1397
+ logger.warn(`[BackendSessionAdapter] HTTP ${response.status} from ${path}`);
1398
+ const httpErr = new Error(`HTTP ${response.status}`) as Error & { status?: number };
1399
+ httpErr.status = response.status;
1400
+ throw httpErr;
1401
+ }
1402
+ return (await response.json()) as T;
1403
+ } finally {
1404
+ clearTimeout(timeout);
1405
+ }
1406
+ }
1407
+
1408
+ /**
1409
+ * PUT raw image bytes directly to a presigned storage URL. Decodes the base64
1410
+ * frame payload to a binary Blob so the wire body is bytes, not a base64 string.
1411
+ * No client key header — the presigned URL carries its own auth.
1412
+ */
1413
+ private async _putBytes(uploadUrl: string, base64: string, contentType: string): Promise<void> {
1414
+ // RN-safe base64→binary: decode to a Uint8Array and send that as the body.
1415
+ // The `fetch('data:…').blob()` round-trip fails under the new architecture
1416
+ // ("Network request failed"); RN's XHR sends a typed array as real binary.
1417
+ const bytes = base64ToBytes(this._stripDataUri(base64));
1418
+
1419
+ const controller = new AbortController();
1420
+ const timeout = setTimeout(() => controller.abort(), this.config.timeoutMs);
1421
+ try {
1422
+ const response = await fetch(uploadUrl, {
1423
+ method: 'PUT',
1424
+ headers: { 'Content-Type': contentType },
1425
+ body: bytes,
1426
+ signal: controller.signal,
1427
+ });
1428
+ if (!response.ok) {
1429
+ throw new Error(`HTTP ${response.status}`);
1430
+ }
1431
+ } finally {
1432
+ clearTimeout(timeout);
1433
+ }
1434
+ }
1435
+
1436
+ /** Strip a leading `data:<mime>;base64,` prefix if the native layer included one. */
1437
+ private _stripDataUri(s: string): string {
1438
+ const comma = s.indexOf(',');
1439
+ return s.startsWith('data:') && comma !== -1 ? s.slice(comma + 1) : s;
1440
+ }
1441
+ }