@bugsee/react-native 0.0.0-stage → 7.0.0-beta2

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 (250) hide show
  1. package/BugseeReactNative.podspec +95 -0
  2. package/LICENSE +21 -0
  3. package/README.md +557 -2
  4. package/android/build.gradle +162 -0
  5. package/android/consumer-rules.pro +2 -0
  6. package/android/src/main/AndroidManifest.xml +33 -0
  7. package/android/src/main/java/com/bugsee/reactnative/AppearanceBridge.java +82 -0
  8. package/android/src/main/java/com/bugsee/reactnative/AttributeBridge.java +209 -0
  9. package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +443 -0
  10. package/android/src/main/java/com/bugsee/reactnative/BridgeJson.java +168 -0
  11. package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +1869 -0
  12. package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +136 -0
  13. package/android/src/main/java/com/bugsee/reactnative/BugseePackage.java +42 -0
  14. package/android/src/main/java/com/bugsee/reactnative/BugseeReactNativeWrapper.java +200 -0
  15. package/android/src/main/java/com/bugsee/reactnative/BugseeStatusMapper.java +66 -0
  16. package/android/src/main/java/com/bugsee/reactnative/BugseeTokens.java +22 -0
  17. package/android/src/main/java/com/bugsee/reactnative/ConsoleEchoDedup.java +202 -0
  18. package/android/src/main/java/com/bugsee/reactnative/CreatedReports.java +127 -0
  19. package/android/src/main/java/com/bugsee/reactnative/DataRequestBridge.java +375 -0
  20. package/android/src/main/java/com/bugsee/reactnative/ExceptionBridge.java +88 -0
  21. package/android/src/main/java/com/bugsee/reactnative/ExceptionExecutors.java +33 -0
  22. package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +375 -0
  23. package/android/src/main/java/com/bugsee/reactnative/NetworkEvents.java +227 -0
  24. package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +498 -0
  25. package/android/src/main/java/com/bugsee/reactnative/PluginEndpoint.java +48 -0
  26. package/android/src/main/java/com/bugsee/reactnative/ReactNativeWebException.java +19 -0
  27. package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +61 -0
  28. package/android/src/main/java/com/bugsee/reactnative/ReactRootOriginTracker.java +867 -0
  29. package/android/src/main/java/com/bugsee/reactnative/ReportArgs.java +58 -0
  30. package/android/src/main/java/com/bugsee/reactnative/ReportHandlerBridge.java +336 -0
  31. package/android/src/main/java/com/bugsee/reactnative/ReportHandlerDeadlines.java +57 -0
  32. package/android/src/main/java/com/bugsee/reactnative/ReportOps.java +287 -0
  33. package/android/src/main/java/com/bugsee/reactnative/SecureRectanglePulls.java +113 -0
  34. package/android/src/main/java/com/bugsee/reactnative/SecureRectangleStore.java +692 -0
  35. package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +143 -0
  36. package/android/src/main/java/com/bugsee/reactnative/WrapperChannelHolder.java +137 -0
  37. package/android/src/main/java/com/bugsee/reactnative/WrapperEventBus.java +110 -0
  38. package/android/src/main/java/com/bugsee/reactnative/WrapperRegistrar.java +54 -0
  39. package/app.plugin.js +4 -0
  40. package/ios/BGSRNConsoleCapture.h +52 -0
  41. package/ios/BGSRNConsoleCapture.mm +344 -0
  42. package/ios/BugseeModule.h +25 -0
  43. package/ios/BugseeModule.mm +2728 -0
  44. package/ios/Package.swift +71 -0
  45. package/ios/Support/Package.resolved +14 -0
  46. package/ios/Support/Package.swift +44 -0
  47. package/ios/Support/Sources/BugseeRNSupport/BGSRNAttributes.m +52 -0
  48. package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReportOps.m +236 -0
  49. package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReports.m +184 -0
  50. package/ios/Support/Sources/BugseeRNSupport/BGSRNDataRequestBridge.m +431 -0
  51. package/ios/Support/Sources/BugseeRNSupport/BGSRNErrorMessage.m +40 -0
  52. package/ios/Support/Sources/BugseeRNSupport/BGSRNEventBus.m +70 -0
  53. package/ios/Support/Sources/BugseeRNSupport/BGSRNExceptions.m +63 -0
  54. package/ios/Support/Sources/BugseeRNSupport/BGSRNGuardedEmit.mm +32 -0
  55. package/ios/Support/Sources/BugseeRNSupport/BGSRNJSON.m +40 -0
  56. package/ios/Support/Sources/BugseeRNSupport/BGSRNLaunchHold.m +147 -0
  57. package/ios/Support/Sources/BugseeRNSupport/BGSRNMainThread.m +23 -0
  58. package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkEvents.m +159 -0
  59. package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkFilter.m +155 -0
  60. package/ios/Support/Sources/BugseeRNSupport/BGSRNPluginEndpoint.m +21 -0
  61. package/ios/Support/Sources/BugseeRNSupport/BGSRNReactRootOriginTracker.m +63 -0
  62. package/ios/Support/Sources/BugseeRNSupport/BGSRNReactWindow.m +251 -0
  63. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportArgs.m +47 -0
  64. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportDeadlines.m +8 -0
  65. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportHandlerBridge.m +308 -0
  66. package/ios/Support/Sources/BugseeRNSupport/BGSRNReportOps.m +345 -0
  67. package/ios/Support/Sources/BugseeRNSupport/BGSRNSecureRectangles.m +508 -0
  68. package/ios/Support/Sources/BugseeRNSupport/BGSRNSettleOnce.m +62 -0
  69. package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +136 -0
  70. package/ios/Support/Sources/BugseeRNSupport/BGSRNStatusMapper.m +18 -0
  71. package/ios/Support/Sources/BugseeRNSupport/BGSRNTokens.m +9 -0
  72. package/ios/Support/Sources/BugseeRNSupport/BGSRNValues.m +5 -0
  73. package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +54 -0
  74. package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapperChannelHolder.m +59 -0
  75. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNAttributes.h +63 -0
  76. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +51 -0
  77. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReports.h +81 -0
  78. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDataRequestBridge.h +118 -0
  79. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNErrorMessage.h +30 -0
  80. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNEventBus.h +45 -0
  81. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNExceptions.h +31 -0
  82. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNGuardedEmit.h +31 -0
  83. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNJSON.h +25 -0
  84. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNLaunchHold.h +86 -0
  85. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNMainThread.h +32 -0
  86. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkEvents.h +28 -0
  87. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkFilter.h +28 -0
  88. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNPluginEndpoint.h +17 -0
  89. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactRootOriginTracker.h +48 -0
  90. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactWindow.h +135 -0
  91. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportArgs.h +17 -0
  92. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportDeadlines.h +37 -0
  93. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +94 -0
  94. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +86 -0
  95. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSecureRectangles.h +198 -0
  96. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSettleOnce.h +25 -0
  97. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +49 -0
  98. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNStatusMapper.h +26 -0
  99. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNTokens.h +14 -0
  100. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNValues.h +18 -0
  101. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapper.h +40 -0
  102. package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +74 -0
  103. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNAttributesTests.m +194 -0
  104. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportOpsTests.m +274 -0
  105. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportsTests.m +240 -0
  106. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDataRequestBridgeTests.m +685 -0
  107. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNErrorMessageTests.m +102 -0
  108. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNEventBusTests.m +136 -0
  109. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNExceptionsTests.m +68 -0
  110. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +41 -0
  111. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.m +166 -0
  112. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNGuardedEmitTests.mm +85 -0
  113. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNJSONTests.m +281 -0
  114. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNLaunchHoldTests.m +230 -0
  115. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNMainThreadTests.m +97 -0
  116. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkEventsTests.m +99 -0
  117. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkFilterTests.m +134 -0
  118. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNPluginEndpointTests.m +38 -0
  119. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactRootOriginTrackerTests.m +210 -0
  120. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactWindowTests.m +548 -0
  121. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportArgsTests.m +51 -0
  122. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportDeadlinesTests.m +22 -0
  123. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +382 -0
  124. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportOpsTests.m +295 -0
  125. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSecureRectanglesTests.m +568 -0
  126. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSettleOnceTests.m +134 -0
  127. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +153 -0
  128. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNStatusMapperTests.m +81 -0
  129. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNValuesTests.m +32 -0
  130. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +205 -0
  131. package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +66 -0
  132. package/ios/react-native-spm-prefix.h +10 -0
  133. package/native-versions.json +10 -0
  134. package/package.json +62 -3
  135. package/plugin/build/bundle-phase.d.ts +41 -0
  136. package/plugin/build/bundle-phase.js +116 -0
  137. package/plugin/build/bundle-phase.js.map +1 -0
  138. package/plugin/build/dsym-script.d.ts +32 -0
  139. package/plugin/build/dsym-script.js +159 -0
  140. package/plugin/build/dsym-script.js.map +1 -0
  141. package/plugin/build/endpoint.d.ts +30 -0
  142. package/plugin/build/endpoint.js +69 -0
  143. package/plugin/build/endpoint.js.map +1 -0
  144. package/plugin/build/gradle.d.ts +65 -0
  145. package/plugin/build/gradle.js +1066 -0
  146. package/plugin/build/gradle.js.map +1 -0
  147. package/plugin/build/index.d.ts +85 -0
  148. package/plugin/build/index.js +217 -0
  149. package/plugin/build/index.js.map +1 -0
  150. package/plugin/build/manifest.d.ts +48 -0
  151. package/plugin/build/manifest.js +69 -0
  152. package/plugin/build/manifest.js.map +1 -0
  153. package/plugin/build/native-versions.baked.json +4 -0
  154. package/plugin/build/native-versions.d.ts +10 -0
  155. package/plugin/build/native-versions.js +27 -0
  156. package/plugin/build/native-versions.js.map +1 -0
  157. package/plugin/build/pbx-string.d.ts +8 -0
  158. package/plugin/build/pbx-string.js +31 -0
  159. package/plugin/build/pbx-string.js.map +1 -0
  160. package/plugin/build/podfile.d.ts +3 -0
  161. package/plugin/build/podfile.js +28 -0
  162. package/plugin/build/podfile.js.map +1 -0
  163. package/plugin/build/properties.d.ts +19 -0
  164. package/plugin/build/properties.js +41 -0
  165. package/plugin/build/properties.js.map +1 -0
  166. package/plugin/build/scheme.d.ts +20 -0
  167. package/plugin/build/scheme.js +107 -0
  168. package/plugin/build/scheme.js.map +1 -0
  169. package/react-native.config.js +26 -0
  170. package/scripts/bugsee-sourcemaps.gradle +201 -0
  171. package/scripts/bugsee-xcode.sh +83 -0
  172. package/scripts/compose-then-inject.js +113 -0
  173. package/scripts/hermes-sourcemaps.js +634 -0
  174. package/scripts/hermesc-preserve-js.cmd +6 -0
  175. package/scripts/hermesc-preserve-js.js +200 -0
  176. package/scripts/hermesc-preserve-js.sh +7 -0
  177. package/src/NativeBugsee.ts +622 -0
  178. package/src/apm/notify.ts +58 -0
  179. package/src/apm/span.ts +403 -0
  180. package/src/apm/types.ts +57 -0
  181. package/src/appearance/report.ts +171 -0
  182. package/src/architecture.ts +48 -0
  183. package/src/attributes/errors.ts +39 -0
  184. package/src/attributes/validate.ts +150 -0
  185. package/src/breadcrumbs/add.ts +58 -0
  186. package/src/breadcrumbs/data.ts +33 -0
  187. package/src/breadcrumbs/filter.ts +215 -0
  188. package/src/breadcrumbs/types.ts +64 -0
  189. package/src/bridge/json.ts +110 -0
  190. package/src/console/capture.ts +180 -0
  191. package/src/console/dedup.ts +175 -0
  192. package/src/data/validate.ts +259 -0
  193. package/src/errorName.ts +32 -0
  194. package/src/exceptions/ErrorBoundary.tsx +92 -0
  195. package/src/exceptions/RootErrorReporter.tsx +61 -0
  196. package/src/exceptions/debugIds.ts +118 -0
  197. package/src/exceptions/handlers.ts +236 -0
  198. package/src/exceptions/options.ts +85 -0
  199. package/src/exceptions/payload.ts +456 -0
  200. package/src/exceptions/report.ts +170 -0
  201. package/src/exceptions/sha1.ts +148 -0
  202. package/src/exceptions/stack.ts +355 -0
  203. package/src/index.ts +962 -0
  204. package/src/logs/filter.ts +90 -0
  205. package/src/logs/log.ts +36 -0
  206. package/src/network/add.ts +165 -0
  207. package/src/network/filter.ts +198 -0
  208. package/src/options/AndroidLaunchOptions.ts +78 -0
  209. package/src/options/BugseeLaunchOptions.ts +190 -0
  210. package/src/options/IOSLaunchOptions.ts +57 -0
  211. package/src/options/android-options-manifest.json +646 -0
  212. package/src/options/createDefaultLaunchOptions.ts +29 -0
  213. package/src/options/endpoint.ts +58 -0
  214. package/src/options/enums.ts +104 -0
  215. package/src/options/ios-enums.json +19 -0
  216. package/src/options/keys.ts +39 -0
  217. package/src/options/option-enums.json +34 -0
  218. package/src/options/option-keys.json +107 -0
  219. package/src/report/BugseeReport.ts +264 -0
  220. package/src/report/CreatedReport.ts +127 -0
  221. package/src/report/dispatcher.ts +95 -0
  222. package/src/report/errors.ts +48 -0
  223. package/src/report/fields.ts +40 -0
  224. package/src/report/types.ts +157 -0
  225. package/src/report/validate.ts +197 -0
  226. package/src/secure/BugseeSecure.tsx +202 -0
  227. package/src/secure/ancestry.ts +622 -0
  228. package/src/secure/drivers.ts +342 -0
  229. package/src/secure/followEvents.ts +57 -0
  230. package/src/secure/hold.ts +99 -0
  231. package/src/secure/measureLoop.ts +323 -0
  232. package/src/secure/nativeAnimation.ts +1005 -0
  233. package/src/secure/rectangles.ts +93 -0
  234. package/src/secure/registry.ts +237 -0
  235. package/src/secure/surface.ts +83 -0
  236. package/src/secure/tracker.ts +723 -0
  237. package/src/secure/transition.ts +488 -0
  238. package/src/secure/unit.ts +22 -0
  239. package/src/status.ts +16 -0
  240. package/src/version.ts +9 -0
  241. package/src/viewtree/anchor.tsx +105 -0
  242. package/src/viewtree/constants.ts +20 -0
  243. package/src/viewtree/fiber.ts +251 -0
  244. package/src/viewtree/requests.ts +347 -0
  245. package/src/viewtree/walk.ts +902 -0
  246. package/src/wrapper/channel.ts +33 -0
  247. package/src/wrapper/collect.ts +52 -0
  248. package/src/wrapper/events.ts +45 -0
  249. package/src/wrapper/identity.ts +54 -0
  250. package/src/wrapper/lifecycle-events.ts +89 -0
