Skip to content

Commit

Permalink
deps(react-native): Bump bugsnag-cocoa to v6.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdowell committed Dec 3, 2020
1 parent 11db017 commit 8523e5c
Show file tree
Hide file tree
Showing 46 changed files with 890 additions and 667 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion packages/react-native/ios/.bugsnag-cocoa-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
86de8c605e82e67433ad91fd777b2aba4854f536
2256dfe86c61e70c57e33325513c37d2951e3441
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -9,7 +9,7 @@
},
"source": {
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v6.2.5"
"tag": "v6.3.0"
},
"frameworks": [
"Foundation",
Expand Down

Large diffs are not rendered by default.

17 changes: 1 addition & 16 deletions packages/react-native/ios/vendor/bugsnag-cocoa/Bugsnag/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -45,13 +46,6 @@ @interface BugsnagNotifier ()
- (NSDictionary *)toDict;
@end

@interface BugsnagEvent ()
- (NSDictionary *_Nonnull)toJson;
- (BOOL)shouldBeSent;
- (instancetype _Nonnull)initWithKSReport:(NSDictionary *_Nonnull)report;
@property NSSet<NSString *> *redactedKeys;
@end

@interface BugsnagConfiguration ()
@property(nonatomic, readwrite, strong) NSMutableArray *onSendBlocks;
- (NSDictionary *_Nonnull)errorApiHeaders;
Expand Down Expand Up @@ -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];
}
Expand Down Expand Up @@ -123,7 +117,7 @@ - (void)sendStoredReports:(NSDictionary <NSString *, 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];
Expand All @@ -137,14 +131,13 @@ - (void)deliverStoredEvents:(NSMutableDictionary<NSString *, BugsnagEvent *> *)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];
}];
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)init NS_UNAVAILABLE;
- (instancetype)initWithConfiguration:(BugsnagConfiguration *)config;

- (void)recordAppUUID;

- (void)setCodeBundleID:(NSString*)codeBundleID;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#if TARGET_OS_OSX
#import <AppKit/AppKit.h>
#else
#import <UIKit/UIKit.h>
#import "BSGUIKit.h"
#endif

#import "BugsnagSystemState.h"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand All @@ -180,47 +185,55 @@ - (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);
}
[self sync];
});
}


- (void)sync {
NSDictionary *state = self.currentLaunchState;
NSError *error = nil;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
//
// BugsnagClient+Private.h
// Bugsnag
//
// Created by Nick Dowell on 26/11/2020.
// Copyright © 2020 Bugsnag Inc. All rights reserved.
//

#import <Bugsnag/BugsnagClient.h>

@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
Loading

0 comments on commit 8523e5c

Please sign in to comment.