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 */,
DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */,
4A87858EE3659604089E2F9F /* [CP] Embed Pods Frameworks */,
DA3C4EB32439438B00A6C4A8 /* Upload Sentry dSYM */,
);
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";
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 */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@ -4505,10 +4524,6 @@
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = NO;
CODE_SIGN_ENTITLEMENTS = Source/iOS/MasterPassword.entitlements;
CODE_SIGN_STYLE = Manual;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/iOS\"",
);
GCC_C_LANGUAGE_STANDARD = c11;
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
@ -4551,10 +4566,6 @@
CODE_SIGN_ENTITLEMENTS = Source/iOS/MasterPassword.entitlements;
CODE_SIGN_STYLE = Manual;
EXCLUDED_SOURCE_FILE_NAMES = libDCIntrospect.a;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/iOS\"",
);
GCC_C_LANGUAGE_STANDARD = c11;
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;

View File

@ -2428,6 +2428,7 @@
DAD9B5EE1762CA3A001835F9 /* Copy LoginHelper */,
DA6556E314D55F3000841C99 /* Run Script: GIT version -> Info.plist */,
43E5966C8C236E86824DDADE /* [CP] Embed Pods Frameworks */,
DA3C4EB2243941AE00A6C4A8 /* Upload Sentry dSYM */,
);
buildRules = (
);
@ -2729,6 +2730,25 @@
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-MasterPassword-macOS/Pods-MasterPassword-macOS-frameworks.sh\"\n";
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 */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
@ -3342,10 +3362,6 @@
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/Mac\"",
);
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = (
@ -3382,10 +3398,6 @@
CODE_SIGN_IDENTITY = "Mac Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "Apple Development";
COMBINE_HIDPI_IMAGES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"\"$(SRCROOT)/External/Mac\"",
);
GCC_PREFIX_HEADER = "Source/MasterPassword-Prefix.pch";
GCC_WARN_ABOUT_DEPRECATED_FUNCTIONS = NO;
HEADER_SEARCH_PATHS = (

View File

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

View File

@ -40,11 +40,10 @@ __END_DECLS
err( message_ @"%@%@", ##__VA_ARGS__, __error && [message_ length]? @"\n": @"", [__error fullDescription]?: @"" ); \
\
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.logger = @"MPError"; \
[SentryClient.sharedClient appendStacktraceToEvent:event]; \
[SentryClient.sharedClient sendEvent:event withCompletionHandler:nil]; \
[SentrySDK captureEvent:event]; \
} \
__error; \
})

View File

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

View File

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