Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: rename BugsnagCrashReport to BugsnagEvent #449

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Changelog
* Add a breadcrumb when Bugsnag first starts with the message "Bugsnag loaded"
[#445](https://github.com/bugsnag/bugsnag-cocoa/pull/445)

* BugsnagCrashReport is now BugsnagEvent
[#449](https://github.com/bugsnag/bugsnag-cocoa/pull/449)

## Bug fixes

* Fix possible report corruption when using `notify()` from multiple threads
Expand Down
12 changes: 6 additions & 6 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ + (BOOL)appDidCrashLastLaunch {
+ (void)notify:(NSException *)exception {
if ([self bugsnagStarted]) {
[self.notifier notifyException:exception
block:^(BugsnagCrashReport *_Nonnull report) {
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
}];
}
Expand All @@ -114,7 +114,7 @@ + (void)notify:(NSException *)exception {
+ (void)notify:(NSException *)exception block:(BugsnagNotifyBlock)block {
if ([self bugsnagStarted]) {
[[self notifier] notifyException:exception
block:^(BugsnagCrashReport *_Nonnull report) {
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;

if (block) {
Expand All @@ -127,7 +127,7 @@ + (void)notify:(NSException *)exception block:(BugsnagNotifyBlock)block {
+ (void)notifyError:(NSError *)error {
if ([self bugsnagStarted]) {
[self.notifier notifyError:error
block:^(BugsnagCrashReport *_Nonnull report) {
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
}];
}
Expand All @@ -136,7 +136,7 @@ + (void)notifyError:(NSError *)error {
+ (void)notifyError:(NSError *)error block:(BugsnagNotifyBlock)block {
if ([self bugsnagStarted]) {
[[self notifier] notifyError:error
block:^(BugsnagCrashReport *_Nonnull report) {
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;

if (block) {
Expand All @@ -150,7 +150,7 @@ + (void)notify:(NSException *)exception withData:(NSDictionary *)metaData {
if ([self bugsnagStarted]) {
[[self notifier]
notifyException:exception
block:^(BugsnagCrashReport *_Nonnull report) {
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
report.metaData = [metaData
BSG_mergedInto:[self.notifier.configuration
Expand All @@ -166,7 +166,7 @@ + (void)notify:(NSException *)exception
[[self notifier]
notifyException:exception
atSeverity:BSGParseSeverity(severity)
block:^(BugsnagCrashReport *_Nonnull report) {
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
report.metaData = [metaData
BSG_mergedInto:[self.notifier.configuration
Expand Down
6 changes: 3 additions & 3 deletions Source/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

#import "BSG_KSCrashReportWriter.h"
#import "BugsnagBreadcrumb.h"
#import "BugsnagCrashReport.h"
#import "BugsnagEvent.h"
#import "BugsnagMetaData.h"

@class BugsnagBreadcrumbs;
Expand All @@ -39,7 +39,7 @@
*
* @param report The default report
*/
typedef void (^BugsnagNotifyBlock)(BugsnagCrashReport *_Nonnull report);
typedef void (^BugsnagNotifyBlock)(BugsnagEvent *_Nonnull report);

/**
* A handler for modifying data before sending it to Bugsnag.
Expand All @@ -54,7 +54,7 @@ typedef void (^BugsnagNotifyBlock)(BugsnagCrashReport *_Nonnull report);
* @return YES if the report should be sent
*/
typedef bool (^BugsnagBeforeSendBlock)(NSDictionary *_Nonnull rawEventData,
BugsnagCrashReport *_Nonnull reports);
BugsnagEvent *_Nonnull reports);

/**
* A configuration block for modifying a session. Intended for internal usage only.
Expand Down
2 changes: 1 addition & 1 deletion Source/BugsnagErrorReportApiClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#import <Foundation/Foundation.h>

#import "BSG_KSCrashReportFilterCompletion.h"
#import "BugsnagCrashReport.h"
#import "BugsnagEvent.h"
#import "BugsnagConfiguration.h"
#import "BugsnagApiClient.h"

Expand Down
4 changes: 2 additions & 2 deletions Source/BugsnagCrashReport.h → Source/BugsnagEvent.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BugsnagCrashReport.h
// BugsnagEvent.h
// Bugsnag
//
// Created by Simon Maynard on 11/26/14.
Expand Down Expand Up @@ -37,7 +37,7 @@ BSGSeverity BSGParseSeverity(NSString *_Nonnull severity);
*/
NSString *_Nonnull BSGFormatSeverity(BSGSeverity severity);

@interface BugsnagCrashReport : NSObject
@interface BugsnagEvent : NSObject

/**
* Create a new crash report from a JSON crash report generated by
Expand Down
6 changes: 3 additions & 3 deletions Source/BugsnagCrashReport.m → Source/BugsnagEvent.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BugsnagCrashReport.m
// BugsnagEvent.m
// Bugsnag
//
// Created by Simon Maynard on 11/26/14.
Expand Down Expand Up @@ -191,7 +191,7 @@ + (instancetype)errorDataFromThreads:(NSArray *)threads;
- (instancetype)initWithClass:(NSString *_Nonnull)errorClass message:(NSString *_Nonnull)errorMessage NS_DESIGNATED_INITIALIZER;
@end

@interface BugsnagCrashReport ()
@interface BugsnagEvent ()

/**
* The type of the error, such as `mach` or `user`
Expand Down Expand Up @@ -222,7 +222,7 @@ @interface BugsnagCrashReport ()
@property (nonatomic, readwrite, getter=isIncomplete) BOOL incomplete;
@end

@implementation BugsnagCrashReport
@implementation BugsnagEvent

- (instancetype)initWithKSReport:(NSDictionary *)report
fileMetadata:(NSString *)metadata {
Expand Down
2 changes: 1 addition & 1 deletion Source/BugsnagHandledState.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Bugsnag. All rights reserved.
//

#import "BugsnagCrashReport.h"
#import "BugsnagEvent.h"
#import <Foundation/Foundation.h>

typedef NS_ENUM(NSUInteger, SeverityReasonType) {
Expand Down
12 changes: 6 additions & 6 deletions Source/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ - (void)setupConnectivityListener {


- (void)notifyError:(NSError *)error
block:(void (^)(BugsnagCrashReport *))block {
block:(void (^)(BugsnagEvent *))block {
BugsnagHandledState *state =
[BugsnagHandledState handledStateWithSeverityReason:HandledError
severity:BSGSeverityWarning
Expand All @@ -542,7 +542,7 @@ - (void)notifyError:(NSError *)error
userInfo:error.userInfo];
[self notify:wrapper
handledState:state
block:^(BugsnagCrashReport *_Nonnull report) {
block:^(BugsnagEvent *_Nonnull report) {
NSMutableDictionary *metadata = [report.metaData mutableCopy];
metadata[@"nserror"] = @{
@"code" : @(error.code),
Expand All @@ -562,7 +562,7 @@ - (void)notifyError:(NSError *)error

- (void)notifyException:(NSException *)exception
atSeverity:(BSGSeverity)severity
block:(void (^)(BugsnagCrashReport *))block {
block:(void (^)(BugsnagEvent *))block {

BugsnagHandledState *state = [BugsnagHandledState
handledStateWithSeverityReason:UserSpecifiedSeverity
Expand All @@ -572,7 +572,7 @@ - (void)notifyException:(NSException *)exception
}

- (void)notifyException:(NSException *)exception
block:(void (^)(BugsnagCrashReport *))block {
block:(void (^)(BugsnagEvent *))block {
BugsnagHandledState *state =
[BugsnagHandledState handledStateWithSeverityReason:HandledException];
[self notify:exception handledState:state block:block];
Expand Down Expand Up @@ -640,7 +640,7 @@ - (void)notifyOutOfMemoryEvent {

- (void)notify:(NSException *)exception
handledState:(BugsnagHandledState *_Nonnull)handledState
block:(void (^)(BugsnagCrashReport *))block {
block:(void (^)(BugsnagEvent *))block {
NSString *exceptionName = exception.name ?: NSStringFromClass([exception class]);
NSString *message = exception.reason;
if (handledState.unhandled) {
Expand All @@ -649,7 +649,7 @@ - (void)notify:(NSException *)exception
[self.sessionTracker handleHandledErrorEvent];
}

BugsnagCrashReport *report = [[BugsnagCrashReport alloc]
BugsnagEvent *report = [[BugsnagEvent alloc]
initWithErrorName:exceptionName
errorMessage:message
configuration:self.configuration
Expand Down
4 changes: 2 additions & 2 deletions Source/BugsnagSink.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (void)filterReports:(NSDictionary <NSString *, NSDictionary *> *)reports

for (NSString *fileKey in reports) {
NSDictionary *report = reports[fileKey];
BugsnagCrashReport *bugsnagReport = [[BugsnagCrashReport alloc] initWithKSReport:report];
BugsnagEvent *bugsnagReport = [[BugsnagEvent alloc] initWithKSReport:report];
if (![bugsnagReport shouldBeSent])
continue;
BOOL shouldSend = YES;
Expand Down Expand Up @@ -127,7 +127,7 @@ - (NSDictionary *)getBodyFromReports:(NSArray *)reports {
NSMutableArray *formatted =
[[NSMutableArray alloc] initWithCapacity:[reports count]];

for (BugsnagCrashReport *report in reports) {
for (BugsnagEvent *report in reports) {
BSGArrayAddSafeObject(formatted, [report toJson]);
}

Expand Down
Loading