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

Add persistence user configuration options #475

Merged
merged 21 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
afe4c10
Added SSKeychain, Added CRUD ops for user data in keychain, hooked up…
robinmacharg Feb 19, 2020
811b638
Moved user-persistence testing from unit to e2e due to entitlement is…
robinmacharg Feb 24, 2020
e98295f
Added PR
robinmacharg Feb 24, 2020
ba521e7
PR fixes: added vendoring prefix, surfaced SKeychain license file
robinmacharg Feb 25, 2020
1a25cd9
Added Vendored SSKeychain to MacOS and tvOS projects, fixed test user…
robinmacharg Feb 25, 2020
c8d8a97
Updated maze-runner revision, re-added BSG_SSKeychain, fixed duplicat…
robinmacharg Feb 26, 2020
f6d1f31
PR feedback: vendoring prefixes, depublicising various bits, tweak Ut…
robinmacharg Feb 28, 2020
10b6fa2
Missed vendoring
robinmacharg Mar 2, 2020
162008b
Remove persisted user data where it's not expected to persist.
robinmacharg Mar 2, 2020
94c4615
Added CI Features to test app project for ease of editing.
robinmacharg Mar 2, 2020
941d0af
Fix for Travis generating random connectivity changes
robinmacharg Mar 3, 2020
c228d6d
Merge branch 'spec-compliance' into spec-compliance-ci-fixing
robinmacharg Mar 4, 2020
d9f21d1
Merge branch 'spec-compliance-ci-fixing' into tom/add-persist-user-co…
robinmacharg Mar 4, 2020
010cdcb
Double check TESTING is being set
robinmacharg Mar 5, 2020
3b3f79a
Expand logging
robinmacharg Mar 5, 2020
32ba30e
Change dir for .xcconfig
robinmacharg Mar 5, 2020
44482c1
Pass extra info in (detect CI)
robinmacharg Mar 5, 2020
8f54f75
fixes
robinmacharg Mar 5, 2020
803ac57
Merge branch 'spec-compliance-ci-fixing' into tom/add-persist-user-co…
robinmacharg Mar 5, 2020
47a4716
Different approach: removed info, rely on URL validation failure (mov…
robinmacharg Mar 5, 2020
0d2a7b0
Merge branch 'spec-compliance-ci-fixing' into tom/add-persist-user-co…
robinmacharg Mar 5, 2020
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
6 changes: 5 additions & 1 deletion Bugsnag.podspec.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@
"git": "https://github.com/bugsnag/bugsnag-cocoa.git",
"tag": "v5.23.0"
},
"frameworks": ["Foundation", "SystemConfiguration"],
"frameworks": [
"Foundation",
"SystemConfiguration",
"Security"
],
"libraries": [
"c++", "z"
],
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ Bugsnag Notifiers on other platforms.

* Remove `Bugsnag.configuration()?`. All access to the configuration object
should be performed prior to calling `Bugsnag.start()`.

