Skip to content

Commit

Permalink
Merge pull request #1185 from bugsnag/release-v6.12.1
Browse files Browse the repository at this point in the history
Release v6.12.1
  • Loading branch information
nickdowell authored Sep 15, 2021
2 parents 849f707 + 28beb7a commit 5918cc9
Show file tree
Hide file tree
Showing 20 changed files with 162 additions and 103 deletions.
4 changes: 2 additions & 2 deletions .jazzy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ author_url: "https://www.bugsnag.com"
author: "Bugsnag Inc"
clean: false # avoid deleting docs/.git
framework_root: "Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.12.0/Bugsnag"
github_file_prefix: "https://github.com/bugsnag/bugsnag-cocoa/tree/v6.12.1/Bugsnag"
github_url: "https://github.com/bugsnag/bugsnag-cocoa"
hide_documentation_coverage: true
module: "Bugsnag"
module_version: "6.12.0"
module_version: "6.12.1"
objc: true
output: "docs"
readme: "README.md"
Expand Down
4 changes: 2 additions & 2 deletions Bugsnag.podspec.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "Bugsnag",
"version": "6.12.0",
"version": "6.12.1",
"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.12.0"
"tag": "v6.12.1"
},
"frameworks": [
"Foundation",
Expand Down
2 changes: 0 additions & 2 deletions Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,6 @@
01847D952644140F00ADA4C7 /* BSGInternalErrorReporter.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSGInternalErrorReporter.m; sourceTree = "<group>"; };
01847DAB26441A5E00ADA4C7 /* BSGInternalErrorReporterTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = BSGInternalErrorReporterTests.m; sourceTree = "<group>"; };
01937CF9257A7B4C00F2DE31 /* Bugsnag+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Bugsnag+Private.h"; sourceTree = "<group>"; };
01937D09257A7ED000F2DE31 /* BugsnagSessionTracker+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagSessionTracker+Private.h"; sourceTree = "<group>"; };
01937D11257A814D00F2DE31 /* BugsnagMetadata+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagMetadata+Private.h"; sourceTree = "<group>"; };
01937D2E257A83A900F2DE31 /* BugsnagApp+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "BugsnagApp+Private.h"; sourceTree = "<group>"; };
019480C42625EE9800E833ED /* BSGAppKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = BSGAppKit.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1688,7 +1687,6 @@
01CCAEFF25D4151C0057268D /* BugsnagLastRunInfo+Private.h */,
00AD1EF82486A17700A27979 /* BugsnagSessionTracker.h */,
00AD1F012486A17900A27979 /* BugsnagSessionTracker.m */,
01937D09257A7ED000F2DE31 /* BugsnagSessionTracker+Private.h */,
CBB0928B2519F891007698BC /* BugsnagSystemState.h */,
CBB0928A2519F891007698BC /* BugsnagSystemState.m */,
00AD1CF124869EBD00A27979 /* Breadcrumbs */,
Expand Down
23 changes: 0 additions & 23 deletions Bugsnag/BugsnagSessionTracker+Private.h

This file was deleted.

18 changes: 14 additions & 4 deletions Bugsnag/BugsnagSessionTracker.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@
#import "BugsnagSession.h"
#import "BugsnagConfiguration.h"

NS_ASSUME_NONNULL_BEGIN

@class BugsnagSessionTrackingApiClient;

typedef void (^SessionTrackerCallback)(BugsnagSession *newSession);
typedef void (^SessionTrackerCallback)(BugsnagSession *_Nullable newSession);

extern NSString *const BSGSessionUpdateNotification;

Expand All @@ -27,8 +29,10 @@ extern NSString *const BSGSessionUpdateNotification;
@return A new session tracker
*/
- (instancetype)initWithConfig:(BugsnagConfiguration *)config
client:(BugsnagClient *)client
postRecordCallback:(void(^)(BugsnagSession *))callback;
client:(nullable BugsnagClient *)client
postRecordCallback:(nullable void(^)(BugsnagSession *))callback;

- (void)startWithNotificationCenter:(NSNotificationCenter *)notificationCenter isInForeground:(BOOL)isInForeground;

/**
Record and send a new session
Expand Down Expand Up @@ -77,12 +81,18 @@ extern NSString *const BSGSessionUpdateNotification;
*/
- (void)incrementEventCountUnhandled:(BOOL)unhandled;

@property (copy, nonatomic) NSString *codeBundleId;

@property (nullable, nonatomic) BugsnagSession *currentSession;

/**
* Retrieves the running session, or nil if the session is stopped or has not yet been started/resumed.
*/
@property (nonatomic, strong, readonly) BugsnagSession *runningSession;
@property (nullable, readonly, nonatomic) BugsnagSession *runningSession;

- (void)addRuntimeVersionInfo:(NSString *)info
withKey:(NSString *)key;

@end

NS_ASSUME_NONNULL_END
51 changes: 50 additions & 1 deletion Bugsnag/BugsnagSessionTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Bugsnag. All rights reserved.
//

#import "BugsnagSessionTracker+Private.h"
#import "BugsnagSessionTracker.h"

#import "BSG_KSSystemInfo.h"
#import "BugsnagApp+Private.h"
Expand All @@ -21,6 +21,12 @@
#import "BugsnagSessionTrackingPayload.h"
#import "BSGFileLocations.h"

#if TARGET_OS_IOS || TARGET_OS_TV
#import "BSGUIKit.h"
#elif TARGET_OS_OSX
#import "BSGAppKit.h"
#endif

/**
Number of seconds in background required to make a new session
*/
Expand Down Expand Up @@ -60,6 +66,49 @@ - (instancetype)initWithConfig:(BugsnagConfiguration *)config
return self;
}

