Skip to content

Commit

Permalink
Merge branch 'v6' into v6-enabled-release-stages
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench authored Mar 30, 2020
2 parents 1d6de56 + 404e23d commit 797b129
Show file tree
Hide file tree
Showing 31 changed files with 723 additions and 145 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ Bugsnag Notifiers on other platforms.
* Rename `notifyReleaseStages` to `enabledReleaseStages`
[#509](https://github.com/bugsnag/bugsnag-cocoa/pull/509)

* Remove unused APIs from `BugsnagSession` interface
[#506](https://github.com/bugsnag/bugsnag-cocoa/pull/506)

* Rename setUser/user interface on `Bugsnag` and `BugsnagConfiguration`
[#505](https://github.com/bugsnag/bugsnag-cocoa/pull/505)

Expand All @@ -20,6 +23,9 @@ Bugsnag Notifiers on other platforms.
* Remove unused APIs on `BugsnagEvent` interface
[#498](https://github.com/bugsnag/bugsnag-cocoa/pull/498)

* Allow addition/removal of `OnBreadcrumb` callbacks
[#508](https://github.com/bugsnag/bugsnag-cocoa/pull/508)

* Remove unused APIs from `BugsnagMetadata` interface
[#501](https://github.com/bugsnag/bugsnag-cocoa/pull/501)

Expand Down Expand Up @@ -173,6 +179,10 @@ Bugsnag Notifiers on other platforms.
* Added `addOnSendBlock:`, `removeOnSendBlock:` and `clearOnSendBlocks` methods to `Bugsnag`
and `BugsnagConfiguration`.
(#485)[https://github.com/bugsnag/bugsnag-cocoa/pull/485]

* Enhanced device orientation change breadcrumbs. These are now reported with "from" and "to" values
in a form consistent with the Android notifier.
(#486)[https://github.com/bugsnag/bugsnag-cocoa/pull/486]

## Bug fixes

Expand All @@ -184,6 +194,9 @@ Bugsnag Notifiers on other platforms.
`locale`) that were missing from the OOM reports.
[#444](https://github.com/bugsnag/bugsnag-cocoa/pull/444)

* Increased the detail in handled event breadcrumbs
[#493](https://github.com/bugsnag/bugsnag-cocoa/pull/493)

## 5.23.0 (2019-12-10)

This release removes support for reporting 'partial' or 'minimal' crash reports
Expand Down
4 changes: 4 additions & 0 deletions OSX/Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
E79E6BDA1F4E3850002B35F9 /* BSG_RFC3339DateTool.m in Sources */ = {isa = PBXBuildFile; fileRef = E79E6B6E1F4E3850002B35F9 /* BSG_RFC3339DateTool.m */; };
E79E6BDB1F4E3850002B35F9 /* BSG_KSCrashReportFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = E79E6B711F4E3850002B35F9 /* BSG_KSCrashReportFilter.h */; };
E79E6BDC1F4E3850002B35F9 /* BSG_KSCrashReportFilterCompletion.h in Headers */ = {isa = PBXBuildFile; fileRef = E79E6B721F4E3850002B35F9 /* BSG_KSCrashReportFilterCompletion.h */; };
E7AB4B9E2423E184004F015A /* BugsnagOnBreadcrumbTest.m in Sources */ = {isa = PBXBuildFile; fileRef = E7AB4B9D2423E184004F015A /* BugsnagOnBreadcrumbTest.m */; };
E7CE78BB1FD94E77001D07E0 /* KSCrashReportConverter_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7CE78991FD94E60001D07E0 /* KSCrashReportConverter_Tests.m */; };
E7CE78BC1FD94E77001D07E0 /* KSCrashReportStore_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7CE78951FD94E5F001D07E0 /* KSCrashReportStore_Tests.m */; };
E7CE78BE1FD94E77001D07E0 /* KSCrashSentry_NSException_Tests.m in Sources */ = {isa = PBXBuildFile; fileRef = E7CE78911FD94E5F001D07E0 /* KSCrashSentry_NSException_Tests.m */; };
Expand Down Expand Up @@ -359,6 +360,7 @@
E79E6B6E1F4E3850002B35F9 /* BSG_RFC3339DateTool.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BSG_RFC3339DateTool.m; path = ../Source/KSCrash/Source/KSCrash/Recording/Tools/BSG_RFC3339DateTool.m; sourceTree = SOURCE_ROOT; };
E79E6B711F4E3850002B35F9 /* BSG_KSCrashReportFilter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_KSCrashReportFilter.h; path = ../Source/KSCrash/Source/KSCrash/Reporting/Filters/BSG_KSCrashReportFilter.h; sourceTree = SOURCE_ROOT; };
E79E6B721F4E3850002B35F9 /* BSG_KSCrashReportFilterCompletion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BSG_KSCrashReportFilterCompletion.h; path = ../Source/KSCrash/Source/KSCrash/Reporting/Filters/BSG_KSCrashReportFilterCompletion.h; sourceTree = SOURCE_ROOT; };
E7AB4B9D2423E184004F015A /* BugsnagOnBreadcrumbTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagOnBreadcrumbTest.m; sourceTree = "<group>"; };
E7CE78871FD94E5F001D07E0 /* KSMach_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSMach_Tests.m; sourceTree = "<group>"; };
E7CE78881FD94E5F001D07E0 /* NSError+SimpleConstructor_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSError+SimpleConstructor_Tests.m"; sourceTree = "<group>"; };
E7CE78891FD94E5F001D07E0 /* KSFileUtils_Tests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KSFileUtils_Tests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -503,6 +505,7 @@
8A2C8FAF1C6BC1F700846019 /* Tests */ = {
isa = PBXGroup;
children = (
E7AB4B9D2423E184004F015A /* BugsnagOnBreadcrumbTest.m */,
00F9393B23FD2D9B008C7073 /* BugsnagTestsDummyClass.h */,
00F9393A23FD2D9B008C7073 /* BugsnagTestsDummyClass.m */,
00F9393123FC168F008C7073 /* BugsnagBaseUnitTest.h */,
Expand Down Expand Up @@ -999,6 +1002,7 @@
E762E9F91F73F7F300E82B43 /* BugsnagHandledStateTest.m in Sources */,
E7CE78C51FD94E77001D07E0 /* KSLogger_Tests.m in Sources */,
E7CE78C11FD94E77001D07E0 /* KSCrashState_Tests.m in Sources */,
E7AB4B9E2423E184004F015A /* BugsnagOnBreadcrumbTest.m in Sources */,
E7CE78C31FD94E77001D07E0 /* KSFileUtils_Tests.m in Sources */,
E7CE78BC1FD94E77001D07E0 /* KSCrashReportStore_Tests.m in Sources */,
E79148611FD82BB7003EFEBF /* BugsnagSessionTrackerTest.m in Sources */,
Expand Down
19 changes: 19 additions & 0 deletions Source/Bugsnag.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,4 +338,23 @@ static NSString *_Nonnull const BugsnagSeverityInfo = @"info";
*/
+ (void)removeOnSendBlock:(BugsnagOnSendBlock _Nonnull)block;

// =============================================================================
// MARK: - onBreadcrumb
// =============================================================================

/**
* Add a callback to be invoked when a breadcrumb is captured by Bugsnag, to
* change the breadcrumb contents as needed
*
* @param block A block which returns YES if the breadcrumb should be captured
*/
+ (void)addOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block;

/**
* Remove the callback that would be invoked when a breadcrumb is captured.
*
* @param block The block to be removed.
*/
+ (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block;

@end
13 changes: 13 additions & 0 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,19 @@ + (void)removeOnSendBlock:(BugsnagOnSendBlock _Nonnull)block
[[self configuration] removeOnSendBlock:block];
}

// =============================================================================
// MARK: - OnBreadcrumb
// =============================================================================

+ (void)addOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block {
[[self configuration] addOnBreadcrumbBlock:block];
}


+ (void)removeOnBreadcrumbBlock:(BugsnagOnBreadcrumbBlock _Nonnull)block {
[[self configuration] removeOnBreadcrumbBlock:block];
}

@end

//
Expand Down
10 changes: 6 additions & 4 deletions Source/BugsnagBreadcrumb.m
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,12 @@ - (NSDictionary *)objectValue {
metadata[[key copy]] = [_metadata[key] copy];
}
return @{
BSGKeyMessage : [_message copy],
BSGKeyTimestamp : timestamp,
BSGKeyType : BSGBreadcrumbTypeValue(_type),
BSGKeyMetadata : metadata
// Note: The Bugsnag Error Reporting API specifies that the breadcrumb "message"
// field should be delivered in as a "name" field. This comment notes that variance.
BSGKeyName : [_message copy],
BSGKeyTimestamp : timestamp,
BSGKeyType : BSGBreadcrumbTypeValue(_type),
BSGKeyMetadata : metadata
};
}
return nil;
Expand Down
21 changes: 20 additions & 1 deletion Source/BugsnagBreadcrumbs.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#import "BugsnagLogger.h"
#import "Private.h"

@interface BugsnagConfiguration ()
@property(nonatomic) NSMutableArray *onBreadcrumbBlocks;
@end

@interface BugsnagBreadcrumb ()
+ (instancetype _Nullable)breadcrumbWithBlock:
(BSGBreadcrumbConfiguration _Nonnull)block;
Expand Down Expand Up @@ -58,7 +62,8 @@ - (void)addBreadcrumbWithBlock:
return;
}
BugsnagBreadcrumb *crumb = [BugsnagBreadcrumb breadcrumbWithBlock:block];
if (crumb) {

if (crumb != nil && [self shouldSendBreadcrumb:crumb]) {
[self resizeToFitCapacity:self.capacity - 1];
dispatch_barrier_sync(self.readWriteQueue, ^{
[self.breadcrumbs addObject:crumb];
Expand All @@ -82,6 +87,20 @@ - (void)addBreadcrumbWithBlock:
}
}

- (BOOL)shouldSendBreadcrumb:(BugsnagBreadcrumb *)crumb {
BugsnagConfiguration *configuration = [Bugsnag configuration];
for (BugsnagOnBreadcrumbBlock block in configuration.onBreadcrumbBlocks) {
@try {
if (!block(crumb)) {
return NO;
}
} @catch (NSException *exception) {
bsg_log_err(@"Error from onBreadcrumb callback: %@", exception);
}
}
return YES;
}

- (NSArray *)cachedBreadcrumbs {
__block NSArray *cache = nil;
dispatch_barrier_sync(self.readWriteQueue, ^{
Expand Down
Loading

0 comments on commit 797b129

Please sign in to comment.