From 032e86162cc110c2eb0904c26669ace12757d6a4 Mon Sep 17 00:00:00 2001 From: Robin Macharg Date: Tue, 24 Mar 2020 18:38:24 +0000 Subject: [PATCH] PR Feedback --- Source/BugsnagClient.m | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/Source/BugsnagClient.m b/Source/BugsnagClient.m index a36a2d29c..ae4b0a4a2 100644 --- a/Source/BugsnagClient.m +++ b/Source/BugsnagClient.m @@ -852,20 +852,28 @@ - (void)batteryChanged:(NSNotification *)notif { - (void)orientationChanged:(NSNotification *)notification { UIDeviceOrientation currentDeviceOrientation = [UIDevice currentDevice].orientation; NSString *orientation = BSGOrientationNameFromEnum(currentDeviceOrientation); - - // Short-circuit the exit if we don't have enough info to record a full breadcrumb - // or the orientation hasn't changed (false positive). + + // No orientation, nothing to be done if (!orientation) { return; } - else if (!_lastOrientation || [orientation isEqualToString:_lastOrientation]) { + + // Update the device orientation in metadata + [[self state] addAttribute:BSGKeyOrientation + withValue:orientation + toTabWithName:BSGKeyDeviceState]; + + // Short-circuit the exit if we don't have enough info to record a full breadcrumb + // or the orientation hasn't changed (false positive). + if (!_lastOrientation || [orientation isEqualToString:_lastOrientation]) { _lastOrientation = orientation; return; } - - [self sendBreadcrumbForOrientationChangeNotification:notification withOrientation:orientation]; - // Preserve the orientation + // We have an orientation, it's not a dupe and we have a lastOrientation. + // Send a breadcrumb and preserve the orientation. + [self sendBreadcrumbForOrientationChangeNotification:notification + withOrientation:orientation]; _lastOrientation = orientation; }