react-native-inapp-inspector 2.3.19 → 2.3.21
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/README.md +14 -14
- package/android/src/main/java/com/inappinspector/NetworkInspectorModule.kt +67 -0
- package/dist/commonjs/analytics.js +1 -24
- package/dist/commonjs/bundle.js +1 -16
- package/dist/commonjs/capture.js +1 -35
- package/dist/commonjs/components/AnalyticsDetail.js +92 -623
- package/dist/commonjs/components/AnalyticsEventCard.js +54 -350
- package/dist/commonjs/components/AnalyticsGraph.js +70 -370
- package/dist/commonjs/components/AnimatedEntrance.js +1 -11
- package/dist/commonjs/components/AppHeaderLogo.js +7 -134
- package/dist/commonjs/components/BrandCircleIcon.js +73 -118
- package/dist/commonjs/components/BrandSquareIcon.js +63 -108
- package/dist/commonjs/components/CodeSnippet.js +48 -623
- package/dist/commonjs/components/ConsoleLogCard.js +63 -537
- package/dist/commonjs/components/CopyButton.js +3 -89
- package/dist/commonjs/components/DiffViewer.js +19 -83
- package/dist/commonjs/components/DomainHeader.js +27 -127
- package/dist/commonjs/components/EmptyState.js +10 -87
- package/dist/commonjs/components/EndOfListFooter.js +7 -81
- package/dist/commonjs/components/ErrorBoundary.js +72 -566
- package/dist/commonjs/components/HeadersSection.js +31 -110
- package/dist/commonjs/components/HighlightText.js +17 -58
- package/dist/commonjs/components/Inspector/AboutModal.d.ts +6 -0
- package/dist/commonjs/components/Inspector/AboutModal.js +243 -0
- package/dist/commonjs/components/Inspector/AnalyticsFilterModal.js +98 -797
- package/dist/commonjs/components/Inspector/AnalyticsTab.js +284 -930
- package/dist/commonjs/components/Inspector/BundleTab.js +551 -2918
- package/dist/commonjs/components/Inspector/ConsoleTab.js +79 -492
- package/dist/commonjs/components/Inspector/CrashDetail.js +123 -672
- package/dist/commonjs/components/Inspector/CrashFilterModal.js +66 -498
- package/dist/commonjs/components/Inspector/CrashTab.js +98 -670
- package/dist/commonjs/components/Inspector/DebuggingTab.js +74 -875
- package/dist/commonjs/components/Inspector/DeviceInfoTab.js +143 -907
- package/dist/commonjs/components/Inspector/FabLauncher.js +42 -466
- package/dist/commonjs/components/Inspector/FeatureUnderDevNotice.js +6 -99
- package/dist/commonjs/components/Inspector/InspectorContext.js +1 -21
- package/dist/commonjs/components/Inspector/InspectorHeader.js +191 -1110
- package/dist/commonjs/components/Inspector/LogDetail.js +168 -994
- package/dist/commonjs/components/Inspector/MainScreen.js +52 -335
- package/dist/commonjs/components/Inspector/MediaGalleryTab.js +97 -644
- package/dist/commonjs/components/Inspector/MediaPreviewModal.js +90 -605
- package/dist/commonjs/components/Inspector/NavigationTracker.js +1 -12
- package/dist/commonjs/components/Inspector/NetworkDetail.js +89 -411
- package/dist/commonjs/components/Inspector/NetworkFilterModal.js +60 -576
- package/dist/commonjs/components/Inspector/NetworkTab.js +84 -514
- package/dist/commonjs/components/Inspector/NpmStarPrompt.js +18 -434
- package/dist/commonjs/components/Inspector/NpmUpdateToast.js +25 -298
- package/dist/commonjs/components/Inspector/PerformanceTab.js +182 -1397
- package/dist/commonjs/components/Inspector/ReduxDetail.js +188 -1089
- package/dist/commonjs/components/Inspector/ReduxTab.js +85 -701
- package/dist/commonjs/components/Inspector/SettingsPanel.js +427 -3807
- package/dist/commonjs/components/Inspector/SkeletonPlaceholder.js +11 -180
- package/dist/commonjs/components/Inspector/StorageTab.js +93 -826
- package/dist/commonjs/components/Inspector/TabBar.js +36 -334
- package/dist/commonjs/components/Inspector/UpdateAvailableModal.js +37 -412
- package/dist/commonjs/components/JsonViewer.js +168 -381
- package/dist/commonjs/components/LogCard.js +57 -567
- package/dist/commonjs/components/LogSyntaxHighlighter.js +11 -130
- package/dist/commonjs/components/MetaAccordion.js +69 -238
- package/dist/commonjs/components/MiniBarChart.js +3 -56
- package/dist/commonjs/components/MiniLineChart.js +3 -58
- package/dist/commonjs/components/NetworkIcons.d.ts +13 -0
- package/dist/commonjs/components/NetworkIcons.js +521 -1022
- package/dist/commonjs/components/QRCodeView.js +5 -79
- package/dist/commonjs/components/SectionHeader.js +15 -37
- package/dist/commonjs/components/SegmentedTabs.js +7 -62
- package/dist/commonjs/components/SkeletonPlaceholder.js +11 -180
- package/dist/commonjs/components/Slider.js +15 -243
- package/dist/commonjs/components/SourcePageCard.js +30 -89
- package/dist/commonjs/components/Toast.js +5 -147
- package/dist/commonjs/components/TouchableScale.js +3 -24
- package/dist/commonjs/components/TreeNode.js +55 -130
- package/dist/commonjs/console.js +1 -16
- package/dist/commonjs/constants/index.js +1 -32
- package/dist/commonjs/constants/telemetryConfig.js +1 -6
- package/dist/commonjs/constants/version.d.ts +1 -1
- package/dist/commonjs/constants/version.js +1 -4
- package/dist/commonjs/crash.js +1 -23
- package/dist/commonjs/customHooks/analyticsLogger.js +1 -250
- package/dist/commonjs/customHooks/bundleAnalyzer.js +1 -957
- package/dist/commonjs/customHooks/consoleLogger.js +6 -445
- package/dist/commonjs/customHooks/crashHandler.js +7 -656
- package/dist/commonjs/customHooks/logFilters.js +1 -23
- package/dist/commonjs/customHooks/networkLogger.js +2 -536
- package/dist/commonjs/customHooks/performanceTracker.js +63 -750
- package/dist/commonjs/customHooks/reduxLogger.js +2 -313
- package/dist/commonjs/customHooks/storageInspector.js +1 -435
- package/dist/commonjs/customHooks/useAccordion.js +1 -18
- package/dist/commonjs/decorators/index.js +1 -100
- package/dist/commonjs/helpers/gaAnalyticsRegistry.js +1 -148
- package/dist/commonjs/helpers/index.d.ts +1 -0
- package/dist/commonjs/helpers/index.js +8 -921
- package/dist/commonjs/helpers/memoryManager.js +1 -99
- package/dist/commonjs/helpers/qrGenerator.js +1 -367
- package/dist/commonjs/helpers/remoteConfig.js +1 -165
- package/dist/commonjs/helpers/searchQueryParser.js +1 -62
- package/dist/commonjs/helpers/settingsStore.js +1 -144
- package/dist/commonjs/helpers/telemetry.js +1 -501
- package/dist/commonjs/helpers/toast.js +1 -20
- package/dist/commonjs/i18n/index.js +1 -90
- package/dist/commonjs/i18n/locales/en.json +1 -1140
- package/dist/commonjs/index.js +5 -2168
- package/dist/commonjs/metro.js +6 -468
- package/dist/commonjs/native/NativeInspector.d.ts +1 -0
- package/dist/commonjs/native/NativeInspector.js +1 -415
- package/dist/commonjs/native/NativeNetworkInspector.js +1 -4
- package/dist/commonjs/network.js +1 -13
- package/dist/commonjs/performance.js +1 -29
- package/dist/commonjs/redux.js +1 -20
- package/dist/commonjs/storage.js +1 -14
- package/dist/commonjs/styles/AppColors.js +1 -423
- package/dist/commonjs/styles/AppFonts.js +1 -17
- package/dist/commonjs/styles/common.js +1 -190
- package/dist/commonjs/styles/index.d.ts +6 -0
- package/dist/commonjs/styles/index.js +1 -1589
- package/dist/commonjs/types/enums.d.ts +0 -1
- package/dist/commonjs/types/enums.js +1 -152
- package/dist/commonjs/types/index.js +1 -18
- package/dist/commonjs/types/interfaces.d.ts +2 -2
- package/dist/commonjs/types/interfaces.js +1 -2
- package/dist/esm/analytics.js +1 -2
- package/dist/esm/bundle.js +1 -2
- package/dist/esm/capture.js +1 -32
- package/dist/esm/components/AnalyticsDetail.js +171 -664
- package/dist/esm/components/AnalyticsEventCard.js +77 -335
- package/dist/esm/components/AnalyticsGraph.js +95 -357
- package/dist/esm/components/AnimatedEntrance.js +1 -6
- package/dist/esm/components/AppHeaderLogo.js +7 -94
- package/dist/esm/components/BrandCircleIcon.js +114 -119
- package/dist/esm/components/BrandSquareIcon.js +73 -78
- package/dist/esm/components/CodeSnippet.js +58 -595
- package/dist/esm/components/ConsoleLogCard.js +91 -526
- package/dist/esm/components/CopyButton.js +3 -51
- package/dist/esm/components/DiffViewer.js +22 -48
- package/dist/esm/components/DomainHeader.js +43 -138
- package/dist/esm/components/EmptyState.js +17 -56
- package/dist/esm/components/EndOfListFooter.js +15 -83
- package/dist/esm/components/ErrorBoundary.js +125 -582
- package/dist/esm/components/HeadersSection.js +52 -93
- package/dist/esm/components/HighlightText.js +17 -53
- package/dist/esm/components/Inspector/AboutModal.d.ts +6 -0
- package/dist/esm/components/Inspector/AboutModal.js +243 -0
- package/dist/esm/components/Inspector/AnalyticsFilterModal.js +225 -886
- package/dist/esm/components/Inspector/AnalyticsTab.js +296 -904
- package/dist/esm/components/Inspector/BundleTab.js +1175 -3502
- package/dist/esm/components/Inspector/ConsoleTab.js +113 -488
- package/dist/esm/components/Inspector/CrashDetail.js +236 -747
- package/dist/esm/components/Inspector/CrashFilterModal.js +149 -541
- package/dist/esm/components/Inspector/CrashTab.js +177 -711
- package/dist/esm/components/Inspector/DebuggingTab.js +164 -925
- package/dist/esm/components/Inspector/DeviceInfoTab.js +199 -924
- package/dist/esm/components/Inspector/FabLauncher.js +68 -454
- package/dist/esm/components/Inspector/FeatureUnderDevNotice.js +14 -70
- package/dist/esm/components/Inspector/InspectorContext.js +1 -12
- package/dist/esm/components/Inspector/InspectorHeader.js +282 -1163
- package/dist/esm/components/Inspector/LogDetail.js +235 -1023
- package/dist/esm/components/Inspector/MainScreen.js +78 -323
- package/dist/esm/components/Inspector/MediaGalleryTab.js +143 -650
- package/dist/esm/components/Inspector/MediaPreviewModal.js +138 -613
- package/dist/esm/components/Inspector/NavigationTracker.js +1 -10
- package/dist/esm/components/Inspector/NetworkDetail.js +138 -455
- package/dist/esm/components/Inspector/NetworkFilterModal.js +122 -597
- package/dist/esm/components/Inspector/NetworkTab.js +125 -517
- package/dist/esm/components/Inspector/NpmStarPrompt.js +58 -434
- package/dist/esm/components/Inspector/NpmUpdateToast.js +45 -281
- package/dist/esm/components/Inspector/PerformanceTab.js +393 -1570
- package/dist/esm/components/Inspector/ReduxDetail.js +307 -1170
- package/dist/esm/components/Inspector/ReduxTab.js +144 -722
- package/dist/esm/components/Inspector/SettingsPanel.js +643 -3985
- package/dist/esm/components/Inspector/SkeletonPlaceholder.js +30 -163
- package/dist/esm/components/Inspector/StorageTab.js +172 -866
- package/dist/esm/components/Inspector/TabBar.js +45 -305
- package/dist/esm/components/Inspector/UpdateAvailableModal.js +80 -418
- package/dist/esm/components/JsonViewer.js +179 -354
- package/dist/esm/components/LogCard.js +93 -565
- package/dist/esm/components/LogSyntaxHighlighter.js +11 -123
- package/dist/esm/components/MetaAccordion.js +136 -267
- package/dist/esm/components/MiniBarChart.js +3 -18
- package/dist/esm/components/MiniLineChart.js +3 -20
- package/dist/esm/components/NetworkIcons.d.ts +13 -0
- package/dist/esm/components/NetworkIcons.js +523 -838
- package/dist/esm/components/QRCodeView.js +8 -45
- package/dist/esm/components/SectionHeader.js +22 -39
- package/dist/esm/components/SegmentedTabs.js +8 -58
- package/dist/esm/components/SkeletonPlaceholder.js +30 -163
- package/dist/esm/components/Slider.js +24 -213
- package/dist/esm/components/SourcePageCard.js +65 -86
- package/dist/esm/components/Toast.js +10 -117
- package/dist/esm/components/TouchableScale.js +3 -19
- package/dist/esm/components/TreeNode.js +58 -95
- package/dist/esm/console.js +1 -2
- package/dist/esm/constants/index.js +1 -28
- package/dist/esm/constants/telemetryConfig.js +1 -3
- package/dist/esm/constants/version.d.ts +1 -1
- package/dist/esm/constants/version.js +1 -1
- package/dist/esm/crash.js +1 -2
- package/dist/esm/customHooks/analyticsLogger.js +1 -230
- package/dist/esm/customHooks/bundleAnalyzer.js +1 -944
- package/dist/esm/customHooks/consoleLogger.js +6 -432
- package/dist/esm/customHooks/crashHandler.js +7 -630
- package/dist/esm/customHooks/logFilters.js +1 -20
- package/dist/esm/customHooks/networkLogger.js +2 -519
- package/dist/esm/customHooks/performanceTracker.js +63 -723
- package/dist/esm/customHooks/reduxLogger.js +2 -293
- package/dist/esm/customHooks/storageInspector.js +1 -418
- package/dist/esm/customHooks/useAccordion.js +1 -16
- package/dist/esm/decorators/index.js +1 -95
- package/dist/esm/helpers/gaAnalyticsRegistry.js +1 -143
- package/dist/esm/helpers/index.d.ts +1 -0
- package/dist/esm/helpers/index.js +8 -861
- package/dist/esm/helpers/memoryManager.js +1 -91
- package/dist/esm/helpers/qrGenerator.js +1 -364
- package/dist/esm/helpers/remoteConfig.js +1 -160
- package/dist/esm/helpers/searchQueryParser.js +1 -59
- package/dist/esm/helpers/settingsStore.js +1 -134
- package/dist/esm/helpers/telemetry.js +1 -489
- package/dist/esm/helpers/toast.js +1 -15
- package/dist/esm/i18n/index.js +1 -78
- package/dist/esm/i18n/locales/en.json +1 -1140
- package/dist/esm/index.js +7 -1982
- package/dist/esm/metro.js +6 -459
- package/dist/esm/native/NativeInspector.d.ts +1 -0
- package/dist/esm/native/NativeInspector.js +1 -382
- package/dist/esm/native/NativeNetworkInspector.js +1 -2
- package/dist/esm/network.js +1 -1
- package/dist/esm/performance.js +1 -2
- package/dist/esm/redux.js +1 -1
- package/dist/esm/storage.js +1 -1
- package/dist/esm/styles/AppColors.js +1 -417
- package/dist/esm/styles/AppFonts.js +1 -13
- package/dist/esm/styles/common.js +1 -186
- package/dist/esm/styles/index.d.ts +6 -0
- package/dist/esm/styles/index.js +1 -1551
- package/dist/esm/types/enums.d.ts +0 -1
- package/dist/esm/types/enums.js +1 -149
- package/dist/esm/types/index.js +1 -2
- package/dist/esm/types/interfaces.d.ts +2 -2
- package/dist/esm/types/interfaces.js +1 -1
- package/ios/NetworkInspectorModule.mm +60 -12
- package/package.json +5 -3
- package/src/native/NativeInspector.ts +18 -0
- package/dist/commonjs/components/Inspector/FeedbackModal.d.ts +0 -7
- package/dist/commonjs/components/Inspector/FeedbackModal.js +0 -552
- package/dist/esm/components/Inspector/FeedbackModal.d.ts +0 -7
- package/dist/esm/components/Inspector/FeedbackModal.js +0 -515
- package/src/analytics.ts +0 -35
- package/src/bundle.ts +0 -25
- package/src/capture.ts +0 -109
- package/src/components/AnalyticsDetail.tsx +0 -870
- package/src/components/AnalyticsEventCard.tsx +0 -444
- package/src/components/AnalyticsGraph.tsx +0 -583
- package/src/components/AnimatedEntrance.tsx +0 -20
- package/src/components/AppHeaderLogo.tsx +0 -143
- package/src/components/BrandCircleIcon.tsx +0 -144
- package/src/components/BrandSquareIcon.tsx +0 -184
- package/src/components/CodeSnippet.tsx +0 -725
- package/src/components/ConsoleLogCard.tsx +0 -679
- package/src/components/CopyButton.tsx +0 -87
- package/src/components/DiffViewer.tsx +0 -82
- package/src/components/DomainHeader.tsx +0 -224
- package/src/components/EmptyState.tsx +0 -97
- package/src/components/EndOfListFooter.tsx +0 -100
- package/src/components/ErrorBoundary.tsx +0 -688
- package/src/components/HeadersSection.tsx +0 -172
- package/src/components/HighlightText.tsx +0 -100
- package/src/components/Inspector/AnalyticsFilterModal.tsx +0 -1250
- package/src/components/Inspector/AnalyticsTab.tsx +0 -1362
- package/src/components/Inspector/BundleTab.tsx +0 -4768
- package/src/components/Inspector/ConsoleTab.tsx +0 -726
- package/src/components/Inspector/CrashDetail.tsx +0 -997
- package/src/components/Inspector/CrashFilterModal.tsx +0 -721
- package/src/components/Inspector/CrashTab.tsx +0 -933
- package/src/components/Inspector/DebuggingTab.tsx +0 -1103
- package/src/components/Inspector/DeviceInfoTab.tsx +0 -1397
- package/src/components/Inspector/FabLauncher.tsx +0 -590
- package/src/components/Inspector/FeatureUnderDevNotice.tsx +0 -94
- package/src/components/Inspector/FeedbackModal.tsx +0 -626
- package/src/components/Inspector/InspectorContext.tsx +0 -28
- package/src/components/Inspector/InspectorHeader.tsx +0 -1583
- package/src/components/Inspector/LogDetail.tsx +0 -1431
- package/src/components/Inspector/MainScreen.tsx +0 -460
- package/src/components/Inspector/MediaGalleryTab.tsx +0 -829
- package/src/components/Inspector/MediaPreviewModal.tsx +0 -783
- package/src/components/Inspector/NavigationTracker.tsx +0 -13
- package/src/components/Inspector/NetworkDetail.tsx +0 -778
- package/src/components/Inspector/NetworkFilterModal.tsx +0 -730
- package/src/components/Inspector/NetworkTab.tsx +0 -820
- package/src/components/Inspector/NpmStarPrompt.tsx +0 -532
- package/src/components/Inspector/NpmUpdateToast.tsx +0 -387
- package/src/components/Inspector/PerformanceTab.tsx +0 -1967
- package/src/components/Inspector/ReduxDetail.tsx +0 -1651
- package/src/components/Inspector/ReduxTab.tsx +0 -987
- package/src/components/Inspector/SettingsPanel.tsx +0 -5136
- package/src/components/Inspector/SkeletonPlaceholder.tsx +0 -206
- package/src/components/Inspector/StorageTab.tsx +0 -1159
- package/src/components/Inspector/TabBar.tsx +0 -431
- package/src/components/Inspector/UpdateAvailableModal.tsx +0 -555
- package/src/components/JsonViewer.tsx +0 -549
- package/src/components/LogCard.tsx +0 -694
- package/src/components/LogSyntaxHighlighter.tsx +0 -178
- package/src/components/MetaAccordion.tsx +0 -355
- package/src/components/MiniBarChart.tsx +0 -42
- package/src/components/MiniLineChart.tsx +0 -33
- package/src/components/NetworkIcons.tsx +0 -2655
- package/src/components/QRCodeView.tsx +0 -75
- package/src/components/SectionHeader.tsx +0 -101
- package/src/components/SegmentedTabs.tsx +0 -84
- package/src/components/SkeletonPlaceholder.tsx +0 -206
- package/src/components/Slider.tsx +0 -300
- package/src/components/SourcePageCard.tsx +0 -150
- package/src/components/Toast.tsx +0 -131
- package/src/components/TouchableScale.tsx +0 -61
- package/src/components/TreeNode.tsx +0 -171
- package/src/console.ts +0 -24
- package/src/constants/index.ts +0 -41
- package/src/constants/telemetryConfig.ts +0 -4
- package/src/constants/version.ts +0 -3
- package/src/crash.ts +0 -32
- package/src/customHooks/analyticsLogger.ts +0 -336
- package/src/customHooks/bundleAnalyzer.ts +0 -1256
- package/src/customHooks/consoleLogger.ts +0 -530
- package/src/customHooks/crashHandler.ts +0 -944
- package/src/customHooks/logFilters.ts +0 -32
- package/src/customHooks/networkLogger.ts +0 -624
- package/src/customHooks/performanceTracker.ts +0 -1014
- package/src/customHooks/reduxLogger.ts +0 -406
- package/src/customHooks/storageInspector.ts +0 -513
- package/src/customHooks/useAccordion.tsx +0 -27
- package/src/decorators/index.ts +0 -184
- package/src/helpers/gaAnalyticsRegistry.ts +0 -204
- package/src/helpers/index.ts +0 -1092
- package/src/helpers/memoryManager.ts +0 -138
- package/src/helpers/qrGenerator.ts +0 -430
- package/src/helpers/remoteConfig.ts +0 -212
- package/src/helpers/searchQueryParser.ts +0 -84
- package/src/helpers/settingsStore.ts +0 -171
- package/src/helpers/telemetry.ts +0 -568
- package/src/helpers/toast.ts +0 -17
- package/src/i18n/index.ts +0 -104
- package/src/i18n/locales/en.json +0 -1141
- package/src/index.tsx +0 -2650
- package/src/metro.ts +0 -598
- package/src/network.ts +0 -22
- package/src/performance.ts +0 -38
- package/src/redux.ts +0 -23
- package/src/storage.ts +0 -18
- package/src/styles/AppColors.ts +0 -455
- package/src/styles/AppFonts.ts +0 -26
- package/src/styles/common.ts +0 -209
- package/src/styles/index.ts +0 -1606
- package/src/types/enums.ts +0 -210
- package/src/types/index.ts +0 -34
- package/src/types/interfaces.ts +0 -535
|
@@ -1,630 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
let isCrashHandlerInitialized = false;
|
|
9
|
-
let lastHandledErrorTimestamp = 0;
|
|
10
|
-
let crashRecordsStore = [];
|
|
11
|
-
let breadcrumbsStore = [];
|
|
12
|
-
const MAX_BREADCRUMBS = 50;
|
|
13
|
-
let maxStoredCrashes = 100;
|
|
14
|
-
const appStartTime = Date.now();
|
|
15
|
-
let isCrashModuleEnabled = false;
|
|
16
|
-
export const setCrashModuleEnabled = (enabled) => {
|
|
17
|
-
isCrashModuleEnabled = enabled;
|
|
18
|
-
};
|
|
19
|
-
export const getCrashModuleEnabled = () => isCrashModuleEnabled;
|
|
20
|
-
export const setMaxCrashLogsLimit = (max) => {
|
|
21
|
-
maxStoredCrashes = Math.max(10, max);
|
|
22
|
-
if (crashRecordsStore.length > maxStoredCrashes) {
|
|
23
|
-
crashRecordsStore = crashRecordsStore.slice(0, maxStoredCrashes);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
export const getMaxCrashLogsLimit = () => maxStoredCrashes;
|
|
27
|
-
export const pruneCrashRecords = (targetCount) => {
|
|
28
|
-
const countToKeep = targetCount !== undefined ? Math.max(0, targetCount) : Math.floor(crashRecordsStore.length / 2);
|
|
29
|
-
const pruned = crashRecordsStore.length - countToKeep;
|
|
30
|
-
if (pruned > 0) {
|
|
31
|
-
crashRecordsStore = crashRecordsStore.slice(0, countToKeep);
|
|
32
|
-
}
|
|
33
|
-
if (breadcrumbsStore.length > 20) {
|
|
34
|
-
breadcrumbsStore = breadcrumbsStore.slice(0, 20);
|
|
35
|
-
}
|
|
36
|
-
return Math.max(0, pruned);
|
|
37
|
-
};
|
|
38
|
-
export const addCrashBreadcrumb = (type, message, data) => {
|
|
39
|
-
if (!isCrashModuleEnabled)
|
|
40
|
-
return;
|
|
41
|
-
try {
|
|
42
|
-
const entry = {
|
|
43
|
-
type,
|
|
44
|
-
message,
|
|
45
|
-
timestamp: Date.now(),
|
|
46
|
-
data,
|
|
47
|
-
};
|
|
48
|
-
breadcrumbsStore.unshift(entry);
|
|
49
|
-
if (breadcrumbsStore.length > MAX_BREADCRUMBS) {
|
|
50
|
-
breadcrumbsStore = breadcrumbsStore.slice(0, MAX_BREADCRUMBS);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
catch { }
|
|
54
|
-
};
|
|
55
|
-
export const recordNavigationBreadcrumb = (fromRoute, toRoute) => {
|
|
56
|
-
addCrashBreadcrumb('navigation', t('crash.breadcrumbNavigation', { from: fromRoute || '/', to: toRoute || '/' }), {
|
|
57
|
-
from: fromRoute,
|
|
58
|
-
to: toRoute,
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
export const recordNetworkBreadcrumb = (url, method, status, duration) => {
|
|
62
|
-
const statusStr = status != null ? ` [${status}]` : '';
|
|
63
|
-
const durStr = duration != null ? ` (${Math.round(duration)}ms)` : '';
|
|
64
|
-
addCrashBreadcrumb('network', `${method.toUpperCase()} ${url}${statusStr}${durStr}`, {
|
|
65
|
-
url,
|
|
66
|
-
method,
|
|
67
|
-
status,
|
|
68
|
-
duration,
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
export const recordReduxBreadcrumb = (actionType, payload) => {
|
|
72
|
-
addCrashBreadcrumb('redux', t('crash.breadcrumbAction', { actionType }), {
|
|
73
|
-
type: actionType,
|
|
74
|
-
payloadSummary: typeof payload === 'object' && payload !== null
|
|
75
|
-
? Object.keys(payload)
|
|
76
|
-
: typeof payload,
|
|
77
|
-
});
|
|
78
|
-
};
|
|
79
|
-
export const recordUserActionBreadcrumb = (action, metadata) => {
|
|
80
|
-
addCrashBreadcrumb('user', action, metadata);
|
|
81
|
-
};
|
|
82
|
-
export const clearCrashBreadcrumbs = () => {
|
|
83
|
-
breadcrumbsStore = [];
|
|
84
|
-
};
|
|
85
|
-
export const getCrashBreadcrumbs = () => {
|
|
86
|
-
return [...breadcrumbsStore];
|
|
87
|
-
};
|
|
88
|
-
export const parseCrashStackTrace = (stack) => {
|
|
89
|
-
if (!stack || typeof stack !== 'string')
|
|
90
|
-
return [];
|
|
91
|
-
const lines = stack.split('\n');
|
|
92
|
-
const frames = [];
|
|
93
|
-
for (const line of lines) {
|
|
94
|
-
const trimmed = line.trim();
|
|
95
|
-
if (!trimmed)
|
|
96
|
-
continue;
|
|
97
|
-
if (trimmed.includes('crashHandler.ts') ||
|
|
98
|
-
trimmed.includes('handleInterceptedCrash') ||
|
|
99
|
-
trimmed.includes('addLogFromCrash') ||
|
|
100
|
-
trimmed.includes('setupGlobalCrashHandler')) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
const iosMatch = trimmed.match(/^([^@]+)@(.*):(\d+):(\d+)$/);
|
|
104
|
-
if (iosMatch) {
|
|
105
|
-
const [, method, file, lineNum, colNum] = iosMatch;
|
|
106
|
-
const cleanFile = file.split('?')[0].split('/').pop() || file;
|
|
107
|
-
const isAppCode = !file.includes('node_modules') &&
|
|
108
|
-
!file.includes('react-native') &&
|
|
109
|
-
!file.includes('react-dom') &&
|
|
110
|
-
!file.includes('hermes') &&
|
|
111
|
-
!file.includes('internal');
|
|
112
|
-
frames.push({
|
|
113
|
-
method: method.trim(),
|
|
114
|
-
file: cleanFile,
|
|
115
|
-
lineNumber: parseInt(lineNum, 10),
|
|
116
|
-
column: parseInt(colNum, 10),
|
|
117
|
-
raw: trimmed,
|
|
118
|
-
isAppCode,
|
|
119
|
-
});
|
|
120
|
-
continue;
|
|
121
|
-
}
|
|
122
|
-
const androidMatch = trimmed.match(/^at\s+(.+)\s+\((.+):(\d+):(\d+)\)$/);
|
|
123
|
-
if (androidMatch) {
|
|
124
|
-
const [, method, file, lineNum, colNum] = androidMatch;
|
|
125
|
-
const cleanFile = file.split('?')[0].split('/').pop() || file;
|
|
126
|
-
const isAppCode = !file.includes('node_modules') &&
|
|
127
|
-
!file.includes('react-native') &&
|
|
128
|
-
!file.includes('react-dom') &&
|
|
129
|
-
!file.includes('internal');
|
|
130
|
-
frames.push({
|
|
131
|
-
method: method.trim(),
|
|
132
|
-
file: cleanFile,
|
|
133
|
-
lineNumber: parseInt(lineNum, 10),
|
|
134
|
-
column: parseInt(colNum, 10),
|
|
135
|
-
raw: trimmed,
|
|
136
|
-
isAppCode,
|
|
137
|
-
});
|
|
138
|
-
continue;
|
|
139
|
-
}
|
|
140
|
-
const simpleMatch = trimmed.match(/^at\s+(.+):(\d+):(\d+)$/);
|
|
141
|
-
if (simpleMatch) {
|
|
142
|
-
const [, file, lineNum, colNum] = simpleMatch;
|
|
143
|
-
const cleanFile = file.split('?')[0].split('/').pop() || file;
|
|
144
|
-
const isAppCode = !file.includes('node_modules') && !file.includes('react-native');
|
|
145
|
-
frames.push({
|
|
146
|
-
method: '<anonymous>',
|
|
147
|
-
file: cleanFile,
|
|
148
|
-
lineNumber: parseInt(lineNum, 10),
|
|
149
|
-
column: parseInt(colNum, 10),
|
|
150
|
-
raw: trimmed,
|
|
151
|
-
isAppCode,
|
|
152
|
-
});
|
|
153
|
-
continue;
|
|
154
|
-
}
|
|
155
|
-
const javaMatch = trimmed.match(/^at\s+([a-zA-Z0-9_$.]+)\(([a-zA-Z0-9_$]+\.java):(\d+)\)$/);
|
|
156
|
-
if (javaMatch) {
|
|
157
|
-
const [, methodPath, fileName, lineNum] = javaMatch;
|
|
158
|
-
const isAppCode = !methodPath.startsWith('com.facebook.react') &&
|
|
159
|
-
!methodPath.startsWith('android.');
|
|
160
|
-
frames.push({
|
|
161
|
-
method: methodPath,
|
|
162
|
-
file: fileName,
|
|
163
|
-
lineNumber: parseInt(lineNum, 10),
|
|
164
|
-
column: 0,
|
|
165
|
-
raw: trimmed,
|
|
166
|
-
isAppCode,
|
|
167
|
-
});
|
|
168
|
-
continue;
|
|
169
|
-
}
|
|
170
|
-
const machOMatch = trimmed.match(/^\d+\s+([^\s]+)\s+(0x[0-9a-fA-F]+)\s+(.+)$/);
|
|
171
|
-
if (machOMatch) {
|
|
172
|
-
const [, binaryName, address, symbol] = machOMatch;
|
|
173
|
-
const isAppCode = !binaryName.startsWith('lib') &&
|
|
174
|
-
!binaryName.startsWith('Core') &&
|
|
175
|
-
!binaryName.startsWith('React');
|
|
176
|
-
frames.push({
|
|
177
|
-
method: symbol,
|
|
178
|
-
file: binaryName,
|
|
179
|
-
lineNumber: 0,
|
|
180
|
-
column: 0,
|
|
181
|
-
raw: trimmed,
|
|
182
|
-
isAppCode,
|
|
183
|
-
});
|
|
184
|
-
continue;
|
|
185
|
-
}
|
|
186
|
-
frames.push({
|
|
187
|
-
method: trimmed.startsWith('at ') ? trimmed.slice(3) : trimmed,
|
|
188
|
-
file: 'runtime',
|
|
189
|
-
lineNumber: 0,
|
|
190
|
-
column: 0,
|
|
191
|
-
raw: trimmed,
|
|
192
|
-
isAppCode: false,
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
return frames;
|
|
196
|
-
};
|
|
197
|
-
const getMemoryDiagnostics = () => {
|
|
198
|
-
try {
|
|
199
|
-
const performance = globalThis.performance;
|
|
200
|
-
if (performance && performance.memory) {
|
|
201
|
-
return {
|
|
202
|
-
usedJSHeapSize: Math.round(performance.memory.usedJSHeapSize / (1024 * 1024)),
|
|
203
|
-
totalJSHeapSize: Math.round(performance.memory.totalJSHeapSize / (1024 * 1024)),
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
catch { }
|
|
208
|
-
return undefined;
|
|
209
|
-
};
|
|
210
|
-
const getScreenDimensions = () => {
|
|
211
|
-
try {
|
|
212
|
-
const window = Dimensions.get('window');
|
|
213
|
-
return `${Math.round(window.width)}x${Math.round(window.height)} (${window.scale}x)`;
|
|
214
|
-
}
|
|
215
|
-
catch {
|
|
216
|
-
return t('crash.unknown');
|
|
217
|
-
}
|
|
218
|
-
};
|
|
219
|
-
export const computeCrashFingerprint = (crash) => {
|
|
220
|
-
const type = crash.type || 'js';
|
|
221
|
-
const name = crash.name || 'Error';
|
|
222
|
-
const topFrame = crash.parsedStack && crash.parsedStack.length > 0
|
|
223
|
-
? crash.parsedStack[0]
|
|
224
|
-
: null;
|
|
225
|
-
const location = topFrame
|
|
226
|
-
? `${topFrame.file}:${topFrame.lineNumber}`
|
|
227
|
-
: 'unknown';
|
|
228
|
-
return `${type}_${name}_${location}`;
|
|
229
|
-
};
|
|
230
|
-
export const getCrashRecords = () => {
|
|
231
|
-
return [...crashRecordsStore];
|
|
232
|
-
};
|
|
233
|
-
export const clearCrashRecords = () => {
|
|
234
|
-
crashRecordsStore = [];
|
|
235
|
-
emitCrashEvent({
|
|
236
|
-
error: null,
|
|
237
|
-
message: '__CLEARED__',
|
|
238
|
-
timestamp: Date.now(),
|
|
239
|
-
});
|
|
240
|
-
};
|
|
241
|
-
export const subscribeCrashEvents = (listener) => {
|
|
242
|
-
crashListeners.push(listener);
|
|
243
|
-
return () => {
|
|
244
|
-
crashListeners = crashListeners.filter(l => l !== listener);
|
|
245
|
-
};
|
|
246
|
-
};
|
|
247
|
-
export const emitCrashEvent = (payload) => {
|
|
248
|
-
if (payload.message !== '__CLEARED__') {
|
|
249
|
-
const now = Date.now();
|
|
250
|
-
if (now - lastHandledErrorTimestamp < 250) {
|
|
251
|
-
return;
|
|
252
|
-
}
|
|
253
|
-
lastHandledErrorTimestamp = now;
|
|
254
|
-
}
|
|
255
|
-
crashListeners.forEach(listener => {
|
|
256
|
-
try {
|
|
257
|
-
listener(payload);
|
|
258
|
-
}
|
|
259
|
-
catch { }
|
|
260
|
-
});
|
|
261
|
-
};
|
|
262
|
-
export const handleInterceptedCrash = (errorOrTitle, rawStack, isFatal = false, customType, componentStack) => {
|
|
263
|
-
try {
|
|
264
|
-
const errorObj = errorOrTitle instanceof Error
|
|
265
|
-
? errorOrTitle
|
|
266
|
-
: typeof errorOrTitle === 'object' && errorOrTitle !== null
|
|
267
|
-
? errorOrTitle
|
|
268
|
-
: new Error(String(errorOrTitle || t('crash.runtimeException')));
|
|
269
|
-
const rawMsg = errorObj.message ||
|
|
270
|
-
(typeof errorOrTitle === 'string' ? errorOrTitle : t('crash.runtimeException'));
|
|
271
|
-
let stackString = '';
|
|
272
|
-
if (typeof rawStack === 'string') {
|
|
273
|
-
stackString = rawStack;
|
|
274
|
-
}
|
|
275
|
-
else if (Array.isArray(rawStack)) {
|
|
276
|
-
stackString = rawStack
|
|
277
|
-
.map(f => `at ${f.methodName || '<anonymous>'} (${f.file || 'unknown'}:${f.lineNumber || 0}:${f.column || 0})`)
|
|
278
|
-
.join('\n');
|
|
279
|
-
}
|
|
280
|
-
else {
|
|
281
|
-
stackString = errorObj.stack || new Error().stack || '';
|
|
282
|
-
}
|
|
283
|
-
let inferredType = customType || CrashType.Js;
|
|
284
|
-
const lowMsg = rawMsg.toLowerCase();
|
|
285
|
-
if (!customType) {
|
|
286
|
-
if (lowMsg.includes('native') ||
|
|
287
|
-
lowMsg.includes('sigsegv') ||
|
|
288
|
-
lowMsg.includes('nsrange') ||
|
|
289
|
-
lowMsg.includes('nullpointerexception') ||
|
|
290
|
-
lowMsg.includes('fatal signal')) {
|
|
291
|
-
inferredType = CrashType.Native;
|
|
292
|
-
}
|
|
293
|
-
else if (lowMsg.includes('promise') ||
|
|
294
|
-
lowMsg.includes('unhandled rejection') ||
|
|
295
|
-
lowMsg.includes('unhandledrejection')) {
|
|
296
|
-
inferredType = CrashType.Promise;
|
|
297
|
-
}
|
|
298
|
-
else if (lowMsg.includes('render') ||
|
|
299
|
-
lowMsg.includes('errorboundary') ||
|
|
300
|
-
componentStack) {
|
|
301
|
-
inferredType = CrashType.Render;
|
|
302
|
-
}
|
|
303
|
-
else {
|
|
304
|
-
inferredType = CrashType.Js;
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
const now = new Date();
|
|
308
|
-
const dateStr = now.toLocaleDateString();
|
|
309
|
-
const timeStr = now.toLocaleTimeString();
|
|
310
|
-
const parsedStack = parseCrashStackTrace(stackString);
|
|
311
|
-
const log = addLogFromCrash(errorObj, `[${isFatal ? t('crash.logFatalCrash') : t('crash.logUnhandledError')}] ${rawMsg}`, stackString, isFatal);
|
|
312
|
-
const isHermes = typeof globalThis.HermesInternal !== 'undefined';
|
|
313
|
-
const isFabric = typeof globalThis.nativeFabricUIManager !== 'undefined';
|
|
314
|
-
const crashRecord = {
|
|
315
|
-
id: `crash_${Date.now()}_${Math.random().toString(36).substr(2, 6)}`,
|
|
316
|
-
error: errorObj,
|
|
317
|
-
isFatal,
|
|
318
|
-
type: inferredType,
|
|
319
|
-
message: rawMsg,
|
|
320
|
-
name: errorObj.name || (isFatal ? t('crash.errorNameFatal') : t('crash.errorNameUnhandled')),
|
|
321
|
-
stack: stackString,
|
|
322
|
-
parsedStack,
|
|
323
|
-
componentStack: componentStack || undefined,
|
|
324
|
-
timestamp: Date.now(),
|
|
325
|
-
dateStr,
|
|
326
|
-
timeStr,
|
|
327
|
-
deviceInfo: {
|
|
328
|
-
platform: Platform.OS,
|
|
329
|
-
osVersion: String(Platform.Version),
|
|
330
|
-
rnVersion: Platform.constants?.reactNativeVersion
|
|
331
|
-
? `${Platform.constants.reactNativeVersion.major}.${Platform.constants.reactNativeVersion.minor}.${Platform.constants.reactNativeVersion.patch}`
|
|
332
|
-
: t('crash.unknown'),
|
|
333
|
-
isHermes,
|
|
334
|
-
isFabric,
|
|
335
|
-
appState: AppState.currentState || 'active',
|
|
336
|
-
},
|
|
337
|
-
memoryInfo: getMemoryDiagnostics(),
|
|
338
|
-
breadcrumbs: [...breadcrumbsStore],
|
|
339
|
-
logId: log?.id,
|
|
340
|
-
};
|
|
341
|
-
crashRecordsStore.unshift(crashRecord);
|
|
342
|
-
if (crashRecordsStore.length > maxStoredCrashes) {
|
|
343
|
-
crashRecordsStore = crashRecordsStore.slice(0, maxStoredCrashes);
|
|
344
|
-
}
|
|
345
|
-
emitCrashEvent({
|
|
346
|
-
error: errorObj,
|
|
347
|
-
isFatal,
|
|
348
|
-
message: `[${isFatal ? t('crash.logFatalCrash') : t('crash.logUnhandledError')}] ${rawMsg}`,
|
|
349
|
-
stack: stackString,
|
|
350
|
-
timestamp: Date.now(),
|
|
351
|
-
logId: log?.id,
|
|
352
|
-
crashRecord,
|
|
353
|
-
});
|
|
354
|
-
try {
|
|
355
|
-
showNativeFloatingButton();
|
|
356
|
-
setNativeFloatingButtonBadge(true);
|
|
357
|
-
}
|
|
358
|
-
catch { }
|
|
359
|
-
return crashRecord;
|
|
360
|
-
}
|
|
361
|
-
catch (err) {
|
|
362
|
-
const fallbackRecord = {
|
|
363
|
-
id: `crash_${Date.now()}`,
|
|
364
|
-
isFatal: true,
|
|
365
|
-
type: CrashType.Js,
|
|
366
|
-
message: String(errorOrTitle || t('crash.unknownException')),
|
|
367
|
-
timestamp: Date.now(),
|
|
368
|
-
dateStr: new Date().toLocaleDateString(),
|
|
369
|
-
timeStr: new Date().toLocaleTimeString(),
|
|
370
|
-
};
|
|
371
|
-
return fallbackRecord;
|
|
372
|
-
}
|
|
373
|
-
};
|
|
374
|
-
export const recordCustomCrash = (error, options) => {
|
|
375
|
-
return handleInterceptedCrash(error, typeof error === 'object' ? error.stack : undefined, options?.isFatal ?? false, options?.type || CrashType.Custom, options?.componentStack);
|
|
376
|
-
};
|
|
377
|
-
export const simulateTestCrash = (type = CrashType.Js, customMessage, customStack) => {
|
|
378
|
-
const err = new Error(customMessage || _defaultSimMessage(type));
|
|
379
|
-
return handleInterceptedCrash(type === CrashType.Native ? err.message : err, customStack || err.stack, type === CrashType.Native, type, type === CrashType.Render ? _buildComponentStack() : undefined);
|
|
380
|
-
};
|
|
381
|
-
const _defaultSimMessage = (type) => {
|
|
382
|
-
switch (type) {
|
|
383
|
-
case 'native':
|
|
384
|
-
return t('crash.simNativeMessage');
|
|
385
|
-
case 'promise':
|
|
386
|
-
return t('crash.simPromiseMessage');
|
|
387
|
-
case 'render':
|
|
388
|
-
return t('crash.simRenderMessage');
|
|
389
|
-
default:
|
|
390
|
-
return t('crash.simJsMessage');
|
|
391
|
-
}
|
|
392
|
-
};
|
|
393
|
-
const _buildComponentStack = () => {
|
|
394
|
-
try {
|
|
395
|
-
const err = new Error();
|
|
396
|
-
if (err.stack) {
|
|
397
|
-
return err.stack
|
|
398
|
-
.split('\n')
|
|
399
|
-
.slice(1, 6)
|
|
400
|
-
.map(line => ` ${line.trim()}`)
|
|
401
|
-
.join('\n');
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
catch { }
|
|
405
|
-
return undefined;
|
|
406
|
-
};
|
|
407
|
-
export const exportCrashReport = (crash, format = 'text') => {
|
|
408
|
-
if (format === 'json') {
|
|
409
|
-
return JSON.stringify(crash, null, 2);
|
|
410
|
-
}
|
|
411
|
-
const uptimeSec = Math.round((crash.timestamp - appStartTime) / 1000);
|
|
412
|
-
if (format === 'markdown') {
|
|
413
|
-
const lines = [];
|
|
414
|
-
lines.push(`## ${t('crash.mdReportTitle', { name: crash.name || 'Error' })}`);
|
|
415
|
-
lines.push(`> **${crash.message}**`);
|
|
416
|
-
lines.push('');
|
|
417
|
-
lines.push(`- **${t('crash.reportType')}** \`${crash.type.toUpperCase()}\``);
|
|
418
|
-
lines.push(`- **${t('crash.reportFatal')}** \`${crash.isFatal
|
|
419
|
-
? t('crash.mdSeverityFatal')
|
|
420
|
-
: t('crash.mdSeverityHandled')}\``);
|
|
421
|
-
lines.push(`- **${t('crash.reportTimestamp')}** ${crash.dateStr} ${crash.timeStr}`);
|
|
422
|
-
lines.push(`- **${t('crash.reportUptime')}** ${uptimeSec}s`);
|
|
423
|
-
lines.push(`- **${t('crash.reportPlatform')}** ${crash.deviceInfo?.platform?.toUpperCase()} (v${crash.deviceInfo?.osVersion})`);
|
|
424
|
-
lines.push(`- **${t('crash.reportReactNative')}** v${crash.deviceInfo?.rnVersion || 'N/A'}`);
|
|
425
|
-
lines.push(`- **${t('crash.jsEngine')}** ${crash.deviceInfo?.isHermes ? t('crash.hermesEngine') : t('crash.jsc')}`);
|
|
426
|
-
lines.push(`- **${t('crash.reportArchitecture')}** ${crash.deviceInfo?.isFabric
|
|
427
|
-
? t('crash.reportFabricNew')
|
|
428
|
-
: t('crash.reportPaperLegacy')}`);
|
|
429
|
-
if (crash.memoryInfo) {
|
|
430
|
-
lines.push(`- **${t('crash.reportJsMemory')}** ${crash.memoryInfo.usedJSHeapSize} MB / ${crash.memoryInfo.totalJSHeapSize} MB`);
|
|
431
|
-
}
|
|
432
|
-
lines.push('');
|
|
433
|
-
lines.push(`### ${t('crash.mdStackTrace')}`);
|
|
434
|
-
lines.push('```');
|
|
435
|
-
lines.push(crash.stack || t('crash.reportNoStackTrace'));
|
|
436
|
-
lines.push('```');
|
|
437
|
-
if (crash.componentStack) {
|
|
438
|
-
lines.push('');
|
|
439
|
-
lines.push(`### ${t('crash.mdComponentHierarchy')}`);
|
|
440
|
-
lines.push('```');
|
|
441
|
-
lines.push(crash.componentStack);
|
|
442
|
-
lines.push('```');
|
|
443
|
-
}
|
|
444
|
-
if (crash.breadcrumbs && crash.breadcrumbs.length > 0) {
|
|
445
|
-
lines.push('');
|
|
446
|
-
lines.push(`### ${t('crash.mdRecentBreadcrumbs')}`);
|
|
447
|
-
crash.breadcrumbs.forEach(b => {
|
|
448
|
-
const time = new Date(b.timestamp).toLocaleTimeString();
|
|
449
|
-
lines.push(`- \`[${time}]\` **[${b.type.toUpperCase()}]** ${b.message}`);
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
return lines.join('\n');
|
|
453
|
-
}
|
|
454
|
-
const lines = [];
|
|
455
|
-
lines.push('====================================================');
|
|
456
|
-
lines.push(` ${t('crash.reportTitle')} `);
|
|
457
|
-
lines.push('====================================================');
|
|
458
|
-
lines.push(`${t('crash.reportErrorName')} ${crash.name || 'Error'}`);
|
|
459
|
-
lines.push(`${t('crash.reportMessage')} ${crash.message}`);
|
|
460
|
-
lines.push(`${t('crash.reportType')} ${crash.type.toUpperCase()}`);
|
|
461
|
-
lines.push(`${t('crash.reportFatal')} ${crash.isFatal ? t('crash.reportFatalYes') : t('crash.reportFatalNo')}`);
|
|
462
|
-
lines.push(`${t('crash.reportTimestamp')} ${crash.dateStr} ${crash.timeStr} (${crash.timestamp})`);
|
|
463
|
-
lines.push(`${t('crash.reportUptime')} ${t('crash.reportUptimeValue', {
|
|
464
|
-
seconds: uptimeSec,
|
|
465
|
-
})}`);
|
|
466
|
-
lines.push(`${t('crash.reportPlatform')} ${crash.deviceInfo?.platform?.toUpperCase()} (v${crash.deviceInfo?.osVersion})`);
|
|
467
|
-
lines.push(`${t('crash.reportReactNative')} ${crash.deviceInfo?.rnVersion || 'N/A'}`);
|
|
468
|
-
lines.push(`${t('crash.reportHermes')} ${crash.deviceInfo?.isHermes
|
|
469
|
-
? t('crash.reportEnabled')
|
|
470
|
-
: t('crash.reportDisabled')}`);
|
|
471
|
-
lines.push(`${t('crash.reportArchitecture')} ${crash.deviceInfo?.isFabric
|
|
472
|
-
? t('crash.reportFabricNew')
|
|
473
|
-
: t('crash.reportPaperLegacy')}`);
|
|
474
|
-
lines.push(`${t('crash.reportScreenSize')} ${getScreenDimensions()}`);
|
|
475
|
-
lines.push(`${t('crash.reportAppState')} ${crash.deviceInfo?.appState || 'active'}`);
|
|
476
|
-
if (crash.memoryInfo) {
|
|
477
|
-
lines.push(`${t('crash.reportJsMemory')} ${crash.memoryInfo.usedJSHeapSize} MB / ${crash.memoryInfo.totalJSHeapSize} MB`);
|
|
478
|
-
}
|
|
479
|
-
lines.push('----------------------------------------------------');
|
|
480
|
-
lines.push(`${t('crash.reportStackTrace')}`);
|
|
481
|
-
lines.push(crash.stack || t('crash.reportNoStackTrace'));
|
|
482
|
-
if (crash.componentStack) {
|
|
483
|
-
lines.push('----------------------------------------------------');
|
|
484
|
-
lines.push(`${t('crash.reportComponentHierarchy')}`);
|
|
485
|
-
lines.push(crash.componentStack);
|
|
486
|
-
}
|
|
487
|
-
if (crash.breadcrumbs && crash.breadcrumbs.length > 0) {
|
|
488
|
-
lines.push('----------------------------------------------------');
|
|
489
|
-
lines.push(`${t('crash.reportRecentBreadcrumbs')}`);
|
|
490
|
-
crash.breadcrumbs.forEach(b => {
|
|
491
|
-
const time = new Date(b.timestamp).toLocaleTimeString();
|
|
492
|
-
lines.push(` [${time}] [${b.type.toUpperCase()}] ${b.message}`);
|
|
493
|
-
});
|
|
494
|
-
}
|
|
495
|
-
lines.push('====================================================');
|
|
496
|
-
return lines.join('\n');
|
|
497
|
-
};
|
|
498
|
-
export const setupGlobalCrashHandler = () => {
|
|
499
|
-
if (isCrashHandlerInitialized)
|
|
500
|
-
return;
|
|
501
|
-
isCrashHandlerInitialized = true;
|
|
502
|
-
try {
|
|
503
|
-
if (LogBox && typeof LogBox.ignoreAllLogs === 'function') {
|
|
504
|
-
LogBox.ignoreAllLogs(true);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
catch { }
|
|
508
|
-
try {
|
|
509
|
-
const LogBoxData = require('react-native/Libraries/LogBox/Data/LogBoxData');
|
|
510
|
-
if (LogBoxData && typeof LogBoxData.setDisabled === 'function') {
|
|
511
|
-
LogBoxData.setDisabled(true);
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
catch { }
|
|
515
|
-
try {
|
|
516
|
-
const networkInspectorModule = NativeModules?.NetworkInspectorModule;
|
|
517
|
-
if (networkInspectorModule) {
|
|
518
|
-
if (typeof networkInspectorModule.enableNativeCrashProtection === 'function') {
|
|
519
|
-
networkInspectorModule.enableNativeCrashProtection();
|
|
520
|
-
}
|
|
521
|
-
const nativeEmitter = new NativeEventEmitter(networkInspectorModule);
|
|
522
|
-
nativeEmitter.addListener('onNativeCrash', (event) => {
|
|
523
|
-
const platform = event?.platform || Platform.OS;
|
|
524
|
-
const msg = `[${platform.toUpperCase()} ${t('crash.nativeCrashTitle')}] ${event?.message || t('crash.nativeUncaughtException')}`;
|
|
525
|
-
const stack = event?.stack || '';
|
|
526
|
-
handleInterceptedCrash(msg, stack, true, 'native');
|
|
527
|
-
});
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
catch { }
|
|
531
|
-
try {
|
|
532
|
-
const tmReg = TurboModuleRegistry || globalThis.__turboModuleProxy;
|
|
533
|
-
const nativeExceptionsManager = NativeModules?.ExceptionsManager ||
|
|
534
|
-
(tmReg?.get ? tmReg.get('ExceptionsManager') : null);
|
|
535
|
-
if (nativeExceptionsManager) {
|
|
536
|
-
nativeExceptionsManager.reportFatalException = (title, stack, exceptionId) => {
|
|
537
|
-
handleInterceptedCrash(title, stack, true, 'native');
|
|
538
|
-
try {
|
|
539
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
540
|
-
nativeExceptionsManager.dismissRedbox();
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
catch { }
|
|
544
|
-
};
|
|
545
|
-
nativeExceptionsManager.reportSoftException = (title, stack, exceptionId) => {
|
|
546
|
-
handleInterceptedCrash(title, stack, false, 'js');
|
|
547
|
-
try {
|
|
548
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
549
|
-
nativeExceptionsManager.dismissRedbox();
|
|
550
|
-
}
|
|
551
|
-
}
|
|
552
|
-
catch { }
|
|
553
|
-
};
|
|
554
|
-
nativeExceptionsManager.reportException = (data) => {
|
|
555
|
-
const msg = data?.message || data?.title || t('crash.nativeException');
|
|
556
|
-
const stack = data?.stack || data?.rawStack;
|
|
557
|
-
handleInterceptedCrash(msg, stack, data?.isFatal ?? true, 'js');
|
|
558
|
-
try {
|
|
559
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
560
|
-
nativeExceptionsManager.dismissRedbox();
|
|
561
|
-
}
|
|
562
|
-
}
|
|
563
|
-
catch { }
|
|
564
|
-
};
|
|
565
|
-
nativeExceptionsManager.updateExceptionMessage = () => { };
|
|
566
|
-
try {
|
|
567
|
-
if (typeof nativeExceptionsManager.dismissRedbox === 'function') {
|
|
568
|
-
nativeExceptionsManager.dismissRedbox();
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
catch { }
|
|
572
|
-
}
|
|
573
|
-
const nativeRedBox = NativeModules?.RedBox ||
|
|
574
|
-
NativeModules?.RCTRedBox ||
|
|
575
|
-
(tmReg?.get ? tmReg.get('RedBox') || tmReg.get('RCTRedBox') : null);
|
|
576
|
-
if (nativeRedBox) {
|
|
577
|
-
if (typeof nativeRedBox.showErrorMessage === 'function') {
|
|
578
|
-
nativeRedBox.showErrorMessage = () => { };
|
|
579
|
-
}
|
|
580
|
-
if (typeof nativeRedBox.showUserError === 'function') {
|
|
581
|
-
nativeRedBox.showUserError = () => { };
|
|
582
|
-
}
|
|
583
|
-
if (typeof nativeRedBox.dismiss === 'function') {
|
|
584
|
-
nativeRedBox.dismiss();
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
catch { }
|
|
589
|
-
try {
|
|
590
|
-
const globalObj = globalThis;
|
|
591
|
-
const errorUtils = globalObj.ErrorUtils;
|
|
592
|
-
if (errorUtils) {
|
|
593
|
-
if (typeof errorUtils.setGlobalHandler === 'function') {
|
|
594
|
-
errorUtils.setGlobalHandler((error, isFatal) => {
|
|
595
|
-
handleInterceptedCrash(error, error?.stack, isFatal ?? false, 'js');
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
if (typeof errorUtils.reportFatalError === 'function') {
|
|
599
|
-
errorUtils.reportFatalError = (error) => {
|
|
600
|
-
handleInterceptedCrash(error, error?.stack, true, 'js');
|
|
601
|
-
};
|
|
602
|
-
}
|
|
603
|
-
if (typeof errorUtils.reportError === 'function') {
|
|
604
|
-
errorUtils.reportError = (error) => {
|
|
605
|
-
handleInterceptedCrash(error, error?.stack, false, 'js');
|
|
606
|
-
};
|
|
607
|
-
}
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
catch { }
|
|
611
|
-
try {
|
|
612
|
-
const globalObj = globalThis;
|
|
613
|
-
const handleUnhandledPromise = (eventOrError) => {
|
|
614
|
-
try {
|
|
615
|
-
const reason = eventOrError?.reason || eventOrError?.detail?.reason || eventOrError;
|
|
616
|
-
const message = reason?.message || String(reason || t('crash.unhandledPromiseRejection'));
|
|
617
|
-
const stack = reason?.stack || (eventOrError?.stack ?? new Error().stack);
|
|
618
|
-
handleInterceptedCrash(reason, stack, false, 'promise');
|
|
619
|
-
}
|
|
620
|
-
catch { }
|
|
621
|
-
};
|
|
622
|
-
if (typeof globalObj.addEventListener === 'function') {
|
|
623
|
-
globalObj.addEventListener('unhandledrejection', handleUnhandledPromise);
|
|
624
|
-
}
|
|
625
|
-
if (typeof globalObj.onunhandledrejection !== 'undefined') {
|
|
626
|
-
globalObj.onunhandledrejection = handleUnhandledPromise;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
catch { }
|
|
630
|
-
};
|
|
1
|
+
import{LogBox as M,NativeModules as v,TurboModuleRegistry as D,NativeEventEmitter as F,Platform as y,AppState as L,Dimensions as B}from"react-native";import{CrashExportFormat as A,CrashType as d}from"../types/enums";import{addLogFromCrash as H}from"./consoleLogger";import{showNativeFloatingButton as U,setNativeFloatingButtonBadge as _}from"../native/NativeInspector";import{t as s}from"../i18n";export{A as CrashExportFormat};let E=[],k=!1,R=0,l=[],g=[];const I=50;let S=100;const T=Date.now();let N=!1;export const setCrashModuleEnabled=e=>{N=e},getCrashModuleEnabled=()=>N,setMaxCrashLogsLimit=e=>{S=Math.max(10,e),l.length>S&&(l=l.slice(0,S))},getMaxCrashLogsLimit=()=>S,pruneCrashRecords=e=>{const t=e!==void 0?Math.max(0,e):Math.floor(l.length/2),n=l.length-t;return n>0&&(l=l.slice(0,t)),g.length>20&&(g=g.slice(0,20)),Math.max(0,n)},addCrashBreadcrumb=(e,t,n)=>{if(N)try{const o={type:e,message:t,timestamp:Date.now(),data:n};g.unshift(o),g.length>I&&(g=g.slice(0,I))}catch{}},recordNavigationBreadcrumb=(e,t)=>{addCrashBreadcrumb("navigation",s("crash.breadcrumbNavigation",{from:e||"/",to:t||"/"}),{from:e,to:t})},recordNetworkBreadcrumb=(e,t,n,o)=>{const r=n!=null?` [${n}]`:"",a=o!=null?` (${Math.round(o)}ms)`:"";addCrashBreadcrumb("network",`${t.toUpperCase()} ${e}${r}${a}`,{url:e,method:t,status:n,duration:o})},recordReduxBreadcrumb=(e,t)=>{addCrashBreadcrumb("redux",s("crash.breadcrumbAction",{actionType:e}),{type:e,payloadSummary:typeof t=="object"&&t!==null?Object.keys(t):typeof t})},recordUserActionBreadcrumb=(e,t)=>{addCrashBreadcrumb("user",e,t)},clearCrashBreadcrumbs=()=>{g=[]},getCrashBreadcrumbs=()=>[...g],parseCrashStackTrace=e=>{if(!e||typeof e!="string")return[];const t=e.split(`
|
|
2
|
+
`),n=[];for(const o of t){const r=o.trim();if(!r||r.includes("crashHandler.ts")||r.includes("handleInterceptedCrash")||r.includes("addLogFromCrash")||r.includes("setupGlobalCrashHandler"))continue;const a=r.match(/^([^@]+)@(.*):(\d+):(\d+)$/);if(a){const[,c,i,u,m]=a,b=i.split("?")[0].split("/").pop()||i,x=!i.includes("node_modules")&&!i.includes("react-native")&&!i.includes("react-dom")&&!i.includes("hermes")&&!i.includes("internal");n.push({method:c.trim(),file:b,lineNumber:parseInt(u,10),column:parseInt(m,10),raw:r,isAppCode:x});continue}const h=r.match(/^at\s+(.+)\s+\((.+):(\d+):(\d+)\)$/);if(h){const[,c,i,u,m]=h,b=i.split("?")[0].split("/").pop()||i,x=!i.includes("node_modules")&&!i.includes("react-native")&&!i.includes("react-dom")&&!i.includes("internal");n.push({method:c.trim(),file:b,lineNumber:parseInt(u,10),column:parseInt(m,10),raw:r,isAppCode:x});continue}const f=r.match(/^at\s+(.+):(\d+):(\d+)$/);if(f){const[,c,i,u]=f,m=c.split("?")[0].split("/").pop()||c,b=!c.includes("node_modules")&&!c.includes("react-native");n.push({method:"<anonymous>",file:m,lineNumber:parseInt(i,10),column:parseInt(u,10),raw:r,isAppCode:b});continue}const $=r.match(/^at\s+([a-zA-Z0-9_$.]+)\(([a-zA-Z0-9_$]+\.java):(\d+)\)$/);if($){const[,c,i,u]=$,m=!c.startsWith("com.facebook.react")&&!c.startsWith("android.");n.push({method:c,file:i,lineNumber:parseInt(u,10),column:0,raw:r,isAppCode:m});continue}const p=r.match(/^\d+\s+([^\s]+)\s+(0x[0-9a-fA-F]+)\s+(.+)$/);if(p){const[,c,i,u]=p,m=!c.startsWith("lib")&&!c.startsWith("Core")&&!c.startsWith("React");n.push({method:u,file:c,lineNumber:0,column:0,raw:r,isAppCode:m});continue}n.push({method:r.startsWith("at ")?r.slice(3):r,file:"runtime",lineNumber:0,column:0,raw:r,isAppCode:!1})}return n};const J=()=>{try{const e=globalThis.performance;if(e&&e.memory)return{usedJSHeapSize:Math.round(e.memory.usedJSHeapSize/(1024*1024)),totalJSHeapSize:Math.round(e.memory.totalJSHeapSize/(1024*1024))}}catch{}},P=()=>{try{const e=B.get("window");return`${Math.round(e.width)}x${Math.round(e.height)} (${e.scale}x)`}catch{return s("crash.unknown")}};export const computeCrashFingerprint=e=>{const t=e.type||"js",n=e.name||"Error",o=e.parsedStack&&e.parsedStack.length>0?e.parsedStack[0]:null,r=o?`${o.file}:${o.lineNumber}`:"unknown";return`${t}_${n}_${r}`},getCrashRecords=()=>[...l],clearCrashRecords=()=>{l=[],emitCrashEvent({error:null,message:"__CLEARED__",timestamp:Date.now()})},subscribeCrashEvents=e=>(E.push(e),()=>{E=E.filter(t=>t!==e)}),emitCrashEvent=e=>{if(e.message!=="__CLEARED__"){const t=Date.now();if(t-R<250)return;R=t}E.forEach(t=>{try{t(e)}catch{}})},handleInterceptedCrash=(e,t,n=!1,o,r)=>{try{const a=e instanceof Error||typeof e=="object"&&e!==null?e:new Error(String(e||s("crash.runtimeException"))),h=a.message||(typeof e=="string"?e:s("crash.runtimeException"));let f="";typeof t=="string"?f=t:Array.isArray(t)?f=t.map(C=>`at ${C.methodName||"<anonymous>"} (${C.file||"unknown"}:${C.lineNumber||0}:${C.column||0})`).join(`
|
|
3
|
+
`):f=a.stack||new Error().stack||"";let $=o||d.Js;const p=h.toLowerCase();o||(p.includes("native")||p.includes("sigsegv")||p.includes("nsrange")||p.includes("nullpointerexception")||p.includes("fatal signal")?$=d.Native:p.includes("promise")||p.includes("unhandled rejection")||p.includes("unhandledrejection")?$=d.Promise:p.includes("render")||p.includes("errorboundary")||r?$=d.Render:$=d.Js);const c=new Date,i=c.toLocaleDateString(),u=c.toLocaleTimeString(),m=parseCrashStackTrace(f),b=H(a,`[${n?s("crash.logFatalCrash"):s("crash.logUnhandledError")}] ${h}`,f,n),x=typeof globalThis.HermesInternal<"u",j=typeof globalThis.nativeFabricUIManager<"u",w={id:`crash_${Date.now()}_${Math.random().toString(36).substr(2,6)}`,error:a,isFatal:n,type:$,message:h,name:a.name||(n?s("crash.errorNameFatal"):s("crash.errorNameUnhandled")),stack:f,parsedStack:m,componentStack:r||void 0,timestamp:Date.now(),dateStr:i,timeStr:u,deviceInfo:{platform:y.OS,osVersion:String(y.Version),rnVersion:y.constants?.reactNativeVersion?`${y.constants.reactNativeVersion.major}.${y.constants.reactNativeVersion.minor}.${y.constants.reactNativeVersion.patch}`:s("crash.unknown"),isHermes:x,isFabric:j,appState:L.currentState||"active"},memoryInfo:J(),breadcrumbs:[...g],logId:b?.id};l.unshift(w),l.length>S&&(l=l.slice(0,S)),emitCrashEvent({error:a,isFatal:n,message:`[${n?s("crash.logFatalCrash"):s("crash.logUnhandledError")}] ${h}`,stack:f,timestamp:Date.now(),logId:b?.id,crashRecord:w});try{U(),_(!0)}catch{}return w}catch{return{id:`crash_${Date.now()}`,isFatal:!0,type:d.Js,message:String(e||s("crash.unknownException")),timestamp:Date.now(),dateStr:new Date().toLocaleDateString(),timeStr:new Date().toLocaleTimeString()}}},recordCustomCrash=(e,t)=>handleInterceptedCrash(e,typeof e=="object"?e.stack:void 0,t?.isFatal??!1,t?.type||d.Custom,t?.componentStack),simulateTestCrash=(e=d.Js,t,n)=>{const o=new Error(t||z(e));return handleInterceptedCrash(e===d.Native?o.message:o,n||o.stack,e===d.Native,e,e===d.Render?V():void 0)};const z=e=>{switch(e){case"native":return s("crash.simNativeMessage");case"promise":return s("crash.simPromiseMessage");case"render":return s("crash.simRenderMessage");default:return s("crash.simJsMessage")}},V=()=>{try{const e=new Error;if(e.stack)return e.stack.split(`
|
|
4
|
+
`).slice(1,6).map(t=>` ${t.trim()}`).join(`
|
|
5
|
+
`)}catch{}};export const exportCrashReport=(e,t="text")=>{if(t==="json")return JSON.stringify(e,null,2);const n=Math.round((e.timestamp-T)/1e3);if(t==="markdown"){const r=[];return r.push(`## ${s("crash.mdReportTitle",{name:e.name||"Error"})}`),r.push(`> **${e.message}**`),r.push(""),r.push(`- **${s("crash.reportType")}** \`${e.type.toUpperCase()}\``),r.push(`- **${s("crash.reportFatal")}** \`${e.isFatal?s("crash.mdSeverityFatal"):s("crash.mdSeverityHandled")}\``),r.push(`- **${s("crash.reportTimestamp")}** ${e.dateStr} ${e.timeStr}`),r.push(`- **${s("crash.reportUptime")}** ${n}s`),r.push(`- **${s("crash.reportPlatform")}** ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),r.push(`- **${s("crash.reportReactNative")}** v${e.deviceInfo?.rnVersion||"N/A"}`),r.push(`- **${s("crash.jsEngine")}** ${e.deviceInfo?.isHermes?s("crash.hermesEngine"):s("crash.jsc")}`),r.push(`- **${s("crash.reportArchitecture")}** ${e.deviceInfo?.isFabric?s("crash.reportFabricNew"):s("crash.reportPaperLegacy")}`),e.memoryInfo&&r.push(`- **${s("crash.reportJsMemory")}** ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),r.push(""),r.push(`### ${s("crash.mdStackTrace")}`),r.push("```"),r.push(e.stack||s("crash.reportNoStackTrace")),r.push("```"),e.componentStack&&(r.push(""),r.push(`### ${s("crash.mdComponentHierarchy")}`),r.push("```"),r.push(e.componentStack),r.push("```")),e.breadcrumbs&&e.breadcrumbs.length>0&&(r.push(""),r.push(`### ${s("crash.mdRecentBreadcrumbs")}`),e.breadcrumbs.forEach(a=>{const h=new Date(a.timestamp).toLocaleTimeString();r.push(`- \`[${h}]\` **[${a.type.toUpperCase()}]** ${a.message}`)})),r.join(`
|
|
6
|
+
`)}const o=[];return o.push("===================================================="),o.push(` ${s("crash.reportTitle")} `),o.push("===================================================="),o.push(`${s("crash.reportErrorName")} ${e.name||"Error"}`),o.push(`${s("crash.reportMessage")} ${e.message}`),o.push(`${s("crash.reportType")} ${e.type.toUpperCase()}`),o.push(`${s("crash.reportFatal")} ${e.isFatal?s("crash.reportFatalYes"):s("crash.reportFatalNo")}`),o.push(`${s("crash.reportTimestamp")} ${e.dateStr} ${e.timeStr} (${e.timestamp})`),o.push(`${s("crash.reportUptime")} ${s("crash.reportUptimeValue",{seconds:n})}`),o.push(`${s("crash.reportPlatform")} ${e.deviceInfo?.platform?.toUpperCase()} (v${e.deviceInfo?.osVersion})`),o.push(`${s("crash.reportReactNative")} ${e.deviceInfo?.rnVersion||"N/A"}`),o.push(`${s("crash.reportHermes")} ${e.deviceInfo?.isHermes?s("crash.reportEnabled"):s("crash.reportDisabled")}`),o.push(`${s("crash.reportArchitecture")} ${e.deviceInfo?.isFabric?s("crash.reportFabricNew"):s("crash.reportPaperLegacy")}`),o.push(`${s("crash.reportScreenSize")} ${P()}`),o.push(`${s("crash.reportAppState")} ${e.deviceInfo?.appState||"active"}`),e.memoryInfo&&o.push(`${s("crash.reportJsMemory")} ${e.memoryInfo.usedJSHeapSize} MB / ${e.memoryInfo.totalJSHeapSize} MB`),o.push("----------------------------------------------------"),o.push(`${s("crash.reportStackTrace")}`),o.push(e.stack||s("crash.reportNoStackTrace")),e.componentStack&&(o.push("----------------------------------------------------"),o.push(`${s("crash.reportComponentHierarchy")}`),o.push(e.componentStack)),e.breadcrumbs&&e.breadcrumbs.length>0&&(o.push("----------------------------------------------------"),o.push(`${s("crash.reportRecentBreadcrumbs")}`),e.breadcrumbs.forEach(r=>{const a=new Date(r.timestamp).toLocaleTimeString();o.push(` [${a}] [${r.type.toUpperCase()}] ${r.message}`)})),o.push("===================================================="),o.join(`
|
|
7
|
+
`)},setupGlobalCrashHandler=()=>{if(!k){k=!0;try{M&&typeof M.ignoreAllLogs=="function"&&M.ignoreAllLogs(!0)}catch{}try{const e=require("react-native/Libraries/LogBox/Data/LogBoxData");e&&typeof e.setDisabled=="function"&&e.setDisabled(!0)}catch{}try{const e=v?.NetworkInspectorModule;e&&(typeof e.enableNativeCrashProtection=="function"&&e.enableNativeCrashProtection(),new F(e).addListener("onNativeCrash",n=>{const r=`[${(n?.platform||y.OS).toUpperCase()} ${s("crash.nativeCrashTitle")}] ${n?.message||s("crash.nativeUncaughtException")}`,a=n?.stack||"";handleInterceptedCrash(r,a,!0,"native")}))}catch{}try{const e=D||globalThis.__turboModuleProxy,t=v?.ExceptionsManager||(e?.get?e.get("ExceptionsManager"):null);if(t){t.reportFatalException=(o,r,a)=>{handleInterceptedCrash(o,r,!0,"native");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportSoftException=(o,r,a)=>{handleInterceptedCrash(o,r,!1,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.reportException=o=>{const r=o?.message||o?.title||s("crash.nativeException"),a=o?.stack||o?.rawStack;handleInterceptedCrash(r,a,o?.isFatal??!0,"js");try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}},t.updateExceptionMessage=()=>{};try{typeof t.dismissRedbox=="function"&&t.dismissRedbox()}catch{}}const n=v?.RedBox||v?.RCTRedBox||(e?.get?e.get("RedBox")||e.get("RCTRedBox"):null);n&&(typeof n.showErrorMessage=="function"&&(n.showErrorMessage=()=>{}),typeof n.showUserError=="function"&&(n.showUserError=()=>{}),typeof n.dismiss=="function"&&n.dismiss())}catch{}try{const t=globalThis.ErrorUtils;t&&(typeof t.setGlobalHandler=="function"&&t.setGlobalHandler((n,o)=>{handleInterceptedCrash(n,n?.stack,o??!1,"js")}),typeof t.reportFatalError=="function"&&(t.reportFatalError=n=>{handleInterceptedCrash(n,n?.stack,!0,"js")}),typeof t.reportError=="function"&&(t.reportError=n=>{handleInterceptedCrash(n,n?.stack,!1,"js")}))}catch{}try{const e=globalThis,t=n=>{try{const o=n?.reason||n?.detail?.reason||n,r=o?.message||String(o||s("crash.unhandledPromiseRejection")),a=o?.stack||(n?.stack??new Error().stack);handleInterceptedCrash(o,a,!1,"promise")}catch{}};typeof e.addEventListener=="function"&&e.addEventListener("unhandledrejection",t),typeof e.onunhandledrejection<"u"&&(e.onunhandledrejection=t)}catch{}}};
|