@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,33 @@
|
|
|
1
|
+
import NativeBugsee from '../NativeBugsee';
|
|
2
|
+
import { LogLevel } from '../options/enums';
|
|
3
|
+
|
|
4
|
+
const LEVELS: ReadonlySet<number> = new Set(Object.values(LogLevel));
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Sends one line into the SDK's wrapper channel, attributed to the wrapper.
|
|
8
|
+
*
|
|
9
|
+
* Internal, and deliberately not exported from the package entry. Its
|
|
10
|
+
* callers forward output this wrapper captured on its own -- Phase 9's
|
|
11
|
+
* `console.*` routing -- and there is to be one native route for those
|
|
12
|
+
* lines, not two. The app's own `Bugsee.log()` does not come here
|
|
13
|
+
* (`logs/log.ts`): with `capture.logs` off the SDKs record nothing from the
|
|
14
|
+
* channel.
|
|
15
|
+
*
|
|
16
|
+
* The app's log filter is NOT run here. Every channel line is filtered
|
|
17
|
+
* natively, once (design doc §10.3); running it in JS as well would call a
|
|
18
|
+
* customer's filter twice on one line.
|
|
19
|
+
*
|
|
20
|
+
* The level crosses by value, 1 Error .. 5 Verbose, identical on both
|
|
21
|
+
* platforms. Anything else is rejected here rather than left to the native
|
|
22
|
+
* default: 0 is iOS's `BugseeLogLevelInvalid`, and a fraction reaches Android
|
|
23
|
+
* as a double that truncates into a level nobody asked for.
|
|
24
|
+
*/
|
|
25
|
+
export function forwardLog(message: string, level: LogLevel = LogLevel.Info): void {
|
|
26
|
+
if (typeof message !== 'string') {
|
|
27
|
+
throw new TypeError(`forwardLog requires message to be a string, got ${typeof message}`);
|
|
28
|
+
}
|
|
29
|
+
if (!LEVELS.has(level)) {
|
|
30
|
+
throw new RangeError('forwardLog requires a LogLevel (1-5)');
|
|
31
|
+
}
|
|
32
|
+
NativeBugsee.wrapperLog(message, level);
|
|
33
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Gathers the facts the wrapper reports about itself.
|
|
3
|
+
*
|
|
4
|
+
* These are JS-side facts — the React Native version, the engine, the build
|
|
5
|
+
* configuration — so JS collects them and hands them down, rather than each
|
|
6
|
+
* bridge trying to work them out natively.
|
|
7
|
+
*/
|
|
8
|
+
import { Platform } from 'react-native';
|
|
9
|
+
import type { WrapperFacts } from './identity';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Wide enough for every supported React Native's own declaration: 0.87 types
|
|
13
|
+
* `prerelease` as a number on some platforms (API-49), and a consumer's tsc
|
|
14
|
+
* checks this file against whichever version the app is on.
|
|
15
|
+
*/
|
|
16
|
+
interface ReactNativeVersion {
|
|
17
|
+
major: number;
|
|
18
|
+
minor: number;
|
|
19
|
+
patch: number;
|
|
20
|
+
prerelease?: string | number | null;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** `0.87.1`, or `0.88.0-rc.1`, or `unknown`. */
|
|
24
|
+
export function formatReactNativeVersion(
|
|
25
|
+
version: ReactNativeVersion | undefined,
|
|
26
|
+
): string {
|
|
27
|
+
if (
|
|
28
|
+
version === undefined ||
|
|
29
|
+
typeof version.major !== 'number' ||
|
|
30
|
+
typeof version.minor !== 'number' ||
|
|
31
|
+
typeof version.patch !== 'number'
|
|
32
|
+
) {
|
|
33
|
+
return 'unknown';
|
|
34
|
+
}
|
|
35
|
+
// Not `major || 0`: every component of 0.0.0 is falsy and would be dropped.
|
|
36
|
+
const core = `${version.major}.${version.minor}.${version.patch}`;
|
|
37
|
+
return version.prerelease ? `${core}-${version.prerelease}` : core;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
declare const __DEV__: boolean;
|
|
41
|
+
|
|
42
|
+
export function collectWrapperFacts(version: string): WrapperFacts {
|
|
43
|
+
return {
|
|
44
|
+
version,
|
|
45
|
+
reactNativeVersion: formatReactNativeVersion(
|
|
46
|
+
Platform.constants?.reactNativeVersion,
|
|
47
|
+
),
|
|
48
|
+
// Hermes announces itself with a global; there is no API for it.
|
|
49
|
+
hermes: (globalThis as { HermesInternal?: unknown }).HermesInternal != null,
|
|
50
|
+
dev: typeof __DEV__ === 'boolean' ? __DEV__ : false,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Status } from '../status';
|
|
2
|
+
import type { LifecycleEventName } from './lifecycle-events';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A lifecycle event as it reaches JavaScript.
|
|
6
|
+
*
|
|
7
|
+
* `name` is typed as the known set OR an arbitrary string, deliberately. A
|
|
8
|
+
* newer SDK adding an event must reach a JS subscriber rather than being
|
|
9
|
+
* dropped by a wrapper that predates it — silently swallowing an unknown event
|
|
10
|
+
* is how a whole feature goes missing with no error anywhere. The union keeps
|
|
11
|
+
* autocomplete useful for the known names without closing the set.
|
|
12
|
+
*/
|
|
13
|
+
export interface LifecycleEvent {
|
|
14
|
+
name: LifecycleEventName | (string & {});
|
|
15
|
+
/** Present only for the events that carry one. */
|
|
16
|
+
reportId?: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The four events that correspond to an SDK status transition.
|
|
21
|
+
*
|
|
22
|
+
* Status is DERIVED from the lifecycle channel rather than delivered by a
|
|
23
|
+
* second native emitter: Android exposes no status listener at all, only
|
|
24
|
+
* `getStatus()`, and iOS's `bugseeDidChangeStatus:` belongs to the app's own
|
|
25
|
+
* `BugseeDelegate` — consuming it would take it away from the app. Deriving
|
|
26
|
+
* keeps one source, one mapping, and one set of tests covering both platforms.
|
|
27
|
+
*/
|
|
28
|
+
const STATUS_BY_EVENT: Partial<Record<string, Status>> = {
|
|
29
|
+
Launching: Status.Launching,
|
|
30
|
+
Launched: Status.Launched,
|
|
31
|
+
Stopping: Status.Stopping,
|
|
32
|
+
Stopped: Status.Stopped,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* The status `event` announces, or `undefined` when it announces none.
|
|
37
|
+
*
|
|
38
|
+
* Undefined rather than a default: reporting a status for an event that is not
|
|
39
|
+
* a transition would tell a caller the SDK had moved when it had not, which is
|
|
40
|
+
* worse than silence because it reads as information. The same applies to an
|
|
41
|
+
* event this version does not know — unknown means unknown, not `Stopped`.
|
|
42
|
+
*/
|
|
43
|
+
export function statusForEvent(event: LifecycleEvent): Status | undefined {
|
|
44
|
+
return STATUS_BY_EVENT[event.name];
|
|
45
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who this wrapper is, as the SDKs' `BugseeWrapper` contract asks.
|
|
3
|
+
*
|
|
4
|
+
* Both platforms expose `wrapperType` / `wrapperVersion` / `wrapperBuild` and
|
|
5
|
+
* a string-to-string `context` map. JS gathers the values because JS is where
|
|
6
|
+
* they are knowable — the React Native version, the engine and the build
|
|
7
|
+
* configuration are all JS-side facts — and hands them to the bridge, which
|
|
8
|
+
* registers a wrapper object carrying them.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The backend's own identifier for this wrapper
|
|
13
|
+
* (`APPLICATION_SUB_TYPE_REACT_NATIVE`). Note that three spellings exist:
|
|
14
|
+
* the Android SDK's doc comment suggests `react-native`, and the 6.x wrapper
|
|
15
|
+
* sent `react`. Symbolication routes on the exception type, not on this, so
|
|
16
|
+
* the choice is about identification rather than dispatch.
|
|
17
|
+
*/
|
|
18
|
+
export const WRAPPER_TYPE = 'react_native';
|
|
19
|
+
|
|
20
|
+
export interface WrapperFacts {
|
|
21
|
+
/** The `@bugsee/react-native` package version. */
|
|
22
|
+
version: string;
|
|
23
|
+
reactNativeVersion: string;
|
|
24
|
+
/** Whether Hermes is the engine, from `global.HermesInternal`. */
|
|
25
|
+
hermes: boolean;
|
|
26
|
+
/** Whether this is a debug build, from `__DEV__`. */
|
|
27
|
+
dev: boolean;
|
|
28
|
+
build?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface WrapperIdentity {
|
|
32
|
+
type: string;
|
|
33
|
+
version: string;
|
|
34
|
+
build?: string;
|
|
35
|
+
/** String-to-string, because that is how both SDKs type it. */
|
|
36
|
+
context: Record<string, string>;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** Reported when a fact is missing, rather than an empty string that reads
|
|
40
|
+
* as "this wrapper has no version". */
|
|
41
|
+
const UNKNOWN = 'unknown';
|
|
42
|
+
|
|
43
|
+
export function wrapperIdentity(facts: WrapperFacts): WrapperIdentity {
|
|
44
|
+
return {
|
|
45
|
+
type: WRAPPER_TYPE,
|
|
46
|
+
version: facts.version || UNKNOWN,
|
|
47
|
+
...(facts.build === undefined ? {} : { build: facts.build }),
|
|
48
|
+
context: {
|
|
49
|
+
'react-native': facts.reactNativeVersion || UNKNOWN,
|
|
50
|
+
'js-engine': facts.hermes ? 'hermes' : 'jsc',
|
|
51
|
+
'build-configuration': facts.dev ? 'debug' : 'release',
|
|
52
|
+
},
|
|
53
|
+
};
|
|
54
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The lifecycle events the SDKs dispatch to a wrapper.
|
|
3
|
+
*
|
|
4
|
+
* Both platforms deliver these **by name**, under `com.bugsee.lifecycle.*`,
|
|
5
|
+
* so the bridge needs no per-platform mapping. That is worth stating because
|
|
6
|
+
* iOS also has a `BugseeLifecycleEventType` enum — but that is the app-facing
|
|
7
|
+
* `BugseeDelegate` channel, not the wrapper's, and its raw values shift
|
|
8
|
+
* between releases (7.0.0-beta2 deleted `Started`, `Resumed` and `Paused`,
|
|
9
|
+
* renumbering everything after `Launched`). Consuming names rather than the
|
|
10
|
+
* enum is what keeps this wrapper unaffected by that, and is a constraint to
|
|
11
|
+
* keep rather than an accident.
|
|
12
|
+
*
|
|
13
|
+
* Every event here fires on both platforms as of Android 7.2.0 and iOS
|
|
14
|
+
* 7.0.0-beta2, which implemented the wrapper channel. Availability is still
|
|
15
|
+
* recorded per event: iOS 7.0.0-beta1 dispatched only six, and the shape is
|
|
16
|
+
* needed again the moment the two SDKs diverge.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
/** Where an event is known to fire. */
|
|
20
|
+
export interface EventAvailability {
|
|
21
|
+
android: boolean;
|
|
22
|
+
ios: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Keyed by the name both SDKs use. Android's wire value is the name prefixed
|
|
27
|
+
* with `com.bugsee.lifecycle.`; iOS sends an enum the bridge maps back.
|
|
28
|
+
*/
|
|
29
|
+
export const LIFECYCLE_EVENTS = {
|
|
30
|
+
Launching: { android: true, ios: true },
|
|
31
|
+
Launched: { android: true, ios: true },
|
|
32
|
+
Stopping: { android: true, ios: true },
|
|
33
|
+
Stopped: { android: true, ios: true },
|
|
34
|
+
BlackoutStarted: { android: true, ios: true },
|
|
35
|
+
BlackoutEnded: { android: true, ios: true },
|
|
36
|
+
RelaunchedAfterCrash: { android: true, ios: true },
|
|
37
|
+
BeforeReportShown: { android: true, ios: true },
|
|
38
|
+
AfterReportShown: { android: true, ios: true },
|
|
39
|
+
BeforeReportAssembled: { android: true, ios: true },
|
|
40
|
+
AfterReportAssembled: { android: true, ios: true },
|
|
41
|
+
ReportAssemblyFailed: { android: true, ios: true },
|
|
42
|
+
BeforeReportUploaded: { android: true, ios: true },
|
|
43
|
+
AfterReportUploaded: { android: true, ios: true },
|
|
44
|
+
ReportUploadFailed: { android: true, ios: true },
|
|
45
|
+
ReportUploadFailedWithFutureRetry: { android: true, ios: true },
|
|
46
|
+
} as const satisfies Record<string, EventAvailability>;
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Events whose `data` carries the report's id. Every other event delivers
|
|
50
|
+
* nil — including `Before`/`AfterReportShown`, which are announced from the
|
|
51
|
+
* report UI before a report exists.
|
|
52
|
+
*/
|
|
53
|
+
export const EVENTS_CARRYING_REPORT_ID: readonly LifecycleEventName[] = [
|
|
54
|
+
'BeforeReportAssembled',
|
|
55
|
+
'AfterReportAssembled',
|
|
56
|
+
'ReportAssemblyFailed',
|
|
57
|
+
'BeforeReportUploaded',
|
|
58
|
+
'AfterReportUploaded',
|
|
59
|
+
'ReportUploadFailed',
|
|
60
|
+
'ReportUploadFailedWithFutureRetry',
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
export type LifecycleEventName = keyof typeof LIFECYCLE_EVENTS;
|
|
64
|
+
|
|
65
|
+
/** The wire form on BOTH platforms since iOS 7.0.0-beta2. */
|
|
66
|
+
export const ANDROID_EVENT_PREFIX = 'com.bugsee.lifecycle.';
|
|
67
|
+
|
|
68
|
+
export function wireEventName(event: LifecycleEventName): string {
|
|
69
|
+
return `${ANDROID_EVENT_PREFIX}${event}`;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/** The event an Android wire name refers to, or undefined if unknown. */
|
|
73
|
+
export function eventFromWireName(
|
|
74
|
+
wire: string,
|
|
75
|
+
): LifecycleEventName | undefined {
|
|
76
|
+
if (!wire.startsWith(ANDROID_EVENT_PREFIX)) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
const name = wire.slice(ANDROID_EVENT_PREFIX.length);
|
|
80
|
+
return name in LIFECYCLE_EVENTS ? (name as LifecycleEventName) : undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Whether this event fires on the platform the app is running. */
|
|
84
|
+
export function firesOn(
|
|
85
|
+
event: LifecycleEventName,
|
|
86
|
+
platform: 'ios' | 'android',
|
|
87
|
+
): boolean {
|
|
88
|
+
return LIFECYCLE_EVENTS[event][platform];
|
|
89
|
+
}
|