2
0

Sentry SDK update to v5

This commit is contained in:
Maarten Billemont 2020-04-04 19:50:37 -04:00
parent 0405c1776c
commit b118bc4e9b
6 changed files with 83 additions and 57 deletions

View File

@ -3453,6 +3453,7 @@
DA5BFA42147E415C00F98B1E /* Resources */, DA5BFA42147E415C00F98B1E /* Resources */,
DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */, DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */,
4A87858EE3659604089E2F9F /* [CP] Embed Pods Frameworks */, 4A87858EE3659604089E2F9F /* [CP] Embed Pods Frameworks */,
DA3C4EB32439438B00A6C4A8 /* Upload Sentry dSYM */,
); );
buildRules = ( buildRules = (
); );
@ -3952,6 +3953,24 @@
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
DA3C4EB32439438B00A6C4A8 /* Upload Sentry dSYM */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Upload Sentry dSYM";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = "/bin/sh -e";
shellScript = "if hash sentry-cli 2>/dev/null; then\n if ! ERROR=$(SENTRY_ORG=lyndir SENTRY_PROJECT=masterpassword-ios sentry-cli upload-dif --log-level info \"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null); then\n echo >&2 \"warning: sentry-cli: $ERROR\"\n fi\nelse\n echo >&2 \"warning: sentry-cli not installed: try brew install getsentry/tools/sentry-cli\"\nfi\n";
};
DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */ = { DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -4505,10 +4524,6 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO; CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CODE_SIGN_ENTITLEMENTS = Source/iOS/MasterPassword.entitlements; CODE_SIGN_ENTITLEMENTS = Source/iOS/MasterPassword.entitlements;
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/iOS\"",
);
GCC_C_LANGUAGE_STANDARD = c11; GCC_C_LANGUAGE_STANDARD = c11;
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch"; GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
@ -4551,10 +4566,6 @@
CODE_SIGN_ENTITLEMENTS = Source/iOS/MasterPassword.entitlements; CODE_SIGN_ENTITLEMENTS = Source/iOS/MasterPassword.entitlements;
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
EXCLUDED_SOURCE_FILE_NAMES = libDCIntrospect.a; EXCLUDED_SOURCE_FILE_NAMES = libDCIntrospect.a;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/iOS\"",
);
GCC_C_LANGUAGE_STANDARD = c11; GCC_C_LANGUAGE_STANDARD = c11;
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch"; GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;

View File

@ -2428,6 +2428,7 @@
DAD9B5EE1762CA3A001835F9 /* Copy LoginHelper */, DAD9B5EE1762CA3A001835F9 /* Copy LoginHelper */,
DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */, DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */,
43E5966C8C236E86824DDADE /* [CP] Embed Pods Frameworks */, 43E5966C8C236E86824DDADE /* [CP] Embed Pods Frameworks */,
DA3C4EB2243941AE00A6C4A8 /* Upload Sentry dSYM */,
); );
buildRules = ( buildRules = (
); );
@ -2729,6 +2730,25 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MasterPassword-macOS/Pods-MasterPassword-macOS-frameworks.sh\"\n"; shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MasterPassword-macOS/Pods-MasterPassword-macOS-frameworks.sh\"\n";
showEnvVarsInLog = 0; showEnvVarsInLog = 0;
}; };
DA3C4EB2243941AE00A6C4A8 /* Upload Sentry dSYM */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 8;
files = (
);
inputFileListPaths = (
);
inputPaths = (
);
name = "Upload Sentry dSYM";
outputFileListPaths = (
);
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 1;
shellPath = "/bin/sh -e";
shellScript = "if hash sentry-cli 2>/dev/null; then\n if ! ERROR=$(SENTRY_ORG=lyndir SENTRY_PROJECT=masterpassword-macos sentry-cli upload-dif --log-level info \"$DWARF_DSYM_FOLDER_PATH\" 2>&1 >/dev/null); then\n echo >&2 \"warning: sentry-cli: $ERROR\"\n fi\nelse\n echo >&2 \"warning: sentry-cli not installed: try brew install getsentry/tools/sentry-cli\"\nfi\n";
showEnvVarsInLog = 0;
};
DA4EF9CB19FD4B600032ECB5 /* Run Script: genassets */ = { DA4EF9CB19FD4B600032ECB5 /* Run Script: genassets */ = {
isa = PBXShellScriptBuildPhase; isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647; buildActionMask = 2147483647;
@ -3342,10 +3362,6 @@
CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/Mac\"",
);
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch"; GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (
@ -3382,10 +3398,6 @@
CODE_SIGN_IDENTITY = "Mac Developer"; CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/Mac\"",
);
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch"; GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO; GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = ( HEADER_SEARCH_PATHS = (

View File

