Skip to content

Commit

Permalink
Merge pull request #41 from MindscapeHQ/md/cr-258/update-report-for-r…
Browse files Browse the repository at this point in the history
…eact-native

[CR-258] Update the crash report property name for stack traces.
  • Loading branch information
mduncan26 authored Sep 6, 2020
2 parents 2c830de + a26373e commit e0f0efa
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 1.4.2
- Updated crash report property name for the stack trace
- Additional guards against the provider generating exceptions

## 1.4.1
- Prefixed KSCrash classes and methods to avoid conflicts with external sources
- The RaygunCrashReportConverter class is now public
Expand Down
2 changes: 1 addition & 1 deletion Sources/Raygun/RaygunDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
#define RAYGUN_CAN_USE_UIKIT 0
#endif

static NSString *_Nonnull const kRaygunClientVersion = @"1.4.1";
static NSString *_Nonnull const kRaygunClientVersion = @"1.4.2";

static NSString *_Nonnull const kRaygunIdentifierUserDefaultsKey = @"com.raygun.identifier";
static NSString *_Nonnull const kRaygunSessionLastSeenDefaultsKey = @"com.raygun.session.lastseen";
Expand Down
2 changes: 1 addition & 1 deletion Sources/Raygun/RaygunErrorMessage.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ - (NSDictionary *)convertToDictionary {
}

if (![RaygunUtils isNullOrEmpty:_stackTrace]) {
dict[@"managedStackTrace"] = _stackTrace;
dict[@"stackTrace"] = _stackTrace;
}

return dict;
Expand Down
76 changes: 50 additions & 26 deletions Sources/Raygun/RaygunLogger.m
Original file line number Diff line number Diff line change
Expand Up @@ -34,41 +34,65 @@
@implementation RaygunLogger

+ (void)logError:(NSString *)message, ... {
va_list args;
va_start(args, message);
NSString *formattedMessage = [[NSString alloc] initWithFormat:message arguments:args];
va_end(args);
[RaygunLogger log:formattedMessage withLevel:RaygunLoggingLevelError];
@try {
va_list args;
va_start(args, message);
NSString *formattedMessage = [[NSString alloc] initWithFormat:message arguments:args];
va_end(args);
[RaygunLogger log:formattedMessage withLevel:RaygunLoggingLevelError];
}
@catch (NSException *exception) {
// Ignore
}
}

+ (void)logWarning:(NSString *)message, ... {
va_list args;
va_start(args, message);
NSString *formattedMessage = [[NSString alloc] initWithFormat:message arguments:args];
va_end(args);
[RaygunLogger log:formattedMessage withLevel:RaygunLoggingLevelWarning];
@try {
va_list args;
va_start(args, message);
NSString *formattedMessage = [[NSString alloc] initWithFormat:message arguments:args];
va_end(args);
[RaygunLogger log:formattedMessage withLevel:RaygunLoggingLevelWarning];
}
@catch (NSException *exception) {
// Ignore
}
}

+ (void)logDebug:(NSString *)message, ... {
va_list args;
va_start(args, message);
NSString *formattedMessage = [[NSString alloc] initWithFormat:message arguments:args];
va_end(args);
[RaygunLogger log:formattedMessage withLevel:RaygunLoggingLevelDebug];
@try {
va_list args;
va_start(args, message);
NSString *formattedMessage = [[NSString alloc] initWithFormat:message arguments:args];
va_end(args);
[RaygunLogger log:formattedMessage withLevel:RaygunLoggingLevelDebug];
}
@catch (NSException *exception) {
// Ignore
}
}

+ (void)logResponseStatusCode:(NSInteger)statusCode {
NSString *message = [self ResponseStatusCodeMessage:statusCode];

switch ((RaygunResponseStatusCode)statusCode) {
case RaygunResponseStatusCodeAccepted: [self logDebug:message]; break;

case RaygunResponseStatusCodeBadMessage: // fall through
case RaygunResponseStatusCodeInvalidApiKey: // fall through
case RaygunResponseStatusCodeLargePayload: // fall through
case RaygunResponseStatusCodeRateLimited: [self logError:message]; break;

default: [self logDebug:message]; break;
@try {
NSString *message = [self ResponseStatusCodeMessage:statusCode];

switch ((RaygunResponseStatusCode)statusCode) {
case RaygunResponseStatusCodeAccepted: {
[self logDebug:message];
} break;

case RaygunResponseStatusCodeBadMessage: // fall through
case RaygunResponseStatusCodeInvalidApiKey: // fall through
case RaygunResponseStatusCodeLargePayload: // fall through
case RaygunResponseStatusCodeRateLimited: {
[self logError:message];
} break;

default: [self logDebug:message]; break;
}
}
@catch (NSException *exception) {
// Ignore
}
}

Expand Down
5 changes: 4 additions & 1 deletion Sources/Raygun/RaygunRealUserMonitoring.m
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,10 @@ - (void)sendTimingEvent:(enum RaygunEventTimingType)type withName:(NSString *)na
if (response != nil) {
@try {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse*)response;
[RaygunLogger logResponseStatusCode:httpResponse.statusCode];
if (httpResponse != nil)
{
[RaygunLogger logResponseStatusCode:httpResponse.statusCode];
}
}
@catch (NSException *exception) {
[RaygunLogger logError:@"Failed to read response code from API request"];
Expand Down
2 changes: 1 addition & 1 deletion raygun4apple.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'raygun4apple'
s.version = '1.4.1'
s.version = '1.4.2'
s.summary = 'Raygun client for Apple platforms'
s.homepage = 'https://raygun.com'
s.authors = { 'Raygun' => '[email protected]' }
Expand Down
4 changes: 2 additions & 2 deletions raygun4apple.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BITCODE_GENERATION_MODE = marker;
CURRENT_PROJECT_VERSION = 1.4.1;
CURRENT_PROJECT_VERSION = 1.4.2;
GCC_PREPROCESSOR_DEFINITIONS = "Raygun_KSLogger_Level=Raygun_KSLogger_Level_None";
OTHER_CFLAGS = "-fembed-bitcode-marker";
SDKROOT = iphoneos;
Expand All @@ -2132,7 +2132,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BITCODE_GENERATION_MODE = bitcode;
CURRENT_PROJECT_VERSION = 1.4.1;
CURRENT_PROJECT_VERSION = 1.4.2;
GCC_PREPROCESSOR_DEFINITIONS = "Raygun_KSLogger_Level=Raygun_KSLogger_Level_None";
OTHER_CFLAGS = "-fembed-bitcode";
SDKROOT = iphoneos;
Expand Down

0 comments on commit e0f0efa

Please sign in to comment.