From 8523e5c3c4a1806eb91b571d11d73f6a66360e1b Mon Sep 17 00:00:00 2001 From: Nick Dowell Date: Wed, 2 Dec 2020 15:28:38 +0000 Subject: [PATCH] deps(react-native): Bump bugsnag-cocoa to v6.3.0 --- CHANGELOG.md | 7 + .../react-native/ios/.bugsnag-cocoa-version | 2 +- .../vendor/bugsnag-cocoa/Bugsnag.podspec.json | 4 +- .../Bugsnag.xcodeproj/project.pbxproj | 71 +++-- .../vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m | 17 +- .../Bugsnag/BugsnagErrorReportSink.m | 37 ++- .../Bugsnag/BugsnagSystemState.h | 2 + .../Bugsnag/BugsnagSystemState.m | 37 ++- .../Bugsnag/Client/BugsnagClient+Private.h | 97 +++++++ .../Bugsnag/Client/BugsnagClient.m | 251 ++++++------------ .../Bugsnag/Client/BugsnagClientInternal.h | 34 --- .../BugsnagConfiguration+Private.h | 24 ++ .../Configuration/BugsnagConfiguration.m | 31 ++- .../Bugsnag/Delivery/BugsnagApiClient.h | 37 ++- .../Bugsnag/Delivery/BugsnagApiClient.m | 176 ++++++------ .../BugsnagSessionTrackingApiClient.h | 3 + .../BugsnagSessionTrackingApiClient.m | 49 ++-- .../Bugsnag/Helpers/BSGJSONSerialization.h | 4 + .../Bugsnag/Helpers/BSGJSONSerialization.m | 40 ++- .../bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h | 40 +++ .../Bugsnag/Helpers/BugsnagKeys.h | 3 - .../Bugsnag/Helpers/BugsnagKeys.m | 3 - .../Source/KSCrash/Recording/BSG_KSCrash.m | 21 +- .../KSCrash/Recording/BSG_KSCrashState.m | 6 +- .../KSCrash/Recording/BSG_KSSystemInfo.h | 9 +- .../KSCrash/Recording/BSG_KSSystemInfo.m | 12 +- .../KSCrash/Recording/Tools/BSG_KSSingleton.h | 71 ----- .../Bugsnag/Payload/BugsnagApp.m | 9 +- .../Bugsnag/Payload/BugsnagAppWithState.m | 1 + .../Bugsnag/Payload/BugsnagDeviceWithState.m | 6 +- .../Bugsnag/Payload/BugsnagError+Private.h | 34 +++ .../Bugsnag/Payload/BugsnagError.m | 8 +- .../Bugsnag/Payload/BugsnagEvent+Private.h | 73 +++++ .../Bugsnag/Payload/BugsnagEvent.m | 186 +++++-------- .../Bugsnag/Payload/BugsnagNotifier.m | 2 +- .../Payload/BugsnagSessionTrackingPayload.m | 3 +- .../Payload/BugsnagStackframe+Private.h | 26 ++ .../Bugsnag/Payload/BugsnagStackframe.m | 6 +- .../Bugsnag/Payload/BugsnagStacktrace.m | 10 +- .../Bugsnag/Payload/BugsnagThread+Private.h | 40 +++ .../Bugsnag/Payload/BugsnagThread.m | 7 +- .../vendor/bugsnag-cocoa/Bugsnag/Private.h | 10 - .../include/Bugsnag/BugsnagStackframe.h | 15 +- .../ios/vendor/bugsnag-cocoa/CHANGELOG.md | 29 ++ .../vendor/bugsnag-cocoa/Framework/Info.plist | 2 +- .../ios/vendor/bugsnag-cocoa/VERSION | 2 +- 46 files changed, 890 insertions(+), 667 deletions(-) create mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h delete mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClientInternal.h create mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration+Private.h create mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h delete mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSSingleton.h create mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h create mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h create mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h create mode 100644 packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 87be550f0b..8085141b81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,15 @@ ## TBD +### Changed + - (react-native): Update bugsnag-android to v5.3.0 - Add integrity header to verify Error and Session API payloads have not changed. [bugsnag-android#978](https://github.com/bugsnag/bugsnag-android/pull/978) +- (react-native): Update bugsnag-cocoa to v6.3.0 + - Add integrity header to verify Error and Session API payloads have not changed. [bugsnag-cocoa#881](https://github.com/bugsnag/bugsnag-cocoa/pull/881) + - Out Of Memory errors now include more information, including custom metadata and user information. [bugsnag-cocoa#915](https://github.com/bugsnag/bugsnag-cocoa/pull/915) [bugsnag-cocoa#908](https://github.com/bugsnag/bugsnag-cocoa/pull/908) + - Fixed incorrect app version reported when sending crash reports from older versions of Bugsnag (before 6.2.3) [bugsnag-cocoa#911](https://github.com/bugsnag/bugsnag-cocoa/pull/911) + - Fixed a rare crash in -[BugsnagClient computeDidCrashLastLaunch] [bugsnag-cocoa#917](https://github.com/bugsnag/bugsnag-cocoa/pull/917) ## v7.5.3 (2020-12-01) diff --git a/packages/react-native/ios/.bugsnag-cocoa-version b/packages/react-native/ios/.bugsnag-cocoa-version index 9320ef112c..257eb4d65e 100644 --- a/packages/react-native/ios/.bugsnag-cocoa-version +++ b/packages/react-native/ios/.bugsnag-cocoa-version @@ -1 +1 @@ -86de8c605e82e67433ad91fd777b2aba4854f536 +2256dfe86c61e70c57e33325513c37d2951e3441 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json index 54121f2cd2..1667150b27 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.podspec.json @@ -1,6 +1,6 @@ { "name": "Bugsnag", - "version": "6.2.5", + "version": "6.3.0", "summary": "The Bugsnag crash reporting framework for Apple platforms.", "homepage": "https://bugsnag.com", "license": "MIT", @@ -9,7 +9,7 @@ }, "source": { "git": "https://github.com/bugsnag/bugsnag-cocoa.git", - "tag": "v6.2.5" + "tag": "v6.3.0" }, "frameworks": [ "Foundation", diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj index 62ba98e1e8..aead8db715 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag.xcodeproj/project.pbxproj @@ -206,9 +206,9 @@ 008967BF2486DA1900DC48C2 /* BugsnagClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967BB2486DA1900DC48C2 /* BugsnagClient.m */; }; 008967C02486DA1900DC48C2 /* BugsnagClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967BB2486DA1900DC48C2 /* BugsnagClient.m */; }; 008967C12486DA1900DC48C2 /* BugsnagClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967BB2486DA1900DC48C2 /* BugsnagClient.m */; }; - 008967C22486DA1900DC48C2 /* BugsnagClientInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClientInternal.h */; }; - 008967C32486DA1900DC48C2 /* BugsnagClientInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClientInternal.h */; }; - 008967C42486DA1900DC48C2 /* BugsnagClientInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClientInternal.h */; }; + 008967C22486DA1900DC48C2 /* BugsnagClient+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClient+Private.h */; }; + 008967C32486DA1900DC48C2 /* BugsnagClient+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClient+Private.h */; }; + 008967C42486DA1900DC48C2 /* BugsnagClient+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClient+Private.h */; }; 008967D32486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967C92486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m */; }; 008967D42486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967C92486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m */; }; 008967D52486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 008967C92486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m */; }; @@ -408,9 +408,6 @@ 008969602486DAD000DC48C2 /* BSG_KSSysCtl.h in Headers */ = {isa = PBXBuildFile; fileRef = 008969042486DAD000DC48C2 /* BSG_KSSysCtl.h */; }; 008969612486DAD000DC48C2 /* BSG_KSSysCtl.h in Headers */ = {isa = PBXBuildFile; fileRef = 008969042486DAD000DC48C2 /* BSG_KSSysCtl.h */; }; 008969622486DAD000DC48C2 /* BSG_KSSysCtl.h in Headers */ = {isa = PBXBuildFile; fileRef = 008969042486DAD000DC48C2 /* BSG_KSSysCtl.h */; }; - 008969632486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 008969052486DAD000DC48C2 /* BSG_KSSingleton.h */; }; - 008969642486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 008969052486DAD000DC48C2 /* BSG_KSSingleton.h */; }; - 008969652486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */ = {isa = PBXBuildFile; fileRef = 008969052486DAD000DC48C2 /* BSG_KSSingleton.h */; }; 008969662486DAD000DC48C2 /* BSG_KSDynamicLinker.c in Sources */ = {isa = PBXBuildFile; fileRef = 008969062486DAD000DC48C2 /* BSG_KSDynamicLinker.c */; }; 008969672486DAD000DC48C2 /* BSG_KSDynamicLinker.c in Sources */ = {isa = PBXBuildFile; fileRef = 008969062486DAD000DC48C2 /* BSG_KSDynamicLinker.c */; }; 008969682486DAD000DC48C2 /* BSG_KSDynamicLinker.c in Sources */ = {isa = PBXBuildFile; fileRef = 008969062486DAD000DC48C2 /* BSG_KSDynamicLinker.c */; }; @@ -637,9 +634,9 @@ 00AD1F142486A17900A27979 /* BugsnagErrorReportSink.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF92486A17700A27979 /* BugsnagErrorReportSink.m */; }; 00AD1F152486A17900A27979 /* BugsnagErrorReportSink.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF92486A17700A27979 /* BugsnagErrorReportSink.m */; }; 00AD1F162486A17900A27979 /* BugsnagErrorReportSink.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EF92486A17700A27979 /* BugsnagErrorReportSink.m */; }; - 00AD1F172486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 00AD1F182486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; - 00AD1F192486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; settings = {ATTRIBUTES = (Private, ); }; }; + 00AD1F172486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; }; + 00AD1F182486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; }; + 00AD1F192486A17900A27979 /* Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFA2486A17700A27979 /* Private.h */; }; 00AD1F212486A17900A27979 /* BugsnagErrorReportSink.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFD2486A17800A27979 /* BugsnagErrorReportSink.h */; }; 00AD1F222486A17900A27979 /* BugsnagErrorReportSink.h in Headers */ = {isa = PBXBuildFile; fileRef = 00AD1EFD2486A17800A27979 /* BugsnagErrorReportSink.h */; }; 00AD1F232486A17900A27979 /* Bugsnag.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1EFE2486A17800A27979 /* Bugsnag.m */; }; @@ -658,12 +655,20 @@ 00AD1F302486A17900A27979 /* BugsnagSessionTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1F012486A17900A27979 /* BugsnagSessionTracker.m */; }; 00AD1F312486A17900A27979 /* BugsnagSessionTracker.m in Sources */ = {isa = PBXBuildFile; fileRef = 00AD1F012486A17900A27979 /* BugsnagSessionTracker.m */; }; 00E636C224878D84006CBF1A /* BSG_RFC3339DateTool.m in Sources */ = {isa = PBXBuildFile; fileRef = 008969142486DAD000DC48C2 /* BSG_RFC3339DateTool.m */; }; + 0140D29A25767C9A00FD0306 /* BugsnagApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */; }; + 012482A325627B51003F7243 /* UIKitTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 012482A225627B51003F7243 /* UIKitTests.m */; }; + 014475FD2566844F0018AB94 /* BugsnagApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */; }; + 01447605256684500018AB94 /* BugsnagApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */; }; + 0187D464255BD7B800C503D9 /* BugsnagApiClientTest.m in Sources */ = {isa = PBXBuildFile; fileRef = CB9103632502320A00E9D1E2 /* BugsnagApiClientTest.m */; }; 01B14C56251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; }; 01B14C57251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; }; 01B14C58251CE55F00118748 /* report-react-native-promise-rejection.json in Resources */ = {isa = PBXBuildFile; fileRef = 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */; }; 01C17AE72542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */; }; 01C17AE82542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */; }; 01C17AE92542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */; }; + 01E8765E256684E700F4B70A /* URLSessionMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 01E8765D256684E700F4B70A /* URLSessionMock.m */; }; + 01E8765F256684E700F4B70A /* URLSessionMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 01E8765D256684E700F4B70A /* URLSessionMock.m */; }; + 01E87660256684E700F4B70A /* URLSessionMock.m in Sources */ = {isa = PBXBuildFile; fileRef = 01E8765D256684E700F4B70A /* URLSessionMock.m */; }; 3A700A9424A63ABC0068CD1B /* BugsnagThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A700A8024A63A8E0068CD1B /* BugsnagThread.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3A700A9524A63AC50068CD1B /* BugsnagSession.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A700A8124A63A8E0068CD1B /* BugsnagSession.h */; settings = {ATTRIBUTES = (Public, ); }; }; 3A700A9624A63AC60068CD1B /* BugsnagStackframe.h in Headers */ = {isa = PBXBuildFile; fileRef = 3A700A8224A63A8E0068CD1B /* BugsnagStackframe.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -847,7 +852,7 @@ E746293C24890C9F00F92D67 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E746292424890BFE00F92D67 /* Foundation.framework */; }; E746293D24890CA400F92D67 /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E746292624890C1100F92D67 /* SystemConfiguration.framework */; }; E746293E24890D2F00F92D67 /* BugsnagBreadcrumbs.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008967B32486D9D700DC48C2 /* BugsnagBreadcrumbs.h */; }; - E746294024890D2F00F92D67 /* BugsnagClientInternal.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClientInternal.h */; }; + E746294024890D2F00F92D67 /* BugsnagClient+Private.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008967BC2486DA1900DC48C2 /* BugsnagClient+Private.h */; }; E746294124890D2F00F92D67 /* BSGConfigurationBuilder.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008967CA2486DA2D00DC48C2 /* BSGConfigurationBuilder.h */; }; E746294524890D2F00F92D67 /* BSGConnectivity.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008967F22486DA4500DC48C2 /* BSGConnectivity.h */; }; E746294624890D2F00F92D67 /* BugsnagApiClient.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008967ED2486DA4400DC48C2 /* BugsnagApiClient.h */; }; @@ -871,7 +876,6 @@ E746296624890D3000F92D67 /* BSGOnErrorSentBlock.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008968FD2486DAD000DC48C2 /* BSGOnErrorSentBlock.h */; }; E746296824890D3000F92D67 /* BSG_KSBacktrace.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008969022486DAD000DC48C2 /* BSG_KSBacktrace.h */; }; E746296924890D3000F92D67 /* BSG_KSSysCtl.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008969042486DAD000DC48C2 /* BSG_KSSysCtl.h */; }; - E746296A24890D3100F92D67 /* BSG_KSSingleton.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008969052486DAD000DC48C2 /* BSG_KSSingleton.h */; }; E746296B24890D3100F92D67 /* BSG_KSFileUtils.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 008969092486DAD000DC48C2 /* BSG_KSFileUtils.h */; }; E746296C24890D3100F92D67 /* BSG_KSSignalInfo.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0089690A2486DAD000DC48C2 /* BSG_KSSignalInfo.h */; }; E746296D24890D3100F92D67 /* NSError+BSG_SimpleConstructor.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 0089690C2486DAD000DC48C2 /* NSError+BSG_SimpleConstructor.h */; }; @@ -970,7 +974,7 @@ 3A700AF924A6492F0068CD1B /* BugsnagDeviceWithState.h in CopyFiles */, 3A700AFA24A6492F0068CD1B /* BugsnagMetadata.h in CopyFiles */, E746293E24890D2F00F92D67 /* BugsnagBreadcrumbs.h in CopyFiles */, - E746294024890D2F00F92D67 /* BugsnagClientInternal.h in CopyFiles */, + E746294024890D2F00F92D67 /* BugsnagClient+Private.h in CopyFiles */, E746294124890D2F00F92D67 /* BSGConfigurationBuilder.h in CopyFiles */, E746294524890D2F00F92D67 /* BSGConnectivity.h in CopyFiles */, E746294624890D2F00F92D67 /* BugsnagApiClient.h in CopyFiles */, @@ -994,7 +998,6 @@ E746296624890D3000F92D67 /* BSGOnErrorSentBlock.h in CopyFiles */, E746296824890D3000F92D67 /* BSG_KSBacktrace.h in CopyFiles */, E746296924890D3000F92D67 /* BSG_KSSysCtl.h in CopyFiles */, - E746296A24890D3100F92D67 /* BSG_KSSingleton.h in CopyFiles */, E746296B24890D3100F92D67 /* BSG_KSFileUtils.h in CopyFiles */, E746296C24890D3100F92D67 /* BSG_KSSignalInfo.h in CopyFiles */, E746296D24890D3100F92D67 /* NSError+BSG_SimpleConstructor.h in CopyFiles */, @@ -1115,7 +1118,7 @@ 008967B22486D9D700DC48C2 /* BugsnagBreadcrumbs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagBreadcrumbs.m; sourceTree = ""; }; 008967B32486D9D700DC48C2 /* BugsnagBreadcrumbs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsnagBreadcrumbs.h; sourceTree = ""; }; 008967BB2486DA1900DC48C2 /* BugsnagClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagClient.m; sourceTree = ""; }; - 008967BC2486DA1900DC48C2 /* BugsnagClientInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BugsnagClientInternal.h; sourceTree = ""; }; + 008967BC2486DA1900DC48C2 /* BugsnagClient+Private.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "BugsnagClient+Private.h"; sourceTree = ""; }; 008967C92486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagEndpointConfiguration.m; sourceTree = ""; }; 008967CA2486DA2D00DC48C2 /* BSGConfigurationBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSGConfigurationBuilder.h; sourceTree = ""; }; 008967CB2486DA2D00DC48C2 /* BugsnagConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagConfiguration.m; sourceTree = ""; }; @@ -1173,7 +1176,6 @@ 008969022486DAD000DC48C2 /* BSG_KSBacktrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSG_KSBacktrace.h; sourceTree = ""; }; 008969032486DAD000DC48C2 /* BSG_KSMach_x86_32.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BSG_KSMach_x86_32.c; sourceTree = ""; }; 008969042486DAD000DC48C2 /* BSG_KSSysCtl.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSG_KSSysCtl.h; sourceTree = ""; }; - 008969052486DAD000DC48C2 /* BSG_KSSingleton.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSG_KSSingleton.h; sourceTree = ""; }; 008969062486DAD000DC48C2 /* BSG_KSDynamicLinker.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BSG_KSDynamicLinker.c; sourceTree = ""; }; 008969072486DAD000DC48C2 /* BSG_KSMach_Arm.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = BSG_KSMach_Arm.c; sourceTree = ""; }; 008969082486DAD000DC48C2 /* BSG_KSJSONCodecObjC.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSG_KSJSONCodecObjC.m; sourceTree = ""; }; @@ -1274,8 +1276,17 @@ 00E636C02487031D006CBF1A /* Bugsnag.podspec.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = Bugsnag.podspec.json; sourceTree = SOURCE_ROOT; }; 00E636C12487031D006CBF1A /* docker-compose.yml */ = {isa = PBXFileReference; lastKnownFileType = text.yaml; path = "docker-compose.yml"; sourceTree = SOURCE_ROOT; }; 00E636C324878FFC006CBF1A /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; + 012482A225627B51003F7243 /* UIKitTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIKitTests.m; sourceTree = ""; }; + 0134524A256BCF7C0088C548 /* BugsnagError+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagError+Private.h"; sourceTree = ""; }; + 0134524B256BD00A0088C548 /* BugsnagThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagThread+Private.h"; sourceTree = ""; }; + 0140D24725765F8F00FD0306 /* BSGUIKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSGUIKit.h; sourceTree = ""; }; + 0195FC3B256BC81400DE6646 /* BugsnagEvent+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagEvent+Private.h"; sourceTree = ""; }; + 0198762E2567D5AB000A7AF3 /* BugsnagStackframe+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagStackframe+Private.h"; sourceTree = ""; }; 01B14C55251CE55F00118748 /* report-react-native-promise-rejection.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "report-react-native-promise-rejection.json"; sourceTree = ""; }; 01C17AE62542ED7F00C102C9 /* KSCrashReportWriterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = KSCrashReportWriterTests.m; sourceTree = ""; }; + 01D8EC3C256FC6C3006F2A2D /* BugsnagConfiguration+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagConfiguration+Private.h"; sourceTree = ""; }; + 01E8765C256684E700F4B70A /* URLSessionMock.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = URLSessionMock.h; sourceTree = ""; }; + 01E8765D256684E700F4B70A /* URLSessionMock.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = URLSessionMock.m; sourceTree = ""; }; 3A700A8024A63A8E0068CD1B /* BugsnagThread.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagThread.h; sourceTree = ""; }; 3A700A8124A63A8E0068CD1B /* BugsnagSession.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagSession.h; sourceTree = ""; }; 3A700A8224A63A8E0068CD1B /* BugsnagStackframe.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BugsnagStackframe.h; sourceTree = ""; }; @@ -1547,7 +1558,6 @@ 008969202486DAD000DC48C2 /* BSG_KSObjCApple.h */, 008969212486DAD000DC48C2 /* BSG_KSSignalInfo.c */, 0089690A2486DAD000DC48C2 /* BSG_KSSignalInfo.h */, - 008969052486DAD000DC48C2 /* BSG_KSSingleton.h */, 008969242486DAD000DC48C2 /* BSG_KSString.c */, 008969122486DAD000DC48C2 /* BSG_KSString.h */, 0089691C2486DAD000DC48C2 /* BSG_KSSysCtl.c */, @@ -1693,6 +1703,9 @@ 008966AE2486D43500DC48C2 /* Swift Tests */, CBA22499251E429C00B87416 /* TestSupport.h */, CBA2249A251E429C00B87416 /* TestSupport.m */, + 01E8765C256684E700F4B70A /* URLSessionMock.h */, + 01E8765D256684E700F4B70A /* URLSessionMock.m */, + 012482A225627B51003F7243 /* UIKitTests.m */, ); path = Tests; sourceTree = ""; @@ -1710,7 +1723,7 @@ isa = PBXGroup; children = ( 008967BB2486DA1900DC48C2 /* BugsnagClient.m */, - 008967BC2486DA1900DC48C2 /* BugsnagClientInternal.h */, + 008967BC2486DA1900DC48C2 /* BugsnagClient+Private.h */, ); path = Client; sourceTree = ""; @@ -1721,6 +1734,7 @@ 008967CA2486DA2D00DC48C2 /* BSGConfigurationBuilder.h */, 008967CC2486DA2D00DC48C2 /* BSGConfigurationBuilder.m */, 008967CB2486DA2D00DC48C2 /* BugsnagConfiguration.m */, + 01D8EC3C256FC6C3006F2A2D /* BugsnagConfiguration+Private.h */, 008967C92486DA2D00DC48C2 /* BugsnagEndpointConfiguration.m */, 008967CF2486DA2D00DC48C2 /* BugsnagErrorTypes.m */, ); @@ -1753,6 +1767,7 @@ CBCF77A225010648004AF22A /* BSGJSONSerialization.m */, 008968112486DA5600DC48C2 /* BSGSerialization.h */, 008968162486DA5600DC48C2 /* BSGSerialization.m */, + 0140D24725765F8F00FD0306 /* BSGUIKit.h */, 008968102486DA5600DC48C2 /* BugsnagCollections.h */, 008968172486DA5600DC48C2 /* BugsnagCollections.m */, 008968152486DA5600DC48C2 /* BugsnagKeys.h */, @@ -1785,7 +1800,9 @@ 008968482486DA9400DC48C2 /* BugsnagDevice.m */, 0089685A2486DA9500DC48C2 /* BugsnagDeviceWithState.m */, 008968512486DA9400DC48C2 /* BugsnagError.m */, + 0134524A256BCF7C0088C548 /* BugsnagError+Private.h */, 008968462486DA9300DC48C2 /* BugsnagEvent.m */, + 0195FC3B256BC81400DE6646 /* BugsnagEvent+Private.h */, 0089684E2486DA9400DC48C2 /* BugsnagHandledState.h */, 008968522486DA9400DC48C2 /* BugsnagHandledState.m */, 008968622486DA9500DC48C2 /* BugsnagNotifier.h */, @@ -1795,11 +1812,13 @@ 008968562486DA9400DC48C2 /* BugsnagSessionTrackingPayload.h */, 008968542486DA9400DC48C2 /* BugsnagSessionTrackingPayload.m */, 008968532486DA9400DC48C2 /* BugsnagStackframe.m */, + 0198762E2567D5AB000A7AF3 /* BugsnagStackframe+Private.h */, 0089684F2486DA9400DC48C2 /* BugsnagStacktrace.h */, 0089685C2486DA9500DC48C2 /* BugsnagStacktrace.m */, 008968552486DA9400DC48C2 /* BugsnagStateEvent.h */, 008968582486DA9500DC48C2 /* BugsnagStateEvent.m */, 008968612486DA9500DC48C2 /* BugsnagThread.m */, + 0134524B256BD00A0088C548 /* BugsnagThread+Private.h */, 0089685F2486DA9500DC48C2 /* BugsnagUser.m */, ); path = Payload; @@ -1946,7 +1965,6 @@ 008968A42486DA9600DC48C2 /* BugsnagSessionTrackingPayload.h in Headers */, CBAA6ABB250BA70E00713376 /* BugsnagKVStore.h in Headers */, E75A5CDB248A5D97005D2C74 /* BugsnagErrorReportSink.h in Headers */, - 008969632486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */, 00AD1F102486A17900A27979 /* BugsnagSessionTracker.h in Headers */, 008968F42486DAB800DC48C2 /* BugsnagSessionFileStore.h in Headers */, 008968882486DA9600DC48C2 /* BugsnagHandledState.h in Headers */, @@ -1954,7 +1972,7 @@ 00896A082486DAD100DC48C2 /* BSG_KSCrashSentry_Private.h in Headers */, 0089683E2486DA6C00DC48C2 /* BugsnagMetadataInternal.h in Headers */, 008969722486DAD000DC48C2 /* BSG_KSSignalInfo.h in Headers */, - 008967C22486DA1900DC48C2 /* BugsnagClientInternal.h in Headers */, + 008967C22486DA1900DC48C2 /* BugsnagClient+Private.h in Headers */, 0089681B2486DA5600DC48C2 /* BSGSerialization.h in Headers */, 00896A262486DAD100DC48C2 /* BSG_KSCrashSentry_Signal.h in Headers */, 008968182486DA5600DC48C2 /* BugsnagCollections.h in Headers */, @@ -2045,7 +2063,6 @@ 008969E82486DAD100DC48C2 /* BSG_KSSystemInfoC.h in Headers */, 008968A52486DA9600DC48C2 /* BugsnagSessionTrackingPayload.h in Headers */, CBAA6ABC250BA70E00713376 /* BugsnagKVStore.h in Headers */, - 008969642486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */, 00AD1F112486A17900A27979 /* BugsnagSessionTracker.h in Headers */, 008968F52486DAB800DC48C2 /* BugsnagSessionFileStore.h in Headers */, 008968892486DA9600DC48C2 /* BugsnagHandledState.h in Headers */, @@ -2053,7 +2070,7 @@ CBCF77A425010648004AF22A /* BSGJSONSerialization.h in Headers */, 0089683F2486DA6C00DC48C2 /* BugsnagMetadataInternal.h in Headers */, 008969732486DAD000DC48C2 /* BSG_KSSignalInfo.h in Headers */, - 008967C32486DA1900DC48C2 /* BugsnagClientInternal.h in Headers */, + 008967C32486DA1900DC48C2 /* BugsnagClient+Private.h in Headers */, 0089681C2486DA5600DC48C2 /* BSGSerialization.h in Headers */, 00896A272486DAD100DC48C2 /* BSG_KSCrashSentry_Signal.h in Headers */, 008968192486DA5600DC48C2 /* BugsnagCollections.h in Headers */, @@ -2145,7 +2162,6 @@ 008969E92486DAD100DC48C2 /* BSG_KSSystemInfoC.h in Headers */, 008968A62486DA9600DC48C2 /* BugsnagSessionTrackingPayload.h in Headers */, CBAA6ABD250BA70F00713376 /* BugsnagKVStore.h in Headers */, - 008969652486DAD000DC48C2 /* BSG_KSSingleton.h in Headers */, 00AD1F122486A17900A27979 /* BugsnagSessionTracker.h in Headers */, 008968F62486DAB800DC48C2 /* BugsnagSessionFileStore.h in Headers */, 0089688A2486DA9600DC48C2 /* BugsnagHandledState.h in Headers */, @@ -2153,7 +2169,7 @@ CBCF77A525010648004AF22A /* BSGJSONSerialization.h in Headers */, 008968402486DA6C00DC48C2 /* BugsnagMetadataInternal.h in Headers */, 008969742486DAD100DC48C2 /* BSG_KSSignalInfo.h in Headers */, - 008967C42486DA1900DC48C2 /* BugsnagClientInternal.h in Headers */, + 008967C42486DA1900DC48C2 /* BugsnagClient+Private.h in Headers */, 0089681D2486DA5600DC48C2 /* BSGSerialization.h in Headers */, 00896A282486DAD100DC48C2 /* BSG_KSCrashSentry_Signal.h in Headers */, 0089681A2486DA5600DC48C2 /* BugsnagCollections.h in Headers */, @@ -2542,6 +2558,7 @@ 0089678A2486D43700DC48C2 /* KSCrashReportStore_Tests.m in Sources */, E701FAAB2490EFD9008D842F /* EventApiValidationTest.m in Sources */, 0089677E2486D43700DC48C2 /* KSLogger_Tests.m in Sources */, + 012482A325627B51003F7243 /* UIKitTests.m in Sources */, 008967482486D43700DC48C2 /* BugsnagUserTest.m in Sources */, 008967962486D43700DC48C2 /* KSCrashState_Tests.m in Sources */, 0089675D2486D43700DC48C2 /* BugsnagSessionTrackingPayloadTest.m in Sources */, @@ -2581,6 +2598,7 @@ 008967542486D43700DC48C2 /* BugsnagOnCrashTest.m in Sources */, 008966F72486D43700DC48C2 /* RegisterErrorDataTest.m in Sources */, 008967152486D43700DC48C2 /* BugsnagCollectionsBSGDictMergeTest.m in Sources */, + 01E8765E256684E700F4B70A /* URLSessionMock.m in Sources */, 008967632486D43700DC48C2 /* BugsnagCollectionsBSGDictSetSafeObjectTest.m in Sources */, 008967AB2486D43700DC48C2 /* KSMach_Tests.m in Sources */, 0089672A2486D43700DC48C2 /* BugsnagStacktraceTest.m in Sources */, @@ -2692,6 +2710,7 @@ buildActionMask = 2147483647; files = ( 008967882486D43700DC48C2 /* KSCrashSentry_NSException_Tests.m in Sources */, + 0140D29A25767C9A00FD0306 /* BugsnagApiClientTest.m in Sources */, E701FAA02490EF4A008D842F /* BugsnagApiValidationTest.m in Sources */, 008966FB2486D43700DC48C2 /* BugsnagCollectionsBSGDictInsertIfNotNilTest.m in Sources */, 0089677F2486D43700DC48C2 /* KSLogger_Tests.m in Sources */, @@ -2750,6 +2769,7 @@ 008967432486D43700DC48C2 /* BugsnagSessionTrackerStopTest.m in Sources */, 008967972486D43700DC48C2 /* KSCrashState_Tests.m in Sources */, 008967762486D43700DC48C2 /* XCTestCase+KSCrash.m in Sources */, + 01E8765F256684E700F4B70A /* URLSessionMock.m in Sources */, 008967312486D43700DC48C2 /* BugsnagStateEventTest.m in Sources */, 004E35362487AFF2007FBAE4 /* BugsnagHandledStateTest.m in Sources */, 01C17AE82542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */, @@ -2891,6 +2911,7 @@ 0089674A2486D43700DC48C2 /* BugsnagUserTest.m in Sources */, 0089673B2486D43700DC48C2 /* BugsnagEventFromKSCrashReportTest.m in Sources */, 0089674D2486D43700DC48C2 /* BSGConnectivityTest.m in Sources */, + 01E87660256684E700F4B70A /* URLSessionMock.m in Sources */, 008966F02486D43700DC48C2 /* BugsnagClientPayloadInfoTest.m in Sources */, 008967652486D43700DC48C2 /* BugsnagCollectionsBSGDictSetSafeObjectTest.m in Sources */, E701FAA92490EF77008D842F /* ClientApiValidationTest.m in Sources */, @@ -2915,6 +2936,8 @@ 01C17AE92542ED7F00C102C9 /* KSCrashReportWriterTests.m in Sources */, 00896A422486DBDD00DC48C2 /* BSGConfigurationBuilderTests.m in Sources */, 008967682486D43700DC48C2 /* BugsnagNotifierTest.m in Sources */, + 01447605256684500018AB94 /* BugsnagApiClientTest.m in Sources */, + 0187D464255BD7B800C503D9 /* BugsnagApiClientTest.m in Sources */, 0089676E2486D43700DC48C2 /* BugsnagTestsDummyClass.m in Sources */, 008967412486D43700DC48C2 /* BugsnagAppTest.m in Sources */, 008967052486D43700DC48C2 /* BugsnagThreadSerializationTest.m in Sources */, @@ -3168,6 +3191,7 @@ 00AD1C8724869B0E00A27979 /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_MODULES_AUTOLINK = NO; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; @@ -3190,6 +3214,7 @@ 00AD1C8824869B0E00A27979 /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_MODULES_AUTOLINK = NO; CODE_SIGN_STYLE = Automatic; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m index 6d69c3d07e..e0fad52457 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m @@ -29,8 +29,7 @@ #import "BSG_KSCrash.h" #import "BugsnagBreadcrumbs.h" #import "BugsnagLogger.h" -#import "BugsnagClient.h" -#import "BugsnagClientInternal.h" +#import "BugsnagClient+Private.h" #import "BugsnagKeys.h" #import "BugsnagPlugin.h" #import "BugsnagHandledState.h" @@ -52,20 +51,6 @@ @interface NSDictionary (BSGKSMerge) - (NSDictionary *)BSG_mergedInto:(NSDictionary *)dest; @end -@interface BugsnagEvent () -@property(readwrite) NSUInteger depth; -@end - -@interface BugsnagClient () -- (void)startListeningForStateChangeNotification:(NSString *_Nonnull)notificationName; -- (void)addBreadcrumbWithBlock:(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block; -- (void)notifyInternal:(BugsnagEvent *_Nonnull)event - block:(BugsnagOnErrorBlock)block; -- (void)addRuntimeVersionInfo:(NSString *)info - withKey:(NSString *)key; -@property (nonatomic) NSString *codeBundleId; -@end - @interface BugsnagMetadata () - (NSDictionary *_Nonnull)toDictionary; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagErrorReportSink.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagErrorReportSink.m index 4bac7ee6fc..03f5a97055 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagErrorReportSink.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagErrorReportSink.m @@ -25,14 +25,15 @@ // #import "BugsnagErrorReportSink.h" + +#import "BSG_KSSystemInfo.h" #import "Bugsnag.h" -#import "BugsnagLogger.h" +#import "BugsnagClient+Private.h" #import "BugsnagCollections.h" -#import "BugsnagClient.h" -#import "BugsnagClientInternal.h" +#import "BugsnagEvent+Private.h" #import "BugsnagKeys.h" +#import "BugsnagLogger.h" #import "BugsnagNotifier.h" -#import "BSG_KSSystemInfo.h" #import "Private.h" // This is private in Bugsnag, but really we want package private so define @@ -45,13 +46,6 @@ @interface BugsnagNotifier () - (NSDictionary *)toDict; @end -@interface BugsnagEvent () -- (NSDictionary *_Nonnull)toJson; -- (BOOL)shouldBeSent; -- (instancetype _Nonnull)initWithKSReport:(NSDictionary *_Nonnull)report; -@property NSSet *redactedKeys; -@end - @interface BugsnagConfiguration () @property(nonatomic, readwrite, strong) NSMutableArray *onSendBlocks; - (NSDictionary *_Nonnull)errorApiHeaders; @@ -92,10 +86,10 @@ - (instancetype)initWithApiClient:(BugsnagErrorReportApiClient *)apiClient { } - (void)finishActiveRequest:(NSString *)requestId - success:(BOOL)success + completed:(BOOL)completed error:(NSError *)error block:(BSGOnErrorSentBlock)block { - block(requestId, success, error); + block(requestId, completed, error); @synchronized (self.activeRequests) { [self.activeRequests removeObject:requestId]; } @@ -123,7 +117,7 @@ - (void)sendStoredReports:(NSDictionary *)ksCrashRe if ([event shouldBeSent] && [self runOnSendBlocks:configuration event:event]) { storedEvents[fileKey] = event; } else { // delete the report as the user has discarded it - [self finishActiveRequest:fileKey success:true error:nil block:block]; + [self finishActiveRequest:fileKey completed:YES error:nil block:block]; } } [self deliverStoredEvents:storedEvents configuration:configuration block:block]; @@ -137,14 +131,13 @@ - (void)deliverStoredEvents:(NSMutableDictionary *)s NSDictionary *requestPayload = [self prepareEventPayload:event]; NSMutableDictionary *apiHeaders = [[configuration errorApiHeaders] mutableCopy]; - BSGDictSetSafeObject(apiHeaders, event.apiKey, BSGHeaderApiKey); - [self.apiClient sendItems:1 - withPayload:requestPayload - toURL:configuration.notifyURL - headers:apiHeaders - onCompletion:^(NSUInteger reportCount, BOOL success, NSError *error) { - [self finishActiveRequest:filename success:success error:error block:block]; - }]; + apiHeaders[BugsnagHTTPHeaderNameApiKey] = event.apiKey; + apiHeaders[BugsnagHTTPHeaderNameStacktraceTypes] = [event.stacktraceTypes componentsJoinedByString:@","]; + [self.apiClient sendJSONPayload:requestPayload headers:apiHeaders toURL:configuration.notifyURL + completionHandler:^(BugsnagApiClientDeliveryStatus status, NSError *error) { + BOOL completed = status == BugsnagApiClientDeliveryStatusDelivered || status == BugsnagApiClientDeliveryStatusUndeliverable; + [self finishActiveRequest:filename completed:completed error:error block:block]; + }]; } } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.h index f8efc7239f..ce9ce6f2bb 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.h @@ -34,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init NS_UNAVAILABLE; - (instancetype)initWithConfiguration:(BugsnagConfiguration *)config; +- (void)recordAppUUID; + - (void)setCodeBundleID:(NSString*)codeBundleID; /** diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m index 3e35ca10f3..d4049e9398 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/BugsnagSystemState.m @@ -10,7 +10,7 @@ #if TARGET_OS_OSX #import #else -#import +#import "BSGUIKit.h" #endif #import "BugsnagSystemState.h" @@ -117,11 +117,16 @@ id blankIfNil(id value) { device[@"modelNumber"] = systemInfo[@ BSG_KSSystemField_Model]; device[@"wordSize"] = @(PLATFORM_WORD_SIZE); device[@"locale"] = [[NSLocale currentLocale] localeIdentifier]; + device[@"runtimeVersions"] = @{ + @"clangVersion": systemInfo[@BSG_KSSystemField_ClangVersion] ?: @"", + @"osBuild": systemInfo[@BSG_KSSystemField_OSVersion] ?: @"" + }; #if BSG_PLATFORM_SIMULATOR device[@"simulator"] = @YES; #else device[@"simulator"] = @NO; #endif + device[@"totalMemory"] = systemInfo[@BSG_KSSystemField_Memory][@"usable"]; NSMutableDictionary *state = [NSMutableDictionary new]; state[BSGKeyApp] = app; @@ -167,11 +172,11 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)config { // MacOS "active" serves the same purpose as "foreground" in iOS [center addObserverForName:NSApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; - [weakSelf bgSetAppValue:@YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf setValue:@YES forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; [center addObserverForName:NSApplicationDidResignActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [weakSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; - [weakSelf bgSetAppValue:@NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf setValue:@NO forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; #else [center addObserverForName:UIApplicationWillTerminateNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { @@ -180,39 +185,48 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)config { }]; [center addObserverForName:UIApplicationWillEnterForegroundNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; - [weakSelf bgSetAppValue:@YES forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf setValue:@YES forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; [center addObserverForName:UIApplicationDidEnterBackgroundNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [weakSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; - [weakSelf bgSetAppValue:@NO forKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; + [weakSelf setValue:@NO forAppKey:SYSTEMSTATE_APP_IS_IN_FOREGROUND]; }]; [center addObserverForName:UIApplicationDidBecomeActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [weakSelf.kvStore setBoolean:YES forKey:SYSTEMSTATE_APP_IS_ACTIVE]; - [weakSelf bgSetAppValue:@YES forKey:SYSTEMSTATE_APP_IS_ACTIVE]; + [weakSelf setValue:@YES forAppKey:SYSTEMSTATE_APP_IS_ACTIVE]; }]; [center addObserverForName:UIApplicationWillResignActiveNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { [weakSelf.kvStore setBoolean:NO forKey:SYSTEMSTATE_APP_IS_ACTIVE]; - [weakSelf bgSetAppValue:@NO forKey:SYSTEMSTATE_APP_IS_ACTIVE]; + [weakSelf setValue:@NO forAppKey:SYSTEMSTATE_APP_IS_ACTIVE]; }]; [center addObserverForName:UIApplicationDidReceiveMemoryWarningNotification object:nil queue:nil usingBlock:^(NSNotification * _Nonnull note) { NSString *date = [BSG_RFC3339DateTool stringFromDate:[NSDate date]]; [weakSelf.kvStore setString:date forKey:SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING]; - [weakSelf bgSetAppValue:date forKey:SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING]; + [weakSelf setValue:date forAppKey:SYSTEMSTATE_APP_LAST_LOW_MEMORY_WARNING]; }]; #endif } return self; } +- (void)recordAppUUID { + // [BSG_KSSystemInfo appUUID] returns nil until we have called _dyld_register_func_for_add_image() + [self setValue:[BSG_KSSystemInfo appUUID] forAppKey:BSGKeyMachoUUID]; +} + - (void)setCodeBundleID:(NSString*)codeBundleID { - [self bgSetAppValue:codeBundleID forKey:BSGKeyCodeBundleId]; + [self setValue:codeBundleID forAppKey:BSGKeyCodeBundleId]; } -- (void)bgSetAppValue:(id)value forKey:(NSString*)key { +- (void)setValue:(id)value forAppKey:(NSString *)key { + [self setValue:value forKey:key inSection:SYSTEMSTATE_KEY_APP]; +} + +- (void)setValue:(id)value forKey:(NSString *)key inSection:(NSString *)section { // Run on a BG thread so we don't monopolize the notification queue. dispatch_async(dispatch_get_global_queue( DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void){ @synchronized (self) { - self.currentLaunchStateRW[SYSTEMSTATE_KEY_APP][key] = value; + self.currentLaunchStateRW[section][key] = value; // User-facing state should never mutate from under them. self.currentLaunchState = copyLaunchState(self.currentLaunchStateRW); } @@ -220,7 +234,6 @@ - (void)bgSetAppValue:(id)value forKey:(NSString*)key { }); } - - (void)sync { NSDictionary *state = self.currentLaunchState; NSError *error = nil; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h new file mode 100644 index 0000000000..f7b835fb3d --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient+Private.h @@ -0,0 +1,97 @@ +// +// BugsnagClient+Private.h +// Bugsnag +// +// Created by Nick Dowell on 26/11/2020. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import + +@class BugsnagBreadcrumbs; +@class BugsnagConfiguration; +@class BugsnagCrashSentry; +@class BugsnagErrorReportApiClient; +@class BugsnagMetadata; +@class BugsnagNotifier; +@class BugsnagPluginClient; +@class BugsnagSessionTracker; +@class BugsnagSystemState; + +NS_ASSUME_NONNULL_BEGIN + +@interface BugsnagClient () + +#pragma mark Properties + +@property (nonatomic) BOOL appDidCrashLastLaunch; + +@property (nullable, retain, nonatomic) BugsnagBreadcrumbs *breadcrumbs; + +@property (nullable, nonatomic) NSString *codeBundleId; + +@property (readonly) NSString *configMetadataFile; + +@property (nullable) NSDictionary *configMetadataFromLastLaunch; + +@property (nullable, retain, nonatomic) BugsnagConfiguration *configuration; + +@property (strong, nonatomic) BugsnagCrashSentry *crashSentry; + +@property (strong, nonatomic) BugsnagErrorReportApiClient *errorReportApiClient; + +@property NSMutableDictionary *extraRuntimeInfo; + +#if TARGET_OS_IOS +@property (strong, nonatomic) NSString *lastOrientation; +#endif + +@property (strong, nonatomic) BugsnagMetadata *metadata; // Used in BugsnagReactNative + +@property (readonly) NSString *metadataFile; + +@property (nullable) NSDictionary *metadataFromLastLaunch; + +@property (strong, nonatomic) BugsnagNotifier *notifier; // Used in BugsnagReactNative + +@property (strong, nonatomic) BugsnagPluginClient *pluginClient; + +@property (strong, nonatomic) BugsnagSessionTracker *sessionTracker; // Used in BugsnagReactNative + +@property (readonly) BOOL started; + +@property (strong, nonatomic) BugsnagMetadata *state; + +@property (strong, nonatomic) NSMutableArray *stateEventBlocks; + +@property (readonly) NSString *stateMetadataFile; + +@property (nullable) NSDictionary *stateMetadataFromLastLaunch; + +@property (strong, nonatomic) BugsnagSystemState *systemState; + +@property (nonatomic) BugsnagUser *user; + +#pragma mark Methods + +- (void)addBreadcrumbWithBlock:(void (^)(BugsnagBreadcrumb *))block; + +- (void)addRuntimeVersionInfo:(NSString *)info withKey:(NSString *)key; + +- (NSDictionary *)collectAppWithState; // Used in BugsnagReactNative + +- (NSArray *)collectBreadcrumbs; // Used in BugsnagReactNative + +- (NSDictionary *)collectDeviceWithState; // Used in BugsnagReactNative + +- (NSArray *)collectThreads:(BOOL)unhandled; // Used in BugsnagReactNative + +- (void)notifyInternal:(BugsnagEvent *)event block:(BugsnagOnErrorBlock)block; + +- (BOOL)shouldReportOOM; + +- (void)start; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m index fc956798e3..ecef18c0bf 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClient.m @@ -26,37 +26,40 @@ #import "BugsnagPlatformConditional.h" -#import "BugsnagClient.h" +#import "BugsnagClient+Private.h" -#import "BugsnagBreadcrumbs.h" -#import "BugsnagClientInternal.h" +#import "BSGCachesDirectory.h" #import "BSGConnectivity.h" -#import "Bugsnag.h" -#import "Private.h" -#import "BugsnagCrashSentry.h" -#import "BugsnagHandledState.h" -#import "BugsnagLogger.h" -#import "BugsnagKeys.h" -#import "BugsnagSessionTracker.h" -#import "BugsnagSessionTrackingApiClient.h" -#import "BugsnagPluginClient.h" -#import "BugsnagSystemState.h" -#import "BSG_RFC3339DateTool.h" +#import "BSGJSONSerialization.h" +#import "BSGSerialization.h" +#import "BSG_KSCrash.h" #import "BSG_KSCrashC.h" -#import "BSG_KSCrashType.h" +#import "BSG_KSCrashReport.h" #import "BSG_KSCrashState.h" -#import "BSG_KSSystemInfo.h" +#import "BSG_KSCrashType.h" #import "BSG_KSMach.h" -#import "BSGSerialization.h" +#import "BSG_KSSystemInfo.h" +#import "BSG_RFC3339DateTool.h" #import "Bugsnag.h" +#import "BugsnagBreadcrumbs.h" +#import "BugsnagCollections.h" +#import "BugsnagConfiguration+Private.h" +#import "BugsnagCrashSentry.h" +#import "BugsnagError+Private.h" #import "BugsnagErrorTypes.h" -#import "BugsnagNotifier.h" +#import "BugsnagEvent+Private.h" +#import "BugsnagHandledState.h" +#import "BugsnagKeys.h" +#import "BugsnagLogger.h" #import "BugsnagMetadataInternal.h" +#import "BugsnagNotifier.h" +#import "BugsnagPluginClient.h" +#import "BugsnagSessionTracker.h" +#import "BugsnagSessionTrackingApiClient.h" #import "BugsnagStateEvent.h" -#import "BugsnagCollections.h" -#import "BSG_KSCrashReport.h" -#import "BSG_KSCrash.h" -#import "BSGJSONSerialization.h" +#import "BugsnagSystemState.h" +#import "BugsnagThread+Private.h" +#import "Private.h" #if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS #define BSGOOMAvailable 1 @@ -65,7 +68,7 @@ #endif #if BSG_PLATFORM_IOS -#import +#import "BSGUIKit.h" #elif BSG_PLATFORM_OSX #import #endif @@ -76,31 +79,29 @@ static NSInteger const BSGNotifierStackFrameCount = 4; -struct bugsnag_data_t { +static struct { // Contains the state of the event (handled/unhandled) char *handledState; // Contains the user-specified metadata, including the user tab from config. - char *metadataJSON; + char *metadataPath; // Contains the Bugsnag configuration, all under the "config" tab. - char *configJSON; + char *configPath; // Contains notifier state, under "deviceState" and crash-specific // information under "crash". - char *stateJSON; + char *statePath; // Contains properties in the Bugsnag payload overridden by the user before // it was sent char *userOverridesJSON; // User onCrash handler void (*onCrash)(const BSG_KSCrashReportWriter *writer); -}; - -static struct bugsnag_data_t bsg_g_bugsnag_data; +} bsg_g_bugsnag_data; static NSDictionary *notificationNameMap; static char *sessionId[128]; static char *sessionStartDate[128]; static char *watchdogSentinelPath = NULL; -static char *crashSentinelPath = NULL; +static char *crashSentinelPath; static NSUInteger handledCount; static NSUInteger unhandledCount; static bool hasRecordedSessions; @@ -121,10 +122,6 @@ @interface BugsnagSession () @property NSUInteger handledCount; @end -@interface BugsnagThread () -+ (NSMutableArray *)serializeThreads:(NSArray *)threads; -@end - @interface BugsnagAppWithState () + (BugsnagAppWithState *)appWithDictionary:(NSDictionary *)event config:(BugsnagConfiguration *)config @@ -155,29 +152,20 @@ void BSSerializeDataCrashHandler(const BSG_KSCrashReportWriter *writer, int type writer->addUIntegerElement(writer, "unhandledCount", unhandledEvents); } if (isCrash) { - if (bsg_g_bugsnag_data.configJSON) { - writer->addJSONElement(writer, "config", bsg_g_bugsnag_data.configJSON); - } - if (bsg_g_bugsnag_data.stateJSON) { - writer->addJSONElement(writer, "state", bsg_g_bugsnag_data.stateJSON); - } + writer->addJSONFileElement(writer, "config", bsg_g_bugsnag_data.configPath); + writer->addJSONFileElement(writer, "metaData", bsg_g_bugsnag_data.metadataPath); + writer->addJSONFileElement(writer, "state", bsg_g_bugsnag_data.statePath); BugsnagBreadcrumbsWriteCrashReport(writer); - if (bsg_g_bugsnag_data.metadataJSON) { - // The API expects "metaData", capitalised as such. Elsewhere is is one word. - writer->addJSONElement(writer, "metaData", bsg_g_bugsnag_data.metadataJSON); - } if (watchdogSentinelPath != NULL) { // Delete the file to indicate a handled termination unlink(watchdogSentinelPath); } - if (crashSentinelPath != NULL) { - // Create a file to indicate that the crash has been handled by - // the library. This exists in case the subsequent `onCrash` handler - // crashes or otherwise corrupts the crash report file. - int fd = open(crashSentinelPath, O_RDWR | O_CREAT, 0644); - if (fd > -1) { - close(fd); - } + // Create a file to indicate that the crash has been handled by + // the library. This exists in case the subsequent `onCrash` handler + // crashes or otherwise corrupts the crash report file. + int fd = open(crashSentinelPath, O_RDWR | O_CREAT, 0644); + if (fd > -1) { + close(fd); } } @@ -242,37 +230,6 @@ void BSSerializeDataCrashHandler(const BSG_KSCrashReportWriter *writer, int type } #endif -/** - * Writes a dictionary to a destination using the BSG_KSCrash JSON encoding - * - * @param dictionary data to encode - * @param destination target location of the data - */ -void BSSerializeJSONDictionary(NSDictionary *dictionary, char **destination) { - if (![BSGJSONSerialization isValidJSONObject:dictionary]) { - bsg_log_err(@"could not serialize metadata: is not valid JSON object"); - return; - } - @try { - NSError *error; - NSData *json = [BSGJSONSerialization dataWithJSONObject:dictionary - options:0 - error:&error]; - - if (!json) { - bsg_log_err(@"could not serialize metadata: %@", error); - return; - } - *destination = reallocf(*destination, [json length] + 1); - if (*destination) { - memcpy(*destination, [json bytes], [json length]); - (*destination)[[json length]] = '\0'; - } - } @catch (NSException *exception) { - bsg_log_err(@"could not serialize metadata: %@", exception); - } -} - /** Save info about the current session to crash data. Ensures that session data is written to unhandled error reports. @@ -301,23 +258,6 @@ void BSGWriteSessionCrashData(BugsnagSession *session) { hasRecordedSessions = true; } -@interface BugsnagClient () -@property(nonatomic, strong) BugsnagCrashSentry *crashSentry; -@property(nonatomic, strong) BugsnagErrorReportApiClient *errorReportApiClient; -@property (nonatomic, strong) BugsnagSystemState *systemState; -@property (nonatomic, strong) BugsnagPluginClient *pluginClient; -@property (nonatomic) BOOL appDidCrashLastLaunch; -@property (nonatomic, strong) BugsnagMetadata *metadata; -@property (nonatomic) NSString *codeBundleId; -@property(nonatomic, readwrite, strong) NSMutableArray *stateEventBlocks; -#if BSG_PLATFORM_IOS -// The previous device orientation - iOS only -@property (nonatomic, strong) NSString *lastOrientation; -#endif -@property NSMutableDictionary *extraRuntimeInfo; -@property (nonatomic) BugsnagUser *user; -@end - @interface BugsnagConfiguration () @property(nonatomic, readwrite, strong) NSMutableSet *plugins; @property(readonly, retain, nullable) NSURL *notifyURL; @@ -326,31 +266,6 @@ @interface BugsnagConfiguration () - (BOOL)shouldRecordBreadcrumbType:(BSGBreadcrumbType)type; @end -@interface BugsnagEvent () -@property(readonly, copy, nonnull) NSDictionary *overrides; -@property(readwrite) NSUInteger depth; -@property(readonly, nonnull) BugsnagHandledState *handledState; -@property (nonatomic, strong) BugsnagMetadata *metadata; -- (void)setOverrideProperty:(NSString *)key value:(id)value; -- (NSDictionary *)toJson; -- (instancetype)initWithApp:(BugsnagAppWithState *)app - device:(BugsnagDeviceWithState *)device - handledState:(BugsnagHandledState *)handledState - user:(BugsnagUser *)user - metadata:(BugsnagMetadata *)metadata - breadcrumbs:(NSArray *)breadcrumbs - errors:(NSArray *)errors - threads:(NSArray *)threads - session:(BugsnagSession *)session; -@end - -@interface BugsnagError () -- (instancetype)initWithErrorClass:(NSString *)errorClass - errorMessage:(NSString *)errorMessage - errorType:(BSGErrorType)errorType - stacktrace:(NSArray *)stacktrace; -@end - @interface BugsnagSessionTracker () @property(nonatomic) NSString *codeBundleId; @end @@ -375,7 +290,6 @@ @implementation BugsnagClient @synthesize configuration; - (instancetype)initWithConfiguration:(BugsnagConfiguration *)initConfiguration { - static NSString *const BSGCrashSentinelFileName = @"bugsnag_handled_crash.txt"; if ((self = [super init])) { // Take a shallow copy of the configuration self.configuration = [initConfiguration copy]; @@ -383,19 +297,29 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)initConfiguration self.notifier = [BugsnagNotifier new]; self.systemState = [[BugsnagSystemState alloc] initWithConfiguration:self.configuration]; - NSString *cacheDir = [NSSearchPathForDirectoriesInDomains( - NSCachesDirectory, NSUserDomainMask, YES) firstObject]; - if (cacheDir) { - NSString *crashPath = [cacheDir stringByAppendingPathComponent:BSGCrashSentinelFileName]; - crashSentinelPath = strdup([crashPath UTF8String]); - } + NSString *cachesDir = [BSGCachesDirectory cachesDirectory]; + NSString *bugsnagDir = [cachesDir stringByAppendingPathComponent:@"bugsnag"]; + [[NSFileManager defaultManager] createDirectoryAtPath:bugsnagDir withIntermediateDirectories:YES attributes:nil error:nil]; + + NSString *crashPath = [cachesDir stringByAppendingPathComponent:@"bugsnag_handled_crash.txt"]; + crashSentinelPath = strdup(crashPath.fileSystemRepresentation); + + _configMetadataFile = [bugsnagDir stringByAppendingPathComponent:@"config.json"]; + bsg_g_bugsnag_data.configPath = strdup(_configMetadataFile.fileSystemRepresentation); + _configMetadataFromLastLaunch = [BSGJSONSerialization JSONObjectWithContentsOfFile:_configMetadataFile options:0 error:nil]; + + _metadataFile = [bugsnagDir stringByAppendingPathComponent:@"metadata.json"]; + bsg_g_bugsnag_data.metadataPath = strdup(_metadataFile.fileSystemRepresentation); + _metadataFromLastLaunch = [BSGJSONSerialization JSONObjectWithContentsOfFile:_metadataFile options:0 error:nil]; + + _stateMetadataFile = [bugsnagDir stringByAppendingPathComponent:@"state.json"]; + bsg_g_bugsnag_data.statePath = strdup(_stateMetadataFile.fileSystemRepresentation); + _stateMetadataFromLastLaunch = [BSGJSONSerialization JSONObjectWithContentsOfFile:_stateMetadataFile options:0 error:nil]; self.stateEventBlocks = [NSMutableArray new]; self.extraRuntimeInfo = [NSMutableDictionary new]; - self.metadataLock = [[NSLock alloc] init]; self.crashSentry = [BugsnagCrashSentry new]; - self.errorReportApiClient = [[BugsnagErrorReportApiClient alloc] initWithConfig:configuration - queueName:@"Error API queue"]; + self.errorReportApiClient = [[BugsnagErrorReportApiClient alloc] initWithSession:configuration.session queueName:@"Error API queue"]; bsg_g_bugsnag_data.onCrash = (void (*)(const BSG_KSCrashReportWriter *))self.configuration.onCrashHandler; static dispatch_once_t once_t; @@ -435,7 +359,7 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)initConfiguration client:self]; #if BSG_PLATFORM_IOS - _lastOrientation = BSGOrientationNameFromEnum([UIDevice currentDevice].orientation); + _lastOrientation = BSGOrientationNameFromEnum([UIDEVICE currentDevice].orientation); #endif _user = self.configuration.user; @@ -550,6 +474,7 @@ - (void)start { [self.crashSentry install:self.configuration apiClient:self.errorReportApiClient onCrash:&BSSerializeDataCrashHandler]; + [self.systemState recordAppUUID]; // Needs to be called after crashSentry installed but before -computeDidCrashLastLaunch [self computeDidCrashLastLaunch]; [self.breadcrumbs removeAllBreadcrumbs]; [self setupConnectivityListener]; @@ -582,10 +507,11 @@ - (void)start { name:UIApplicationDidReceiveMemoryWarningNotification object:nil]; - [UIDevice currentDevice].batteryMonitoringEnabled = YES; - [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; + [UIDEVICE currentDevice].batteryMonitoringEnabled = YES; + [[UIDEVICE currentDevice] beginGeneratingDeviceOrientationNotifications]; [self batteryChanged:nil]; + [self orientationChanged:nil]; [self addTerminationObserver:UIApplicationWillTerminateNotification]; #elif BSG_PLATFORM_OSX @@ -712,8 +638,7 @@ - (void)computeDidCrashLastLaunch { BOOL handledCrashLastLaunch = appCrashSentinelExists || crashState->crashedLastLaunch; if (appCrashSentinelExists) { NSError *error = nil; - [manager removeItemAtPath:didCrashSentinelPath error:&error]; - if (error) { + if (![manager removeItemAtPath:didCrashSentinelPath error:&error]) { bsg_log_err(@"Failed to remove crash sentinel file: %@", error); unlink(crashSentinelPath); } @@ -735,6 +660,10 @@ - (void)computeDidCrashLastLaunch { [self notifyOutOfMemoryEvent]; bsg_g_bugsnag_data.onCrash = onCrash; } + + self.configMetadataFromLastLaunch = nil; + self.metadataFromLastLaunch = nil; + self.stateMetadataFromLastLaunch = nil; } - (void)setCodeBundleId:(NSString *)codeBundleId { @@ -752,8 +681,8 @@ - (void)unsubscribeFromNotifications:(id)sender { [BSGConnectivity stopMonitoring]; #if BSG_PLATFORM_IOS - [UIDevice currentDevice].batteryMonitoringEnabled = NO; - [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications]; + [UIDEVICE currentDevice].batteryMonitoringEnabled = NO; + [[UIDEVICE currentDevice] endGeneratingDeviceOrientationNotifications]; #endif } @@ -824,11 +753,9 @@ - (void)setupConnectivityListener { [strongSelf flushPendingReports]; } - [self addAutoBreadcrumbOfType:BSGBreadcrumbTypeState - withMessage:@"Connectivity changed" - andMetadata:@{ - @"type" : connectionType - }]; + [strongSelf addAutoBreadcrumbOfType:BSGBreadcrumbTypeState + withMessage:@"Connectivity changed" + andMetadata:@{@"type": connectionType}]; }]; } @@ -1014,15 +941,17 @@ - (void)notifyOutOfMemoryEvent { handledStateWithSeverityReason:LikelyOutOfMemory severity:BSGSeverityError attrValue:nil]; - NSDictionary *appState = @{@"oom": lastLaunchInfo, @"didOOM": @YES}; + NSMutableDictionary *appState = [self.stateMetadataFromLastLaunch mutableCopy] ?: [NSMutableDictionary dictionary]; + appState[@"didOOM"] = @YES; + appState[@"oom"] = lastLaunchInfo; [self.crashSentry reportUserException:BSGOutOfMemoryErrorClass reason:message handledState:[handledState toJson] appState:appState callbackOverrides:@{} eventOverrides:nil - metadata:@{} - config:@{}]; + metadata:self.metadataFromLastLaunch + config:self.configMetadataFromLastLaunch]; } - (void)notify:(NSException *)exception @@ -1169,17 +1098,11 @@ - (void)addBreadcrumbWithBlock:(void (^)(BugsnagBreadcrumb *))block { - (void)metadataChanged:(BugsnagMetadata *)metadata { @synchronized(metadata) { if (metadata == self.metadata) { - if ([self.metadataLock tryLock]) { - BSSerializeJSONDictionary([metadata toDictionary], - &bsg_g_bugsnag_data.metadataJSON); - [self.metadataLock unlock]; - } + [BSGJSONSerialization writeJSONObject:[metadata toDictionary] toFile:self.metadataFile options:0 error:nil]; } else if (metadata == self.configuration.config) { - BSSerializeJSONDictionary([metadata getMetadataFromSection:BSGKeyConfig], - &bsg_g_bugsnag_data.configJSON); + [BSGJSONSerialization writeJSONObject:[metadata getMetadataFromSection:BSGKeyConfig] toFile:self.configMetadataFile options:0 error:nil]; } else if (metadata == self.state) { - BSSerializeJSONDictionary([metadata toDictionary], - &bsg_g_bugsnag_data.stateJSON); + [BSGJSONSerialization writeJSONObject:[metadata toDictionary] toFile:self.stateMetadataFile options:0 error:nil]; } } } @@ -1191,9 +1114,9 @@ - (void)metadataChanged:(BugsnagMetadata *)metadata { */ #if BSG_PLATFORM_IOS - (void)batteryChanged:(NSNotification *)notification { - NSNumber *batteryLevel = @([UIDevice currentDevice].batteryLevel); - BOOL charging = [UIDevice currentDevice].batteryState == UIDeviceBatteryStateCharging || - [UIDevice currentDevice].batteryState == UIDeviceBatteryStateFull; + NSNumber *batteryLevel = @([UIDEVICE currentDevice].batteryLevel); + BOOL charging = [UIDEVICE currentDevice].batteryState == UIDeviceBatteryStateCharging || + [UIDEVICE currentDevice].batteryState == UIDeviceBatteryStateFull; [self.state addMetadata:batteryLevel withKey:BSGKeyBatteryLevel @@ -1211,7 +1134,7 @@ - (void)batteryChanged:(NSNotification *)notification { * @param notification The orientation-change notification */ - (void)orientationChanged:(NSNotification *)notification { - UIDeviceOrientation currentDeviceOrientation = [UIDevice currentDevice].orientation; + UIDeviceOrientation currentDeviceOrientation = [UIDEVICE currentDevice].orientation; NSString *orientation = BSGOrientationNameFromEnum(currentDeviceOrientation); // No orientation, nothing to be done diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClientInternal.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClientInternal.h deleted file mode 100644 index 9c2281ea9b..0000000000 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Client/BugsnagClientInternal.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// BugsnagClientInternal.h -// Bugsnag -// -// Created by Jamie Lynch on 31/03/2020. -// Copyright © 2020 Bugsnag. All rights reserved. -// - -#import - -#import "BugsnagClient.h" - -@class BugsnagBreadcrumbs; -@class BugsnagClient; -@class BugsnagSessionTracker; -@class BugsnagConfiguration; -@class BugsnagMetadata; -@class BugsnagNotifier; - -@interface BugsnagClient () - -@property(nonatomic, readwrite, retain) BugsnagBreadcrumbs *_Nullable breadcrumbs; -@property(nonatomic, readwrite, retain) BugsnagConfiguration *_Nullable configuration; -@property(nonatomic, readwrite, strong) BugsnagMetadata *_Nonnull state; -@property(nonatomic, readwrite, strong) BugsnagNotifier *_Nonnull notifier; -@property(nonatomic, readwrite, strong) NSLock *_Nonnull metadataLock; -@property(nonatomic, readwrite, strong) BugsnagSessionTracker *_Nonnull sessionTracker; -@property(readonly) BOOL started; - -- (void)start; - -- (BOOL)shouldReportOOM; - -@end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration+Private.h new file mode 100644 index 0000000000..5d53c3d9a4 --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration+Private.h @@ -0,0 +1,24 @@ +// +// BugsnagConfiguration+Private.h +// Bugsnag +// +// Created by Nick Dowell on 26/11/2020. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface BugsnagConfiguration () + +/// Initializes the configuration with values previously stored in metadata. +- (instancetype)initWithMetadata:(NSDictionary *)JSONObject NS_DESIGNATED_INITIALIZER; + +/// Throws an NSInvalidArgumentException if the API key is empty or missing. +/// Logs a warning message if the API key is not in the expected format. +- (void)validate; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m index c71e60c3d7..838be9ae97 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Configuration/BugsnagConfiguration.m @@ -24,9 +24,10 @@ // THE SOFTWARE. // -#import "BugsnagConfiguration.h" +#import "BugsnagConfiguration+Private.h" #import "BSGConfigurationBuilder.h" +#import "BugsnagApiClient.h" #import "Private.h" static const int BSGApiKeyLength = 32; @@ -230,6 +231,18 @@ - (instancetype)initWithApiKey:(NSString *)apiKey { return self; } +- (instancetype)initWithMetadata:(NSDictionary *)metadata { + if (!(self = [super init])) { + return nil; + } + _appVersion = metadata[BSGKeyAppVersion]; + _context = metadata[BSGKeyContext]; + _bundleVersion = metadata[BSGKeyBundleVersion]; + _enabledReleaseStages = metadata[BSGKeyEnabledReleaseStages]; + _releaseStage = metadata[BSGKeyReleaseStage]; + return self; +} + // ----------------------------------------------------------------------------- // MARK: - Instance Methods // ----------------------------------------------------------------------------- @@ -306,19 +319,17 @@ - (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block { } - (NSDictionary *)errorApiHeaders { - return @{ - BSGHeaderApiPayloadVersion: @"4.0", - BSGHeaderApiKey: self.apiKey, - BSGHeaderApiSentAt: [BSG_RFC3339DateTool stringFromDate:[NSDate new]] + return @{BugsnagHTTPHeaderNameApiKey: self.apiKey ?: @"", + BugsnagHTTPHeaderNamePayloadVersion: @"4.0", + BugsnagHTTPHeaderNameSentAt: [BSG_RFC3339DateTool stringFromDate:[NSDate date]] }; } - (NSDictionary *)sessionApiHeaders { - return @{ - BSGHeaderApiPayloadVersion: @"1.0", - BSGHeaderApiKey: self.apiKey, - BSGHeaderApiSentAt: [BSG_RFC3339DateTool stringFromDate:[NSDate new]] - }; + return @{BugsnagHTTPHeaderNameApiKey: self.apiKey ?: @"", + BugsnagHTTPHeaderNamePayloadVersion: @"1.0", + BugsnagHTTPHeaderNameSentAt: [BSG_RFC3339DateTool stringFromDate:[NSDate date]] + }; } - (void)setEndpoints:(BugsnagEndpointConfiguration *)endpoints { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h index d1cca8eab4..9023ad53bb 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.h @@ -5,14 +5,28 @@ #import -@class BugsnagConfiguration; +NS_ASSUME_NONNULL_BEGIN -typedef void (^RequestCompletion)(NSUInteger reportCount, BOOL success, NSError *error); +typedef NSString * BugsnagHTTPHeaderName NS_TYPED_ENUM; + +extern BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameApiKey; +extern BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameIntegrity; +extern BugsnagHTTPHeaderName const BugsnagHTTPHeaderNamePayloadVersion; +extern BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameSentAt; +extern BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameStacktraceTypes; + +typedef NS_ENUM(NSInteger, BugsnagApiClientDeliveryStatus) { + /// The payload was delivered successfully and can be deleted. + BugsnagApiClientDeliveryStatusDelivered, + /// The payload was not delivered but can be retried, e.g. when there was a loss of connectivity. + BugsnagApiClientDeliveryStatusFailed, + /// The payload cannot be delivered and should be deleted without attempting to retry. + BugsnagApiClientDeliveryStatusUndeliverable, +}; @interface BugsnagApiClient : NSObject -- (instancetype)initWithConfig:(BugsnagConfiguration *)configuration - queueName:(NSString *)queueName; +- (instancetype)initWithSession:(nullable NSURLSession *)session queueName:(NSString *)queueName; /** * Send outstanding reports @@ -21,14 +35,15 @@ typedef void (^RequestCompletion)(NSUInteger reportCount, BOOL success, NSError - (NSOperation *)deliveryOperation; -- (void)sendItems:(NSUInteger)count - withPayload:(NSDictionary *)payload - toURL:(NSURL *)url - headers:(NSDictionary *)headers - onCompletion:(RequestCompletion)onCompletion; +- (void)sendJSONPayload:(NSDictionary *)payload + headers:(NSDictionary *)headers + toURL:(NSURL *)url + completionHandler:(void (^)(BugsnagApiClientDeliveryStatus status, NSError * _Nullable error))completionHandler; -@property(readonly) NSOperationQueue *sendQueue; -@property(readonly) BugsnagConfiguration *config; +- (NSString *)SHA1HashStringWithData:(NSData *)data; +@property(readonly) NSOperationQueue *sendQueue; @end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m index 7f89c966de..7e3b454ba2 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagApiClient.m @@ -4,6 +4,7 @@ // #import "BugsnagApiClient.h" + #import "BugsnagConfiguration.h" #import "Bugsnag.h" #import "BugsnagKeys.h" @@ -11,115 +12,116 @@ #import "Private.h" #import "BSGJSONSerialization.h" -@interface BSGDelayOperation : NSOperation -@end +#import + +BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameApiKey = @"Bugsnag-Api-Key"; +BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameIntegrity = @"Bugsnag-Integrity"; +BugsnagHTTPHeaderName const BugsnagHTTPHeaderNamePayloadVersion = @"Bugsnag-Payload-Version"; +BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameSentAt = @"Bugsnag-Sent-At"; +BugsnagHTTPHeaderName const BugsnagHTTPHeaderNameStacktraceTypes = @"Bugsnag-Stacktrace-Types"; + +typedef NS_ENUM(NSInteger, HTTPStatusCode) { + /// 402 Payment Required: a nonstandard client error status response code that is reserved for future use. + /// + /// This status code is returned by ngrok when a tunnel has expired. + HTTPStatusCodePaymentRequired = 402, + + /// 407 Proxy Authentication Required: the request has not been applied because it lacks valid authentication credentials + /// for a proxy server that is between the browser and the server that can access the requested resource. + HTTPStatusCodeProxyAuthenticationRequired = 407, + + /// 408 Request Timeout: the server would like to shut down this unused connection. + HTTPStatusCodeClientTimeout = 408, + + /// 429 Too Many Requests: the user has sent too many requests in a given amount of time ("rate limiting"). + HTTPStatusCodeTooManyRequests = 429, +}; @interface BugsnagApiClient() -@property (nonatomic, strong) NSURLSession *generatedSession; +@property (nonatomic, strong) NSURLSession *session; @end @implementation BugsnagApiClient -- (instancetype)initWithConfig:(BugsnagConfiguration *)configuration - queueName:(NSString *)queueName { +- (instancetype)initWithSession:(nullable NSURLSession *)session queueName:(NSString *)queueName { if (self = [super init]) { _sendQueue = [NSOperationQueue new]; _sendQueue.maxConcurrentOperationCount = 1; - _config = configuration; - if ([_sendQueue respondsToSelector:@selector(qualityOfService)]) { _sendQueue.qualityOfService = NSQualityOfServiceUtility; } _sendQueue.name = queueName; + _session = session ?: [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration ephemeralSessionConfiguration]]; } return self; } - (void)flushPendingData { [self.sendQueue cancelAllOperations]; - BSGDelayOperation *delay = [BSGDelayOperation new]; + NSOperation *delay = [NSBlockOperation blockOperationWithBlock:^{ [NSThread sleepForTimeInterval:1]; }]; NSOperation *deliver = [self deliveryOperation]; [deliver addDependency:delay]; [self.sendQueue addOperations:@[delay, deliver] waitUntilFinished:NO]; } - (NSOperation *)deliveryOperation { - bsg_log_err(@"Should override deliveryOperation in super class"); + bsg_log_err(@"Should override deliveryOperation in subclass"); return [NSOperation new]; } #pragma mark - Delivery - -- (void)sendItems:(NSUInteger)count - withPayload:(NSDictionary *)payload - toURL:(NSURL *)url - headers:(NSDictionary *)headers - onCompletion:(RequestCompletion)onCompletion { - - @try { - NSError *error = nil; - NSData *jsonData = - [BSGJSONSerialization dataWithJSONObject:payload - options:0 - error:&error]; - - if (jsonData == nil) { - if (onCompletion) { - onCompletion(0, NO, error); - } - return; +- (void)sendJSONPayload:(NSDictionary *)payload + headers:(NSDictionary *)headers + toURL:(NSURL *)url + completionHandler:(void (^)(BugsnagApiClientDeliveryStatus status, NSError * _Nullable error))completionHandler { + + if (![BSGJSONSerialization isValidJSONObject:payload]) { + bsg_log_err(@"Error: Invalid JSON payload passed to %s", __PRETTY_FUNCTION__); + return completionHandler(BugsnagApiClientDeliveryStatusUndeliverable, nil); + } + + NSError *error = nil; + NSData *data = [BSGJSONSerialization dataWithJSONObject:payload options:0 error:&error]; + if (!data) { + bsg_log_err(@"Error: Could not encode JSON payload passed to %s", __PRETTY_FUNCTION__); + return completionHandler(BugsnagApiClientDeliveryStatusUndeliverable, error); + } + + NSMutableDictionary *mutableHeaders = [headers mutableCopy]; + mutableHeaders[BugsnagHTTPHeaderNameIntegrity] = [NSString stringWithFormat:@"sha1 %@", [self SHA1HashStringWithData:data]]; + + NSMutableURLRequest *request = [self prepareRequest:url headers:mutableHeaders]; + + [[self.session uploadTaskWithRequest:request fromData:data completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { + if (![response isKindOfClass:[NSHTTPURLResponse class]]) { + return completionHandler(BugsnagApiClientDeliveryStatusFailed, error ?: + [NSError errorWithDomain:@"BugsnagApiClientErrorDomain" code:0 userInfo:@{ + NSLocalizedDescriptionKey: @"Request failed: no response was received", + NSURLErrorFailingURLErrorKey: url }]); } - NSMutableURLRequest *request = [self prepareRequest:url headers:headers]; - - if ([NSURLSession class]) { - NSURLSession *session = [self prepareSession]; - NSURLSessionTask *task = [session - uploadTaskWithRequest:request - fromData:jsonData - completionHandler:^(NSData *_Nullable responseBody, - NSURLResponse *_Nullable response, - NSError *_Nullable requestErr) { - if (onCompletion) { - onCompletion(count, requestErr == nil, requestErr); - } - }]; - [task resume]; - } else { -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-declarations" - NSURLResponse *response = nil; - request.HTTPBody = jsonData; - [NSURLConnection sendSynchronousRequest:request - returningResponse:&response - error:&error]; - if (onCompletion) { - onCompletion(count, error == nil, error); - } -#pragma clang diagnostic pop + + NSInteger statusCode = ((NSHTTPURLResponse *)response).statusCode; + + if (statusCode / 100 == 2) { + return completionHandler(BugsnagApiClientDeliveryStatusDelivered, nil); } - } @catch (NSException *exception) { - if (onCompletion) { - onCompletion(count, NO, - [NSError errorWithDomain:exception.reason - code:420 - userInfo:@{BSGKeyException: exception}]); + + error = [NSError errorWithDomain:@"BugsnagApiClientErrorDomain" code:1 userInfo:@{ + NSLocalizedDescriptionKey: [NSString stringWithFormat:@"Request failed: unacceptable status code %ld (%@)", + (long)statusCode, [NSHTTPURLResponse localizedStringForStatusCode:statusCode]], + NSURLErrorFailingURLErrorKey: url }]; + + if (statusCode / 100 == 4 && + statusCode != HTTPStatusCodePaymentRequired && + statusCode != HTTPStatusCodeProxyAuthenticationRequired && + statusCode != HTTPStatusCodeClientTimeout && + statusCode != HTTPStatusCodeTooManyRequests) { + return completionHandler(BugsnagApiClientDeliveryStatusUndeliverable, error); } - } -} - -- (NSURLSession *)prepareSession { - NSURLSession *session = [Bugsnag configuration].session; - if (session) { - return session; - } else { - if (!self.generatedSession) { - _generatedSession = [NSURLSession - sessionWithConfiguration:[NSURLSessionConfiguration - defaultSessionConfiguration]]; - } - return self.generatedSession; - } + + return completionHandler(BugsnagApiClientDeliveryStatusFailed, error); + }] resume]; } - (NSMutableURLRequest *)prepareRequest:(NSURL *)url @@ -137,17 +139,21 @@ - (NSMutableURLRequest *)prepareRequest:(NSURL *)url return request; } -- (void)dealloc { - [self.sendQueue cancelAllOperations]; +- (NSString *)SHA1HashStringWithData:(NSData *)data { + if (!data) { + return nil; + } + unsigned char md[CC_SHA1_DIGEST_LENGTH]; + CC_SHA1(data.bytes, (CC_LONG)data.length, md); + return [NSString stringWithFormat:@"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", + md[0], md[1], md[2], md[3], md[4], + md[5], md[6], md[7], md[8], md[9], + md[10], md[11], md[12], md[13], md[14], + md[15], md[16], md[17], md[18], md[19]]; } -@end - -@implementation BSGDelayOperation -const NSTimeInterval BSG_SEND_DELAY_SECS = 1; - -- (void)main { - [NSThread sleepForTimeInterval:BSG_SEND_DELAY_SECS]; +- (void)dealloc { + [self.sendQueue cancelAllOperations]; } @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h index 0250973309..0d1ad33671 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.h @@ -6,10 +6,13 @@ #import #import "BugsnagApiClient.h" +@class BugsnagConfiguration; @class BugsnagSessionFileStore; @interface BugsnagSessionTrackingApiClient : BugsnagApiClient +- (instancetype)initWithConfig:(BugsnagConfiguration *)configuration queueName:(NSString *)queueName; + /** * Asynchronously delivers sessions written to the store * diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m index b087b6c46a..374dc2e17a 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Delivery/BugsnagSessionTrackingApiClient.m @@ -21,15 +21,16 @@ @interface BugsnagConfiguration () @interface BugsnagSessionTrackingApiClient () @property NSMutableSet *activeIds; @property(nonatomic) NSString *codeBundleId; +@property(nonatomic) BugsnagConfiguration *config; @end @implementation BugsnagSessionTrackingApiClient -- (instancetype)initWithConfig:(BugsnagConfiguration *)configuration - queueName:(NSString *)queueName { - if (self = [super initWithConfig:configuration queueName:queueName]) { +- (instancetype)initWithConfig:(BugsnagConfiguration *)configuration queueName:(NSString *)queueName { + if ((self = [super initWithSession:configuration.session queueName:queueName])) { _activeIds = [NSMutableSet new]; + _config = configuration; } return self; } @@ -69,27 +70,29 @@ - (void)deliverSessionsInStore:(BugsnagSessionFileStore *)store { codeBundleId:self.codeBundleId]; NSMutableDictionary *data = [payload toJson]; NSDictionary *HTTPHeaders = @{ - @"Bugsnag-Payload-Version": @"1.0", - @"Bugsnag-API-Key": apiKey, - @"Bugsnag-Sent-At": [BSG_RFC3339DateTool stringFromDate:[NSDate new]] + BugsnagHTTPHeaderNameApiKey: apiKey ?: @"", + BugsnagHTTPHeaderNamePayloadVersion: @"1.0", + BugsnagHTTPHeaderNameSentAt: [BSG_RFC3339DateTool stringFromDate:[NSDate date]] }; - [self sendItems:1 - withPayload:data - toURL:sessionURL - headers:HTTPHeaders - onCompletion:^(NSUInteger sentCount, BOOL success, NSError *error) { - if (success && error == nil) { - bsg_log_info(@"Sent session %@ to Bugsnag", session.id); - [store deleteFileWithId:fileId]; - } else { - bsg_log_warn(@"Failed to send sessions to Bugsnag: %@", error); - } - - // remove request - @synchronized (self.activeIds) { - [self.activeIds removeObject:fileId]; - } - }]; + [self sendJSONPayload:data headers:HTTPHeaders toURL:sessionURL + completionHandler:^(BugsnagApiClientDeliveryStatus status, NSError *error) { + switch (status) { + case BugsnagApiClientDeliveryStatusDelivered: + bsg_log_info(@"Sent session %@ to Bugsnag", session.id); + [store deleteFileWithId:fileId]; + break; + case BugsnagApiClientDeliveryStatusFailed: + bsg_log_warn(@"Failed to send sessions to Bugsnag: %@", error); + break; + case BugsnagApiClientDeliveryStatusUndeliverable: + bsg_log_warn(@"Failed to send sessions to Bugsnag: %@", error); + [store deleteFileWithId:fileId]; + break; + } + @synchronized (self.activeIds) { + [self.activeIds removeObject:fileId]; + } + }]; }]; } } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h index 8efa6220af..8aedfe573d 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.h @@ -44,6 +44,10 @@ NS_ASSUME_NONNULL_BEGIN */ + (nullable id)JSONObjectWithStream:(NSInputStream *)stream options:(NSJSONReadingOptions)opt error:(NSError **)error; ++ (BOOL)writeJSONObject:(id)JSONObject toFile:(NSString *)file options:(NSJSONWritingOptions)options error:(NSError **)errorPtr; + ++ (nullable id)JSONObjectWithContentsOfFile:(NSString *)file options:(NSJSONReadingOptions)options error:(NSError **)errorPtr; + @end NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m index 5c4f81e2a7..c536210e60 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGJSONSerialization.m @@ -17,14 +17,14 @@ @implementation BSGJSONSerialization NSUnderlyingErrorKey: exception, }; - return [NSError errorWithDomain:@"com.bugsnag" code:1 userInfo:userInfo]; + return [NSError errorWithDomain:@"BSGJSONSerializationErrorDomain" code:1 userInfo:userInfo]; } + (BOOL)isValidJSONObject:(id)obj { @try { return [NSJSONSerialization isValidJSONObject:obj]; } @catch (NSException *exception) { - return false; + return NO; } } @@ -32,7 +32,9 @@ + (nullable NSData *)dataWithJSONObject:(id)obj options:(NSJSONWritingOptions)op @try { return [NSJSONSerialization dataWithJSONObject:obj options:opt error:error]; } @catch (NSException *exception) { - *error = wrapException(exception); + if (error) { + *error = wrapException(exception); + } return nil; } } @@ -41,7 +43,9 @@ + (nullable id)JSONObjectWithData:(NSData *)data options:(NSJSONReadingOptions)o @try { return [NSJSONSerialization JSONObjectWithData:data options:opt error:error]; } @catch (NSException *exception) { - *error = wrapException(exception); + if (error) { + *error = wrapException(exception); + } return nil; } } @@ -50,7 +54,9 @@ + (NSInteger)writeJSONObject:(id)obj toStream:(NSOutputStream *)stream options:( @try { return [NSJSONSerialization writeJSONObject:obj toStream:stream options:opt error:error]; } @catch (NSException *exception) { - *error = wrapException(exception); + if (error) { + *error = wrapException(exception); + } return 0; } } @@ -59,9 +65,31 @@ + (nullable id)JSONObjectWithStream:(NSInputStream *)stream options:(NSJSONReadi @try { return [NSJSONSerialization JSONObjectWithStream:stream options:opt error:error]; } @catch (NSException *exception) { - *error = wrapException(exception); + if (error) { + *error = wrapException(exception); + } return nil; } } ++ (BOOL)writeJSONObject:(id)JSONObject toFile:(NSString *)file options:(NSJSONWritingOptions)options error:(NSError **)errorPtr { + if (![BSGJSONSerialization isValidJSONObject:JSONObject]) { + if (errorPtr) { + *errorPtr = [NSError errorWithDomain:@"BSGJSONSerializationErrorDomain" code:0 userInfo:@{ + NSLocalizedDescriptionKey: @"Not a valid JSON object"}]; + } + return NO; + } + NSData *data = [BSGJSONSerialization dataWithJSONObject:JSONObject options:options error:errorPtr]; + return [data writeToFile:file options:NSDataWritingAtomic error:errorPtr]; +} + ++ (nullable id)JSONObjectWithContentsOfFile:(NSString *)file options:(NSJSONReadingOptions)options error:(NSError **)errorPtr { + NSData *data = [NSData dataWithContentsOfFile:file options:0 error:errorPtr]; + if (!data) { + return nil; + } + return [BSGJSONSerialization JSONObjectWithData:data options:options error:errorPtr]; +} + @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h new file mode 100644 index 0000000000..bbe3eae937 --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BSGUIKit.h @@ -0,0 +1,40 @@ +// +// BSGUIKit.h +// Bugsnag +// +// Created by Nick Dowell on 01/12/2020. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import + +// When used in some memory constrained contexts such as a file provider extension, linking to UIKit is problematic. +// These macros exist to allow the use of UIKit without adding a link-time dependency on it. + +#define UIAPPLICATION NSClassFromString(@"UIApplication") +#define UIDEVICE NSClassFromString(@"UIDevice") + +#define UIApplicationDidBecomeActiveNotification @"UIApplicationDidBecomeActiveNotification" +#define UIApplicationDidEnterBackgroundNotification @"UIApplicationDidEnterBackgroundNotification" +#define UIApplicationDidReceiveMemoryWarningNotification @"UIApplicationDidReceiveMemoryWarningNotification" +#define UIApplicationUserDidTakeScreenshotNotification @"UIApplicationUserDidTakeScreenshotNotification" +#define UIApplicationWillEnterForegroundNotification @"UIApplicationWillEnterForegroundNotification" +#define UIApplicationWillResignActiveNotification @"UIApplicationWillResignActiveNotification" +#define UIApplicationWillTerminateNotification @"UIApplicationWillTerminateNotification" +#define UIDeviceBatteryLevelDidChangeNotification @"UIDeviceBatteryLevelDidChangeNotification" +#define UIDeviceBatteryStateDidChangeNotification @"UIDeviceBatteryStateDidChangeNotification" +#define UIDeviceOrientationDidChangeNotification @"UIDeviceOrientationDidChangeNotification" +#define UIKeyboardDidHideNotification @"UIKeyboardDidHideNotification" +#define UIKeyboardDidShowNotification @"UIKeyboardDidShowNotification" +#define UIMenuControllerDidHideMenuNotification @"UIMenuControllerDidHideMenuNotification" +#define UIMenuControllerDidShowMenuNotification @"UIMenuControllerDidShowMenuNotification" +#define UIScreenBrightnessDidChangeNotification @"UIScreenBrightnessDidChangeNotification" +#define UITableViewSelectionDidChangeNotification @"UITableViewSelectionDidChangeNotification" +#define UITextFieldTextDidBeginEditingNotification @"UITextFieldTextDidBeginEditingNotification" +#define UITextFieldTextDidEndEditingNotification @"UITextFieldTextDidEndEditingNotification" +#define UITextViewTextDidBeginEditingNotification @"UITextViewTextDidBeginEditingNotification" +#define UITextViewTextDidEndEditingNotification @"UITextViewTextDidEndEditingNotification" +#define UIWindowDidBecomeHiddenNotification @"UIWindowDidBecomeHiddenNotification" +#define UIWindowDidBecomeKeyNotification @"UIWindowDidBecomeKeyNotification" +#define UIWindowDidBecomeVisibleNotification @"UIWindowDidBecomeVisibleNotification" +#define UIWindowDidResignKeyNotification @"UIWindowDidResignKeyNotification" diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.h index 9901e59cca..bfa014f138 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.h @@ -101,9 +101,6 @@ extern NSString *const BSGKeyUser; extern NSString *const BSGKeyUuid; extern NSString *const BSGKeyVersion; extern NSString *const BSGKeyWarning; -extern NSString *const BSGHeaderApiKey; -extern NSString *const BSGHeaderApiPayloadVersion; -extern NSString *const BSGHeaderApiSentAt; #define BSGKeyHwCputype "hw.cputype" #define BSGKeyHwCpusubtype "hw.cpusubtype" diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.m index 806c5c8746..36119c9f9c 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Helpers/BugsnagKeys.m @@ -97,6 +97,3 @@ NSString *const BSGKeyUuid = @"uuid"; NSString *const BSGKeyVersion = @"version"; NSString *const BSGKeyWarning = @"warning"; -NSString *const BSGHeaderApiKey = @"Bugsnag-Api-Key"; -NSString *const BSGHeaderApiPayloadVersion = @"Bugsnag-Payload-Version"; -NSString *const BSGHeaderApiSentAt = @"Bugsnag-Sent-At"; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m index 9800783867..009802fc0d 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrash.m @@ -31,12 +31,11 @@ #import "BSG_KSCrashC.h" #import "BSG_KSJSONCodecObjC.h" -#import "BSG_KSSingleton.h" #import "NSError+BSG_SimpleConstructor.h" //#define BSG_KSLogger_LocalLevel TRACE #import "BSG_KSLogger.h" -#import "BugsnagThread.h" +#import "BugsnagThread+Private.h" #import "BSGJSONSerialization.h" #import "BSGSerialization.h" #import "Bugsnag.h" @@ -44,7 +43,7 @@ #import "BSG_KSCrashReportFields.h" #if BSG_HAS_UIKIT -#import +#import "BSGUIKit.h" #endif #if TARGET_OS_OSX #import @@ -74,13 +73,6 @@ #pragma mark - Globals - // ============================================================================ -@interface BugsnagThread () -+ (NSMutableArray *)threadsFromArray:(NSArray *)threads - binaryImages:(NSArray *)binaryImages - depth:(NSUInteger)depth - errorType:(NSString *)errorType; -@end - @interface BSG_KSCrash () @property(nonatomic, readwrite, retain) NSString *bundleName; @@ -126,7 +118,14 @@ @implementation BSG_KSCrash #pragma mark - Lifecycle - // ============================================================================ -IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(BSG_KSCrash) ++ (BSG_KSCrash *)sharedInstance { + static id sharedInstance; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + sharedInstance = [[self alloc] init]; + }); + return sharedInstance; +} - (instancetype)init { return [self diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m index 410f6ff212..c7cd921e33 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSCrashState.m @@ -36,7 +36,7 @@ #include "BSG_KSLogger.h" #if (TARGET_OS_TV || TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR) -#import +#import "BSGUIKit.h" #endif #include #include @@ -180,7 +180,9 @@ bool bsg_kscrashstate_i_loadState(BSG_KSCrash_State *const context, NSError *error = nil; NSData *data = [NSData dataWithContentsOfFile:[NSString stringWithUTF8String:path] options:0 error:&error]; if (error != nil) { - BSG_KSLOG_ERROR(@"%s: Could not load file: %@", path, error); + if (!(error.domain == NSCocoaErrorDomain && error.code == NSFileReadNoSuchFileError)) { + BSG_KSLOG_ERROR(@"%s: Could not load file: %@", path, error); + } return false; } id objectContext = [BSG_KSJSONCodec decode:data options:0 error:&error]; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h index 660009ffdc..f0e8ef10fb 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.h @@ -60,7 +60,7 @@ #import "BugsnagPlatformConditional.h" #if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS -#import +#import "BSGUIKit.h" #endif /** @@ -74,6 +74,12 @@ */ + (NSDictionary *)systemInfo; +/** Get this application's UUID. + * + * @return The UUID. + */ ++ (NSString *)appUUID; + /** * The build version of the OS */ @@ -99,6 +105,7 @@ * YES if the app is currently shown in the foreground */ + (BOOL)isInForeground:(UIApplicationState)state; + #endif @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m index af11e3e0ce..00b9cc8a66 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/BSG_KSSystemInfo.m @@ -42,7 +42,7 @@ #import #if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS -#import +#import "BSGUIKit.h" #endif @implementation BSG_KSSystemInfo @@ -176,10 +176,10 @@ + (NSString *)deviceAndAppHash { NSMutableData *data = nil; #if BSG_HAS_UIDEVICE - if ([[UIDevice currentDevice] + if ([[UIDEVICE currentDevice] respondsToSelector:@selector(identifierForVendor)]) { data = [NSMutableData dataWithLength:16]; - [[UIDevice currentDevice].identifierForVendor + [[UIDEVICE currentDevice].identifierForVendor getUUIDBytes:data.mutableBytes]; } else #endif @@ -354,8 +354,8 @@ + (NSDictionary *)systemInfo { BSGDictSetSafeObject(sysInfo, @__clang_version__, @BSG_KSSystemField_ClangVersion); #endif #if BSG_HAS_UIDEVICE - BSGDictSetSafeObject(sysInfo, [UIDevice currentDevice].systemName, @BSG_KSSystemField_SystemName); - BSGDictSetSafeObject(sysInfo, [UIDevice currentDevice].systemVersion, @BSG_KSSystemField_SystemVersion); + BSGDictSetSafeObject(sysInfo, [UIDEVICE currentDevice].systemName, @BSG_KSSystemField_SystemName); + BSGDictSetSafeObject(sysInfo, [UIDEVICE currentDevice].systemVersion, @BSG_KSSystemField_SystemVersion); #else BSGDictSetSafeObject(sysInfo, @"Mac OS", @BSG_KSSystemField_SystemName); NSOperatingSystemVersion version = @@ -458,7 +458,7 @@ + (UIApplicationState)currentAppState { // Calling this API indirectly to avoid a compile-time check that // [UIApplication sharedApplication] is not called from app extensions // (which is handled above) - UIApplication *app = [UIApplication performSelector:@selector(sharedApplication)]; + UIApplication *app = [UIAPPLICATION performSelector:@selector(sharedApplication)]; return [app applicationState]; }; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSSingleton.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSSingleton.h deleted file mode 100644 index 197a4dbcae..0000000000 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/KSCrash/Source/KSCrash/Recording/Tools/BSG_KSSingleton.h +++ /dev/null @@ -1,71 +0,0 @@ -// -// KSSingleton.h -// -// Created by Karl Stenerud on 2013-02-10. -// -// Copyright (c) 2012 Karl Stenerud. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall remain in place -// in this source code. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// - -#ifndef HDR_BSG_KSSingleton_h -#define HDR_BSG_KSSingleton_h - -/** Create a "sharedInstance" method with the specified type. - * - * @param TYPE The type to return from "sharedInstance". - */ -#define IMPLEMENT_SHARED_INSTANCE(TYPE) \ - +(TYPE *)sharedInstance { \ - static id sharedInstance = nil; \ - static dispatch_once_t onceToken; \ - dispatch_once(&onceToken, ^{ \ - sharedInstance = [[self alloc] init]; \ - }); \ - return sharedInstance; \ - } - -/** Create an exclusive "sharedInstance" method with the specified type. - * This will also implement "allocWithZone:" and actively prohibit multiple - * instances from existing. - * - * Note: This won't stop someone from manually creating an instance BEFORE - * sharedInstance is called, but if that does happen, you'll still see a failed - * alloc. - * - * @param TYPE The type to return from "sharedInstance". - */ -#define IMPLEMENT_EXCLUSIVE_SHARED_INSTANCE(TYPE) \ - IMPLEMENT_SHARED_INSTANCE(TYPE) \ - \ - +(id)allocWithZone : (NSZone *)zone { \ - @synchronized(self) { \ - static id singleInstance = nil; \ - if (singleInstance != nil) { \ - NSLog(@"Error: Only one instance allowed. Use [%@ " \ - @"sharedInstance] to access it", \ - self); \ - return nil; \ - } \ - singleInstance = [super allocWithZone:zone]; \ - return singleInstance; \ - } \ - } - -#endif // HDR_KSSingleton_h diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m index a47b82d402..ef67113972 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagApp.m @@ -57,13 +57,10 @@ + (void)populateFields:(BugsnagApp *)app { NSDictionary *system = event[BSGKeySystem]; app.id = system[@"CFBundleIdentifier"]; - app.bundleVersion = [event valueForKeyPath:@"user.config.bundleVersion"] ?: - (config.bundleVersion ?: system[@"CFBundleVersion"]); + app.bundleVersion = config.bundleVersion ?: system[@"CFBundleVersion"]; app.dsymUuid = system[@"app_uuid"]; - // Preferentially take App version values from the event, the config and the system - app.version = [event valueForKeyPath:@"user.config.appVersion"] ?: - (config.appVersion ?: system[@"CFBundleShortVersionString"]); - app.releaseStage = [event valueForKeyPath:@"user.config.releaseStage"] ?: config.releaseStage; + app.version = config.appVersion ?: system[@"CFBundleShortVersionString"]; + app.releaseStage = config.releaseStage; app.codeBundleId = [event valueForKeyPath:@"user.state.app.codeBundleId"] ?: codeBundleId; app.type = config.appType; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState.m index bf6906c884..21a52d7478 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagAppWithState.m @@ -59,6 +59,7 @@ + (BugsnagAppWithState *)appWithOomData:(NSDictionary *)event { BugsnagAppWithState *app = [BugsnagAppWithState new]; app.id = event[@"id"]; + app.dsymUuid = event[BSGKeyMachoUUID]; app.releaseStage = event[@"releaseStage"]; app.version = event[@"version"]; app.bundleVersion = event[@"bundleVersion"]; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m index 7ff0cc916e..226a6e6416 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagDeviceWithState.m @@ -15,7 +15,7 @@ #import "BugsnagSystemState.h" #import "Bugsnag.h" -NSDictionary *BSGParseDeviceMetadata(NSDictionary *event) { +NSMutableDictionary *BSGParseDeviceMetadata(NSDictionary *event) { NSMutableDictionary *device = [NSMutableDictionary new]; NSDictionary *state = [event valueForKeyPath:@"user.state.deviceState"]; [device addEntriesFromDictionary:state]; @@ -95,9 +95,13 @@ + (BugsnagDeviceWithState *)deviceWithOomData:(NSDictionary *)data { device.id = data[@"id"]; device.osVersion = data[@"osVersion"]; device.osName = data[@"osName"]; + device.manufacturer = @"Apple"; device.model = data[@"model"]; device.modelNumber = data[@"modelNumber"]; + device.orientation = data[@"orientation"]; device.locale = data[@"locale"]; + device.runtimeVersions = data[@"runtimeVersions"]; + device.totalMemory = data[@"totalMemory"]; return device; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h new file mode 100644 index 0000000000..c358f46430 --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError+Private.h @@ -0,0 +1,34 @@ +// +// BugsnagError+Private.h +// Bugsnag +// +// Created by Nick Dowell on 23/11/2020. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@class BugsnagThread; + +@interface BugsnagError () + +- (instancetype)initWithEvent:(NSDictionary *)event errorReportingThread:(nullable BugsnagThread *)thread; + +- (instancetype)initWithErrorClass:(NSString *)errorClass + errorMessage:(NSString *)errorMessage + errorType:(BSGErrorType)errorType + stacktrace:(nullable NSArray *)stacktrace; + ++ (BugsnagError *)errorFromJson:(NSDictionary *)json; + +- (NSDictionary *)toDictionary; + +@end + +BSGErrorType BSGParseErrorType(NSString *errorType); + +NSString *BSGSerializeErrorType(BSGErrorType errorType); + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m index ba6a536da7..9a8fc7ddde 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagError.m @@ -7,8 +7,9 @@ // #import "BugsnagError.h" + #import "BugsnagKeys.h" -#import "BugsnagStackframe.h" +#import "BugsnagStackframe+Private.h" #import "BugsnagStacktrace.h" #import "BugsnagCollections.h" #import "RegisterErrorData.h" @@ -71,11 +72,6 @@ BSGErrorType BSGParseErrorType(NSString *errorType) { return error[BSGKeyReason] ?: @""; } -@interface BugsnagStackframe () -- (NSDictionary *)toDictionary; -+ (BugsnagStackframe *)frameFromJson:(NSDictionary *)json; -@end - @interface BugsnagStacktrace () @property NSMutableArray *trace; @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h new file mode 100644 index 0000000000..09642ab110 --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent+Private.h @@ -0,0 +1,73 @@ +// +// BugsnagEvent+Private.h +// Bugsnag +// +// Created by Nick Dowell on 23/11/2020. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface BugsnagEvent () + +@property (copy, nonatomic) NSString *codeBundleId; + +/// User-provided exception metadata. +@property (readwrite, copy, nullable, nonatomic) NSDictionary *customException; + +/// Number of frames to discard at the top of the generated stacktrace. Stacktraces from raised exceptions are unaffected. +@property NSUInteger depth; + +/// A unique hash identifying this device for the application or vendor. +@property (readwrite, copy, nullable, nonatomic) NSString *deviceAppHash; + +/// The release stages used to notify at the time this report is captured. +@property (readwrite, copy, nullable) NSArray *enabledReleaseStages; + +/// Raw error data added to metadata. +@property (readwrite, copy, nullable) NSDictionary *error; + +/// The event state (whether the error is handled/unhandled.) +@property (readonly) BugsnagHandledState *handledState; + +@property (strong, nonatomic) BugsnagMetadata *metadata; + +/// Property overrides. +@property (readonly, copy) NSDictionary *overrides; + +@property NSSet *redactedKeys; + +/// The release stage of the application +@property (readwrite, copy, nullable) NSString *releaseStage; + +@property (strong, nullable, nonatomic) BugsnagSession *session; + +/// An array of string representations of BSGErrorType describing the types of stackframe / stacktrace in this error. +@property (readonly, nonatomic) NSArray *stacktraceTypes; + +- (instancetype)initWithApp:(nullable BugsnagAppWithState *)app + device:(nullable BugsnagDeviceWithState *)device + handledState:(BugsnagHandledState *)handledState + user:(nullable BugsnagUser *)user + metadata:(nullable BugsnagMetadata *)metadata + breadcrumbs:(NSArray *)breadcrumbs + errors:(NSArray *)errors + threads:(NSArray *)threads + session:(nullable BugsnagSession *)session; + +- (instancetype)initWithKSReport:(NSDictionary *)KSReport; + +- (instancetype)initWithUserData:(NSDictionary *)event; + +/// Whether this report should be sent, based on release stage information cached at crash time and within the application currently. +- (BOOL)shouldBeSent; + +- (void)setOverrideProperty:(NSString *)key value:(id)value; + +- (NSDictionary *)toJson; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m index fbbba4dfe2..2fdae7b70f 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagEvent.m @@ -9,33 +9,37 @@ #import "BugsnagPlatformConditional.h" #if BSG_PLATFORM_IOS -#import +#import "BSGUIKit.h" #include #endif #import + #import "BSGSerialization.h" +#import "BSG_KSCrashReportFields.h" +#import "BSG_RFC3339DateTool.h" #import "Bugsnag.h" #import "BugsnagBreadcrumbs.h" #import "BugsnagCollections.h" +#import "BugsnagConfiguration+Private.h" +#import "BugsnagError+Private.h" +#import "BugsnagEvent+Private.h" #import "BugsnagHandledState.h" -#import "BugsnagLogger.h" #import "BugsnagKeys.h" +#import "BugsnagLogger.h" #import "BugsnagSession.h" -#import "Private.h" -#import "BSG_RFC3339DateTool.h" -#import "BugsnagStacktrace.h" -#import "BugsnagThread.h" -#import "RegisterErrorData.h" #import "BugsnagSessionInternal.h" +#import "BugsnagStacktrace.h" +#import "BugsnagThread+Private.h" #import "BugsnagUser.h" -#import "BSG_KSCrashReportFields.h" +#import "Private.h" +#import "RegisterErrorData.h" static NSString *const DEFAULT_EXCEPTION_TYPE = @"cocoa"; // MARK: - Accessing hidden methods/properties -NSDictionary *_Nonnull BSGParseDeviceMetadata(NSDictionary *_Nonnull event); +NSMutableDictionary *_Nonnull BSGParseDeviceMetadata(NSDictionary *_Nonnull event); NSDictionary *_Nonnull BSGParseAppMetadata(NSDictionary *_Nonnull event); @interface BugsnagAppWithState () @@ -81,57 +85,14 @@ - (NSDictionary *)toDictionary; - (instancetype)deepCopy; @end -@interface BugsnagStackframe () -+ (BugsnagStackframe *)frameFromDict:(NSDictionary *)dict - withImages:(NSArray *)binaryImages; -@end - -@interface BugsnagStackframe () -+ (BugsnagStackframe *)frameFromDict:(NSDictionary *)dict - withImages:(NSArray *)binaryImages; -+ (BugsnagStackframe *)frameFromJson:(NSDictionary *)json; -@end - -@interface BugsnagThread () -@property BugsnagStacktrace *trace; -- (NSDictionary *)toDictionary; - -- (instancetype)initWithThread:(NSDictionary *)thread - binaryImages:(NSArray *)binaryImages; - -+ (NSMutableArray *)threadsFromArray:(NSArray *)threads - binaryImages:(NSArray *)binaryImages - depth:(NSUInteger)depth - errorType:(NSString *)errorType; - -+ (NSMutableArray *)serializeThreads:(NSArray *)threads; -@end - @interface BugsnagStacktrace () - (NSArray *)toArray; @end -@interface BugsnagThread () -- (instancetype)initWithThread:(NSDictionary *)thread - binaryImages:(NSArray *)binaryImages; - -+ (NSMutableArray *)threadsFromArray:(NSArray *)threads - binaryImages:(NSArray *)binaryImages - depth:(NSUInteger)depth - errorType:(NSString *)errorType; -+ (instancetype)threadFromJson:(NSDictionary *)json; -@end - @interface BugsnagStacktrace () - (NSArray *)toArray; @end -@interface BugsnagError () -- (NSDictionary *)toDictionary; -- (instancetype)initWithEvent:(NSDictionary *)event errorReportingThread:(BugsnagThread *)thread; -+ (BugsnagError *)errorFromJson:(NSDictionary *)json; -@end - // MARK: - KSCrashReport parsing NSString *_Nonnull BSGParseErrorClass(NSDictionary *error, NSString *errorType); NSString *BSGParseErrorMessage(NSDictionary *report, NSDictionary *error, NSString *errorType); @@ -244,66 +205,6 @@ - (instancetype)initWithDictionary:(NSDictionary *)dict; - (instancetype)initWithUserId:(NSString *)userId name:(NSString *)name emailAddress:(NSString *)emailAddress; @end -@interface BugsnagEvent () - -/** - * A unique hash identifying this device for the application or vendor - */ -@property(nonatomic, readwrite, copy, nullable) NSString *deviceAppHash; -/** - * User-provided exception metadata - */ -@property(nonatomic, readwrite, copy, nullable) NSDictionary *customException; -@property(nonatomic, strong) BugsnagSession *session; - -/** - * The event state (whether the error is handled/unhandled) - */ -@property(readonly, nonnull) BugsnagHandledState *handledState; - -- (NSDictionary *_Nonnull)toJson; - -/** - * Whether this report should be sent, based on release stage information - * cached at crash time and within the application currently - * - * @return YES if the report should be sent - */ -- (BOOL)shouldBeSent; - -/** - * The release stages used to notify at the time this report is captured - */ -@property(readwrite, copy, nullable) NSArray *enabledReleaseStages; - -/** - * Property overrides - */ -@property(readonly, copy, nonnull) NSDictionary *overrides; - -/** - * Number of frames to discard at the top of the generated stacktrace. - * Stacktraces from raised exceptions are unaffected. - */ -@property(readwrite) NSUInteger depth; - -@property (nonatomic, strong) BugsnagMetadata *metadata; - -/** - * Raw error data added to metadata - */ -@property(readwrite, copy, nullable) NSDictionary *error; - -/** - * The release stage of the application - */ -@property(readwrite, copy, nullable) NSString *releaseStage; - -@property NSSet *redactedKeys; - -@property(nonatomic) NSString *codeBundleId; -@end - @implementation BugsnagEvent /** @@ -383,7 +284,6 @@ - (instancetype)initWithKSReport:(NSDictionary *)event { * @return a BugsnagEvent containing the parsed information */ - (instancetype)initWithOOMData:(NSDictionary *)event { - // no threads or metadata captured for OOMs NSDictionary *sessionData = [event valueForKeyPath:@"user.state.oom.session"]; BugsnagSession *session; BugsnagUser *user; @@ -394,13 +294,26 @@ - (instancetype)initWithOOMData:(NSDictionary *)event { user = session.user; } } - BugsnagMetadata *metadata = [BugsnagMetadata new]; + + NSDictionary *metaData = [event valueForKeyPath:@"user.metaData"]; + if (!metaData) { + bsg_log_err(@"user.metaData was missing from the OOM KSCrashReport"); + } + BugsnagMetadata *metadata = [[BugsnagMetadata alloc] initWithDictionary:metaData ?: @{}]; // Cocoa-specific, non-spec., device and app data [metadata addMetadata:BSGParseDeviceMetadata(event) toSection:BSGKeyDevice]; [metadata addMetadata:BSGParseAppMetadata(event) toSection:BSGKeyApp]; - BugsnagEvent *obj = [self initWithApp:[BugsnagAppWithState appWithOomData:[event valueForKeyPath:@"user.state.oom.app"]] - device:[BugsnagDeviceWithState deviceWithOomData:[event valueForKeyPath:@"user.state.oom.device"]] + BugsnagAppWithState *app = [BugsnagAppWithState appWithOomData:[event valueForKeyPath:@"user.state.oom.app"]]; + BugsnagDeviceWithState *device = [BugsnagDeviceWithState deviceWithOomData:[event valueForKeyPath:@"user.state.oom.device"]]; + + if (!user) { + NSString *deviceAppHash = [event valueForKeyPath:@"system.device_app_hash"]; + user = [self parseUser:event deviceAppHash:deviceAppHash deviceId:device.id]; + } + + BugsnagEvent *obj = [self initWithApp:app + device:device handledState:[BugsnagHandledState handledStateWithSeverityReason:LikelyOutOfMemory] user:user metadata:metadata @@ -423,7 +336,6 @@ - (instancetype)initWithOOMData:(NSDictionary *)event { * @return a BugsnagEvent containing the parsed information */ - (instancetype)initWithKSCrashData:(NSDictionary *)event { - BugsnagConfiguration *config = [Bugsnag configuration]; NSDictionary *error = [event valueForKeyPath:@"crash.error"]; NSString *errorType = error[BSGKeyType]; @@ -492,7 +404,12 @@ - (instancetype)initWithKSCrashData:(NSDictionary *)event { NSString *deviceAppHash = [event valueForKeyPath:@"system.device_app_hash"]; BugsnagDeviceWithState *device = [BugsnagDeviceWithState deviceWithDictionary:event]; BugsnagUser *user = [self parseUser:event deviceAppHash:deviceAppHash deviceId:device.id]; - BugsnagEvent *obj = [self initWithApp:[BugsnagAppWithState appWithDictionary:event config:config codeBundleId:self.codeBundleId] + BugsnagConfiguration *config = [[BugsnagConfiguration alloc] initWithMetadata:[event valueForKeyPath:@"user.config"]]; + BugsnagAppWithState *app = [BugsnagAppWithState appWithDictionary:event config:config codeBundleId:self.codeBundleId]; + if (!app.type) { // Configuration.type does not get stored in the crash report at the time of writing. + app.type = [Bugsnag configuration].appType; + } + BugsnagEvent *obj = [self initWithApp:app device:device handledState:handledState user:user @@ -907,4 +824,37 @@ - (void)updateUnhandled:(BOOL)val { self.handledState.unhandled = val; } +#pragma mark - + +- (NSArray *)stacktraceTypes { + NSMutableSet *stacktraceTypes = [NSMutableSet set]; + + // The error in self.errors is not always the error that will be sent; this is the case when used in React Native. + // Using [self toJson] to ensure this uses the same logic of reading from self.customException instead. + NSDictionary *json = [self toJson]; + NSArray *exceptions = json[BSGKeyExceptions]; + for (NSDictionary *exception in exceptions) { + BugsnagError *error = [BugsnagError errorFromJson:exception]; + + [stacktraceTypes addObject:BSGSerializeErrorType(error.type)]; + + for (BugsnagStackframe *stackframe in error.stacktrace) { + if (stackframe.type) { + [stacktraceTypes addObject:stackframe.type]; + } + } + } + + for (BugsnagThread *thread in self.threads) { + [stacktraceTypes addObject:BSGSerializeThreadType(thread.type)]; + for (BugsnagStackframe *stackframe in thread.stacktrace) { + if (stackframe.type) { + [stacktraceTypes addObject:stackframe.type]; + } + } + } + + return stacktraceTypes.allObjects; +} + @end diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m index 5300f336d3..abfc3961a7 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagNotifier.m @@ -23,7 +23,7 @@ - (instancetype)init { #else self.name = @"Bugsnag Objective-C"; #endif - self.version = @"6.2.5"; + self.version = @"6.3.0"; self.url = @"https://github.com/bugsnag/bugsnag-cocoa"; self.dependencies = [NSMutableArray new]; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.m index f0aab677ad..adb0cd438e 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagSessionTrackingPayload.m @@ -8,8 +8,7 @@ #import "BugsnagSessionTrackingPayload.h" #import "BugsnagCollections.h" -#import "BugsnagClient.h" -#import "BugsnagClientInternal.h" +#import "BugsnagClient+Private.h" #import "Bugsnag.h" #import "BugsnagKeys.h" #import "BugsnagNotifier.h" diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h new file mode 100644 index 0000000000..2f3becb2ca --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe+Private.h @@ -0,0 +1,26 @@ +// +// BugsnagStackframe+Private.h +// Bugsnag +// +// Created by Nick Dowell on 20/11/2020. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface BugsnagStackframe () + +/// Constructs a stackframe object from a stackframe dictionary and list of images captured by KSCrash. ++ (nullable instancetype)frameFromDict:(NSDictionary *)dict withImages:(NSArray *> *)binaryImages; + +/// Constructs a stackframe object from a JSON object (typically loaded from disk.) ++ (instancetype)frameFromJson:(NSDictionary *)json; + +/// Returns a JSON compatible representation of the stackframe. +- (NSDictionary *)toDictionary; + +@end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m index 87665a34e0..a248b01a8b 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStackframe.m @@ -6,7 +6,7 @@ // Copyright © 2020 Bugsnag. All rights reserved. // -#import "BugsnagStackframe.h" +#import "BugsnagStackframe+Private.h" #import "BSG_KSBacktrace.h" #import "BSG_KSDynamicLinker.h" @@ -14,6 +14,8 @@ #import "BugsnagKeys.h" #import "BugsnagLogger.h" +BugsnagStackframeType const BugsnagStackframeTypeCocoa = @"cocoa"; + @implementation BugsnagStackframe + (NSDictionary *_Nullable)findImageAddr:(unsigned long)addr inImages:(NSArray *)images { @@ -36,6 +38,7 @@ + (BugsnagStackframe *)frameFromJson:(NSDictionary *)json { frame.frameAddress = [self readInt:json key:BSGKeyFrameAddress]; frame.symbolAddress = [self readInt:json key:BSGKeySymbolAddr]; frame.machoLoadAddress = [self readInt:json key:BSGKeyMachoLoadAddr]; + frame.type = json[BSGKeyType]; return frame; } @@ -183,6 +186,7 @@ - (NSDictionary *)toDictionary { if (self.isLr) { BSGDictSetSafeObject(dict, @(self.isLr), BSGKeyIsLR); } + dict[BSGKeyType] = self.type; return dict; } diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStacktrace.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStacktrace.m index f13fc9ead9..106d4f5f05 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStacktrace.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagStacktrace.m @@ -7,15 +7,9 @@ // #import "BugsnagStacktrace.h" -#import "BugsnagStackframe.h" -#import "BugsnagKeys.h" -@interface BugsnagStackframe () -+ (BugsnagStackframe *)frameFromDict:(NSDictionary *)dict - withImages:(NSArray *)binaryImages; -- (NSDictionary *)toDictionary; -+ (instancetype)frameFromJson:(NSDictionary *)json; -@end +#import "BugsnagKeys.h" +#import "BugsnagStackframe+Private.h" @interface BugsnagStacktrace () @property NSMutableArray *trace; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h new file mode 100644 index 0000000000..1caf2459d2 --- /dev/null +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread+Private.h @@ -0,0 +1,40 @@ +// +// BugsnagThread+Private.h +// Bugsnag +// +// Created by Nick Dowell on 23/11/2020. +// Copyright © 2020 Bugsnag Inc. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface BugsnagThread () + +@property BugsnagStacktrace *trace; + +- (instancetype)initWithThread:(NSDictionary *)thread binaryImages:(NSArray *)binaryImages; + ++ (instancetype)threadFromJson:(NSDictionary *)json; + ++ (NSDictionary *)enhanceThreadInfo:(NSDictionary *)thread + depth:(NSUInteger)depth + errorType:(nullable NSString *)errorType; + ++ (NSMutableArray *)serializeThreads:(NSArray *)threads; + ++ (NSMutableArray *)threadsFromArray:(NSArray *)threads + binaryImages:(NSArray *)binaryImages + depth:(NSUInteger)depth + errorType:(nullable NSString *)errorType; + +- (NSDictionary *)toDictionary; + +@end + +BSGThreadType BSGParseThreadType(NSString *type); + +NSString *BSGSerializeThreadType(BSGThreadType type); + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m index 90e51e8fba..a9bf3da9b3 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Payload/BugsnagThread.m @@ -7,8 +7,9 @@ // #import "BugsnagThread.h" + #import "BugsnagCollections.h" -#import "BugsnagStackframe.h" +#import "BugsnagStackframe+Private.h" #import "BugsnagStacktrace.h" #import "BugsnagKeys.h" @@ -29,10 +30,6 @@ + (instancetype)stacktraceFromJson:(NSDictionary *)json; @property NSMutableArray *trace; @end -@interface BugsnagStackframe () -- (NSDictionary *)toDictionary; -@end - @implementation BugsnagThread + (instancetype)threadFromJson:(NSDictionary *)json { diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h index 012345506a..0f560223f4 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Private.h @@ -17,16 +17,6 @@ #pragma mark - -@interface BugsnagConfiguration () - -/// Throws an NSInvalidArgumentException if the API key is empty or missing. -/// Logs a warning message if the API key is not in the expected format. -- (void)validate; - -@end - -#pragma mark - - @interface BugsnagBreadcrumb () - (NSDictionary *_Nullable)objectValue; diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h index 9aefaba8d3..9224ba3dc0 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/include/Bugsnag/BugsnagStackframe.h @@ -8,6 +8,12 @@ #import +NS_ASSUME_NONNULL_BEGIN + +typedef NSString * BugsnagStackframeType NS_TYPED_ENUM; + +FOUNDATION_EXPORT BugsnagStackframeType const BugsnagStackframeTypeCocoa; + /** * Represents a single stackframe from a stacktrace. */ @@ -58,11 +64,18 @@ */ @property BOOL isLr; +/** + * The type of the stack frame, if it differs from that of the containing error or event. + */ +@property(nullable) BugsnagStackframeType type; + /** * Returns an array of stackframe objects representing the provided call stack strings. * * The call stack strings should follow the format used by `[NSThread callStackSymbols]` and `backtrace_symbols()`. */ -+ (NSArray *_Nullable)stackframesWithCallStackSymbols:(NSArray *_Nonnull)callStackSymbols; ++ (nullable NSArray *)stackframesWithCallStackSymbols:(NSArray *)callStackSymbols; @end + +NS_ASSUME_NONNULL_END diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md index ad764bb15c..acb1453f62 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/CHANGELOG.md @@ -1,6 +1,35 @@ Changelog ========= +## 6.3.0 (2020-12-02) + +### Enhancements + +* Out Of Memory errors now include more information, including custom metadata and user information. + [#915](https://github.com/bugsnag/bugsnag-cocoa/pull/915) + [#908](https://github.com/bugsnag/bugsnag-cocoa/pull/908) + +* Bugsnag can now be used without UIKit, reducing memory usage in app extensions. + [#919](https://github.com/bugsnag/bugsnag-cocoa/pull/919) + +### Bug fixes + +* Fixed incorrect app version reported when sending crash reports from older versions of Bugsnag (before 6.2.3) + [#911](https://github.com/bugsnag/bugsnag-cocoa/pull/911) + +* Fixed a rare crash in -[BugsnagClient computeDidCrashLastLaunch] + [#917](https://github.com/bugsnag/bugsnag-cocoa/pull/917) + +## 6.2.6 (2020-11-25) + +### Bug fixes + +* Error and session deliveries that fail with an HTTP error status code will now be retried if appropriate. + [#895](https://github.com/bugsnag/bugsnag-cocoa/pull/895) + +* Fixed a rare crash in BugsnagClient's network connectivity observer block. + [#904](https://github.com/bugsnag/bugsnag-cocoa/pull/904) + ## 6.2.5 (2020-11-18) ### Bug fixes diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist index 25d57e29c4..26fb6024e3 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/Framework/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 6.2.5 + 6.3.0 CFBundleVersion 1 diff --git a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION index a6534bb333..798e38995c 100644 --- a/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION +++ b/packages/react-native/ios/vendor/bugsnag-cocoa/VERSION @@ -1 +1 @@ -6.2.5 +6.3.0