@ -73,7 +73,7 @@ static MPAppDelegate_Shared *instance;
- (void)setActiveUser:(MPUserEntity *)activeUser { - (void)setActiveUser:(MPUserEntity *)activeUser {
NSManagedObjectID *activeUserOID = activeUser.permanentObjectID; NSManagedObjectID *activeUserOID = activeUser.permanentObjectID;
if ([self.activeUserOID isEqualTo:activeUserOID]) if ([self.activeUserOID isEqual:activeUserOID])
return; return;
if (self.key) if (self.key)

View File

@ -40,11 +40,10 @@ __END_DECLS
err( message_ @"%@%@", ##__VA_ARGS__, __error && [message_ length]? @"\n": @"", [__error fullDescription]?: @"" ); \ err( message_ @"%@%@", ##__VA_ARGS__, __error && [message_ length]? @"\n": @"", [__error fullDescription]?: @"" ); \
\ \
if (__error && [[MPConfig get].sendInfo boolValue]) { \ if (__error && [[MPConfig get].sendInfo boolValue]) { \
SentryEvent *event = [[SentryEvent alloc] initWithLevel:kSentrySeverityError]; \ SentryEvent *event = [[SentryEvent alloc] initWithLevel:kSentryLevelError]; \
event.message = strf(@"%@: %@", message_, [__error localizedDescription]); \ event.message = strf(@"%@: %@", message_, [__error localizedDescription]); \
event.logger = @"MPError"; \ event.logger = @"MPError"; \
[SentryClient.sharedClient appendStacktraceToEvent:event]; \ [SentrySDK captureEvent:event]; \
[SentryClient.sharedClient sendEvent:event withCompletionHandler:nil]; \
} \ } \
__error; \ __error; \
}) })

View File

