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

Robin/rename bugsnag notifier class to bugsnag client #480

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 @@ Bugsnag Notifiers on other platforms.

## Enhancements

* `BugsnagNotifier` is now `BugsnagClient`.
[#480](https://github.com/bugsnag/bugsnag-cocoa/pull/480)

* Add a breadcrumb when Bugsnag first starts with the message "Bugsnag loaded"
[#445](https://github.com/bugsnag/bugsnag-cocoa/pull/445)

Expand Down
16 changes: 8 additions & 8 deletions OSX/Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
0061D83A2405B23A0041C068 /* BSG_SSKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = 0061D8372405B23A0041C068 /* BSG_SSKeychain.m */; };
0061D83B2405B23A0041C068 /* LICENSE in Resources */ = {isa = PBXBuildFile; fileRef = 0061D8382405B23A0041C068 /* LICENSE */; };
0061D83C2405B23A0041C068 /* BSG_SSKeychain.h in Headers */ = {isa = PBXBuildFile; fileRef = 0061D8392405B23A0041C068 /* BSG_SSKeychain.h */; };
0089B6EB2411682000D5A7F2 /* BugsnagClient.m in Sources */ = {isa = PBXBuildFile; fileRef = 0089B6E92411682000D5A7F2 /* BugsnagClient.m */; };
0089B6EC2411682000D5A7F2 /* BugsnagClient.h in Headers */ = {isa = PBXBuildFile; fileRef = 0089B6EA2411682000D5A7F2 /* BugsnagClient.h */; };
00D7AC9C23E97F8100FBE4A7 /* BugsnagEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 00D7AC9A23E97F8100FBE4A7 /* BugsnagEvent.m */; };
00D7AC9D23E97F8100FBE4A7 /* BugsnagEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 00D7AC9B23E97F8100FBE4A7 /* BugsnagEvent.h */; settings = {ATTRIBUTES = (Public, ); }; };
00D7ACA423E9854C00FBE4A7 /* BugsnagEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00D7ACA223E984B300FBE4A7 /* BugsnagEventTests.m */; };
Expand All @@ -30,8 +32,6 @@
8A2C8FD41C6BC2C800846019 /* BugsnagConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C8FC21C6BC2C800846019 /* BugsnagConfiguration.m */; };
8A2C8FD71C6BC2C800846019 /* BugsnagMetadata.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A2C8FC51C6BC2C800846019 /* BugsnagMetadata.h */; settings = {ATTRIBUTES = (Public, ); }; };
8A2C8FD81C6BC2C800846019 /* BugsnagMetadata.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C8FC61C6BC2C800846019 /* BugsnagMetadata.m */; };
8A2C8FD91C6BC2C800846019 /* BugsnagNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A2C8FC71C6BC2C800846019 /* BugsnagNotifier.h */; };
8A2C8FDA1C6BC2C800846019 /* BugsnagNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C8FC81C6BC2C800846019 /* BugsnagNotifier.m */; };
8A2C8FDD1C6BC2C800846019 /* BugsnagSink.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A2C8FCB1C6BC2C800846019 /* BugsnagSink.h */; };
8A2C8FDE1C6BC2C800846019 /* BugsnagSink.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C8FCC1C6BC2C800846019 /* BugsnagSink.m */; };
8A2C8FEA1C6BC38900846019 /* BugsnagBreadcrumbsTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C8FE01C6BC38200846019 /* BugsnagBreadcrumbsTest.m */; };
Expand Down Expand Up @@ -194,6 +194,8 @@
0061D8372405B23A0041C068 /* BSG_SSKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSG_SSKeychain.m; sourceTree = "<group>"; };
0061D8382405B23A0041C068 /* LICENSE */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
0061D8392405B23A0041C068 /* BSG_SSKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSG_SSKeychain.h; sourceTree = "<group>"; };
0089B6E92411682000D5A7F2 /* BugsnagClient.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagClient.m; path = ../Source/BugsnagClient.m; sourceTree = "<group>"; };
0089B6EA2411682000D5A7F2 /* BugsnagClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BugsnagClient.h; path = ../Source/BugsnagClient.h; sourceTree = "<group>"; };
00D7AC9A23E97F8100FBE4A7 /* BugsnagEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagEvent.m; path = ../Source/BugsnagEvent.m; sourceTree = "<group>"; };
00D7AC9B23E97F8100FBE4A7 /* BugsnagEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BugsnagEvent.h; path = ../Source/BugsnagEvent.h; sourceTree = "<group>"; };
00D7ACA223E984B300FBE4A7 /* BugsnagEventTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BugsnagEventTests.m; sourceTree = "<group>"; };
Expand All @@ -218,8 +220,6 @@
8A2C8FC21C6BC2C800846019 /* BugsnagConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagConfiguration.m; path = ../Source/BugsnagConfiguration.m; sourceTree = SOURCE_ROOT; };
8A2C8FC51C6BC2C800846019 /* BugsnagMetadata.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BugsnagMetadata.h; path = ../Source/BugsnagMetadata.h; sourceTree = SOURCE_ROOT; };
8A2C8FC61C6BC2C800846019 /* BugsnagMetadata.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagMetadata.m; path = ../Source/BugsnagMetadata.m; sourceTree = SOURCE_ROOT; };
8A2C8FC71C6BC2C800846019 /* BugsnagNotifier.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BugsnagNotifier.h; path = ../Source/BugsnagNotifier.h; sourceTree = SOURCE_ROOT; };
8A2C8FC81C6BC2C800846019 /* BugsnagNotifier.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagNotifier.m; path = ../Source/BugsnagNotifier.m; sourceTree = SOURCE_ROOT; };
8A2C8FCB1C6BC2C800846019 /* BugsnagSink.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BugsnagSink.h; path = ../Source/BugsnagSink.h; sourceTree = SOURCE_ROOT; };
8A2C8FCC1C6BC2C800846019 /* BugsnagSink.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagSink.m; path = ../Source/BugsnagSink.m; sourceTree = SOURCE_ROOT; };
8A2C8FE01C6BC38200846019 /* BugsnagBreadcrumbsTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = BugsnagBreadcrumbsTest.m; path = ../Tests/BugsnagBreadcrumbsTest.m; sourceTree = SOURCE_ROOT; };
Expand Down Expand Up @@ -437,6 +437,8 @@
8A6C6FAF2257884C00E8EF24 /* BSGOutOfMemoryWatchdog.m */,
E791483E1FD82B35003EFEBF /* BugsnagApiClient.h */,
E791483D1FD82B35003EFEBF /* BugsnagApiClient.m */,
0089B6EA2411682000D5A7F2 /* BugsnagClient.h */,
0089B6E92411682000D5A7F2 /* BugsnagClient.m */,
E79148401FD82B35003EFEBF /* BugsnagFileStore.h */,
E79148451FD82B36003EFEBF /* BugsnagFileStore.m */,
E79148341FD82B34003EFEBF /* BugsnagKSCrashSysInfoParser.h */,
Expand Down Expand Up @@ -476,8 +478,6 @@
8A2C8FC21C6BC2C800846019 /* BugsnagConfiguration.m */,
8A2C8FC51C6BC2C800846019 /* BugsnagMetadata.h */,
8A2C8FC61C6BC2C800846019 /* BugsnagMetadata.m */,
8A2C8FC71C6BC2C800846019 /* BugsnagNotifier.h */,
8A2C8FC81C6BC2C800846019 /* BugsnagNotifier.m */,
8A2C8FCB1C6BC2C800846019 /* BugsnagSink.h */,
8A2C8FCC1C6BC2C800846019 /* BugsnagSink.m */,
8A2C8FA61C6BC1F700846019 /* Info.plist */,
Expand Down Expand Up @@ -763,6 +763,7 @@
8A2C8FCF1C6BC2C800846019 /* BugsnagBreadcrumb.h in Headers */,
E79148511FD82B36003EFEBF /* BugsnagApiClient.h in Headers */,
E79E6BDB1F4E3850002B35F9 /* BSG_KSCrashReportFilter.h in Headers */,
0089B6EC2411682000D5A7F2 /* BugsnagClient.h in Headers */,
E79E6BA11F4E3850002B35F9 /* BSG_KSCrashSentry_CPPException.h in Headers */,
E79E6B041F4E3847002B35F9 /* BugsnagErrorReportApiClient.h in Headers */,
8A530CB822FDC38300F0C108 /* BSG_KSCrashIdentifier.h in Headers */,
Expand All @@ -775,7 +776,6 @@
E79E6BA01F4E3850002B35F9 /* BSG_KSCrashSentry.h in Headers */,
E79E6BA91F4E3850002B35F9 /* BSG_KSCrashSentry_Private.h in Headers */,
E79148481FD82B36003EFEBF /* BugsnagUser.h in Headers */,
8A2C8FD91C6BC2C800846019 /* BugsnagNotifier.h in Headers */,
E79E6B8A1F4E3850002B35F9 /* BSG_KSCrashAdvanced.h in Headers */,
E79E6BC61F4E3850002B35F9 /* BSG_KSObjC.h in Headers */,
E79E6BCE1F4E3850002B35F9 /* BSG_KSString.h in Headers */,
Expand Down Expand Up @@ -894,10 +894,10 @@
8A627CDA1EC3B75200F7C04E /* BSGSerialization.m in Sources */,
E79E6BAA1F4E3850002B35F9 /* BSG_KSCrashSentry_Signal.c in Sources */,
8A2C8FDE1C6BC2C800846019 /* BugsnagSink.m in Sources */,
0089B6EB2411682000D5A7F2 /* BugsnagClient.m in Sources */,
E79E6BBE1F4E3850002B35F9 /* BSG_KSMach.c in Sources */,
E79E6B991F4E3850002B35F9 /* BSG_KSCrashType.c in Sources */,
E79E6BC01F4E3850002B35F9 /* BSG_KSMach_Arm.c in Sources */,
8A2C8FDA1C6BC2C800846019 /* BugsnagNotifier.m in Sources */,
E79E6B8F1F4E3850002B35F9 /* BSG_KSCrashDoctor.m in Sources */,
E791484E1FD82B36003EFEBF /* BugsnagKSCrashSysInfoParser.m in Sources */,
E791484F1FD82B36003EFEBF /* BugsnagSessionTrackingPayload.m in Sources */,
Expand Down
60 changes: 30 additions & 30 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@
#import "Bugsnag.h"
#import "BSG_KSCrash.h"
#import "BugsnagLogger.h"
#import "BugsnagNotifier.h"
#import "BugsnagClient.h"
#import "BugsnagKeys.h"
#import "BugsnagPlugin.h"

