Skip to content

Commit

Permalink
Merge branch 'v6' into v6-on-error
Browse files Browse the repository at this point in the history
  • Loading branch information
fractalwrench committed Apr 22, 2020
2 parents 75cc5ee + 724b26d commit 2011265
Show file tree
Hide file tree
Showing 32 changed files with 261 additions and 118 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,24 @@ Bugsnag Notifiers on other platforms.
* Make `BugsnagOnErrorBlock` return `BOOL` rather than `void`
[#555](https://github.com/bugsnag/bugsnag-cocoa/pull/555)

* Make `BugsnagPlugin` take `BugsnagClient` as param
[#558](https://github.com/bugsnag/bugsnag-cocoa/pull/558)

* Make user editable on `BugsnagEvent`
[#557](https://github.com/bugsnag/bugsnag-cocoa/pull/557)

* Add getter for `Bugsnag.context`
[#554](https://github.com/bugsnag/bugsnag-cocoa/pull/554)

* Make `BugsnagUser` properties readonly
[#556](https://github.com/bugsnag/bugsnag-cocoa/pull/556)

* Add `sendThreads` property to `BugsnagConfiguration`
[#549](https://github.com/bugsnag/bugsnag-cocoa/pull/549)

* Hide additional methods from public API
[#552](https://github.com/bugsnag/bugsnag-cocoa/pull/552)

* Add structured app/device fields to `BugsnagSession`
[#546](https://github.com/bugsnag/bugsnag-cocoa/pull/546)

Expand Down
17 changes: 6 additions & 11 deletions Source/Bugsnag.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,6 @@
+ (void)notifyError:(NSError *_Nonnull)error
block:(BugsnagOnErrorBlock _Nullable)block;

/**
* Intended for use by other clients (React Native/Unity). Calling this method
* directly from iOS is not supported.
*/
+ (void)internalClientNotify:(NSException *_Nonnull)exception
withData:(NSDictionary *_Nullable)metadata
block:(BugsnagOnErrorBlock _Nullable)block;

// =============================================================================
// MARK: - Breadcrumbs
// =============================================================================
Expand Down Expand Up @@ -217,12 +209,15 @@
// =============================================================================

/**
* Replicates BugsnagConfiguration.context
*
* @param context A general summary of what was happening in the application
* Retrieves the context - a general summary of what was happening in the application
*/
+ (void)setContext:(NSString *_Nullable)context;

/**
* Retrieves the context - a general summary of what was happening in the application
*/
+ (NSString *_Nullable)context;

// =============================================================================
// MARK: - User
// =============================================================================
Expand Down
14 changes: 14 additions & 0 deletions Source/Bugsnag.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ @interface BugsnagEvent ()
@interface BugsnagClient ()
- (void)startListeningForStateChangeNotification:(NSString *_Nonnull)notificationName;
- (void)addBreadcrumbWithBlock:(void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block;
- (void)internalClientNotify:(NSException *_Nonnull)exception
withData:(NSDictionary *_Nullable)metadata
block:(BugsnagOnErrorBlock _Nullable)block;
@end

@interface BugsnagMetadata ()
Expand Down Expand Up @@ -148,6 +151,10 @@ + (void)notifyError:(NSError *)error block:(BugsnagOnErrorBlock)block {
}
}

/**
* Intended for use by other clients (React Native/Unity). Calling this method
* directly from iOS is not supported.
*/
+ (void)internalClientNotify:(NSException *_Nonnull)exception
withData:(NSDictionary *_Nullable)metadata
block:(BugsnagOnErrorBlock _Nullable)block {
Expand Down Expand Up @@ -303,6 +310,13 @@ + (void)setContext:(NSString *_Nullable)context {
}
}

+ (NSString *_Nullable)context {
if ([self bugsnagStarted]) {
return self.client.context;
}
return nil;
}

+ (BugsnagUser *)user {
return self.client.user;
}
Expand Down
2 changes: 0 additions & 2 deletions Source/BugsnagBreadcrumb.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ typedef NS_OPTIONS(NSUInteger, BSGEnabledBreadcrumbType) {

@class BugsnagBreadcrumb;

typedef void (^BSGBreadcrumbConfiguration)(BugsnagBreadcrumb *_Nonnull);

@interface BugsnagBreadcrumb : NSObject

@property(readonly, nullable) NSDate *timestamp;
Expand Down
2 changes: 2 additions & 0 deletions Source/BugsnagBreadcrumb.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#import "BugsnagLogger.h"
#import "BugsnagKeys.h"

typedef void (^BSGBreadcrumbConfiguration)(BugsnagBreadcrumb *_Nonnull);

NSString *BSGBreadcrumbTypeValue(BSGBreadcrumbType type) {
switch (type) {
case BSGBreadcrumbTypeLog:
Expand Down
2 changes: 2 additions & 0 deletions Source/BugsnagBreadcrumbs.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

#import "BugsnagBreadcrumb.h"

typedef void (^BSGBreadcrumbConfiguration)(BugsnagBreadcrumb *_Nonnull);

@interface BugsnagBreadcrumbs : NSObject

/**
Expand Down
18 changes: 2 additions & 16 deletions Source/BugsnagClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,18 +74,6 @@
- (void)notifyError:(NSError *_Nonnull)error
block:(BugsnagOnErrorBlock _Nullable)block;

/**
* Notify Bugsnag of an exception. Only intended for React Native/Unity use.
*
* @param exception the exception
* @param metadata the metadata
* @param block Configuration block for adding additional report
* information
*/
- (void)internalClientNotify:(NSException *_Nonnull)exception
withData:(NSDictionary *_Nullable)metadata
block:(BugsnagOnErrorBlock _Nullable)block;

// =============================================================================
// MARK: - Breadcrumbs
// =============================================================================
Expand Down Expand Up @@ -204,11 +192,9 @@ NS_SWIFT_NAME(leaveBreadcrumb(_:metadata:type:));
// =============================================================================

/**
* Replicates BugsnagConfiguration.context
*
* @param context A general summary of what was happening in the application
* Retrieves the context - a general summary of what was happening in the application
*/
- (void)setContext:(NSString *_Nullable)context;
@property NSString *_Nullable context;

/**
* @return YES if Bugsnag has been started and the previous launch crashed
Expand Down
24 changes: 24 additions & 0 deletions Source/BugsnagClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -281,13 +281,21 @@ @interface BugsnagConfiguration ()
@property(readwrite, retain, nullable) BugsnagMetadata *metadata;
@property(readwrite, retain, nullable) BugsnagMetadata *config;
@property(readonly, strong, nullable) BugsnagBreadcrumbs *breadcrumbs;
- (BOOL)shouldRecordBreadcrumbType:(BSGBreadcrumbType)type;
@end

@interface BugsnagEvent ()
@property(readonly, copy, nonnull) NSDictionary *overrides;
@property(readwrite) NSUInteger depth;
@property(readonly, nonnull) BugsnagHandledState *handledState;
@property (nonatomic, strong) BugsnagMetadata *metadata;

- (instancetype _Nonnull)initWithErrorName:(NSString *_Nonnull)name
errorMessage:(NSString *_Nonnull)message
configuration:(BugsnagConfiguration *_Nonnull)config
metadata:(BugsnagMetadata *_Nullable)metadata
handledState:(BugsnagHandledState *_Nonnull)handledState
session:(BugsnagSession *_Nullable)session;
@end

@interface BugsnagMetadata ()
Expand All @@ -296,6 +304,10 @@ - (NSDictionary *_Nonnull)toDictionary;
- (id)deepCopy;
@end

@interface BugsnagUser ()
- (instancetype)initWithDictionary:(NSDictionary *)dict;
@end

@interface Bugsnag ()
+ (NSDateFormatter *_Nonnull)payloadDateFormatter;
@end
Expand Down Expand Up @@ -748,6 +760,10 @@ - (void)setContext:(NSString *_Nullable)context {
self.configuration.context = context;
}

- (NSString *)context {
return self.configuration.context;
}

// MARK: - Notify

- (void)notifyError:(NSError *_Nonnull)error {
Expand Down Expand Up @@ -796,6 +812,14 @@ - (void)notify:(NSException *)exception
[self notify:exception handledState:state block:block];
}

/**
* Notify Bugsnag of an exception. Only intended for React Native/Unity use.
*
* @param exception the exception
* @param metadata the metadata
* @param block Configuration block for adding additional report
* information
*/
- (void)internalClientNotify:(NSException *_Nonnull)exception
withData:(NSDictionary *_Nullable)metadata
block:(BugsnagOnErrorBlock _Nullable)block
Expand Down
8 changes: 0 additions & 8 deletions Source/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,4 @@ typedef NS_OPTIONS(NSUInteger, BSGEnabledErrorType) {

- (void)addPlugin:(id<BugsnagPlugin> _Nonnull)plugin;

/**
* Should the specified type of breadcrumb be recorded?
*
* @param type The type of breadcrumb
*
* @returns A boolean indicating whether the specified breadcrumb type should be recorded
*/
- (BOOL)shouldRecordBreadcrumbType:(BSGBreadcrumbType)type;
@end
6 changes: 6 additions & 0 deletions Source/BugsnagConfiguration.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ @interface BugsnagMetadata ()
- (NSDictionary *_Nonnull)toDictionary;
@end

@interface BugsnagUser ()
- (instancetype)initWithDictionary:(NSDictionary *)dict;
- (instancetype)initWithUserId:(NSString *)userId name:(NSString *)name emailAddress:(NSString *)emailAddress;
- (NSDictionary *)toJson;
@end

@interface BugsnagConfiguration ()

/**
Expand Down
59 changes: 23 additions & 36 deletions Source/BugsnagEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
@class BugsnagMetadata;
@class BugsnagThread;
@class BugsnagError;
@class BugsnagUser;

typedef NS_ENUM(NSUInteger, BSGSeverity) {
BSGSeverityError,
Expand All @@ -27,41 +28,6 @@ typedef NS_ENUM(NSUInteger, BSGSeverity) {

@interface BugsnagEvent : NSObject <BugsnagMetadataStore>

// -----------------------------------------------------------------------------
// MARK: - Initialisation
// -----------------------------------------------------------------------------

/**
* Create a new crash report from a JSON crash report generated by
* BugsnagCrashSentry
*
* @param report a BugsnagCrashSentry JSON report
*
* @return a Bugsnag crash report
*/
- (instancetype _Nonnull)initWithKSReport:(NSDictionary *_Nonnull)report;

/**
* Create a basic crash report from raw parts.
*
* Assumes that the exception is handled.
*
* @param name The name of the exception
* @param message The reason or message from the exception
* @param config Bugsnag configuration
* @param metadata additional data to attach to the report
* @param handledState the handled state of the error
*
* @return a Bugsnag crash report
*/
- (instancetype _Nonnull)
initWithErrorName:(NSString *_Nonnull)name
errorMessage:(NSString *_Nonnull)message
configuration:(BugsnagConfiguration *_Nonnull)config
metadata:(BugsnagMetadata *_Nullable)metadata
handledState:(BugsnagHandledState *_Nonnull)handledState
session:(BugsnagSession *_Nullable)session;

// -----------------------------------------------------------------------------
// MARK: - Properties
// -----------------------------------------------------------------------------
Expand Down Expand Up @@ -97,7 +63,7 @@ initWithErrorName:(NSString *_Nonnull)name
* - Reads default to the BugsnagConfiguration apiKey value unless explicitly set.
* - Writes are not persisted to BugsnagConfiguration.
*/
@property(readwrite, copy, nonnull) NSString *apiKey;
@property(readwrite, copy, nullable) NSString *apiKey;

/**
* Device information such as OS name and version
Expand Down Expand Up @@ -130,5 +96,26 @@ initWithErrorName:(NSString *_Nonnull)name
*/
@property(nullable) id originalError;


// =============================================================================
// MARK: - User
// =============================================================================

/**
* The current user
*/
@property(readonly, nonatomic, nonnull) BugsnagUser *user;

/**
* Set user metadata
*
* @param userId ID of the user
* @param name Name of the user
* @param email Email address of the user
*/
- (void)setUser:(NSString *_Nullable)userId
withEmail:(NSString *_Nullable)email
andName:(NSString *_Nullable)name;

@end

Loading

0 comments on commit 2011265

Please sign in to comment.