-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature: Replaced Crashlytics with Sentry
Crash logging is now handled by the Sentry service. Signed-off-by: Christopher Snowhill <[email protected]>
- Loading branch information
Showing
20 changed files
with
224 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,9 @@ | |
|
||
#import "PreferencesController.h" | ||
|
||
@import Firebase; | ||
#import "FeedbackController.h" | ||
|
||
@import Sentry; | ||
|
||
void *kAppControllerContext = &kAppControllerContext; | ||
|
||
|
@@ -166,19 +168,14 @@ - (BOOL)application:(NSApplication *)sender delegateHandlesKey:(NSString *)key { | |
return [key isEqualToString:@"currentEntry"]; | ||
} | ||
|
||
static BOOL consentLastEnabled = NO; | ||
|
||
- (void)awakeFromNib { | ||
#if DEBUG | ||
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @(NO) }]; | ||
#else | ||
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"NSApplicationCrashOnExceptions": @(YES) }]; | ||
#endif | ||
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"crashlyticsConsented": @(NO), | ||
@"crashlyticsAskedConsent": @(NO) }]; | ||
|
||
[FIRApp configure]; | ||
|
||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.crashlyticsConsented" options:(NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew) context:kAppControllerContext]; | ||
[[NSUserDefaults standardUserDefaults] registerDefaults:@{ @"sentryConsented": @(NO), | ||
@"sentryAskedConsent": @(NO) }]; | ||
|
||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.sentryConsented" options:(NSKeyValueObservingOptionInitial | NSKeyValueObservingOptionNew) context:kAppControllerContext]; | ||
|
||
[[totalTimeField cell] setBackgroundStyle:NSBackgroundStyleRaised]; | ||
|
||
[self.infoButton setToolTip:NSLocalizedString(@"InfoButtonTooltip", @"")]; | ||
|
@@ -323,10 +320,45 @@ - (void)observeValueForKeyPath:(NSString *)keyPath | |
return; | ||
} | ||
|
||
if([keyPath isEqualToString:@"values.crashlyticsConsented"]) { | ||
BOOL enabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"crashlyticsConsented"]; | ||
[[FIRCrashlytics crashlytics] setCrashlyticsCollectionEnabled:enabled]; | ||
[FIRAnalytics setAnalyticsCollectionEnabled:enabled]; | ||
if([keyPath isEqualToString:@"values.sentryConsented"]) { | ||
BOOL enabled = [[NSUserDefaults standardUserDefaults] boolForKey:@"sentryConsented"]; | ||
if(enabled != consentLastEnabled) { | ||
if(enabled) { | ||
[SentrySDK startWithConfigureOptions:^(SentryOptions *options) { | ||
options.dsn = @"https://[email protected]/3"; | ||
options.debug = YES; // Enabled debug when first installing is always helpful | ||
|
||
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring. | ||
// We recommend adjusting this value in production. | ||
options.tracesSampleRate = @1.0; | ||
|
||
// Adds IP for users. | ||
// For more information, visit: https://docs.sentry.io/platforms/apple/data-management/data-collected/ | ||
options.sendDefaultPii = YES; | ||
|
||
// And now to set up user feedback prompting | ||
options.onCrashedLastRun = ^void(SentryEvent * _Nonnull event) { | ||
// capture user feedback | ||
FeedbackController *fbcon = [[FeedbackController alloc] init]; | ||
[fbcon performSelectorOnMainThread:@selector(showWindow:) withObject:nil waitUntilDone:YES]; | ||
if([fbcon waitForCompletion]) { | ||
SentryUserFeedback *userFeedback = [[SentryUserFeedback alloc] initWithEventId:[event eventId]]; | ||
|
||
userFeedback.comments = [fbcon comments]; | ||
userFeedback.email = [fbcon email]; | ||
userFeedback.name = [fbcon name]; | ||
|
||
[SentrySDK captureUserFeedback:userFeedback]; | ||
} | ||
}; | ||
}]; | ||
} else { | ||
if([SentrySDK isEnabled]) { | ||
[SentrySDK close]; | ||
} | ||
} | ||
consentLastEnabled = enabled; | ||
} | ||
} else if([keyPath isEqualToString:@"playlistController.currentEntry"]) { | ||
PlaylistEntry *entry = playlistController.currentEntry; | ||
NSString *appTitle = NSLocalizedString(@"CogTitle", @""); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.