- (void)startWithNotificationCenter:(NSNotificationCenter *)notificationCenter isInForeground:(BOOL)isInForeground {
if (isInForeground) {
[self startNewSessionIfAutoCaptureEnabled];
} else {
bsg_log_debug(@"Not starting session because app is not in the foreground");
}

#if TARGET_OS_IOS || TARGET_OS_TV

[notificationCenter addObserver:self
selector:@selector(handleAppForegroundEvent)
name:UIApplicationWillEnterForegroundNotification
object:nil];

[notificationCenter addObserver:self
selector:@selector(handleAppForegroundEvent)
name:UIApplicationDidBecomeActiveNotification
object:nil];

[notificationCenter addObserver:self
selector:@selector(handleAppBackgroundEvent)
name:UIApplicationDidEnterBackgroundNotification
object:nil];

#elif TARGET_OS_OSX

[notificationCenter addObserver:self
selector:@selector(handleAppForegroundEvent)
name:NSApplicationWillBecomeActiveNotification
object:nil];

[notificationCenter addObserver:self
selector:@selector(handleAppForegroundEvent)
name:NSApplicationDidBecomeActiveNotification
object:nil];

[notificationCenter addObserver:self
selector:@selector(handleAppBackgroundEvent)
name:NSApplicationDidResignActiveNotification
object:nil];
#endif
}

- (void)setCodeBundleId:(NSString *)codeBundleId {
_codeBundleId = codeBundleId;
self.apiClient.codeBundleId = codeBundleId;
Expand Down
2 changes: 1 addition & 1 deletion Bugsnag/Client/BugsnagClient+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ NS_ASSUME_NONNULL_BEGIN

@property (nullable, nonatomic) NSDictionary *metadataFromLastLaunch;

@property (strong, nonatomic) BugsnagNotifier *notifier; // Used in BugsnagReactNative
@property (readonly, nonatomic) BugsnagNotifier *notifier; // Used in BugsnagReactNative

@property (strong, nonatomic) BugsnagPluginClient *pluginClient;

Expand Down
68 changes: 21 additions & 47 deletions Bugsnag/Client/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
#import "BugsnagNotifier.h"
#import "BugsnagPluginClient.h"
#import "BugsnagSession+Private.h"
#import "BugsnagSessionTracker+Private.h"
#import "BugsnagSessionTracker.h"
#import "BugsnagSessionTrackingApiClient.h"
#import "BugsnagStackframe+Private.h"
#import "BugsnagStateEvent.h"
Expand Down Expand Up @@ -208,7 +208,7 @@ - (instancetype)initWithConfiguration:(BugsnagConfiguration *)configuration {
BSGKeyApp: @{BSGKeyIsLaunching: @YES},
BSGKeyClient: BSGDictionaryWithKeyAndObject(BSGKeyContext, _configuration.context)
}];
self.notifier = [BugsnagNotifier new];
_notifier = configuration.notifier ?: [[BugsnagNotifier alloc] init];
self.systemState = [[BugsnagSystemState alloc] initWithConfiguration:configuration];