@ -75,42 +75,45 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
@try { @try {
// Sentry // Sentry
SentryClient.sharedClient = [[SentryClient alloc] initWithDsn:decrypt( sentryDSN ) didFailWithError:nil]; [SentrySDK initWithOptions:@{
@"dsn" : decrypt( sentryDSN ),
#ifdef DEBUG #ifdef DEBUG
SentryClient.sharedClient.environment = @"Development"; @"debug" : @(YES),
@"environment": @"Development",
#elif PUBLIC #elif PUBLIC
SentryClient.sharedClient.environment = @"Public"; @"debug" : @(NO),
@"environment": @"Public",
#else #else
SentryClient.sharedClient.environment = @"Private"; @"debug" : @(NO),
@"environment": @"Private",
#endif #endif
SentryClient.sharedClient.enabled = [MPMacConfig get].sendInfo; @"enabled" : [MPMacConfig get].sendInfo,
[SentryClient.sharedClient enableAutomaticBreadcrumbTracking]; }];
[SentryClient.sharedClient startCrashHandlerWithError:nil];
[[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) { [[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) {
PearlLogLevel level = PearlLogLevelWarn; PearlLogLevel level = PearlLogLevelWarn;
if ([[MPConfig get].sendInfo boolValue]) if ([[MPConfig get].sendInfo boolValue])
level = PearlLogLevelDebug; level = PearlLogLevelDebug;
if (message.level >= level) { if (message.level >= level) {
SentrySeverity sentryLevel = kSentrySeverityInfo; SentryLevel sentryLevel = kSentryLevelInfo;
switch (message.level) { switch (message.level) {
case PearlLogLevelTrace: case PearlLogLevelTrace:
sentryLevel = kSentrySeverityDebug; sentryLevel = kSentryLevelDebug;
break; break;
case PearlLogLevelDebug: case PearlLogLevelDebug:
sentryLevel = kSentrySeverityDebug; sentryLevel = kSentryLevelDebug;
break; break;
case PearlLogLevelInfo: case PearlLogLevelInfo:
sentryLevel = kSentrySeverityInfo; sentryLevel = kSentryLevelInfo;
break; break;
case PearlLogLevelWarn: case PearlLogLevelWarn:
sentryLevel = kSentrySeverityWarning; sentryLevel = kSentryLevelWarning;
break; break;
case PearlLogLevelError: case PearlLogLevelError:
sentryLevel = kSentrySeverityError; sentryLevel = kSentryLevelError;
break; break;
case PearlLogLevelFatal: case PearlLogLevelFatal:
sentryLevel = kSentrySeverityFatal; sentryLevel = kSentryLevelFatal;
break; break;
} }
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] initWithLevel:sentryLevel category:@"Pearl"]; SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] initWithLevel:sentryLevel category:@"Pearl"];
@ -118,7 +121,7 @@ static OSStatus MPHotKeyHander(EventHandlerCallRef nextHandler, EventRef theEven
breadcrumb.message = message.message; breadcrumb.message = message.message;
breadcrumb.timestamp = message.occurrence; breadcrumb.timestamp = message.occurrence;
breadcrumb.data = @{ @"file": message.fileName, @"line": @(message.lineNumber), @"function": message.function }; breadcrumb.data = @{ @"file": message.fileName, @"line": @(message.lineNumber), @"function": message.function };
[SentryClient.sharedClient.breadcrumbs addBreadcrumb:breadcrumb]; [SentrySDK addBreadcrumb:breadcrumb];
} }
return YES; return YES;

View File

@ -83,42 +83,45 @@ void mpw_log_sink_pearl(const MPLogEvent *record) {
@try { @try {
// Sentry // Sentry
SentryClient.sharedClient = [[SentryClient alloc] initWithDsn:decrypt( sentryDSN ) didFailWithError:nil]; [SentrySDK initWithOptions:@{
@"dsn" : decrypt( sentryDSN ),
#ifdef DEBUG #ifdef DEBUG
SentryClient.sharedClient.environment = @"Development"; @"debug" : @(YES),
@"environment": @"Development",
#elif PUBLIC #elif PUBLIC
SentryClient.sharedClient.environment = @"Public"; @"debug" : @(NO),
@"environment": @"Public",
#else #else
SentryClient.sharedClient.environment = @"Private"; @"debug" : @(NO),
@"environment": @"Private",
#endif #endif
SentryClient.sharedClient.enabled = [MPiOSConfig get].sendInfo; @"enabled" : [MPiOSConfig get].sendInfo,
[SentryClient.sharedClient enableAutomaticBreadcrumbTracking]; }];
[SentryClient.sharedClient startCrashHandlerWithError:nil];
[[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) { [[PearlLogger get] registerListener:^BOOL(PearlLogMessage *message) {
PearlLogLevel level = PearlLogLevelWarn; PearlLogLevel level = PearlLogLevelWarn;
if ([[MPConfig get].sendInfo boolValue]) if ([[MPConfig get].sendInfo boolValue])
level = PearlLogLevelDebug; level = PearlLogLevelDebug;
if (message.level >= level) { if (message.level >= level) {
SentrySeverity sentryLevel = kSentrySeverityInfo; SentryLevel sentryLevel = kSentryLevelInfo;
switch (message.level) { switch (message.level) {
case PearlLogLevelTrace: case PearlLogLevelTrace:
sentryLevel = kSentrySeverityDebug; sentryLevel = kSentryLevelNone;
break; break;
case PearlLogLevelDebug: case PearlLogLevelDebug:
sentryLevel = kSentrySeverityDebug; sentryLevel = kSentryLevelDebug;
break; break;
case PearlLogLevelInfo: case PearlLogLevelInfo:
sentryLevel = kSentrySeverityInfo; sentryLevel = kSentryLevelInfo;
break; break;
case PearlLogLevelWarn: case PearlLogLevelWarn:
sentryLevel = kSentrySeverityWarning; sentryLevel = kSentryLevelWarning;
break; break;
case PearlLogLevelError: case PearlLogLevelError:
sentryLevel = kSentrySeverityError; sentryLevel = kSentryLevelError;
break; break;
case PearlLogLevelFatal: case PearlLogLevelFatal:
sentryLevel = kSentrySeverityFatal; sentryLevel = kSentryLevelFatal;
break; break;
} }
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] initWithLevel:sentryLevel category:@"Pearl"]; SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] initWithLevel:sentryLevel category:@"Pearl"];
@ -126,7 +129,7 @@ void mpw_log_sink_pearl(const MPLogEvent *record) {
breadcrumb.message = message.message; breadcrumb.message = message.message;
breadcrumb.timestamp = message.occurrence; breadcrumb.timestamp = message.occurrence;
breadcrumb.data = @{ @"file": message.fileName, @"line": @(message.lineNumber), @"function": message.function }; breadcrumb.data = @{ @"file": message.fileName, @"line": @(message.lineNumber), @"function": message.function };
[SentryClient.sharedClient.breadcrumbs addBreadcrumb:breadcrumb]; [SentrySDK addBreadcrumb:breadcrumb];
} }
return YES; return YES;
@ -716,13 +719,11 @@ void mpw_log_sink_pearl(const MPLogEvent *record) {
#else #else
prefs[@"reviewedVersion"] = @(YES); prefs[@"reviewedVersion"] = @(YES);
#endif #endif
PearlMainQueueOperation( ^{
if (![[SentryClient.sharedClient.extra dictionaryWithValuesForKeys:prefs.allKeys] isEqualToDictionary:prefs]) { [SentrySDK configureScope:^(SentryScope *scope) {
NSMutableDictionary *extra = [SentryClient.sharedClient.extra mutableCopy]?: [NSMutableDictionary dictionary]; for (NSString *pref in prefs.allKeys)
[extra addEntriesFromDictionary:prefs]; [scope setExtraValue:prefs[pref] forKey:pref];
SentryClient.sharedClient.extra = extra; }];
}
} );
} }
else { else {
[Countly.sharedInstance cancelConsentForAllFeatures]; [Countly.sharedInstance cancelConsentForAllFeatures];