* User information is now persisted between application runs by default. When set a users'
email, id and name are set on `BugsnagConfiguration` they are stored in the Keychain and
restored if an application is restarted. The values are also copied to the configuration metadata.
[#469](https://github.com/bugsnag/bugsnag-cocoa/pull/469)

## Bug fixes

Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: https://github.com/bugsnag/maze-runner
revision: 009e6c6b19d2411b38b383129b00ff9dad67d731
revision: ea26bb118b9160d7d26fb9d71310804abebea1b7
specs:
bugsnag-maze-runner (1.0.0)
cucumber (~> 3.1.0)
Expand Down
30 changes: 27 additions & 3 deletions OSX/Bugsnag.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
004A41F223FEE08E0092DF97 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 004A41F123FEE08E0092DF97 /* Security.framework */; };
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 */; };
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 Down Expand Up @@ -44,7 +48,6 @@
8A6C6FB12257884C00E8EF24 /* BSGOutOfMemoryWatchdog.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A6C6FAF2257884C00E8EF24 /* BSGOutOfMemoryWatchdog.m */; };
8A6C6FB22257884C00E8EF24 /* BSGOutOfMemoryWatchdog.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A6C6FB02257884C00E8EF24 /* BSGOutOfMemoryWatchdog.h */; };
8A87352C1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A87352B1C6D3B1600EDBD5B /* BSG_KSCrashReportWriter.h */; settings = {ATTRIBUTES = (Public, ); }; };
8ACF0F752018136200173809 /* BugsnagCrashReportTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8A2C8FE11C6BC38200846019 /* BugsnagCrashReportTests.m */; };
8AD1E3FA23EDDD4F0044F919 /* BSGConnectivityTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD1E3F823EDDD3F0044F919 /* BSGConnectivityTest.m */; };
8AD9FA891E086351002859A7 /* BugsnagConfigurationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 8AD9FA851E0862DC002859A7 /* BugsnagConfigurationTests.m */; };
E72352C11F55924A00436528 /* BSGConnectivity.h in Headers */ = {isa = PBXBuildFile; fileRef = E72352BF1F55924A00436528 /* BSGConnectivity.h */; };
Expand Down Expand Up @@ -187,6 +190,10 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
004A41F123FEE08E0092DF97 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
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>"; };
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 Down Expand Up @@ -375,6 +382,7 @@
E7433AD31F4F64F400C082D1 /* libc++.tbd in Frameworks */,
E7433AD21F4F64EF00C082D1 /* libz.tbd in Frameworks */,
8A2C8FF01C6BC3A200846019 /* SystemConfiguration.framework in Frameworks */,
004A41F223FEE08E0092DF97 /* Security.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand All @@ -389,6 +397,17 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
004A41DD23FEDF2B0092DF97 /* SSKeychain */ = {
isa = PBXGroup;
children = (
0061D8392405B23A0041C068 /* BSG_SSKeychain.h */,
0061D8372405B23A0041C068 /* BSG_SSKeychain.m */,
0061D8382405B23A0041C068 /* LICENSE */,
);
name = SSKeychain;
path = ../Source/SSKeychain;
sourceTree = "<group>";
};
8A2C8F971C6BC1F700846019 = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -437,7 +456,6 @@
E794E8041F9F746D00A67EE7 /* BugsnagKeys.h */,
E762E9FA1F73F80200E82B43 /* BugsnagHandledState.h */,
E762E9FB1F73F80200E82B43 /* BugsnagHandledState.m */,
E79E6B081F4E3850002B35F9 /* BSG_KSCrash */,
E79E6AFC1F4E3847002B35F9 /* BugsnagCrashSentry.h */,
E79E6AFD1F4E3847002B35F9 /* BugsnagCrashSentry.m */,
E79E6AFE1F4E3847002B35F9 /* BugsnagErrorReportApiClient.h */,
Expand All @@ -464,6 +482,8 @@
8A2C8FCC1C6BC2C800846019 /* BugsnagSink.m */,
8A2C8FA61C6BC1F700846019 /* Info.plist */,
8A2C902F1C6BF3AC00846019 /* module.modulemap */,
E79E6B081F4E3850002B35F9 /* BSG_KSCrash */,
004A41DD23FEDF2B0092DF97 /* SSKeychain */,
);
name = Bugsnag;
sourceTree = SOURCE_ROOT;
Expand All @@ -480,7 +500,6 @@
4B406C1622CAD96400464D1D /* BugsnagCollectionsBSGDictMergeTest.m */,
4B406C1722CAD96400464D1D /* BugsnagCollectionsBSGDictSetSafeObjectTest.m */,
4B775FD222CBE02A004839C5 /* BugsnagCollectionsBSGDictInsertIfNotNilTest.m */,
E7CE78861FD94E40001D07E0 /* KSCrash */,
E791482D1FD82B0C003EFEBF /* BugsnagSessionTest.m */,
E791482B1FD82B0C003EFEBF /* BugsnagSessionTrackerTest.m */,
E791482C1FD82B0C003EFEBF /* BugsnagSessionTrackingPayloadTest.m */,
Expand All @@ -491,6 +510,7 @@
8A2C8FE21C6BC38200846019 /* BugsnagSinkTests.m */,
8A2C8FE41C6BC38200846019 /* report.json */,
8A2C8FB21C6BC1F700846019 /* TestsInfo.plist */,
E7CE78861FD94E40001D07E0 /* KSCrash */,
);
name = Tests;
path = ../Tests;
Expand All @@ -499,6 +519,7 @@
8A2C8FF51C6BC3C200846019 /* Frameworks */ = {
isa = PBXGroup;
children = (
004A41F123FEE08E0092DF97 /* Security.framework */,
8A2C90421C6C03FF00846019 /* Foundation.framework */,
8A2C90401C6C03F000846019 /* Cocoa.framework */,
8A2C8FF31C6BC3AE00846019 /* libc++.tbd */,
Expand Down Expand Up @@ -749,6 +770,7 @@
E79E6B8C1F4E3850002B35F9 /* BSG_KSCrashC.h in Headers */,
E79E6BDC1F4E3850002B35F9 /* BSG_KSCrashReportFilterCompletion.h in Headers */,
E79E6BC41F4E3850002B35F9 /* BSG_KSMachApple.h in Headers */,
0061D83C2405B23A0041C068 /* BSG_SSKeychain.h in Headers */,
E79E6BAD1F4E3850002B35F9 /* BSG_KSCrashSentry_User.h in Headers */,
E79E6BA01F4E3850002B35F9 /* BSG_KSCrashSentry.h in Headers */,
E79E6BA91F4E3850002B35F9 /* BSG_KSCrashSentry_Private.h in Headers */,
Expand Down Expand Up @@ -847,6 +869,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
0061D83B2405B23A0041C068 /* LICENSE in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -917,6 +940,7 @@
E79148521FD82B36003EFEBF /* BugsnagUser.m in Sources */,
E79E6B891F4E3850002B35F9 /* BSG_KSCrash.m in Sources */,
E79E6BAC1F4E3850002B35F9 /* BSG_KSCrashSentry_User.c in Sources */,
0061D83A2405B23A0041C068 /* BSG_SSKeychain.m in Sources */,
E79148581FD82B36003EFEBF /* BugsnagFileStore.m in Sources */,
E79E6BDA1F4E3850002B35F9 /* BSG_RFC3339DateTool.m in Sources */,
E72352C21F55924A00436528 /* BSGConnectivity.m in Sources */,
Expand Down
68 changes: 50 additions & 18 deletions Source/BugsnagConfiguration.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ typedef NS_ENUM(NSInteger, BSGConfigurationErrorCode) {
BSGConfigurationErrorInvalidApiKey = 0
};

/**
* User info persistence keys
*/
extern NSString * _Nonnull const kBugsnagUserKeychainAccount;
extern NSString * _Nonnull const kBugsnagUserEmailAddress;
extern NSString * _Nonnull const kBugsnagUserName;
extern NSString * _Nonnull const kBugsnagUserUserId;
robinmacharg marked this conversation as resolved.
Show resolved Hide resolved

/**
* A configuration block for modifying an error report
*
Expand Down Expand Up @@ -85,6 +93,10 @@ typedef NSDictionary *_Nullable (^BugsnagBeforeNotifyHook)(

@interface BugsnagConfiguration : NSObject

// -----------------------------------------------------------------------------
// MARK: - Properties
// -----------------------------------------------------------------------------

/**
* The API key of a Bugsnag project
*/
Expand Down Expand Up @@ -198,6 +210,38 @@ NSArray<BugsnagOnSessionBlock> *onSessionBlocks;
*/
@property(readonly, retain, nullable) NSURL *sessionURL;

@property(retain, nullable) NSString *codeBundleId;
@property(retain, nullable) NSString *notifierType;

/**
* The maximum number of breadcrumbs to keep and sent to Bugsnag.
* By default, we'll keep and send the 25 most recent breadcrumb log
* messages.
*/
@property NSUInteger maxBreadcrumbs;

/**
* Determines whether app sessions should be tracked automatically. By default this value is true.
* If this value is updated after +[Bugsnag start] is called, only subsequent automatic sessions
* will be captured.
*/
@property BOOL shouldAutoCaptureSessions __deprecated_msg("Use autoTrackSessions instead");

/**
* YES if uncaught exceptions should be reported automatically
*/
@property BOOL autoNotify __deprecated_msg("Use autoDetectErrors instead");

/**
* Whether User information should be persisted to disk between application runs.
* Defaults to True.
*/
@property BOOL persistUser;

// -----------------------------------------------------------------------------
// MARK: - Methods
// -----------------------------------------------------------------------------

/**
* Required declaration to suppress a superclass designated-initializer error
*/
Expand Down Expand Up @@ -267,29 +311,17 @@ NSArray<BugsnagOnSessionBlock> *onSessionBlocks;
*/
- (BOOL)shouldSendReports;

/**
* The maximum number of breadcrumbs to keep and sent to Bugsnag.
* By default, we'll keep and send the 25 most recent breadcrumb log
* messages.
*/
@property NSUInteger maxBreadcrumbs;
- (NSDictionary *_Nonnull)errorApiHeaders;
- (NSDictionary *_Nonnull)sessionApiHeaders;

/**
* Determines whether app sessions should be tracked automatically. By default this value is true.
* If this value is updated after +[Bugsnag start] is called, only subsequent automatic sessions
* will be captured.
* Store user data in a secure location that persists between application runs
*/
@property BOOL shouldAutoCaptureSessions __deprecated_msg("Use autoTrackSessions instead");
- (void)persistUserData;

/**
* YES if uncaught exceptions should be reported automatically
* Delete persisted user data
*/
@property BOOL autoNotify __deprecated_msg("Use autoDetectErrors instead");

- (NSDictionary *_Nonnull)errorApiHeaders;
- (NSDictionary *_Nonnull)sessionApiHeaders;

@property(retain, nullable) NSString *codeBundleId;
@property(retain, nullable) NSString *notifierType;
- (void)deletePersistedUserData;

@end
Loading