BSGFileLocations *fileLocations = [BSGFileLocations current];
Expand Down Expand Up @@ -313,7 +313,6 @@ - (void)start {
[self.notificationBreadcrumbs start];

NSNotificationCenter *center = [NSNotificationCenter defaultCenter];
[self watchLifecycleEvents:center];

#if BSG_PLATFORM_IOS
[center addObserver:self
Expand Down Expand Up @@ -349,13 +348,18 @@ - (void)start {
object:nil];
}

[center addObserver:self
selector:@selector(applicationWillTerminate:)
#if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS
name:UIApplicationWillTerminateNotification
#elif BSG_PLATFORM_OSX
name:NSApplicationWillTerminateNotification
#endif
object:nil];

self.started = YES;

if (bsg_kscrashstate_currentState()->applicationIsInForeground) {
[self.sessionTracker startNewSessionIfAutoCaptureEnabled];
} else {
bsg_log_debug(@"Not starting session because app is not in the foreground");
}
[self.sessionTracker startWithNotificationCenter:center isInForeground:bsg_kscrashstate_currentState()->applicationIsInForeground];

// Record a "Bugsnag Loaded" message
[self addAutoBreadcrumbOfType:BSGBreadcrumbTypeState withMessage:@"Bugsnag loaded" andMetadata:nil];
Expand Down Expand Up @@ -486,6 +490,7 @@ - (void)setCodeBundleId:(NSString *)codeBundleId {
* Removes observers and listeners to prevent allocations when the app is terminated
*/
- (void)applicationWillTerminate:(__unused NSNotification *)notification {
[[NSNotificationCenter defaultCenter] removeObserver:self.sessionTracker];
[[NSNotificationCenter defaultCenter] removeObserver:self];
[BSGConnectivity stopMonitoring];

Expand All @@ -495,45 +500,6 @@ - (void)applicationWillTerminate:(__unused NSNotification *)notification {
#endif
}

- (void)watchLifecycleEvents:(NSNotificationCenter *)center {
NSNotificationName foregroundName;
NSNotificationName backgroundName;
NSNotificationName terminateName;

#if BSG_PLATFORM_IOS || BSG_PLATFORM_TVOS
foregroundName = UIApplicationWillEnterForegroundNotification;
backgroundName = UIApplicationDidEnterBackgroundNotification;
terminateName = UIApplicationWillTerminateNotification;
#elif BSG_PLATFORM_OSX
foregroundName = NSApplicationWillBecomeActiveNotification;
backgroundName = NSApplicationDidResignActiveNotification;
terminateName = NSApplicationWillTerminateNotification;
#endif

[center addObserver:self
selector:@selector(applicationWillEnterForeground:)
name:foregroundName
object:nil];

[center addObserver:self
selector:@selector(applicationWillEnterBackground:)
name:backgroundName
object:nil];

[center addObserver:self
selector:@selector(applicationWillTerminate:)
name:terminateName
object:nil];
}

- (void)applicationWillEnterForeground:(__unused NSNotification *)notification {
[self.sessionTracker handleAppForegroundEvent];
}

- (void)applicationWillEnterBackground:(__unused NSNotification *)notification {
[self.sessionTracker handleAppBackgroundEvent];
}

- (void)thermalStateDidChange:(NSNotification *)notification API_AVAILABLE(ios(11.0), tvos(11.0)) {
NSProcessInfo *processInfo = notification.object;

Expand All @@ -556,6 +522,10 @@ - (void)thermalStateDidChange:(NSNotification *)notification API_AVAILABLE(ios(1
self.lastThermalState = processInfo.thermalState;
}

// =============================================================================
// MARK: - Session Tracking
// =============================================================================

- (void)startSession {
[self.sessionTracker startNewSession];
}
Expand All @@ -568,6 +538,10 @@ - (BOOL)resumeSession {
return [self.sessionTracker resumeSession];
}

// =============================================================================
// MARK: - Connectivity Listener
// =============================================================================

/**
* Monitor the Bugsnag endpoint to detect changes in connectivity,
* flush pending events when (re)connected and report connectivity
Expand Down
4 changes: 4 additions & 0 deletions Bugsnag/Configuration/BugsnagConfiguration+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#import <Bugsnag/BugsnagConfiguration.h>

@class BugsnagNotifier;

NS_ASSUME_NONNULL_BEGIN

@interface BugsnagConfiguration ()
Expand All @@ -25,6 +27,8 @@ NS_ASSUME_NONNULL_BEGIN

@property (copy, nonatomic) BugsnagMetadata *metadata;

@property (nullable, nonatomic) BugsnagNotifier *notifier;

@property (readonly, nullable, nonatomic) NSURL *notifyURL;

@property (nonatomic) NSMutableArray<BugsnagOnBreadcrumbBlock> *onBreadcrumbBlocks;
Expand Down
10 changes: 9 additions & 1 deletion Bugsnag/Payload/BugsnagNotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,18 @@ NS_ASSUME_NONNULL_BEGIN

@interface BugsnagNotifier : NSObject

/// Initializes the object with details of the Cocoa notifier.
- (instancetype)init NS_DESIGNATED_INITIALIZER;

- (instancetype)initWithName:(NSString *)name
version:(NSString *)version
url:(NSString *)url
dependencies:(NSArray<BugsnagNotifier *> *)dependencies NS_DESIGNATED_INITIALIZER;

@property (copy, nonatomic) NSString *name;
@property (copy, nonatomic) NSString *version;
@property (copy, nonatomic) NSString *url;
@property (nonatomic) NSMutableArray<BugsnagNotifier *> *dependencies;
@property (copy, nonatomic) NSArray<BugsnagNotifier *> *dependencies;

- (NSDictionary *)toDict;

Expand Down
27 changes: 20 additions & 7 deletions Bugsnag/Payload/BugsnagNotifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,30 @@ @implementation BugsnagNotifier
- (instancetype)init {
if ((self = [super init])) {
#if BSG_PLATFORM_TVOS
self.name = @"tvOS Bugsnag Notifier";
_name = @"tvOS Bugsnag Notifier";
#elif BSG_PLATFORM_IOS
self.name = @"iOS Bugsnag Notifier";
_name = @"iOS Bugsnag Notifier";
#elif BSG_PLATFORM_OSX
self.name = @"OSX Bugsnag Notifier";
_name = @"OSX Bugsnag Notifier";
#else
self.name = @"Bugsnag Objective-C";
_name = @"Bugsnag Objective-C";
#endif
self.version = @"6.12.0";
self.url = @"https://github.com/bugsnag/bugsnag-cocoa";
self.dependencies = [NSMutableArray new];
_version = @"6.12.1";
_url = @"https://github.com/bugsnag/bugsnag-cocoa";
_dependencies = @[];
}
return self;
}

- (instancetype)initWithName:(NSString *)name
version:(NSString *)version
url:(NSString *)url
dependencies:(NSArray<BugsnagNotifier *> *)dependencies {
if ((self = [super init])) {
_name = [name copy];
_version = [version copy];
_url = [url copy];
_dependencies = [dependencies copy];
}
return self;
}
Expand Down
Loading

0 comments on commit 5918cc9

Please sign in to comment.