@bugsee/react-native 0.0.0-stage → 7.0.0-beta1
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.
- package/BugseeReactNative.podspec +95 -0
- package/LICENSE +21 -0
- package/README.md +552 -2
- package/android/build.gradle +162 -0
- package/android/consumer-rules.pro +2 -0
- package/android/src/main/AndroidManifest.xml +33 -0
- package/android/src/main/java/com/bugsee/reactnative/AppearanceBridge.java +82 -0
- package/android/src/main/java/com/bugsee/reactnative/AttributeBridge.java +209 -0
- package/android/src/main/java/com/bugsee/reactnative/BreadcrumbFilterBridge.java +443 -0
- package/android/src/main/java/com/bugsee/reactnative/BridgeJson.java +168 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeModule.java +1869 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeOptionEnums.java +136 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseePackage.java +42 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeReactNativeWrapper.java +200 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeStatusMapper.java +66 -0
- package/android/src/main/java/com/bugsee/reactnative/BugseeTokens.java +22 -0
- package/android/src/main/java/com/bugsee/reactnative/ConsoleEchoDedup.java +202 -0
- package/android/src/main/java/com/bugsee/reactnative/CreatedReports.java +127 -0
- package/android/src/main/java/com/bugsee/reactnative/DataRequestBridge.java +375 -0
- package/android/src/main/java/com/bugsee/reactnative/ExceptionBridge.java +88 -0
- package/android/src/main/java/com/bugsee/reactnative/ExceptionExecutors.java +33 -0
- package/android/src/main/java/com/bugsee/reactnative/LogFilterBridge.java +375 -0
- package/android/src/main/java/com/bugsee/reactnative/NetworkEvents.java +227 -0
- package/android/src/main/java/com/bugsee/reactnative/NetworkFilterBridge.java +498 -0
- package/android/src/main/java/com/bugsee/reactnative/PluginEndpoint.java +48 -0
- package/android/src/main/java/com/bugsee/reactnative/ReactNativeWebException.java +19 -0
- package/android/src/main/java/com/bugsee/reactnative/ReactNativeWrapperInitProvider.java +61 -0
- package/android/src/main/java/com/bugsee/reactnative/ReactRootOriginTracker.java +867 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportArgs.java +58 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportHandlerBridge.java +336 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportHandlerDeadlines.java +57 -0
- package/android/src/main/java/com/bugsee/reactnative/ReportOps.java +287 -0
- package/android/src/main/java/com/bugsee/reactnative/SecureRectanglePulls.java +113 -0
- package/android/src/main/java/com/bugsee/reactnative/SecureRectangleStore.java +692 -0
- package/android/src/main/java/com/bugsee/reactnative/SpanHandles.java +143 -0
- package/android/src/main/java/com/bugsee/reactnative/WrapperChannelHolder.java +137 -0
- package/android/src/main/java/com/bugsee/reactnative/WrapperEventBus.java +110 -0
- package/android/src/main/java/com/bugsee/reactnative/WrapperRegistrar.java +54 -0
- package/app.plugin.js +4 -0
- package/ios/BGSRNConsoleCapture.h +52 -0
- package/ios/BGSRNConsoleCapture.mm +344 -0
- package/ios/BugseeModule.h +25 -0
- package/ios/BugseeModule.mm +2728 -0
- package/ios/Package.swift +71 -0
- package/ios/Support/Package.resolved +14 -0
- package/ios/Support/Package.swift +44 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNAttributes.m +52 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReportOps.m +236 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNCreatedReports.m +184 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNDataRequestBridge.m +431 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNErrorMessage.m +40 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNEventBus.m +70 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNExceptions.m +63 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNGuardedEmit.mm +32 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNJSON.m +40 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNLaunchHold.m +147 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNMainThread.m +23 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkEvents.m +159 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNNetworkFilter.m +155 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNPluginEndpoint.m +21 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReactRootOriginTracker.m +63 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReactWindow.m +251 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportArgs.m +47 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportDeadlines.m +8 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportHandlerBridge.m +308 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNReportOps.m +345 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSecureRectangles.m +508 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSettleOnce.m +62 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNSpanHandles.m +136 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNStatusMapper.m +18 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNTokens.m +9 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNValues.m +5 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapper.m +54 -0
- package/ios/Support/Sources/BugseeRNSupport/BGSRNWrapperChannelHolder.m +59 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNAttributes.h +63 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReportOps.h +51 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNCreatedReports.h +81 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNDataRequestBridge.h +118 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNErrorMessage.h +30 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNEventBus.h +45 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNExceptions.h +31 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNGuardedEmit.h +31 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNJSON.h +25 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNLaunchHold.h +86 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNMainThread.h +32 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkEvents.h +28 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNNetworkFilter.h +28 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNPluginEndpoint.h +17 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactRootOriginTracker.h +48 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReactWindow.h +135 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportArgs.h +17 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportDeadlines.h +37 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportHandlerBridge.h +94 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNReportOps.h +86 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSecureRectangles.h +198 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSettleOnce.h +25 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNSpanHandles.h +49 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNStatusMapper.h +26 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNTokens.h +14 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNValues.h +18 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapper.h +40 -0
- package/ios/Support/Sources/BugseeRNSupport/include/BGSRNWrapperChannelHolder.h +74 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNAttributesTests.m +194 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportOpsTests.m +274 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNCreatedReportsTests.m +240 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNDataRequestBridgeTests.m +685 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNErrorMessageTests.m +102 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNEventBusTests.m +136 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNExceptionsTests.m +68 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.h +41 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNFakeReport.m +166 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNGuardedEmitTests.mm +85 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNJSONTests.m +281 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNLaunchHoldTests.m +230 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNMainThreadTests.m +97 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkEventsTests.m +99 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNNetworkFilterTests.m +134 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNPluginEndpointTests.m +38 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactRootOriginTrackerTests.m +210 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReactWindowTests.m +548 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportArgsTests.m +51 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportDeadlinesTests.m +22 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportHandlerBridgeTests.m +382 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNReportOpsTests.m +295 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSecureRectanglesTests.m +568 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSettleOnceTests.m +134 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNSpanHandlesTests.m +153 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNStatusMapperTests.m +81 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNValuesTests.m +32 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperChannelHolderTests.m +205 -0
- package/ios/Support/Tests/BugseeRNSupportTests/BGSRNWrapperTests.m +66 -0
- package/ios/react-native-spm-prefix.h +10 -0
- package/native-versions.json +10 -0
- package/package.json +62 -3
- package/plugin/build/bundle-phase.d.ts +41 -0
- package/plugin/build/bundle-phase.js +116 -0
- package/plugin/build/bundle-phase.js.map +1 -0
- package/plugin/build/dsym-script.d.ts +32 -0
- package/plugin/build/dsym-script.js +159 -0
- package/plugin/build/dsym-script.js.map +1 -0
- package/plugin/build/endpoint.d.ts +30 -0
- package/plugin/build/endpoint.js +69 -0
- package/plugin/build/endpoint.js.map +1 -0
- package/plugin/build/gradle.d.ts +65 -0
- package/plugin/build/gradle.js +1066 -0
- package/plugin/build/gradle.js.map +1 -0
- package/plugin/build/index.d.ts +85 -0
- package/plugin/build/index.js +217 -0
- package/plugin/build/index.js.map +1 -0
- package/plugin/build/manifest.d.ts +48 -0
- package/plugin/build/manifest.js +69 -0
- package/plugin/build/manifest.js.map +1 -0
- package/plugin/build/native-versions.baked.json +4 -0
- package/plugin/build/native-versions.d.ts +10 -0
- package/plugin/build/native-versions.js +27 -0
- package/plugin/build/native-versions.js.map +1 -0
- package/plugin/build/pbx-string.d.ts +8 -0
- package/plugin/build/pbx-string.js +31 -0
- package/plugin/build/pbx-string.js.map +1 -0
- package/plugin/build/podfile.d.ts +3 -0
- package/plugin/build/podfile.js +28 -0
- package/plugin/build/podfile.js.map +1 -0
- package/plugin/build/properties.d.ts +19 -0
- package/plugin/build/properties.js +41 -0
- package/plugin/build/properties.js.map +1 -0
- package/plugin/build/scheme.d.ts +20 -0
- package/plugin/build/scheme.js +107 -0
- package/plugin/build/scheme.js.map +1 -0
- package/react-native.config.js +26 -0
- package/scripts/bugsee-sourcemaps.gradle +201 -0
- package/scripts/bugsee-xcode.sh +83 -0
- package/scripts/compose-then-inject.js +113 -0
- package/scripts/hermes-sourcemaps.js +634 -0
- package/scripts/hermesc-preserve-js.cmd +6 -0
- package/scripts/hermesc-preserve-js.js +200 -0
- package/scripts/hermesc-preserve-js.sh +7 -0
- package/src/NativeBugsee.ts +622 -0
- package/src/apm/notify.ts +58 -0
- package/src/apm/span.ts +403 -0
- package/src/apm/types.ts +57 -0
- package/src/appearance/report.ts +171 -0
- package/src/architecture.ts +48 -0
- package/src/attributes/errors.ts +39 -0
- package/src/attributes/validate.ts +150 -0
- package/src/breadcrumbs/add.ts +58 -0
- package/src/breadcrumbs/data.ts +33 -0
- package/src/breadcrumbs/filter.ts +215 -0
- package/src/breadcrumbs/types.ts +64 -0
- package/src/bridge/json.ts +110 -0
- package/src/console/capture.ts +180 -0
- package/src/console/dedup.ts +175 -0
- package/src/data/validate.ts +259 -0
- package/src/errorName.ts +32 -0
- package/src/exceptions/ErrorBoundary.tsx +92 -0
- package/src/exceptions/RootErrorReporter.tsx +61 -0
- package/src/exceptions/debugIds.ts +118 -0
- package/src/exceptions/handlers.ts +236 -0
- package/src/exceptions/options.ts +85 -0
- package/src/exceptions/payload.ts +456 -0
- package/src/exceptions/report.ts +170 -0
- package/src/exceptions/sha1.ts +148 -0
- package/src/exceptions/stack.ts +355 -0
- package/src/index.ts +944 -0
- package/src/logs/filter.ts +90 -0
- package/src/logs/log.ts +36 -0
- package/src/network/add.ts +165 -0
- package/src/network/filter.ts +198 -0
- package/src/options/AndroidLaunchOptions.ts +78 -0
- package/src/options/BugseeLaunchOptions.ts +190 -0
- package/src/options/IOSLaunchOptions.ts +57 -0
- package/src/options/android-options-manifest.json +646 -0
- package/src/options/createDefaultLaunchOptions.ts +29 -0
- package/src/options/endpoint.ts +58 -0
- package/src/options/enums.ts +104 -0
- package/src/options/ios-enums.json +19 -0
- package/src/options/keys.ts +39 -0
- package/src/options/option-enums.json +34 -0
- package/src/options/option-keys.json +107 -0
- package/src/report/BugseeReport.ts +264 -0
- package/src/report/CreatedReport.ts +127 -0
- package/src/report/dispatcher.ts +95 -0
- package/src/report/errors.ts +48 -0
- package/src/report/fields.ts +40 -0
- package/src/report/types.ts +157 -0
- package/src/report/validate.ts +197 -0
- package/src/secure/BugseeSecure.tsx +202 -0
- package/src/secure/ancestry.ts +622 -0
- package/src/secure/drivers.ts +342 -0
- package/src/secure/followEvents.ts +57 -0
- package/src/secure/hold.ts +99 -0
- package/src/secure/measureLoop.ts +323 -0
- package/src/secure/nativeAnimation.ts +1005 -0
- package/src/secure/rectangles.ts +93 -0
- package/src/secure/registry.ts +237 -0
- package/src/secure/surface.ts +83 -0
- package/src/secure/tracker.ts +723 -0
- package/src/secure/transition.ts +488 -0
- package/src/secure/unit.ts +22 -0
- package/src/status.ts +16 -0
- package/src/version.ts +9 -0
- package/src/viewtree/anchor.tsx +105 -0
- package/src/viewtree/constants.ts +20 -0
- package/src/viewtree/fiber.ts +251 -0
- package/src/viewtree/requests.ts +347 -0
- package/src/viewtree/walk.ts +902 -0
- package/src/wrapper/channel.ts +33 -0
- package/src/wrapper/collect.ts +52 -0
- package/src/wrapper/events.ts +45 -0
- package/src/wrapper/identity.ts +54 -0
- package/src/wrapper/lifecycle-events.ts +89 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
package com.bugsee.reactnative;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
|
|
5
|
+
import com.bugsee.library.contracts.performance.SpanStatus;
|
|
6
|
+
|
|
7
|
+
import java.util.ArrayList;
|
|
8
|
+
import java.util.Collections;
|
|
9
|
+
import java.util.IdentityHashMap;
|
|
10
|
+
import java.util.Iterator;
|
|
11
|
+
import java.util.LinkedHashMap;
|
|
12
|
+
import java.util.List;
|
|
13
|
+
import java.util.Map;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* The spans the bridge is holding onto.
|
|
17
|
+
*
|
|
18
|
+
* <p>A span is an object with a lifetime. The registry is the strong
|
|
19
|
+
* reference that would leak it: {@link #finish} calls through to the span
|
|
20
|
+
* and then drops every entry whose span is now finished, including a child
|
|
21
|
+
* a parent finish cancelled. {@link #size} and {@link #contains} are what
|
|
22
|
+
* the tests assert, so a finish that forgets to remove the entry fails them.
|
|
23
|
+
*/
|
|
24
|
+
final class SpanHandles {
|
|
25
|
+
|
|
26
|
+
/** What the registry needs from a span. The module adapts the SDK's {@code Span}. */
|
|
27
|
+
interface Retained {
|
|
28
|
+
/** {@code status} null is the no-arg {@code finish}. */
|
|
29
|
+
void finish(@Nullable SpanStatus status);
|
|
30
|
+
|
|
31
|
+
boolean isFinished();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private static final class Entry {
|
|
35
|
+
final Object identity;
|
|
36
|
+
final Retained retained;
|
|
37
|
+
|
|
38
|
+
Entry(final Object identity, final Retained retained) {
|
|
39
|
+
this.identity = identity;
|
|
40
|
+
this.retained = retained;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
private final Map<String, Entry> byHandle = new LinkedHashMap<>();
|
|
45
|
+
private final Map<Object, String> byIdentity = new IdentityHashMap<>();
|
|
46
|
+
private int next = 1;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Holds {@code retained} for {@code identity}. The same identity returns
|
|
50
|
+
* the handle already issued and does not store {@code retained} again.
|
|
51
|
+
* A null identity is not a span: the map would reject it, and nothing is
|
|
52
|
+
* stored. Synchronized like {@code CreatedReports}: {@code invalidate}
|
|
53
|
+
* calls {@link #releaseAll} on another thread.
|
|
54
|
+
*/
|
|
55
|
+
synchronized String retain(@Nullable final Object identity, @Nullable final Retained retained) {
|
|
56
|
+
if (identity == null || retained == null) {
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
final String existing = byIdentity.get(identity);
|
|
60
|
+
if (existing != null) {
|
|
61
|
+
return existing;
|
|
62
|
+
}
|
|
63
|
+
final String handle = "sp-" + next;
|
|
64
|
+
next += 1;
|
|
65
|
+
byHandle.put(handle, new Entry(identity, retained));
|
|
66
|
+
byIdentity.put(identity, handle);
|
|
67
|
+
return handle;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Finishes {@code handle}, then drops that handle even when
|
|
72
|
+
* {@code isFinished()} is still false (a no-op span can leave the flag
|
|
73
|
+
* down). Other retained spans are dropped only when they now report
|
|
74
|
+
* finished. Empty when {@code handle} is not held.
|
|
75
|
+
*/
|
|
76
|
+
synchronized List<String> finish(final String handle, @Nullable final SpanStatus status) {
|
|
77
|
+
final Entry entry = byHandle.get(handle);
|
|
78
|
+
if (entry == null) {
|
|
79
|
+
return Collections.emptyList();
|
|
80
|
+
}
|
|
81
|
+
entry.retained.finish(status);
|
|
82
|
+
return releaseFinished(handle);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Drops every handle. Does not finish the spans. Used when the module goes away. */
|
|
86
|
+
synchronized void releaseAll() {
|
|
87
|
+
byHandle.clear();
|
|
88
|
+
byIdentity.clear();
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
synchronized boolean contains(final String handle) {
|
|
92
|
+
return byHandle.containsKey(handle);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
synchronized int size() {
|
|
96
|
+
return byHandle.size();
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@Nullable
|
|
100
|
+
synchronized Retained get(final String handle) {
|
|
101
|
+
final Entry entry = byHandle.get(handle);
|
|
102
|
+
return entry == null ? null : entry.retained;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* The SDK status for a wire integer, or null when it is outside the
|
|
107
|
+
* enum. The integer is the ordinal: Android's {@code SpanStatus} has no
|
|
108
|
+
* separate value, and iOS declares the same numbers from 0.
|
|
109
|
+
*/
|
|
110
|
+
@Nullable
|
|
111
|
+
static SpanStatus status(final int wire) {
|
|
112
|
+
final SpanStatus[] values = SpanStatus.values();
|
|
113
|
+
if (wire < 0 || wire >= values.length) {
|
|
114
|
+
return null;
|
|
115
|
+
}
|
|
116
|
+
final SpanStatus status = values[wire];
|
|
117
|
+
if (status.ordinal() != wire) {
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
return status;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/** Caller holds the lock. {@code called} is removed whether or not it reports finished. */
|
|
124
|
+
private List<String> releaseFinished(final String called) {
|
|
125
|
+
final List<String> released = new ArrayList<>();
|
|
126
|
+
final Entry calledEntry = byHandle.remove(called);
|
|
127
|
+
if (calledEntry != null) {
|
|
128
|
+
byIdentity.remove(calledEntry.identity);
|
|
129
|
+
released.add(called);
|
|
130
|
+
}
|
|
131
|
+
final Iterator<Map.Entry<String, Entry>> entries = byHandle.entrySet().iterator();
|
|
132
|
+
while (entries.hasNext()) {
|
|
133
|
+
final Map.Entry<String, Entry> entry = entries.next();
|
|
134
|
+
if (!entry.getValue().retained.isFinished()) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
released.add(entry.getKey());
|
|
138
|
+
byIdentity.remove(entry.getValue().identity);
|
|
139
|
+
entries.remove();
|
|
140
|
+
}
|
|
141
|
+
return released;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
package com.bugsee.reactnative;
|
|
2
|
+
|
|
3
|
+
import android.util.Log;
|
|
4
|
+
|
|
5
|
+
import androidx.annotation.NonNull;
|
|
6
|
+
import androidx.annotation.Nullable;
|
|
7
|
+
|
|
8
|
+
import com.bugsee.library.contracts.exchange.NetworkEvent;
|
|
9
|
+
import com.bugsee.library.contracts.internal.BugseeWrapperChannel;
|
|
10
|
+
import com.bugsee.library.contracts.internal.LogSource;
|
|
11
|
+
import com.bugsee.library.contracts.options.LogLevel;
|
|
12
|
+
|
|
13
|
+
import java.util.concurrent.atomic.AtomicBoolean;
|
|
14
|
+
import java.util.concurrent.atomic.AtomicReference;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The SDK's wrapper channel, held for the whole process.
|
|
18
|
+
*
|
|
19
|
+
* <p>The channel is how this wrapper submits what it captured in JS -- log
|
|
20
|
+
* lines now, network events and breadcrumbs later -- attributed as wrapper
|
|
21
|
+
* data rather than as the app's own calls. It is delivered to whichever
|
|
22
|
+
* {@link BugseeReactNativeWrapper} is registered, but it lives here rather
|
|
23
|
+
* than on that instance: the wrapper is replaced when {@code setWrapperInfo}
|
|
24
|
+
* refines the identity, and the SDK hands the replacement a fresh channel.
|
|
25
|
+
* The last one delivered is the live one; an earlier one is inert.
|
|
26
|
+
*
|
|
27
|
+
* <p>Nothing is buffered. A channel held before {@code launch} accepts and
|
|
28
|
+
* drops what it is given, which is the spec'd behaviour, not an error.
|
|
29
|
+
*
|
|
30
|
+
* <p>Every line sent through here is filtered natively by the app's log
|
|
31
|
+
* filter, once; this wrapper never runs that filter in JS (design doc
|
|
32
|
+
* §10.3). The channel's {@code log} has no flag to say otherwise.
|
|
33
|
+
*/
|
|
34
|
+
final class WrapperChannelHolder {
|
|
35
|
+
|
|
36
|
+
private static final String TAG = "BugseeRN";
|
|
37
|
+
|
|
38
|
+
/** Where a filter fault is reported. Logcat in production; injectable for tests. */
|
|
39
|
+
interface Diagnostics {
|
|
40
|
+
void report(@NonNull String message, @NonNull Throwable error);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
private static final WrapperChannelHolder SHARED =
|
|
44
|
+
new WrapperChannelHolder((message, error) ->
|
|
45
|
+
Log.w(TAG, message + ": " + error.getClass().getName()));
|
|
46
|
+
|
|
47
|
+
@NonNull
|
|
48
|
+
static WrapperChannelHolder shared() {
|
|
49
|
+
return SHARED;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private final Diagnostics diagnostics;
|
|
53
|
+
private final AtomicReference<BugseeWrapperChannel> channel = new AtomicReference<>();
|
|
54
|
+
// One per producer: a shared flag would hide the second filter's fault
|
|
55
|
+
// once the first had fired.
|
|
56
|
+
private final AtomicBoolean logFaultReported = new AtomicBoolean();
|
|
57
|
+
private final AtomicBoolean networkFaultReported = new AtomicBoolean();
|
|
58
|
+
|
|
59
|
+
WrapperChannelHolder(@NonNull final Diagnostics diagnostics) {
|
|
60
|
+
this.diagnostics = diagnostics;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Called from inside {@code Bugsee.setWrapper}, under the SDK's
|
|
65
|
+
* registration lock: a plain store, and nothing that could block.
|
|
66
|
+
*/
|
|
67
|
+
void set(@NonNull final BugseeWrapperChannel delivered) {
|
|
68
|
+
channel.set(delivered);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** After {@code setWrapper(null)}, which retires the channel SDK-side too. */
|
|
72
|
+
void clear() {
|
|
73
|
+
channel.set(null);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* One JS line, as source {@code Custom} with no tag.
|
|
78
|
+
*
|
|
79
|
+
* <p>The tag stays null because iOS has nowhere to put one, and a line
|
|
80
|
+
* must read the same on both platforms. The source is always set here,
|
|
81
|
+
* never left to the SDK, which on iOS would read a missing one as
|
|
82
|
+
* {@code Unknown}.
|
|
83
|
+
*
|
|
84
|
+
* <p>The app's filter runs on this thread, and on Android an exception it
|
|
85
|
+
* throws comes back here. This thread is React Native's, where an escaping
|
|
86
|
+
* exception is a crash, so it stops here and is reported once per process:
|
|
87
|
+
* the report is itself a logcat line, which the SDK's logcat capture can
|
|
88
|
+
* feed back into the same filter.
|
|
89
|
+
*/
|
|
90
|
+
void log(@Nullable final String message, final int level) {
|
|
91
|
+
final BugseeWrapperChannel current = channel.get();
|
|
92
|
+
if (current == null) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
try {
|
|
96
|
+
current.log(null, message, levelFor(level), LogSource.Custom);
|
|
97
|
+
} catch (final Throwable e) {
|
|
98
|
+
if (logFaultReported.compareAndSet(false, true)) {
|
|
99
|
+
diagnostics.report("the app's log filter threw on a wrapper log line "
|
|
100
|
+
+ "(reported once per process)", e);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Always {@code requiresFiltering = true}. {@code false} skips the SDK's
|
|
107
|
+
* built-in network sanitizer as well as the app's filter, and nothing this
|
|
108
|
+
* wrapper sends has been through either.
|
|
109
|
+
*/
|
|
110
|
+
void addNetworkEvent(@Nullable final NetworkEvent event) {
|
|
111
|
+
final BugseeWrapperChannel current = channel.get();
|
|
112
|
+
if (current == null) {
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
current.addNetworkEvent(event, true);
|
|
117
|
+
} catch (final Throwable e) {
|
|
118
|
+
if (networkFaultReported.compareAndSet(false, true)) {
|
|
119
|
+
diagnostics.report("the app's network filter threw on a wrapper network event "
|
|
120
|
+
+ "(reported once per process)", e);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* By value, the table both platforms share: 1 Error ... 5 Verbose, and
|
|
127
|
+
* anything else Info. Never {@code values()[n]} -- Error is value 1 at
|
|
128
|
+
* ordinal 0. Range-checked before the byte cast, which would otherwise
|
|
129
|
+
* wrap 257 round to 1.
|
|
130
|
+
*/
|
|
131
|
+
static LogLevel levelFor(final int wire) {
|
|
132
|
+
if (wire < 1 || wire > 5) {
|
|
133
|
+
return LogLevel.Info;
|
|
134
|
+
}
|
|
135
|
+
return LogLevel.fromRawValue((byte) wire, LogLevel.Info);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
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.util.concurrent.atomic.AtomicReference;
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Carries the SDK's lifecycle and status events from the wrapper to the React
|
|
12
|
+
* Native bridge.
|
|
13
|
+
*
|
|
14
|
+
* <p>The two ends have different lifetimes, which is the whole reason this
|
|
15
|
+
* exists. The wrapper is registered at process start by
|
|
16
|
+
* {@link ReactNativeWrapperInitProvider}, before React Native has loaded, and
|
|
17
|
+
* it is replaced again when {@code setWrapperInfo} runs. The bridge appears
|
|
18
|
+
* later, can be torn down and recreated by a reload, and is absent entirely
|
|
19
|
+
* during start-up. Wiring the wrapper directly to a module would mean either
|
|
20
|
+
* dropping the module's events after a reload or holding a dead module alive.
|
|
21
|
+
*
|
|
22
|
+
* <p>Events that arrive with no bridge attached are dropped, deliberately and
|
|
23
|
+
* without complaint: during start-up there is no JavaScript to deliver them
|
|
24
|
+
* to, and queueing them would deliver a burst of stale lifecycle transitions
|
|
25
|
+
* the moment JS appeared, which is worse than not delivering them at all. A
|
|
26
|
+
* caller that needs the current state asks {@code getStatus}.
|
|
27
|
+
*/
|
|
28
|
+
final class WrapperEventBus {
|
|
29
|
+
|
|
30
|
+
private static final String TAG = "BugseeRN";
|
|
31
|
+
|
|
32
|
+
/** The prefix both SDKs put on every lifecycle event name. */
|
|
33
|
+
private static final String LIFECYCLE_PREFIX = "com.bugsee.lifecycle.";
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* What the bridge implements to receive events.
|
|
37
|
+
*
|
|
38
|
+
* <p>Lifecycle only. Status transitions are DERIVED from this channel in
|
|
39
|
+
* JavaScript rather than carried separately: Android exposes no status
|
|
40
|
+
* listener at all, and iOS's {@code bugseeDidChangeStatus:} belongs to the
|
|
41
|
+
* app's own delegate, so a second channel would have no source on either
|
|
42
|
+
* platform.
|
|
43
|
+
*/
|
|
44
|
+
interface Sink {
|
|
45
|
+
void onLifecycleEvent(@NonNull String name, @Nullable String reportId);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
private static final WrapperEventBus SHARED = new WrapperEventBus();
|
|
49
|
+
|
|
50
|
+
@NonNull
|
|
51
|
+
static WrapperEventBus shared() {
|
|
52
|
+
return SHARED;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Atomic because the SDK dispatches from its own background threads while
|
|
57
|
+
* the bridge attaches and detaches from the React thread.
|
|
58
|
+
*/
|
|
59
|
+
private final AtomicReference<Sink> sink = new AtomicReference<>();
|
|
60
|
+
|
|
61
|
+
@Nullable
|
|
62
|
+
Sink sink() {
|
|
63
|
+
return sink.get();
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
void attach(@NonNull final Sink newSink) {
|
|
67
|
+
sink.set(newSink);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Detaches {@code stale} only if it is still the attached sink.
|
|
72
|
+
*
|
|
73
|
+
* <p>Identity-checked rather than an unconditional clear: a fast reload can
|
|
74
|
+
* construct and attach the new module before the old one is torn down, and
|
|
75
|
+
* an unconditional clear would then silence the live bridge.
|
|
76
|
+
*/
|
|
77
|
+
void detach(@NonNull final Sink stale) {
|
|
78
|
+
sink.compareAndSet(stale, null);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Forwards a lifecycle event, with the SDK's {@code com.bugsee.lifecycle.}
|
|
83
|
+
* prefix removed.
|
|
84
|
+
*
|
|
85
|
+
* <p>An unrecognised name is forwarded unchanged rather than dropped. A
|
|
86
|
+
* newer SDK adding an event must not have it silently swallowed by an older
|
|
87
|
+
* wrapper: that hides a whole feature, and the JS side can decide what to
|
|
88
|
+
* do with a name it does not know.
|
|
89
|
+
*/
|
|
90
|
+
void emitLifecycle(@NonNull final String rawName, @Nullable final String reportId) {
|
|
91
|
+
final Sink current = sink.get();
|
|
92
|
+
if (current == null) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
final String name = rawName.startsWith(LIFECYCLE_PREFIX)
|
|
97
|
+
? rawName.substring(LIFECYCLE_PREFIX.length())
|
|
98
|
+
: rawName;
|
|
99
|
+
|
|
100
|
+
// A dead bridge throws from the emit, and this runs on the SDK's
|
|
101
|
+
// dispatch thread: letting it escape would break the SDK's own
|
|
102
|
+
// lifecycle handling for a fault that is entirely ours.
|
|
103
|
+
try {
|
|
104
|
+
current.onLifecycleEvent(name, reportId);
|
|
105
|
+
} catch (final Throwable e) {
|
|
106
|
+
Log.w(TAG, "Failed to deliver lifecycle event " + name + ": " + e.getClass().getName());
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
package com.bugsee.reactnative;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import com.bugsee.library.Bugsee;
|
|
7
|
+
import com.bugsee.library.contracts.internal.BugseeWrapper;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The one place this wrapper calls {@code Bugsee.setWrapper}.
|
|
11
|
+
*
|
|
12
|
+
* <p>The wrapper-channel spec requires a wrapper not to register concurrently
|
|
13
|
+
* with itself, and this one registers from two threads: the init provider at
|
|
14
|
+
* process start, and {@code setWrapperInfo} on the native-modules thread once
|
|
15
|
+
* JS is up. On Android the SDK delivers the channel under its registration
|
|
16
|
+
* lock, so two racing registrations could leave a superseded channel stored.
|
|
17
|
+
* Every registration takes {@link #LOCK} instead; a test fails any
|
|
18
|
+
* {@code setWrapper} call made anywhere else.
|
|
19
|
+
*
|
|
20
|
+
* <p>This cannot deadlock against the SDK's lock: the callback that runs
|
|
21
|
+
* under it, {@code onWrapperChannelAvailable}, only stores the channel and
|
|
22
|
+
* never takes {@link #LOCK}.
|
|
23
|
+
*/
|
|
24
|
+
final class WrapperRegistrar {
|
|
25
|
+
|
|
26
|
+
/** Its own interface: {@code java.util.function} needs API 24, minSdk is 21. */
|
|
27
|
+
interface Setter {
|
|
28
|
+
void set(@Nullable BugseeWrapper wrapper);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
private static final Object LOCK = new Object();
|
|
32
|
+
private static final Setter SDK = Bugsee::setWrapper;
|
|
33
|
+
|
|
34
|
+
private WrapperRegistrar() {
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static void register(@Nullable final BugseeWrapper wrapper) {
|
|
38
|
+
registerWith(SDK, wrapper);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* A non-null wrapper is handed its channel from inside {@code setter}, so
|
|
43
|
+
* the holder is cleared only after a null registration -- clearing after
|
|
44
|
+
* every one would wipe the channel the moment it arrived.
|
|
45
|
+
*/
|
|
46
|
+
static void registerWith(@NonNull final Setter setter, @Nullable final BugseeWrapper wrapper) {
|
|
47
|
+
synchronized (LOCK) {
|
|
48
|
+
setter.set(wrapper);
|
|
49
|
+
if (wrapper == null) {
|
|
50
|
+
WrapperChannelHolder.shared().clear();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
package/app.plugin.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Installs the RCTLog hook once. Native-sourced lines (RN core, native
|
|
7
|
+
* modules) are forwarded through the wrapper channel, source Custom, so they
|
|
8
|
+
* meet the user's log filter once. JavaScript-sourced lines are the console
|
|
9
|
+
* echo the JS patch already forwards; they are not forwarded again.
|
|
10
|
+
*
|
|
11
|
+
* Android already receives those native lines through logcat. iOS does not:
|
|
12
|
+
* the SDK's os_log capture is disabled, and RCTLog's default function writes
|
|
13
|
+
* only os_log of the raw message. This hook is the native capture. A stderr
|
|
14
|
+
* stamp of a noted console line is dropped once, and so is one raw stdout or
|
|
15
|
+
* stderr line of that text: that is the console echo. A Custom line is not
|
|
16
|
+
* that echo. Keeping the channel line ends the equal-text claim. A later
|
|
17
|
+
* Custom line of the same text is kept, including `Bugsee.log` and a native
|
|
18
|
+
* `RCTLog` forwarded as Custom.
|
|
19
|
+
*
|
|
20
|
+
* A native line arms the same echo drop before the rest of the log function
|
|
21
|
+
* chain runs, so an app that mirrors RCTLog to stderr does not record it a
|
|
22
|
+
* second time. In a Debug build RN re-logs a native warning from JS (LogBox);
|
|
23
|
+
* that JavaScript delivery arms one more drop, for its own echo. The line is
|
|
24
|
+
* recorded and filtered once.
|
|
25
|
+
*/
|
|
26
|
+
void BGSRNInstallConsoleCapture(void);
|
|
27
|
+
|
|
28
|
+
/** Arms a drop of the stderr stamp and one raw stdio line of `message`. Does not record a line. */
|
|
29
|
+
void BGSRNNoteConsoleEcho(NSString * _Nullable message);
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* The wrapper channel is about to record `message`. The filter call inside
|
|
33
|
+
* that record is the channel line. Keeping it clears the equal-text claim.
|
|
34
|
+
* It does not arm a drop of the next equal line. Pair with
|
|
35
|
+
* `BGSRNEndChannelLine`.
|
|
36
|
+
*/
|
|
37
|
+
void BGSRNBeginChannelLine(NSString * _Nullable message);
|
|
38
|
+
|
|
39
|
+
/** Ends the channel line begun with `message`. */
|
|
40
|
+
void BGSRNEndChannelLine(NSString * _Nullable message);
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* YES when `line` is the console echo and should be dropped. `source` is the
|
|
44
|
+
* event's log source, or a negative value when the event does not expose one.
|
|
45
|
+
* A stderr stamp is dropped once. One raw stdout (1) or stderr (2) line of
|
|
46
|
+
* the noted text is dropped once. Keeping the channel line clears the
|
|
47
|
+
* equal-text claim. A later Custom line of the same text is not that echo
|
|
48
|
+
* and is not dropped.
|
|
49
|
+
*/
|
|
50
|
+
BOOL BGSRNDropConsoleEcho(NSString * _Nullable line, NSInteger source);
|
|
51
|
+
|
|
52
|
+
NS_ASSUME_NONNULL_END
|