@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.
- package/BugseeReactNative.podspec +95 -0
- package/LICENSE +21 -0
- package/README.md +557 -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 +962 -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,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The endpoint override, which the two SDKs spell differently.
|
|
3
|
+
*
|
|
4
|
+
* iOS reads a plain `endpoint` key — not namespaced — and uses it VERBATIM as
|
|
5
|
+
* the API base. Its own default is `https://api.bugsee.com/v2`, so a supplied
|
|
6
|
+
* value must carry the version segment or every request loses it.
|
|
7
|
+
*
|
|
8
|
+
* Android reads `com.bugsee.option.$$ENDPOINT`, whose default base is
|
|
9
|
+
* version-EXCLUSIVE (`https://api.bugsee.com`, with `/v2/<resource>` appended
|
|
10
|
+
* per request). Its `apiUrl()` normalises either form, so the value passes
|
|
11
|
+
* through untouched and a caller who supplied `/v2` is not punished for it.
|
|
12
|
+
*
|
|
13
|
+
* This is why one endpoint string from the caller becomes two different
|
|
14
|
+
* payloads: the same value cannot be correct for both SDKs.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Android's key. Namespaced, and one of the `$$` internal options. */
|
|
18
|
+
export const ANDROID_ENDPOINT_KEY = 'com.bugsee.option.$$ENDPOINT';
|
|
19
|
+
|
|
20
|
+
/** iOS's key. Deliberately NOT `com.bugsee.option.*` — the SDK reads it flat. */
|
|
21
|
+
export const IOS_ENDPOINT_KEY = 'endpoint';
|
|
22
|
+
|
|
23
|
+
const VERSION_SEGMENT = '/v2';
|
|
24
|
+
|
|
25
|
+
/** The payload for one platform, or `{}` when there is nothing to send. */
|
|
26
|
+
export function endpointFor(
|
|
27
|
+
platform: 'ios' | 'android',
|
|
28
|
+
endpoint: string | undefined,
|
|
29
|
+
): Record<string, string> {
|
|
30
|
+
// Not `endpoint?.trim()`: the signature says string, but the call arrives
|
|
31
|
+
// from untyped JS as often as from TypeScript, and a non-string would throw
|
|
32
|
+
// here rather than being read as "no endpoint supplied".
|
|
33
|
+
const trimmed = typeof endpoint === 'string' ? endpoint.trim() : '';
|
|
34
|
+
if (trimmed === '') {
|
|
35
|
+
// Not `{ key: '' }`: an empty override would replace the SDK's own
|
|
36
|
+
// default with nothing rather than leaving it alone.
|
|
37
|
+
return {};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (platform === 'android') {
|
|
41
|
+
return { [ANDROID_ENDPOINT_KEY]: trimmed };
|
|
42
|
+
}
|
|
43
|
+
if (platform !== 'ios') {
|
|
44
|
+
// Not "assume iOS": a wrong platform string would then produce an iOS
|
|
45
|
+
// payload that the other SDK silently ignores, which looks like the
|
|
46
|
+
// endpoint simply not working.
|
|
47
|
+
throw new Error('endpointFor expects "ios" or "android"');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Strip a trailing slash first, so a value ending in "/" does not become
|
|
51
|
+
// "…//v2" and one ending in "/v2/" is recognised as already versioned.
|
|
52
|
+
const base = trimmed.replace(/\/+$/, '');
|
|
53
|
+
return {
|
|
54
|
+
[IOS_ENDPOINT_KEY]: base.endsWith(VERSION_SEGMENT)
|
|
55
|
+
? base
|
|
56
|
+
: `${base}${VERSION_SEGMENT}`,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The option enums, as the numbers that cross the bridge.
|
|
3
|
+
*
|
|
4
|
+
* These are each enum's INTERNAL VALUE, not its ordinal. The two diverge on
|
|
5
|
+
* four of the five — Error is value 1 at ordinal 0, Fullscreen is value 20 at
|
|
6
|
+
* ordinal 3 — and only VideoQuality coincides. iOS consumes these numbers
|
|
7
|
+
* directly; the Android bridge converts them with each enum's own
|
|
8
|
+
* fromIntValue/fromRawValue, never values()[n].
|
|
9
|
+
*
|
|
10
|
+
* Verified against the SDK sources, not the design doc: an earlier reading of
|
|
11
|
+
* VideoMode with a regex that excluded digits dropped V1 and V2 and made
|
|
12
|
+
* Fullscreen look like ordinal 1.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export const LogLevel = {
|
|
16
|
+
Error: 1,
|
|
17
|
+
Warning: 2,
|
|
18
|
+
Info: 3,
|
|
19
|
+
Debug: 4,
|
|
20
|
+
Verbose: 5,
|
|
21
|
+
} as const;
|
|
22
|
+
export type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
23
|
+
|
|
24
|
+
export const VideoMode = {
|
|
25
|
+
None: 0,
|
|
26
|
+
V1: 1,
|
|
27
|
+
V2: 2,
|
|
28
|
+
Fullscreen: 20,
|
|
29
|
+
DirectBuffers: 21,
|
|
30
|
+
} as const;
|
|
31
|
+
export type VideoMode = (typeof VideoMode)[keyof typeof VideoMode];
|
|
32
|
+
|
|
33
|
+
export const VideoQuality = {
|
|
34
|
+
Default: 0,
|
|
35
|
+
Medium: 1,
|
|
36
|
+
High: 2,
|
|
37
|
+
} as const;
|
|
38
|
+
export type VideoQuality = (typeof VideoQuality)[keyof typeof VideoQuality];
|
|
39
|
+
|
|
40
|
+
export const FrameRate = {
|
|
41
|
+
Low: 1,
|
|
42
|
+
Medium: 2,
|
|
43
|
+
High: 3,
|
|
44
|
+
// Raw: 4 — Android only. See WITHHELD_FROM_JS below.
|
|
45
|
+
} as const;
|
|
46
|
+
export type FrameRate = (typeof FrameRate)[keyof typeof FrameRate];
|
|
47
|
+
|
|
48
|
+
export const IssueSeverity = {
|
|
49
|
+
VeryLow: 1,
|
|
50
|
+
Medium: 2,
|
|
51
|
+
High: 3,
|
|
52
|
+
Critical: 4,
|
|
53
|
+
Blocker: 5,
|
|
54
|
+
} as const;
|
|
55
|
+
export type IssueSeverity = (typeof IssueSeverity)[keyof typeof IssueSeverity];
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* How the iOS crash reporter intercepts crashes. iOS only: Android has no Mach
|
|
59
|
+
* exceptions, and tvOS runs every value as BSD.
|
|
60
|
+
*
|
|
61
|
+
* - `BSD`: BSD signal handlers.
|
|
62
|
+
* - `Mach`: a Mach exception handler, plus a BSD signal handler for SIGABRT.
|
|
63
|
+
* Other signals raised by software (`raise()`, `kill()`) are not reported.
|
|
64
|
+
* - `MachAndBSD`: both, so hardware faults and signals raised by software are
|
|
65
|
+
* reported. The SDK default.
|
|
66
|
+
*
|
|
67
|
+
* Checked against the iOS header through `ios-enums.json`: the Android-sourced
|
|
68
|
+
* fixture has no such enum.
|
|
69
|
+
*/
|
|
70
|
+
export const CrashHandlerType = {
|
|
71
|
+
BSD: 1,
|
|
72
|
+
Mach: 2,
|
|
73
|
+
MachAndBSD: 3,
|
|
74
|
+
} as const;
|
|
75
|
+
export type CrashHandlerType = (typeof CrashHandlerType)[keyof typeof CrashHandlerType];
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* SDK enum members this package deliberately does not expose, with the value
|
|
79
|
+
* they carry natively.
|
|
80
|
+
*
|
|
81
|
+
* A cross-platform enum can only offer what both platforms accept. Leaving a
|
|
82
|
+
* one-sided member out is the correct call, but doing it by simply not typing
|
|
83
|
+
* it is not: the drift guard in `__tests__/enums.test.ts` compares our
|
|
84
|
+
* constants against members extracted from the SDK sources, so an unexplained
|
|
85
|
+
* omission is indistinguishable from the transcription slip that guard exists
|
|
86
|
+
* to catch. `IssueSeverity` once gained a `Low` that does not exist and lost
|
|
87
|
+
* `Blocker`, shifting three values the SDK would have accepted as different,
|
|
88
|
+
* valid severities.
|
|
89
|
+
*
|
|
90
|
+
* So a withheld member is written down here instead. The guard then requires
|
|
91
|
+
* exposed + withheld to equal the SDK exactly, which keeps its teeth: a member
|
|
92
|
+
* added natively still fails until someone decides which side it belongs on.
|
|
93
|
+
*/
|
|
94
|
+
export const WITHHELD_FROM_JS = {
|
|
95
|
+
/**
|
|
96
|
+
* Android `FrameRate` has `Raw = 4`; iOS `BugseeFrameRate` stops at
|
|
97
|
+
* `High = 3` (ios/sdk `origin/nextgen`, `BugseeConstants.h`, checked
|
|
98
|
+
* 2026-09-22 — there is no `BugseeFrameRateRaw` anywhere in the headers).
|
|
99
|
+
*
|
|
100
|
+
* Exposing it would give JavaScript a value that silently means a different
|
|
101
|
+
* capture rate per platform. Move it into `FrameRate` if iOS gains it.
|
|
102
|
+
*/
|
|
103
|
+
FrameRate: { Raw: 4 },
|
|
104
|
+
} as const;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"IssueSeverity": {
|
|
3
|
+
"BugseeSeverityLow": 1,
|
|
4
|
+
"BugseeSeverityMedium": 2,
|
|
5
|
+
"BugseeSeverityHigh": 3,
|
|
6
|
+
"BugseeSeverityCritical": 4,
|
|
7
|
+
"BugseeSeverityBlocker": 5
|
|
8
|
+
},
|
|
9
|
+
"IssueType": {
|
|
10
|
+
"BGSIssueTypeBug": 0,
|
|
11
|
+
"BGSIssueTypeCrash": 1,
|
|
12
|
+
"BGSIssueTypeError": 2
|
|
13
|
+
},
|
|
14
|
+
"CrashHandlerType": {
|
|
15
|
+
"BugseeCrashHandlerTypeBSD": 1,
|
|
16
|
+
"BugseeCrashHandlerTypeMach": 2,
|
|
17
|
+
"BugseeCrashHandlerTypeMachAndBSD": 3
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The real `com.bugsee.option.*` keys each SDK accepts.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from the SDK sources by `scripts/cli-extract-option-keys.ts` and
|
|
5
|
+
* committed, because neither SDK publishes a manifest yet and CI has no SDK
|
|
6
|
+
* checkout. Regenerate it rather than editing it by hand.
|
|
7
|
+
*/
|
|
8
|
+
import keys from './option-keys.json';
|
|
9
|
+
|
|
10
|
+
/** Accepted by both platforms — the great majority in 7.x. */
|
|
11
|
+
export const SHARED_KEYS: readonly string[] = keys.shared;
|
|
12
|
+
/** Accepted only by iOS; sending one to Android is a key it never agreed to. */
|
|
13
|
+
export const IOS_ONLY_KEYS: readonly string[] = keys.ios;
|
|
14
|
+
/** Accepted only by Android. */
|
|
15
|
+
export const ANDROID_ONLY_KEYS: readonly string[] = keys.android;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Keys each SDK honours but does not declare where the extractor looks.
|
|
19
|
+
*
|
|
20
|
+
* Both are the endpoint override, and neither is in the generated fixture:
|
|
21
|
+
* Android registers `$$ENDPOINT` directly in OptionsDescriptors.java with a
|
|
22
|
+
* string literal rather than declaring it in the Options interface, and iOS
|
|
23
|
+
* reads a flat `endpoint` out of the options dictionary
|
|
24
|
+
* (`bgs_options()[@"endpoint"]` in BGSNetworkManager) rather than exposing a
|
|
25
|
+
* BugseeOption constant. Listed here so the platform guard knows they are
|
|
26
|
+
* legitimate, and so nobody "tidies" them away as typos.
|
|
27
|
+
*/
|
|
28
|
+
export const UNDECLARED_KEYS: Readonly<Record<'ios' | 'android', readonly string[]>> = {
|
|
29
|
+
ios: ['endpoint'],
|
|
30
|
+
android: ['com.bugsee.option.$$ENDPOINT'],
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export function keysFor(platform: 'ios' | 'android'): ReadonlySet<string> {
|
|
34
|
+
return new Set([
|
|
35
|
+
...SHARED_KEYS,
|
|
36
|
+
...(platform === 'ios' ? IOS_ONLY_KEYS : ANDROID_ONLY_KEYS),
|
|
37
|
+
...UNDECLARED_KEYS[platform],
|
|
38
|
+
]);
|
|
39
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"LogLevel": {
|
|
3
|
+
"Error": 1,
|
|
4
|
+
"Warning": 2,
|
|
5
|
+
"Info": 3,
|
|
6
|
+
"Debug": 4,
|
|
7
|
+
"Verbose": 5
|
|
8
|
+
},
|
|
9
|
+
"VideoMode": {
|
|
10
|
+
"None": 0,
|
|
11
|
+
"V1": 1,
|
|
12
|
+
"V2": 2,
|
|
13
|
+
"Fullscreen": 20,
|
|
14
|
+
"DirectBuffers": 21
|
|
15
|
+
},
|
|
16
|
+
"VideoQuality": {
|
|
17
|
+
"Default": 0,
|
|
18
|
+
"Medium": 1,
|
|
19
|
+
"High": 2
|
|
20
|
+
},
|
|
21
|
+
"FrameRate": {
|
|
22
|
+
"Low": 1,
|
|
23
|
+
"Medium": 2,
|
|
24
|
+
"High": 3,
|
|
25
|
+
"Raw": 4
|
|
26
|
+
},
|
|
27
|
+
"IssueSeverity": {
|
|
28
|
+
"VeryLow": 1,
|
|
29
|
+
"Medium": 2,
|
|
30
|
+
"High": 3,
|
|
31
|
+
"Critical": 4,
|
|
32
|
+
"Blocker": 5
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"shared": [
|
|
3
|
+
"com.bugsee.option.capture.breadcrumbs",
|
|
4
|
+
"com.bugsee.option.capture.breadcrumbs.extras",
|
|
5
|
+
"com.bugsee.option.capture.logs",
|
|
6
|
+
"com.bugsee.option.capture.logs.level",
|
|
7
|
+
"com.bugsee.option.capture.network",
|
|
8
|
+
"com.bugsee.option.capture.network.body-size-limit",
|
|
9
|
+
"com.bugsee.option.capture.network.body-without-type",
|
|
10
|
+
"com.bugsee.option.capture.network.default-sanitizer",
|
|
11
|
+
"com.bugsee.option.capture.network.on-launch",
|
|
12
|
+
"com.bugsee.option.capture.screenshot",
|
|
13
|
+
"com.bugsee.option.capture.screenshot.scale",
|
|
14
|
+
"com.bugsee.option.capture.video",
|
|
15
|
+
"com.bugsee.option.capture.video.adaptive",
|
|
16
|
+
"com.bugsee.option.capture.video.frame-rate",
|
|
17
|
+
"com.bugsee.option.capture.video.quality",
|
|
18
|
+
"com.bugsee.option.capture.video.scale",
|
|
19
|
+
"com.bugsee.option.capture.view-hierarchy",
|
|
20
|
+
"com.bugsee.option.capture.webview.advanced",
|
|
21
|
+
"com.bugsee.option.capture.webview.report-trigger",
|
|
22
|
+
"com.bugsee.option.config.duration",
|
|
23
|
+
"com.bugsee.option.config.max-data-size",
|
|
24
|
+
"com.bugsee.option.config.notify-flush-delay",
|
|
25
|
+
"com.bugsee.option.config.wifi-only-upload",
|
|
26
|
+
"com.bugsee.option.detect.anomaly",
|
|
27
|
+
"com.bugsee.option.detect.crash",
|
|
28
|
+
"com.bugsee.option.detect.early-crash",
|
|
29
|
+
"com.bugsee.option.detect.exit",
|
|
30
|
+
"com.bugsee.option.detect.frustration",
|
|
31
|
+
"com.bugsee.option.detect.hang",
|
|
32
|
+
"com.bugsee.option.detect.hang.level.fair",
|
|
33
|
+
"com.bugsee.option.detect.hang.level.medium",
|
|
34
|
+
"com.bugsee.option.detect.hang.level.severe",
|
|
35
|
+
"com.bugsee.option.detect.http-errors",
|
|
36
|
+
"com.bugsee.option.detect.main_thread_misuse",
|
|
37
|
+
"com.bugsee.option.performance.adaptive-sampling",
|
|
38
|
+
"com.bugsee.option.performance.enabled",
|
|
39
|
+
"com.bugsee.option.performance.sample-rate",
|
|
40
|
+
"com.bugsee.option.reporting.defaults.bug-priority",
|
|
41
|
+
"com.bugsee.option.reporting.defaults.crash-priority",
|
|
42
|
+
"com.bugsee.option.reporting.defaults.error-priority",
|
|
43
|
+
"com.bugsee.option.reporting.triggers.screenshot",
|
|
44
|
+
"com.bugsee.option.reporting.triggers.shake",
|
|
45
|
+
"com.bugsee.option.reporting.ui.description-required",
|
|
46
|
+
"com.bugsee.option.reporting.ui.email-required",
|
|
47
|
+
"com.bugsee.option.reporting.ui.labels-enabled",
|
|
48
|
+
"com.bugsee.option.reporting.ui.labels-required",
|
|
49
|
+
"com.bugsee.option.reporting.ui.priority-selector-enabled",
|
|
50
|
+
"com.bugsee.option.reporting.ui.summary-required"
|
|
51
|
+
],
|
|
52
|
+
"ios": [
|
|
53
|
+
"com.bugsee.option.capture.avplayer",
|
|
54
|
+
"com.bugsee.option.capture.bluetooth-status",
|
|
55
|
+
"com.bugsee.option.capture.camera-preview",
|
|
56
|
+
"com.bugsee.option.capture.crash-handler-type",
|
|
57
|
+
"com.bugsee.option.capture.crash-signals",
|
|
58
|
+
"com.bugsee.option.capture.device-network-names",
|
|
59
|
+
"com.bugsee.option.capture.disk-space",
|
|
60
|
+
"com.bugsee.option.capture.logs.oslog",
|
|
61
|
+
"com.bugsee.option.capture.on-device-symbolication",
|
|
62
|
+
"com.bugsee.option.capture.sample-buffer-display-layer",
|
|
63
|
+
"com.bugsee.option.capture.status-bar-info",
|
|
64
|
+
"com.bugsee.option.capture.video.max-frame-rate",
|
|
65
|
+
"com.bugsee.option.capture.video.min-frame-rate",
|
|
66
|
+
"com.bugsee.option.capture.video.privacy-blur",
|
|
67
|
+
"com.bugsee.option.capture.websocket",
|
|
68
|
+
"com.bugsee.option.config.build-target",
|
|
69
|
+
"com.bugsee.option.config.build-type",
|
|
70
|
+
"com.bugsee.option.config.data-encryption",
|
|
71
|
+
"com.bugsee.option.detect.crash.fill_empty_exception_stacks",
|
|
72
|
+
"com.bugsee.option.detect.crash.swift_async_stacktraces",
|
|
73
|
+
"com.bugsee.option.reporting.ui.style"
|
|
74
|
+
],
|
|
75
|
+
"android": [
|
|
76
|
+
"com.bugsee.option.capture.logs.allsources",
|
|
77
|
+
"com.bugsee.option.capture.respect-flag-secure",
|
|
78
|
+
"com.bugsee.option.capture.video.custom-muxer",
|
|
79
|
+
"com.bugsee.option.capture.video.fullscreen-keep-running",
|
|
80
|
+
"com.bugsee.option.capture.video.fullscreen-remember-decision",
|
|
81
|
+
"com.bugsee.option.capture.video.mode",
|
|
82
|
+
"com.bugsee.option.capture.video.secure-scrolling",
|
|
83
|
+
"com.bugsee.option.capture.webview.domain-allowlist",
|
|
84
|
+
"com.bugsee.option.config.max-pending-report-age",
|
|
85
|
+
"com.bugsee.option.config.max-pending-reports",
|
|
86
|
+
"com.bugsee.option.config.report-handler-callback-timeout",
|
|
87
|
+
"com.bugsee.option.config.report-processing-in-process",
|
|
88
|
+
"com.bugsee.option.detect.anr.sampling",
|
|
89
|
+
"com.bugsee.option.detect.exit.bg_low_memory_as_error",
|
|
90
|
+
"com.bugsee.option.detect.exit.dependency_died",
|
|
91
|
+
"com.bugsee.option.detect.exit.excessive_resource_usage",
|
|
92
|
+
"com.bugsee.option.detect.exit.low_memory",
|
|
93
|
+
"com.bugsee.option.detect.exit.not_responding",
|
|
94
|
+
"com.bugsee.option.detect.exit.not_responding.as_crash",
|
|
95
|
+
"com.bugsee.option.detect.exit.other",
|
|
96
|
+
"com.bugsee.option.detect.exit.package_state_changed",
|
|
97
|
+
"com.bugsee.option.detect.exit.package_updated",
|
|
98
|
+
"com.bugsee.option.detect.exit.permission_changed",
|
|
99
|
+
"com.bugsee.option.detect.exit.unknown",
|
|
100
|
+
"com.bugsee.option.detect.exit.user_requested",
|
|
101
|
+
"com.bugsee.option.detect.exit.user_was_stopped",
|
|
102
|
+
"com.bugsee.option.detect.hang.sampling",
|
|
103
|
+
"com.bugsee.option.performance.upload-mode",
|
|
104
|
+
"com.bugsee.option.reporting.triggers.broadcast",
|
|
105
|
+
"com.bugsee.option.reporting.triggers.notification-bar"
|
|
106
|
+
]
|
|
107
|
+
}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
import NativeBugsee from '../NativeBugsee';
|
|
2
|
+
import { encodeBridgeObject } from '../bridge/json';
|
|
3
|
+
import type { IssueSeverity } from '../options/enums';
|
|
4
|
+
import { BugseeReportError, ReportErrorCode } from './errors';
|
|
5
|
+
import type {
|
|
6
|
+
BugseeReport,
|
|
7
|
+
BugseeReportSnapshot,
|
|
8
|
+
ReportPatch,
|
|
9
|
+
ReportType,
|
|
10
|
+
} from './types';
|
|
11
|
+
import {
|
|
12
|
+
normalizeFilePath,
|
|
13
|
+
severityFromNative,
|
|
14
|
+
validateBase64,
|
|
15
|
+
validateNonEmptyString,
|
|
16
|
+
validateReportPatch,
|
|
17
|
+
} from './validate';
|
|
18
|
+
|
|
19
|
+
const KNOWN_ERROR_CODES: ReadonlySet<string> = new Set(
|
|
20
|
+
Object.values(ReportErrorCode),
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Translates a native rejection into a `BugseeReportError` carrying the same
|
|
25
|
+
* `.code`, so a caller can match on `.code` no matter which side raised it.
|
|
26
|
+
* Anything else -- a rejection with no recognised code -- passes through
|
|
27
|
+
* unchanged rather than being reinterpreted as something it is not.
|
|
28
|
+
*/
|
|
29
|
+
export function toReportError(error: unknown): unknown {
|
|
30
|
+
if (error instanceof BugseeReportError) {
|
|
31
|
+
return error;
|
|
32
|
+
}
|
|
33
|
+
const code = (error as { code?: unknown } | null | undefined)?.code;
|
|
34
|
+
if (typeof code === 'string' && KNOWN_ERROR_CODES.has(code)) {
|
|
35
|
+
const message = (error as { message?: unknown }).message;
|
|
36
|
+
return new BugseeReportError(
|
|
37
|
+
code as ReportErrorCode,
|
|
38
|
+
typeof message === 'string' ? message : code,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
return error;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function emptySnapshot(): BugseeReportSnapshot {
|
|
45
|
+
return {
|
|
46
|
+
summary: undefined,
|
|
47
|
+
description: undefined,
|
|
48
|
+
severity: undefined,
|
|
49
|
+
labels: [],
|
|
50
|
+
attributes: {},
|
|
51
|
+
screenshotDisplayIds: [],
|
|
52
|
+
attachmentNames: [],
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function normalizeSnapshot(raw: unknown): BugseeReportSnapshot {
|
|
57
|
+
if (typeof raw !== 'object' || raw === null) {
|
|
58
|
+
return emptySnapshot();
|
|
59
|
+
}
|
|
60
|
+
const source = raw as Record<string, unknown>;
|
|
61
|
+
|
|
62
|
+
const attributes: Record<string, string | number | boolean> = {};
|
|
63
|
+
const rawAttributes = source.attributes;
|
|
64
|
+
if (typeof rawAttributes === 'object' && rawAttributes !== null) {
|
|
65
|
+
for (const [key, value] of Object.entries(
|
|
66
|
+
rawAttributes as Record<string, unknown>,
|
|
67
|
+
)) {
|
|
68
|
+
if (
|
|
69
|
+
typeof value === 'string' ||
|
|
70
|
+
typeof value === 'number' ||
|
|
71
|
+
typeof value === 'boolean'
|
|
72
|
+
) {
|
|
73
|
+
// Defined, not assigned: `attributes["__proto__"] = value` would hit
|
|
74
|
+
// Object.prototype's setter and drop the attribute. The object itself
|
|
75
|
+
// stays ordinary (hasOwnProperty, toString): callers get it as-is.
|
|
76
|
+
Object.defineProperty(attributes, key, {
|
|
77
|
+
value,
|
|
78
|
+
enumerable: true,
|
|
79
|
+
writable: true,
|
|
80
|
+
configurable: true,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const screenshotDisplayIds = Array.isArray(source.screenshotDisplayIds)
|
|
87
|
+
? [...(source.screenshotDisplayIds as number[])].sort((a, b) => a - b)
|
|
88
|
+
: [];
|
|
89
|
+
|
|
90
|
+
const summary = source.summary;
|
|
91
|
+
const description = source.description;
|
|
92
|
+
|
|
93
|
+
return {
|
|
94
|
+
summary: typeof summary === 'string' ? summary : undefined,
|
|
95
|
+
description: typeof description === 'string' ? description : undefined,
|
|
96
|
+
severity: severityFromNative(source.severity),
|
|
97
|
+
labels: Array.isArray(source.labels) ? [...(source.labels as string[])] : [],
|
|
98
|
+
attributes,
|
|
99
|
+
screenshotDisplayIds,
|
|
100
|
+
attachmentNames: Array.isArray(source.attachmentNames)
|
|
101
|
+
? [...(source.attachmentNames as string[])]
|
|
102
|
+
: [],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* The live `BugseeReport` handed to a `BugseeReportHandler` callback.
|
|
108
|
+
*
|
|
109
|
+
* One instance per delivered event -- two `onAfterReportCreated` calls for
|
|
110
|
+
* the same report get two independent proxies, each scoped to its own
|
|
111
|
+
* `handleId`. `markDead()` is not part of the public `BugseeReport` contract;
|
|
112
|
+
* only the dispatcher, which owns this proxy's lifetime, calls it.
|
|
113
|
+
*/
|
|
114
|
+
export class BugseeReportProxy implements BugseeReport {
|
|
115
|
+
readonly id: string;
|
|
116
|
+
readonly type: ReportType;
|
|
117
|
+
private readonly handleId: string;
|
|
118
|
+
private dead = false;
|
|
119
|
+
|
|
120
|
+
constructor(handleId: string, id: string, type: ReportType) {
|
|
121
|
+
this.handleId = handleId;
|
|
122
|
+
this.id = id;
|
|
123
|
+
this.type = type;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Marks this handle dead. Every operation after this rejects locally with
|
|
128
|
+
* `E_REPORT_HANDLE_DEAD` without crossing the bridge. Called by the
|
|
129
|
+
* dispatcher exactly once per handle -- when the callback that received
|
|
130
|
+
* this report settles, or when its deadline passes first.
|
|
131
|
+
*/
|
|
132
|
+
markDead(): void {
|
|
133
|
+
this.dead = true;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private ensureAlive(): void {
|
|
137
|
+
if (this.dead) {
|
|
138
|
+
throw new BugseeReportError(
|
|
139
|
+
ReportErrorCode.HandleDead,
|
|
140
|
+
'This BugseeReport handle is no longer valid: its handler has ' +
|
|
141
|
+
'already settled, or its deadline has passed.',
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
private async callNative<T>(fn: () => Promise<T>): Promise<T> {
|
|
147
|
+
try {
|
|
148
|
+
return await fn();
|
|
149
|
+
} catch (error) {
|
|
150
|
+
throw toReportError(error);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
async read(): Promise<BugseeReportSnapshot> {
|
|
155
|
+
this.ensureAlive();
|
|
156
|
+
const raw = await this.callNative(() =>
|
|
157
|
+
NativeBugsee.reportRead(this.handleId),
|
|
158
|
+
);
|
|
159
|
+
return normalizeSnapshot(raw);
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
async getSummary(): Promise<string | undefined> {
|
|
163
|
+
return (await this.read()).summary;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
async setSummary(value: string | null): Promise<void> {
|
|
167
|
+
await this.update({ summary: value });
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async getDescription(): Promise<string | undefined> {
|
|
171
|
+
return (await this.read()).description;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
async setDescription(value: string | null): Promise<void> {
|
|
175
|
+
await this.update({ description: value });
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async getSeverity(): Promise<IssueSeverity | undefined> {
|
|
179
|
+
return (await this.read()).severity;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
async setSeverity(value: IssueSeverity): Promise<void> {
|
|
183
|
+
await this.update({ severity: value });
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async getLabels(): Promise<string[]> {
|
|
187
|
+
return (await this.read()).labels;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
async setLabels(labels: readonly string[]): Promise<void> {
|
|
191
|
+
await this.update({ labels });
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
async getAttributes(): Promise<Record<string, string | number | boolean>> {
|
|
195
|
+
return (await this.read()).attributes;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async setAttribute(
|
|
199
|
+
name: string,
|
|
200
|
+
value: string | number | boolean | null,
|
|
201
|
+
): Promise<void> {
|
|
202
|
+
await this.update({ attributes: { [name]: value } });
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
async clearAttributes(): Promise<void> {
|
|
206
|
+
await this.update({ clearAttributes: true });
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async getScreenshotDisplayIds(): Promise<number[]> {
|
|
210
|
+
return (await this.read()).screenshotDisplayIds;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
async getAttachmentNames(): Promise<string[]> {
|
|
214
|
+
return (await this.read()).attachmentNames;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
async addFileAttachment(
|
|
218
|
+
path: string,
|
|
219
|
+
options: { name: string; mimeType?: string; move?: boolean },
|
|
220
|
+
): Promise<void> {
|
|
221
|
+
this.ensureAlive();
|
|
222
|
+
const normalizedPath = normalizeFilePath(
|
|
223
|
+
validateNonEmptyString(path, 'path'),
|
|
224
|
+
);
|
|
225
|
+
validateNonEmptyString(normalizedPath, 'path');
|
|
226
|
+
const name = validateNonEmptyString(options?.name, 'name');
|
|
227
|
+
await this.callNative(() =>
|
|
228
|
+
NativeBugsee.reportAddFileAttachment(
|
|
229
|
+
this.handleId,
|
|
230
|
+
normalizedPath,
|
|
231
|
+
name,
|
|
232
|
+
options?.mimeType ?? null,
|
|
233
|
+
options?.move ?? false,
|
|
234
|
+
),
|
|
235
|
+
);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
async addDataAttachment(
|
|
239
|
+
base64: string,
|
|
240
|
+
options: { name: string; mimeType?: string },
|
|
241
|
+
): Promise<void> {
|
|
242
|
+
this.ensureAlive();
|
|
243
|
+
const validBase64 = validateBase64(base64);
|
|
244
|
+
const name = validateNonEmptyString(options?.name, 'name');
|
|
245
|
+
await this.callNative(() =>
|
|
246
|
+
NativeBugsee.reportAddDataAttachment(
|
|
247
|
+
this.handleId,
|
|
248
|
+
validBase64,
|
|
249
|
+
name,
|
|
250
|
+
options?.mimeType ?? null,
|
|
251
|
+
),
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
async update(patch: ReportPatch): Promise<void> {
|
|
256
|
+
this.ensureAlive();
|
|
257
|
+
// Validated in full before anything crosses the bridge: a patch with one
|
|
258
|
+
// bad field must send nothing, not everything except that field. Then
|
|
259
|
+
// sent as JSON text, the only form in which a clearing `null` survives
|
|
260
|
+
// iOS's TurboModule argument conversion.
|
|
261
|
+
const wire = encodeBridgeObject(validateReportPatch(patch));
|
|
262
|
+
await this.callNative(() => NativeBugsee.reportUpdate(this.handleId, wire));
|
|
263
|
+
}
|
|
264
|
+
}
|