static BugsnagNotifier *bsg_g_bugsnag_notifier = NULL;
static BugsnagClient *bsg_g_bugsnag_client = NULL;
static NSMutableArray <id<BugsnagPlugin>> *registeredPlugins;

@interface Bugsnag ()
+ (BugsnagNotifier *)notifier;
+ (BugsnagClient *)client;
+ (BOOL)bugsnagStarted;
+ (void)registerPlugin:(id<BugsnagPlugin>)plugin;
@end
Expand All @@ -54,16 +54,16 @@ + (void)startBugsnagWithApiKey:(NSString *)apiKey {

+ (void)startBugsnagWithConfiguration:(BugsnagConfiguration *)configuration {
@synchronized(self) {
bsg_g_bugsnag_notifier =
[[BugsnagNotifier alloc] initWithConfiguration:configuration];
bsg_g_bugsnag_client =
[[BugsnagClient alloc] initWithConfiguration:configuration];
[self startPlugins];
[bsg_g_bugsnag_notifier start];
[bsg_g_bugsnag_client start];
}
}

+ (BugsnagConfiguration *)configuration {
if ([self bugsnagStarted]) {
return self.notifier.configuration;
return self.client.configuration;
}
return nil;
}
Expand All @@ -72,8 +72,8 @@ + (BugsnagConfiguration *)instance {
return [self configuration];
}

+ (BugsnagNotifier *)notifier {
return bsg_g_bugsnag_notifier;
+ (BugsnagClient *)client {
return bsg_g_bugsnag_client;
}

+ (void)registerPlugin:(id<BugsnagPlugin>)plugin {
Expand All @@ -93,14 +93,14 @@ + (void)startPlugins {

+ (BOOL)appDidCrashLastLaunch {
if ([self bugsnagStarted]) {
return [self.notifier appCrashedLastLaunch];
return [self.client appCrashedLastLaunch];
}
return NO;
}

+ (void)notify:(NSException *)exception {
if ([self bugsnagStarted]) {
[self.notifier notifyException:exception
[self.client notifyException:exception
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
}];
Expand All @@ -109,7 +109,7 @@ + (void)notify:(NSException *)exception {

+ (void)notify:(NSException *)exception block:(BugsnagOnErrorBlock)block {
if ([self bugsnagStarted]) {
[[self notifier] notifyException:exception
[[self client] notifyException:exception
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;

Expand All @@ -122,7 +122,7 @@ + (void)notify:(NSException *)exception block:(BugsnagOnErrorBlock)block {

+ (void)notifyError:(NSError *)error {
if ([self bugsnagStarted]) {
[self.notifier notifyError:error
[self.client notifyError:error
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
}];
Expand All @@ -131,7 +131,7 @@ + (void)notifyError:(NSError *)error {

+ (void)notifyError:(NSError *)error block:(BugsnagOnErrorBlock)block {
if ([self bugsnagStarted]) {
[[self notifier] notifyError:error
[[self client] notifyError:error
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;

Expand All @@ -144,12 +144,12 @@ + (void)notifyError:(NSError *)error block:(BugsnagOnErrorBlock)block {

+ (void)notify:(NSException *)exception withData:(NSDictionary *)metadata {
if ([self bugsnagStarted]) {
[[self notifier]
[[self client]
notifyException:exception
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
report.metadata = [metadata
BSG_mergedInto:[self.notifier.configuration
BSG_mergedInto:[self.client.configuration
.metadata toDictionary]];
}];
}
Expand All @@ -159,13 +159,13 @@ + (void)notify:(NSException *)exception
withData:(NSDictionary *)metadata
atSeverity:(NSString *)severity {
if ([self bugsnagStarted]) {
[[self notifier]
[[self client]
notifyException:exception
atSeverity:BSGParseSeverity(severity)
block:^(BugsnagEvent *_Nonnull report) {
report.depth += 2;
report.metadata = [metadata
BSG_mergedInto:[self.notifier.configuration
BSG_mergedInto:[self.client.configuration
.metadata toDictionary]];
report.severity = BSGParseSeverity(severity);
}];
Expand All @@ -176,7 +176,7 @@ + (void)internalClientNotify:(NSException *_Nonnull)exception
withData:(NSDictionary *_Nullable)metadata
block:(BugsnagOnErrorBlock _Nullable)block {
if ([self bugsnagStarted]) {
[self.notifier internalClientNotify:exception
[self.client internalClientNotify:exception
withData:metadata
block:block];
}
Expand All @@ -190,20 +190,20 @@ + (void)addMetadataToSection:(NSString *_Nonnull)section
key:(NSString *_Nonnull)key
value:(id _Nullable)value {
if ([self bugsnagStarted]) {
[self.notifier.configuration.metadata addAttribute:key
[self.client.configuration.metadata addAttribute:key
withValue:value
toTabWithName:section];
}
}

+ (void)clearMetadataInSection:(NSString *)section {
if ([self bugsnagStarted]) {
[self.notifier.configuration.metadata clearMetadataInSection:section];
[self.client.configuration.metadata clearMetadataInSection:section];
}
}

+ (BOOL)bugsnagStarted {
if (!self.notifier.started) {
if (!self.client.started) {
bsg_log_err(@"Ensure you have started Bugsnag with startWithApiKey: "
@"before calling any other Bugsnag functions.");

Expand All @@ -223,44 +223,44 @@ + (void)leaveBreadcrumbWithMessage:(NSString *)message {
+ (void)leaveBreadcrumbWithBlock:
(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block {
if ([self bugsnagStarted]) {
[self.notifier addBreadcrumbWithBlock:block];
[self.client addBreadcrumbWithBlock:block];
}
}

+ (void)leaveBreadcrumbForNotificationName:
(NSString *_Nonnull)notificationName {
if ([self bugsnagStarted]) {
[self.notifier crumbleNotification:notificationName];
[self.client crumbleNotification:notificationName];
}
}

+ (void)setBreadcrumbCapacity:(NSUInteger)capacity {
if ([self bugsnagStarted]) {
[self.notifier.configuration setMaxBreadcrumbs:capacity];
[self.client.configuration setMaxBreadcrumbs:capacity];
}
}

+ (void)clearBreadcrumbs {
if ([self bugsnagStarted]) {
[self.notifier clearBreadcrumbs];
[self.client clearBreadcrumbs];
}
}

+ (void)startSession {
if ([self bugsnagStarted]) {
[self.notifier startSession];
[self.client startSession];
}
}

+ (void)pauseSession {
if ([self bugsnagStarted]) {
[self.notifier pauseSession];
[self.client pauseSession];
}
}

+ (BOOL)resumeSession {
if ([self bugsnagStarted]) {
return [self.notifier resumeSession];
return [self.client resumeSession];
} else {
return false;
}
Expand All @@ -280,7 +280,7 @@ + (void)clearMetadataInSection:(NSString *_Nonnull)sectionName
withKey:(NSString *_Nonnull)key
{
if ([self bugsnagStarted]) {
[self.notifier.configuration.metadata clearMetadataInSection:sectionName
[self.client.configuration.metadata clearMetadataInSection:sectionName
key:key];
}
}
Expand Down
2 changes: 1 addition & 1 deletion Source/BugsnagNotifier.h → Source/BugsnagClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

@class BugsnagSessionTracker;

@interface BugsnagNotifier : NSObject <BugsnagMetadataDelegate>
@interface BugsnagClient : NSObject <BugsnagMetadataDelegate>

@property(nonatomic, readwrite, retain)
BugsnagConfiguration *_Nullable configuration;
Expand Down
12 changes: 6 additions & 6 deletions Source/BugsnagNotifier.m → Source/BugsnagClient.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//
// BugsnagNotifier.m
// BugsnagClient.m
//
// Created by Conrad Irwin on 2014-10-01.
//
Expand All @@ -24,7 +24,7 @@
// THE SOFTWARE.
//

#import "BugsnagNotifier.h"
#import "BugsnagClient.h"
#import "BSGConnectivity.h"
#import "Bugsnag.h"
#import "Private.h"
Expand Down Expand Up @@ -201,15 +201,15 @@ void BSGWriteSessionCrashData(BugsnagSession *session) {
hasRecordedSessions = true;
}

@interface BugsnagNotifier ()
@interface BugsnagClient ()
@property(nonatomic, strong) BugsnagCrashSentry *crashSentry;
@property(nonatomic, strong) BugsnagErrorReportApiClient *errorReportApiClient;
@property(nonatomic, strong, readwrite) BugsnagSessionTracker *sessionTracker;
@property (nonatomic, strong) BSGOutOfMemoryWatchdog *oomWatchdog;
@property (nonatomic) BOOL appCrashedLastLaunch;
@end

@implementation BugsnagNotifier
@implementation BugsnagClient

@synthesize configuration;

Expand Down Expand Up @@ -527,7 +527,7 @@ - (void)setupConnectivityListener {

// ARC Reference - 4.2 __weak Semantics
// http://clang.llvm.org/docs/AutomaticReferenceCounting.html
// Avoid potential strong reference cycle between the notifier instance and
// Avoid potential strong reference cycle between the 'client' instance and
// the BSGConnectivity static storage.
__weak typeof(self) weakSelf = self;
[BSGConnectivity monitorURL:url
Expand Down Expand Up @@ -681,7 +681,7 @@ - (void)notify:(NSException *)exception
// 2 -[BSG_KSCrash
// reportUserException:reason:language:lineOfCode:stackTrace:terminateProgram:]
// 3 -[BugsnagCrashSentry reportUserException:reason:]
// 4 -[BugsnagNotifier notify:message:block:]
// 4 -[BugsnagClient notify:message:block:]

int depth = (int)(BSGNotifierStackFrameCount + report.depth);

Expand Down
Loading