@@ -0,0 +1,162 @@
1
+ // The Android side of the bridge.
2
+ //
3
+ // Split deliberately: everything in `com.bugsee.reactnative` that translates
4
+ // between the JS wire shape and the Bugsee SDK's types is plain Java with no
5
+ // React Native dependency, so it is unit-testable here without codegen or a
6
+ // device. The TurboModule that calls into it does need React Native and the
7
+ // generated spec, and is exercised by the example app instead.
8
+ plugins {
9
+ id 'com.android.library'
10
+ }
11
+
12
+ // Finding the single version source takes more care than it looks like it
13
+ // should. `rootDir` is the app's root project, not this repo's, so that is out.
14
+ // And `projectDir` inside an app is the *autolink symlink*
15
+ // (<app>/node_modules/@bugsee/react-native/android), so walking up from it
16
+ // lands in <app>/node_modules, not in this repo. Canonicalise first, then walk
17
+ // up until the file appears.
18
+ def nativeVersionsFile = { ->
19
+ def dir = projectDir.canonicalFile
20
+ while (dir != null) {
21
+ def candidate = new File(dir, 'native-versions.json')
22
+ if (candidate.isFile()) {
23
+ return candidate
24
+ }
25
+ dir = dir.parentFile
26
+ }
27
+ throw new GradleException(
28
+ "native-versions.json not found above ${projectDir.canonicalFile}. " +
29
+ "Every pinned native version comes from that one file.")
30
+ }()
31
+ def nativeVersions = new groovy.json.JsonSlurper().parse(nativeVersionsFile)
32
+
33
+ // The wrapper's own version, compiled in so the init provider can report an
34
+ // identity with no JS runtime. Found the same way as native-versions.json and
35
+ // for the same reason: inside an app, projectDir is the autolink symlink.
36
+ def packageJsonFile = { ->
37
+ def dir = projectDir.canonicalFile
38
+ while (dir != null) {
39
+ def candidate = new File(dir, 'package.json')
40
+ if (candidate.isFile()
41
+ && new groovy.json.JsonSlurper().parse(candidate).name == '@bugsee/react-native') {
42
+ return candidate
43
+ }
44
+ dir = dir.parentFile
45
+ }
46
+ throw new GradleException(
47
+ "@bugsee/react-native package.json not found above ${projectDir.canonicalFile}. " +
48
+ "The wrapper version reported to the SDK comes from that one file.")
49
+ }()
50
+ def wrapperVersion = new groovy.json.JsonSlurper().parse(packageJsonFile).version
51
+
52
+ // Two builds consume this file.
53
+ //
54
+ // Inside an app, React Native's autolinking includes the module and the app's
55
+ // settings.gradle has already substituted in `com.facebook.react`, which runs
56
+ // codegen and puts react-android on the compile classpath. That is the real
57
+ // configuration and the default here.
58
+ //
59
+ // The repo-root build exists only to run the marshalling unit tests without
60
+ // first building an app, and has neither the plugin nor an app to resolve
61
+ // react-android from. It sets `bugsee.standalone=true`, and this file then
62
+ // drops the TurboModule — the one source that needs both — from the source
63
+ // set. The tests cover the plain-Java classes, which are all that build is for.
64
+ def standalone = providers.gradleProperty('bugsee.standalone').getOrElse('false') == 'true'
65
+ if (!standalone) {
66
+ apply plugin: 'com.facebook.react'
67
+ }
68
+
69
+ android {
70
+ namespace 'com.bugsee.reactnative'
71
+ compileSdk 35
72
+
73
+ defaultConfig {
74
+ // The Bugsee Android SDK supports API 21+ and defends that floor
75
+ // deliberately (its own build pins androidx.webkit to 1.14.0 because
76
+ // 1.15.0+ require 23/24). A wrapper must not raise the floor above the
77
+ // SDK it wraps.
78
+ minSdk 21
79
+
80
+ // Read by ReactNativeWrapperInitProvider, which registers the wrapper
81
+ // before any JS exists and so cannot be handed this from the bridge.
82
+ buildConfigField 'String', 'WRAPPER_VERSION', "\"${wrapperVersion}\""
83
+
84
+ // The backend routes RN exceptions on ReactNativeWebException's FQCN;
85
+ // keep the name through the app's R8 pass (Task 7.1c / 7.5a).
86
+ consumerProguardFiles 'consumer-rules.pro'
87
+ }
88
+
89
+ buildFeatures {
90
+ buildConfig true
91
+ }
92
+
93
+ compileOptions {
94
+ // Matches the SDK, which compiles at 1.8 throughout (and pins
95
+ // jvmTarget to JVM_1_8). Emitting newer bytecode from the wrapper than
96
+ // the library it bridges to buys nothing and narrows who can consume it.
97
+ sourceCompatibility JavaVersion.VERSION_1_8
98
+ targetCompatibility JavaVersion.VERSION_1_8
99
+ }
100
+
101
+ if (standalone) {
102
+ sourceSets {
103
+ main {
104
+ java.exclude 'com/bugsee/reactnative/BugseeModule.java'
105
+ java.exclude 'com/bugsee/reactnative/BugseePackage.java'
106
+ java.exclude 'com/bugsee/reactnative/ReactRootOriginTracker.java'
107
+ }
108
+ test {
109
+ // Depends on the class excluded above, and on
110
+ // com.facebook.react.bridge.LifecycleEventListener, which is
111
+ // only on the classpath via the react-android dependency this
112
+ // build never adds (see the `implementation` below).
113
+ java.exclude 'com/bugsee/reactnative/ReactRootOriginTrackerTest.java'
114
+ }
115
+ }
116
+ }
117
+
118
+ testOptions {
119
+ // android.util.Log is not implemented in a plain JVM test; by default
120
+ // every call throws "not mocked". That turns a catch block whose only
121
+ // job is to log into a rethrow, so a test asserting "this must not
122
+ // escape" fails for a reason that cannot happen on a device. Defaults
123
+ // make the framework stubs inert instead.
124
+ unitTests.returnDefaultValues = true
125
+ unitTests.all {
126
+ useJUnit()
127
+ testLogging { events 'passed', 'failed', 'skipped' }
128
+ }
129
+ }
130
+ }
131
+
132
+ dependencies {
133
+ // Pinned from the single version source so the enum values these tests
134
+ // assert on are the ones that actually ship.
135
+ api "com.bugsee:bugsee-android:${nativeVersions.android.sdk}"
136
+ // Native crash detection is a SEPARATE artifact. Without it the SDK looks
137
+ // correctly integrated and silently reports no native crash at all: a real
138
+ // SIGSEGV on a device produced a tombstone, no Bugsee report, and no NDK
139
+ // line in logcat. The only thing the wrapper saw was a RelaunchedAfterCrash
140
+ // lifecycle event, which comes from ApplicationExitInfo and is not a report.
141
+ // `api`, not `implementation`, to match the core SDK: an app that wants to
142
+ // configure NdkOptions needs the types on its own compile classpath.
143
+ api "com.bugsee:bugsee-android-ndk:${nativeVersions.android.sdk}"
144
+ // RN's NetworkingModule builds an OkHttpClient. The Bugsee plugin injects
145
+ // into every OkHttpClient.Builder.build() only when this artifact is on
146
+ // the classpath, and it auto-adds the artifact only when the app directly
147
+ // declares com.squareup.okhttp3 — which a typical RN app never does, so
148
+ // a JS fetch would otherwise never reach a bundle. `api`, like the core
149
+ // SDK: the interceptor class has to be in the app, not only this module.
150
+ api "com.bugsee:bugsee-android-okhttp:${nativeVersions.android.sdk}"
151
+ // For @Nullable/@NonNull. The SDK exposes these types in its own public
152
+ // API, so a consumer has androidx.annotation on the classpath regardless.
153
+ implementation 'androidx.annotation:annotation:1.9.1'
154
+ if (!standalone) {
155
+ implementation 'com.facebook.react:react-android'
156
+ }
157
+ testImplementation 'junit:junit:4.13.2'
158
+ // A real org.json for BridgeJsonTest. android.jar's copy is stubs, which
159
+ // with returnDefaultValues parse every input into nothing at all -- a
160
+ // test of the parser would pass or fail for reasons unrelated to it.
161
+ testImplementation 'org.json:json:20240303'
162
+ }
@@ -0,0 +1,2 @@
1
+ # The Bugsee backend routes React Native exceptions on this class name.
2
+ -keepnames class com.bugsee.reactnative.ReactNativeWebException
@@ -0,0 +1,33 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
3
+
4
+ <application>
5
+ <!--
6
+ Registers the React Native wrapper with the SDK before the SDK can
7
+ launch.
8
+
9
+ Why a ContentProvider at all: under auto-init the SDK launches from
10
+ its own BugseeInitProvider, which is a ContentProvider and therefore
11
+ runs BEFORE Application.onCreate, before any app code, and long
12
+ before React Native has a JS runtime. Registering from JS, as we did,
13
+ cannot beat that. Providers start in DESCENDING initOrder, so 200
14
+ puts us ahead of the SDK's 100. This is the same convention the SDK's
15
+ own extensions use (see BugseeExtensionInitProviderBase).
16
+
17
+ Why the class is NOT called Bugsee*InitProvider: the Bugsee Gradle
18
+ plugin strips every provider matching `^.*\.Bugsee[A-Za-z0-9_]+InitProvider$`
19
+ from the merged manifest and compensates by injecting that extension's
20
+ register<Name>Extension() call into BugseeInitProvider. We are a
21
+ wrapper, not an SDK extension, and have no such method. A matching
22
+ name would be removed with nothing put back, and the wrapper would
23
+ silently never register. The name is load-bearing; a test asserts it.
24
+ -->
25
+ <provider
26
+ android:name="com.bugsee.reactnative.ReactNativeWrapperInitProvider"
27
+ android:authorities="${applicationId}.bugseereactnativewrapperinit"
28
+ android:directBootAware="true"
29
+ android:exported="false"
30
+ android:initOrder="200" />
31
+ </application>
32
+
33
+ </manifest>
@@ -0,0 +1,82 @@
1
+ package com.bugsee.reactnative;
2
+
3
+ import androidx.annotation.ColorInt;
4
+ import androidx.annotation.NonNull;
5
+ import androidx.annotation.Nullable;
6
+
7
+ import com.bugsee.library.Bugsee;
8
+ import com.bugsee.library.contracts.appearance.Appearance;
9
+
10
+ import java.util.Locale;
11
+
12
+ /**
13
+ * Report colors through {@code Bugsee.getAppearance()}.
14
+ *
15
+ * <p>{@code property} is a {@code ReportAppearance} constant value, such as
16
+ * {@code ReportAppearance.BackgroundColor} ({@code Report::BackgroundColor}).
17
+ * Components are 0–255. Android packs them ARGB, alpha in the high byte.
18
+ */
19
+ public final class AppearanceBridge {
20
+
21
+ private AppearanceBridge() {
22
+ }
23
+
24
+ public static void setColor(
25
+ @NonNull final String property,
26
+ final int r,
27
+ final int g,
28
+ final int b,
29
+ final int a
30
+ ) {
31
+ if (property.length() == 0) {
32
+ throw new IllegalArgumentException("report appearance property is empty");
33
+ }
34
+ checkComponent(r);
35
+ checkComponent(g);
36
+ checkComponent(b);
37
+ checkComponent(a);
38
+ final Appearance appearance = Bugsee.getAppearance();
39
+ appearance.setColor(property, Integer.valueOf(packArgb(r, g, b, a)));
40
+ }
41
+
42
+ @Nullable
43
+ @ColorInt
44
+ public static Integer getColor(@NonNull final String property) {
45
+ if (property.length() == 0) {
46
+ return null;
47
+ }
48
+ return Bugsee.getAppearance().getColor(property);
49
+ }
50
+
51
+ /**
52
+ * {@code #rrggbbaa}, or {@code ""} when the SDK has no color stored.
53
+ * Alpha is last, matching the CSS hex the JS setter accepts.
54
+ */
55
+ @NonNull
56
+ public static String toHex(@Nullable final Integer color) {
57
+ if (color == null) {
58
+ return "";
59
+ }
60
+ final int packed = color.intValue();
61
+ return String.format(
62
+ Locale.US,
63
+ "#%02x%02x%02x%02x",
64
+ Integer.valueOf((packed >> 16) & 0xff),
65
+ Integer.valueOf((packed >> 8) & 0xff),
66
+ Integer.valueOf(packed & 0xff),
67
+ Integer.valueOf((packed >>> 24) & 0xff)
68
+ );
69
+ }
70
+
71
+ static int packArgb(final int r, final int g, final int b, final int a) {
72
+ return (a & 0xff) << 24 | (r & 0xff) << 16 | (g & 0xff) << 8 | (b & 0xff);
73
+ }
74
+
75
+ private static void checkComponent(final int value) {
76
+ if (value < 0 || value > 255) {
77
+ // The range only: the component is the app's value, and this message
78
+ // reaches JS (a synchronous method) or a crash log.
79
+ throw new IllegalArgumentException("color component out of range 0..255");
80
+ }
81
+ }
82
+ }
@@ -0,0 +1,209 @@
1
+ package com.bugsee.reactnative;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.Nullable;
5
+
6
+ import android.util.Log;
7
+
8
+ import java.io.Serializable;
9
+ import java.util.ArrayList;
10
+ import java.util.HashMap;
11
+ import java.util.List;
12
+ import java.util.Map;
13
+ import java.util.Set;
14
+ import java.util.concurrent.ConcurrentHashMap;
15
+
16
+ /**
17
+ * The custom-attribute rules, between the JS wire shape and the SDK's
18
+ * {@code Bugsee.*} attribute surface. Plain Java, so every rule here is
19
+ * unit-tested without React Native or a device.
20
+ *
21
+ * <p>Two facts about the SDK drive this class (design doc, Phase 5):
22
+ * <ul>
23
+ * <li>Neither platform's {@code setAttribute} reports a dropped value
24
+ * truthfully, so a set is only trusted after a read-back confirms the SDK
25
+ * kept it ({@link #setAndVerify}).</li>
26
+ * <li>{@code Bugsee.getAttribute} (in-memory) and {@code Bugsee.getAllAttributes}
27
+ * (persisted, what the report is built from) can disagree: a fractional
28
+ * value is stored as a 32-bit float, so the persisted copy reads back
29
+ * widened, e.g. {@code 0.1} as {@code 0.10000000149011612} -- exactly what
30
+ * {@code manifest.json} carries. {@link #readable} and {@link #readOne}
31
+ * always read the persisted copy.</li>
32
+ * </ul>
33
+ */
34
+ final class AttributeBridge {
35
+
36
+ private static final String TAG = "BugseeRN";
37
+
38
+ /** The largest (and smallest, negated) integral double a {@code long} carries exactly. */
39
+ static final long MAX_SAFE_LONG = 9_007_199_254_740_991L;
40
+
41
+ /**
42
+ * Class names {@link #readable} has already logged as unsupported, for
43
+ * the life of the process. A read can run many times over that life --
44
+ * once per {@code getAllAttributes} call -- so without this, mixed-in
45
+ * native code that keeps writing a type this bridge does not know about
46
+ * would re-log every such entry, on every read, forever.
47
+ */
48
+ private static final Set<String> LOGGED_UNSUPPORTED_TYPES = ConcurrentHashMap.newKeySet();
49
+
50
+ /** What {@link #readable} calls to report a dropped, unsupported-type entry. */
51
+ interface UnsupportedTypeLogger {
52
+ void log(@NonNull String attributeName, @NonNull String className);
53
+ }
54
+
55
+ private static final UnsupportedTypeLogger DEFAULT_UNSUPPORTED_TYPE_LOGGER =
56
+ (attributeName, className) -> Log.w(TAG, "attribute \"" + attributeName
57
+ + "\" has an unsupported type " + className
58
+ + "; dropped (logged once per type, per process)");
59
+
60
+ private AttributeBridge() {
61
+ }
62
+
63
+ /** Test-only: clears the once-per-type guard {@link #readable} keeps for the process's life. */
64
+ static void resetLoggedUnsupportedTypesForTest() {
65
+ LOGGED_UNSUPPORTED_TYPES.clear();
66
+ }
67
+
68
+ /** What the module implements against; the production adapter calls {@code Bugsee.*}. */
69
+ interface Sdk {
70
+ void set(String name, Serializable value);
71
+
72
+ /** {@code Bugsee.getAttribute}: the in-memory copy. */
73
+ @Nullable
74
+ Object getInMemory(String name);
75
+
76
+ /** {@code Bugsee.getAllAttributes}: the persisted copy the report is built from. */
77
+ @Nullable
78
+ Map<String, Serializable> getPersisted();
79
+ }
80
+
81
+ /**
82
+ * A JS number as the SDK should store it. An integral value within a
83
+ * {@code long}'s exact double range crosses as {@link Long}; the SDK
84
+ * would otherwise store a large integral value as a 32-bit float and
85
+ * round it (the design doc's {@code 9007199254740991} example rounds up
86
+ * to {@code ...992} as a {@code Double}). Anything else -- fractional, or
87
+ * integral but too large -- crosses as {@link Double}.
88
+ *
89
+ * <p>{@code -0.0} is integral and within range, so it takes the same path
90
+ * and becomes {@code Long} {@code 0}: a narrowing {@code double}-to-
91
+ * {@code long} conversion has no signed zero to preserve.
92
+ */
93
+ @NonNull
94
+ static Serializable numberValue(final double v) {
95
+ if (!Double.isInfinite(v) && !Double.isNaN(v)
96
+ && v == Math.rint(v) && Math.abs(v) <= MAX_SAFE_LONG) {
97
+ return (long) v;
98
+ }
99
+ return v;
100
+ }
101
+
102
+ /**
103
+ * Sets {@code value}, then reads it straight back through
104
+ * {@link Sdk#getInMemory} and reports whether the SDK actually kept it.
105
+ * Neither SDK's {@code setAttribute} reports a drop truthfully -- Android's
106
+ * is {@code void}, and iOS returns {@code YES} even when it discards a
107
+ * value for size -- so this read-back is the only honest signal.
108
+ */
109
+ static boolean setAndVerify(
110
+ @NonNull final Sdk sdk,
111
+ @NonNull final String name,
112
+ @NonNull final Serializable value
113
+ ) {
114
+ sdk.set(name, value);
115
+ return value.equals(sdk.getInMemory(name));
116
+ }
117
+
118
+ /**
119
+ * The persisted attributes as JS can carry them: {@code string | number |
120
+ * boolean | string[]}.
121
+ *
122
+ * <p>A {@link Float} -- what the SDK stores a large or fractional
123
+ * {@code Double} as -- widens with {@code (double) floatValue()}, the same
124
+ * widening the SDK's own JSON writer applies when it builds
125
+ * {@code manifest.json}; any other {@link Number} (an {@link Integer} or
126
+ * {@link Long} the SDK stored as given) widens with {@code doubleValue()},
127
+ * which is exact for every value this bridge could have written through
128
+ * {@link #numberValue}. A {@code Set<String>} becomes a {@link List} of its
129
+ * string elements. Anything else has no JS representation and is
130
+ * dropped, and its class name is reported through {@link
131
+ * UnsupportedTypeLogger} once per type, for the life of the process
132
+ * (see {@link #LOGGED_UNSUPPORTED_TYPES}) -- not once per read, since it
133
+ * means the SDK is carrying a type this bridge does not know about, and
134
+ * a read can happen many times.
135
+ */
136
+ @NonNull
137
+ static Map<String, Object> readable(@Nullable final Map<String, Serializable> persisted) {
138
+ return readable(persisted, DEFAULT_UNSUPPORTED_TYPE_LOGGER);
139
+ }
140
+
141
+ /** {@link #readable(Map)}, with the unsupported-type logger injectable for tests. */
142
+ @NonNull
143
+ static Map<String, Object> readable(
144
+ @Nullable final Map<String, Serializable> persisted,
145
+ @NonNull final UnsupportedTypeLogger logger
146
+ ) {
147
+ final Map<String, Object> result = new HashMap<>();
148
+ if (persisted == null) {
149
+ return result;
150
+ }
151
+ for (final Map.Entry<String, Serializable> entry : persisted.entrySet()) {
152
+ final Object value = entry.getValue();
153
+ if (value instanceof String || value instanceof Boolean) {
154
+ result.put(entry.getKey(), value);
155
+ } else if (value instanceof Float) {
156
+ result.put(entry.getKey(), (double) ((Float) value).floatValue());
157
+ } else if (value instanceof Number) {
158
+ result.put(entry.getKey(), ((Number) value).doubleValue());
159
+ } else if (value instanceof Set) {
160
+ final List<String> list = new ArrayList<>();
161
+ for (final Object element : (Set<?>) value) {
162
+ if (element instanceof String) {
163
+ list.add((String) element);
164
+ }
165
+ }
166
+ result.put(entry.getKey(), list);
167
+ } else if (value != null) {
168
+ final String className = value.getClass().getName();
169
+ if (LOGGED_UNSUPPORTED_TYPES.add(className)) {
170
+ logger.log(entry.getKey(), className);
171
+ }
172
+ }
173
+ }
174
+ return result;
175
+ }
176
+
177
+ /**
178
+ * One attribute, read from the persisted copy -- never {@link Sdk#getInMemory},
179
+ * which can hold a value the persisted store would round differently. See
180
+ * the class doc.
181
+ */
182
+ @Nullable
183
+ static Object readOne(@NonNull final Sdk sdk, @NonNull final String name) {
184
+ return readable(sdk.getPersisted()).get(name);
185
+ }
186
+
187
+ /**
188
+ * The user identifier as JS should see it: {@code null} and {@code ""}
189
+ * both read as absent. Android stores {@code ""} as given, and iOS's own
190
+ * getter never returns it, so this is the one place both platforms agree
191
+ * on "no identifier".
192
+ */
193
+ @Nullable
194
+ static String identifier(@Nullable final String raw) {
195
+ return raw == null || raw.isEmpty() ? null : raw;
196
+ }
197
+
198
+ /**
199
+ * The message a promise rejects with when {@code operation} (e.g.
200
+ * {@code "getAttribute"}) throws. Named by the operation only -- never
201
+ * the exception's own message, which can echo the attribute name or
202
+ * value that made the SDK throw. {@link BugseeModule} logs the
203
+ * exception's class name, never its message.
204
+ */
205
+ @NonNull
206
+ static String failureMessage(@NonNull final String operation) {
207
+ return operation + " failed";
208
+ }
209
+ }