From 4656f4535071a11d098dcd914d67fd4cb2c2de7f Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Wed, 14 Sep 2022 10:45:15 -0800 Subject: [PATCH 01/54] test: generate graphs for benchmarks (#2158) --- scripts/process-benchmark-raw-results.py | 41 ++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/scripts/process-benchmark-raw-results.py b/scripts/process-benchmark-raw-results.py index 67d0b382110..0469b4b1916 100755 --- a/scripts/process-benchmark-raw-results.py +++ b/scripts/process-benchmark-raw-results.py @@ -3,6 +3,8 @@ import argparse import functools import math +import matplotlib.pyplot as plt +import subprocess import sys """A script to parse an XCUITest console log, extract raw benchmark values, and statistically analyze the SDK profiler's CPU overhead.""" @@ -10,6 +12,8 @@ def main(): parser = argparse.ArgumentParser(description=__doc__) parser.add_argument('log_file_path', help='Path to the log file to parse.') + parser.add_argument('device_class', help='The class of device the benchmarks were run on.') + parser.add_argument('device_name', help='The name of the actual device the benchmarks were run on.') args = parser.parse_args() def extract_values(line): @@ -24,6 +28,7 @@ def overhead(readings): return 100.0 * (int(readings[0]) + int(readings[1])) / (int(readings[2]) + int(readings[3])) percentages = [f'{y:.3f}' for y in sorted([overhead(x) for x in results])] + percentage_values = [y for y in sorted([overhead(x) for x in results])] count = len(percentages) middle_index = int(math.floor(count / 2)) @@ -31,8 +36,28 @@ def overhead(readings): mean = functools.reduce(lambda res, next: res + float(next), percentages, 0) / len(percentages) + p0 = percentages[0] + p0_value = percentage_values[0] + p90_index = math.ceil(len(percentages) * 0.9) p90 = percentages[p90_index - 1] + p90_value = percentage_values[p90_index - 1] + + p99_index = math.ceil(len(percentages) * 0.99) + p99 = percentages[p99_index - 1] + p99_value = percentage_values[p99_index - 1] + + p99_9_index = math.ceil(len(percentages) * 0.999) + p99_9 = percentages[p99_9_index - 1] + p99_9_value = percentage_values[p99_9_index - 1] + + p99_999_index = math.ceil(len(percentages) * 0.99999) + p99_999 = percentages[p99_999_index - 1] + p99_999_value = percentage_values[p99_999_index - 1] + + p99_99999_index = math.ceil(len(percentages) * 0.9999999) + p99_99999 = percentages[p99_99999_index - 1] + p99_99999_value = percentage_values[p99_99999_index - 1] print(f'''Benchmark report ---------------- @@ -41,9 +66,25 @@ def overhead(readings): Median: {median:.3f} Mean: {mean:.3f} +P0: {p0} P90: {p90} +P99: {p99} +P99.9: {p99_9} +P99.999: {p99_999} +P99.99999: {p99_99999} ''') + percentiles = [p0_value, p90_value, p99_value, p99_9_value, p99_999_value, p99_99999_value] + print(f"{percentiles=}") + plt.title(f'Cpu time increase percentage for {args.device_class} devices (run on {args.device_name})') + plt.plot(percentiles, marker='o') + plt.ylabel('Cpu time increase %') + plt.xlabel('Percentile') + plt.xticks(ticks=[0, 1, 2, 3, 4, 5], labels=['0%', '90%', '99%', '99.9%', '99.999%', '99.99999%']) + plt.grid(True) + filename = f'ios_benchmarks_{args.device_class}_{args.device_name}.png' + plt.savefig(filename) + subprocess.check_call(['open', filename]) if __name__ == '__main__': main() From aacfd57faebba0bd102910f5544c9f307d6e7282 Mon Sep 17 00:00:00 2001 From: Olivier Halligon Date: Wed, 14 Sep 2022 20:51:29 +0200 Subject: [PATCH 02/54] docs: fix PR reference in CHANGELOG (#2157) --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6f4cec7655c..7d865515fec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -563,7 +563,7 @@ For a detailed explanation how to upgrade please checkout the [migration guide] - ref: SentryEvent.timestamp changed to nullable. - ref: Add read-only scope property to Hub (#975) - ref: Remove SentryException.userReported (#974) -- ref: Replace SentryLogLevel with SentryLevel (#978) +- ref: Replace SentryLogLevel with SentryLevel (#979) - fix: Mark frames as inApp (#956) ### Features From fcd5c6e3ecf458c36aa04ed73c4612b11d228edb Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 15 Sep 2022 08:19:05 +0200 Subject: [PATCH 03/54] docs: Add a note on flaky tests to Contributing (#2161) --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8ffb292cca2..eb48be8c583 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,6 +51,10 @@ Test can either be ran inside from Xcode or via make test ``` +### Flaky tests + +If you see a test being flaky, you should ideally fix it immediately. If that's not feasible, you can disable the test in the test scheme, add a suffix _disabled to the test, so it's clear when looking at the test that it is disabled, and create a GH issue with the label flaky test. Disabling the test in the scheme has the advantage that the test report will state "X tests passed, Y tests failed, Z tests skipped". + ## Code Formatting Please follow the convention of removing the copyright code comments at the top of files. We only keep them inside [SentryCrash](/SentryCrash/), as the code is based on [KSCrash](https://github.com/kstenerud/KSCrash). From 1503071bd2732e487f99e106acaf5f8686fa8b1a Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 15 Sep 2022 08:19:16 +0200 Subject: [PATCH 04/54] Fix typos in changelog (#2153) --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d865515fec..5b4b0bbcc9a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -444,7 +444,7 @@ for ViewControllers, HTTP requests, app start and slow and frozen frames. - feat: Add breadcrumbs for HTTP requests (#1258) - feat: Add clearAttachments to Scope (#1195) - feat: Expose tracked screen frames (#1262) -- feat: Expose AppStartMeasurment for Hybrid SDKs (#1251) +- feat: Expose AppStartMeasurement for Hybrid SDKs (#1251) ### Fixes @@ -460,7 +460,7 @@ for ViewControllers, HTTP requests, app start and slow and frozen frames. ## 7.2.0-beta.9 - feat: Expose tracked screen frames (#1262) -- feat: Expose AppStartMeasurment for Hybrid SDKs (#1251) +- feat: Expose AppStartMeasurement for Hybrid SDKs (#1251) - fix: Span serialization HTTP data in wrong place. (#1255) - feat: Add tags to Sentry Span (#1243) From be275f395f0aea1fe0b163611979c2e44ed05eb1 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Thu, 15 Sep 2022 08:19:32 +0200 Subject: [PATCH 05/54] ref: Fix typo in measurement (#2154) --- Sources/Sentry/PrivateSentrySDKOnly.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Sources/Sentry/PrivateSentrySDKOnly.m b/Sources/Sentry/PrivateSentrySDKOnly.m index 13740a4b1df..2f32ebf2532 100644 --- a/Sources/Sentry/PrivateSentrySDKOnly.m +++ b/Sources/Sentry/PrivateSentrySDKOnly.m @@ -12,7 +12,7 @@ @implementation PrivateSentrySDKOnly -static SentryOnAppStartMeasurementAvailable _onAppStartMeasurmentAvailable; +static SentryOnAppStartMeasurementAvailable _onAppStartMeasurementAvailable; static BOOL _appStartMeasurementHybridSDKMode = NO; #if SENTRY_HAS_UIKIT static BOOL _framesTrackingMeasurementHybridSDKMode = NO; @@ -59,13 +59,13 @@ + (SentryOptions *)options + (SentryOnAppStartMeasurementAvailable)onAppStartMeasurementAvailable { - return _onAppStartMeasurmentAvailable; + return _onAppStartMeasurementAvailable; } + (void)setOnAppStartMeasurementAvailable: (SentryOnAppStartMeasurementAvailable)onAppStartMeasurementAvailable { - _onAppStartMeasurmentAvailable = onAppStartMeasurementAvailable; + _onAppStartMeasurementAvailable = onAppStartMeasurementAvailable; } + (BOOL)appStartMeasurementHybridSDKMode From 71a368ca384a8a0bbe70b30460416be808e1b1f4 Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Wed, 14 Sep 2022 23:31:29 -0800 Subject: [PATCH 06/54] meta: add macros for easier logging (#2163) Co-authored-by: Sentry Github Bot --- Sources/Sentry/include/SentryLog.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Sources/Sentry/include/SentryLog.h b/Sources/Sentry/include/SentryLog.h index 011110316e2..237e036f4a5 100644 --- a/Sources/Sentry/include/SentryLog.h +++ b/Sources/Sentry/include/SentryLog.h @@ -15,3 +15,14 @@ SENTRY_NO_INIT @end NS_ASSUME_NONNULL_END + +#define SENTRY_LOG_DEBUG(...) \ + [SentryLog logWithMessage:[NSString stringWithFormat:__VA_ARGS__] andLevel:kSentryLevelDebug] +#define SENTRY_LOG_INFO(...) \ + [SentryLog logWithMessage:[NSString stringWithFormat:__VA_ARGS__] andLevel:kSentryLevelInfo] +#define SENTRY_LOG_WARN(...) \ + [SentryLog logWithMessage:[NSString stringWithFormat:__VA_ARGS__] andLevel:kSentryLevelWarning] +#define SENTRY_LOG_ERROR(...) \ + [SentryLog logWithMessage:[NSString stringWithFormat:__VA_ARGS__] andLevel:kSentryLevelError] +#define SENTRY_LOG_CRITICAL(...) \ + [SentryLog logWithMessage:[NSString stringWithFormat:__VA_ARGS__] andLevel:kSentryLevelCritical] From 8c568faffd4828cb23c68bc3315f27fcaf44ef0a Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Thu, 15 Sep 2022 11:54:44 +0200 Subject: [PATCH 07/54] fix: Enable testCaptureMessage again (#2166) * fix: Enable testCaptureMessage again Locally it's 100% fine and I haven't seen this one come up in other PRs. Let's see what happens and if we can re-enable it. #skip-changelog * Trigger tests --- Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme | 3 --- 1 file changed, 3 deletions(-) diff --git a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme index 17a7718bd12..9629e068f43 100644 --- a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme +++ b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme @@ -55,9 +55,6 @@ ReferencedContainer = "container:Sentry.xcodeproj"> - - From c342413b8dfcd6058aa4111e22b2bce2542cd6f3 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Thu, 15 Sep 2022 14:24:11 +0200 Subject: [PATCH 08/54] ref: Use the new logging macros (#2170) * meta: use the new logging macros #skip-changelog * Fix missing quote --- Sources/Sentry/SentryANRTracker.m | 15 +-- Sources/Sentry/SentryAppStartTracker.m | 18 +-- .../SentryAppStartTrackingIntegration.m | 4 +- Sources/Sentry/SentryBaseIntegration.m | 4 +- Sources/Sentry/SentryBreadcrumbTracker.m | 13 +- Sources/Sentry/SentryClient.m | 20 ++- Sources/Sentry/SentryCoreDataTracker.m | 12 +- .../Sentry/SentryCrashInstallationReporter.m | 6 +- Sources/Sentry/SentryCrashReportConverter.m | 4 +- Sources/Sentry/SentryCrashReportSink.m | 12 +- Sources/Sentry/SentryCrashScopeObserver.m | 3 +- Sources/Sentry/SentryEnvelope.m | 35 +++--- Sources/Sentry/SentryFileManager.m | 60 +++------ Sources/Sentry/SentryHttpTransport.m | 3 +- Sources/Sentry/SentryHub.m | 25 ++-- Sources/Sentry/SentryNSDataTracker.m | 17 +-- Sources/Sentry/SentryNSURLRequest.m | 12 +- Sources/Sentry/SentryNetworkTracker.m | 3 +- .../Sentry/SentryNetworkTrackingIntegration.m | 5 +- Sources/Sentry/SentryOptions.m | 10 +- Sources/Sentry/SentryOutOfMemoryTracker.m | 3 +- Sources/Sentry/SentryPerformanceTracker.m | 3 +- .../SentryPerformanceTrackingIntegration.m | 4 +- Sources/Sentry/SentryProfiler.mm | 6 +- .../Sentry/SentryQueueableRequestManager.m | 4 +- Sources/Sentry/SentryRequestOperation.m | 47 +++---- Sources/Sentry/SentrySDK.m | 30 ++--- Sources/Sentry/SentryScope.m | 3 +- Sources/Sentry/SentrySerialization.m | 31 ++--- Sources/Sentry/SentrySessionTracker.m | 4 +- Sources/Sentry/SentryStacktrace.m | 3 +- Sources/Sentry/SentrySubClassFinder.m | 3 +- Sources/Sentry/SentrySystemEventBreadcrumbs.m | 12 +- Sources/Sentry/SentryTracer.m | 18 ++- .../Sentry/SentryUIViewControllerSwizzling.m | 115 +++++++----------- 35 files changed, 203 insertions(+), 364 deletions(-) diff --git a/Sources/Sentry/SentryANRTracker.m b/Sources/Sentry/SentryANRTracker.m index 4bbf4f0b567..c4446533237 100644 --- a/Sources/Sentry/SentryANRTracker.m +++ b/Sources/Sentry/SentryANRTracker.m @@ -65,7 +65,7 @@ - (void)detectANRs ticksSinceUiUpdate = 0; if (reported) { - [SentryLog logWithMessage:@"ANR stopped." andLevel:kSentryLevelWarning]; + SENTRY_LOG_WARN(@"ANR stopped."); [self ANRStopped]; } @@ -81,10 +81,8 @@ - (void)detectANRs [[self.currentDate date] timeIntervalSinceDate:blockDeadline]; if (deltaFromNowToBlockDeadline >= self.timeoutInterval) { - NSString *message = - [NSString stringWithFormat:@"Ignoring ANR because the delta is too big: %f.", - deltaFromNowToBlockDeadline]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"Ignoring ANR because the delta is too big: %f.", deltaFromNowToBlockDeadline); continue; } @@ -92,12 +90,11 @@ - (void)detectANRs reported = YES; if (![self.crashWrapper isApplicationInForeground]) { - [SentryLog logWithMessage:@"Ignoring ANR because the app is in the background" - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Ignoring ANR because the app is in the background"); continue; } - [SentryLog logWithMessage:@"ANR detected." andLevel:kSentryLevelWarning]; + SENTRY_LOG_WARN(@"ANR detected."); [self ANRDetected]; } } @@ -172,7 +169,7 @@ - (void)start - (void)stop { @synchronized(threadLock) { - [SentryLog logWithMessage:@"Stopping ANR detection" andLevel:kSentryLevelInfo]; + SENTRY_LOG_INFO(@"Stopping ANR detection"); [self.thread cancel]; running = NO; } diff --git a/Sources/Sentry/SentryAppStartTracker.m b/Sources/Sentry/SentryAppStartTracker.m index ab4347acc2f..e958678c2d1 100644 --- a/Sources/Sentry/SentryAppStartTracker.m +++ b/Sources/Sentry/SentryAppStartTracker.m @@ -120,24 +120,21 @@ - (void)buildAppStartMeasurement // Check if prewarm is available. Just to be safe to not drop app start data on earlier OS // verions. if ([self isActivePrewarmAvailable] && isActivePrewarm) { - [SentryLog logWithMessage:@"The app was prewarmed. Not measuring app start." - andLevel:kSentryLevelInfo]; + SENTRY_LOG_INFO(@"The app was prewarmed. Not measuring app start."); return; } SentryAppStartType appStartType = [self getStartType]; if (appStartType == SentryAppStartTypeUnknown) { - [SentryLog logWithMessage:@"Unknown start type. Not measuring app start." - andLevel:kSentryLevelWarning]; + SENTRY_LOG_WARN(@"Unknown start type. Not measuring app start."); return; } if (self.wasInBackground) { // If the app was already running in the background it's not a cold or warm // start. - [SentryLog logWithMessage:@"App was in background. Not measuring app start." - andLevel:kSentryLevelInfo]; + SENTRY_LOG_INFO(@"App was in background. Not measuring app start."); return; } @@ -157,12 +154,9 @@ - (void)buildAppStartMeasurement // Safety check to not report app starts that are completely off. if (appStartDuration >= SENTRY_APP_START_MAX_DURATION) { - NSString *message = [NSString - stringWithFormat: - @"The app start exceeded the max duration of %f seconds. Not measuring app " - @"start.", - SENTRY_APP_START_MAX_DURATION]; - [SentryLog logWithMessage:message andLevel:kSentryLevelInfo]; + SENTRY_LOG_INFO( + @"The app start exceeded the max duration of %f seconds. Not measuring app start.", + SENTRY_APP_START_MAX_DURATION); return; } diff --git a/Sources/Sentry/SentryAppStartTrackingIntegration.m b/Sources/Sentry/SentryAppStartTrackingIntegration.m index 561b497fa77..c1662b6e321 100644 --- a/Sources/Sentry/SentryAppStartTrackingIntegration.m +++ b/Sources/Sentry/SentryAppStartTrackingIntegration.m @@ -45,9 +45,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options return YES; #else - [SentryLog logWithMessage:@"NO UIKit -> SentryAppStartTracker will not track app start up time." - andLevel:kSentryLevelDebug]; - + SENTRY_LOG_DEBUG(@"NO UIKit -> SentryAppStartTracker will not track app start up time."); return NO; #endif } diff --git a/Sources/Sentry/SentryBaseIntegration.m b/Sources/Sentry/SentryBaseIntegration.m index f709f465156..f5a68a47137 100644 --- a/Sources/Sentry/SentryBaseIntegration.m +++ b/Sources/Sentry/SentryBaseIntegration.m @@ -26,9 +26,7 @@ - (void)logWithOptionName:(NSString *)optionName - (void)logWithReason:(NSString *)reason { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Not going to enable %@ %@.", - self.integrationName, reason] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Not going to enable %@ %@.", self.integrationName, reason); } - (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options diff --git a/Sources/Sentry/SentryBreadcrumbTracker.m b/Sources/Sentry/SentryBreadcrumbTracker.m index a39180d0d82..6022b4d18bb 100644 --- a/Sources/Sentry/SentryBreadcrumbTracker.m +++ b/Sources/Sentry/SentryBreadcrumbTracker.m @@ -70,9 +70,8 @@ - (void)trackApplicationUIKitNotifications // UIApplicationDidEnterBackgroundNotification NSNotificationName backgroundNotificationName = NSApplicationWillResignActiveNotification; #else - [SentryLog logWithMessage:@"NO UIKit, OSX and Catalyst -> [SentryBreadcrumbTracker " - @"trackApplicationUIKitNotifications] does nothing." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"NO UIKit, OSX and Catalyst -> [SentryBreadcrumbTracker " + @"trackApplicationUIKitNotifications] does nothing."); #endif // not available for macOS @@ -169,9 +168,7 @@ - (void)swizzleSendAction forKey:SentryBreadcrumbTrackerSwizzleSendAction]; #else - [SentryLog logWithMessage:@"NO UIKit -> [SentryBreadcrumbTracker " - @"swizzleSendAction] does nothing." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"NO UIKit -> [SentryBreadcrumbTracker swizzleSendAction] does nothing."); #endif } @@ -205,9 +202,7 @@ - (void)swizzleViewDidAppear SentrySwizzleModeOncePerClassAndSuperclasses, swizzleViewDidAppearKey); # pragma clang diagnostic pop #else - [SentryLog logWithMessage:@"NO UIKit -> [SentryBreadcrumbTracker " - @"swizzleViewDidAppear] does nothing." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"NO UIKit -> [SentryBreadcrumbTracker swizzleViewDidAppear] does nothing."); #endif } diff --git a/Sources/Sentry/SentryClient.m b/Sources/Sentry/SentryClient.m index f321256c813..3d112b74c3c 100644 --- a/Sources/Sentry/SentryClient.m +++ b/Sources/Sentry/SentryClient.m @@ -89,7 +89,7 @@ - (_Nullable instancetype)initWithOptions:(SentryOptions *)options andCurrentDateProvider:[SentryDefaultCurrentDateProvider sharedInstance] error:&error]; if (nil != error) { - [SentryLog logWithMessage:error.localizedDescription andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"%@", error.localizedDescription); return nil; } @@ -382,7 +382,7 @@ - (SentryId *)sendEvent:(SentryEvent *)event if (nil == session.releaseName || [session.releaseName length] == 0) { SentryTraceContext *traceContext = [self getTraceStateWithEvent:event withScope:scope]; - [SentryLog logWithMessage:DropSessionLogMessage andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(DropSessionLogMessage); [self.transportAdapter sendEvent:event traceContext:traceContext @@ -402,7 +402,7 @@ - (SentryId *)sendEvent:(SentryEvent *)event - (void)captureSession:(SentrySession *)session { if (nil == session.releaseName || [session.releaseName length] == 0) { - [SentryLog logWithMessage:DropSessionLogMessage andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(DropSessionLogMessage); return; } @@ -434,8 +434,7 @@ - (void)captureUserFeedback:(SentryUserFeedback *)userFeedback } if ([SentryId.empty isEqual:userFeedback.eventId]) { - [SentryLog logWithMessage:@"Capturing UserFeedback with an empty event id. Won't send it." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Capturing UserFeedback with an empty event id. Won't send it."); return; } @@ -482,8 +481,7 @@ - (SentryEvent *_Nullable)prepareEvent:(SentryEvent *)event // Transactions have their own sampleRate if (eventIsNotATransaction && [self isSampled:self.options.sampleRate]) { - [SentryLog logWithMessage:@"Event got sampled, will not send the event" - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Event got sampled, will not send the event"); [self recordLostEvent:kSentryDataCategoryError reason:kSentryDiscardReasonSampleRate]; return nil; } @@ -604,8 +602,7 @@ - (BOOL)isDisabled - (void)logDisabledMessage { - [SentryLog logWithMessage:@"SDK disabled or no DSN set. Won't do anyting." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SDK disabled or no DSN set. Won't do anyting."); } - (SentryEvent *_Nullable)callEventProcessors:(SentryEvent *)event @@ -615,9 +612,8 @@ - (SentryEvent *_Nullable)callEventProcessors:(SentryEvent *)event for (SentryEventProcessor processor in SentryGlobalEventProcessor.shared.processors) { newEvent = processor(newEvent); if (nil == newEvent) { - [SentryLog logWithMessage:@"SentryScope callEventProcessors: An event " - @"processor decided to remove this event." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SentryScope callEventProcessors: An event processor decided to " + @"remove this event."); break; } } diff --git a/Sources/Sentry/SentryCoreDataTracker.m b/Sources/Sentry/SentryCoreDataTracker.m index e420f93c8e7..28d58d9bef3 100644 --- a/Sources/Sentry/SentryCoreDataTracker.m +++ b/Sources/Sentry/SentryCoreDataTracker.m @@ -52,10 +52,8 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context [fetchSpan finishWithStatus:error != nil ? kSentrySpanStatusInternalError : kSentrySpanStatusOk]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"SentryCoreDataTracker automatically " - @"finished span with status: %@", - error == nil ? @"ok" : @"error"] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@", + error == nil ? @"ok" : @"error"); } return result; @@ -96,10 +94,8 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context [fetchSpan finishWithStatus:*error != nil ? kSentrySpanStatusInternalError : kSentrySpanStatusOk]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"SentryCoreDataTracker automatically " - @"finished span with status: %@", - *error == nil ? @"ok" : @"error"] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SentryCoreDataTracker automatically finished span with status: %@", + *error == nil ? @"ok" : @"error"); } return result; diff --git a/Sources/Sentry/SentryCrashInstallationReporter.m b/Sources/Sentry/SentryCrashInstallationReporter.m index c14ee63fbd9..8db49f69b85 100644 --- a/Sources/Sentry/SentryCrashInstallationReporter.m +++ b/Sources/Sentry/SentryCrashInstallationReporter.m @@ -39,11 +39,9 @@ - (void)sendAllReportsWithCompletion:(SentryCrashReportFilterCompletion)onComple [super sendAllReportsWithCompletion:^(NSArray *filteredReports, BOOL completed, NSError *error) { if (nil != error) { - [SentryLog logWithMessage:error.localizedDescription andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"%@", error.localizedDescription); } - [SentryLog logWithMessage:[NSString stringWithFormat:@"Sent %lu crash report(s)", - (unsigned long)filteredReports.count] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Sent %lu crash report(s)", (unsigned long)filteredReports.count); if (completed && onCompletion) { onCompletion(filteredReports, completed, error); } diff --git a/Sources/Sentry/SentryCrashReportConverter.m b/Sources/Sentry/SentryCrashReportConverter.m index e9f961c37fe..2de9cac42fd 100644 --- a/Sources/Sentry/SentryCrashReportConverter.m +++ b/Sources/Sentry/SentryCrashReportConverter.m @@ -141,9 +141,7 @@ - (SentryEvent *_Nullable)convertReportToEvent return event; } @catch (NSException *exception) { - NSString *errorMessage = - [NSString stringWithFormat:@"Could not convert report:%@", exception.description]; - [SentryLog logWithMessage:errorMessage andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Could not convert report:%@", exception.description); } return nil; } diff --git a/Sources/Sentry/SentryCrashReportSink.m b/Sources/Sentry/SentryCrashReportSink.m index a82a6683e12..af3300f1482 100644 --- a/Sources/Sentry/SentryCrashReportSink.m +++ b/Sources/Sentry/SentryCrashReportSink.m @@ -62,13 +62,11 @@ - (void)filterReports:(NSArray *)reports [self handleConvertedEvent:event report:report sentReports:sentReports]; } } else { - [SentryLog logWithMessage:@"Crash reports were found but no " - @"[SentrySDK.currentHub getClient] is set. Cannot send " - @"crash reports to Sentry. This is probably a " - @"misconfiguration, make sure you set the client with " - @"[SentrySDK.currentHub bindClient] before calling " - @"startCrashHandlerWithError:." - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR( + @"Crash reports were found but no [SentrySDK.currentHub getClient] is set. " + @"Cannot send crash reports to Sentry. This is probably a misconfiguration, " + @"make sure you set the client with [SentrySDK.currentHub bindClient] before " + @"calling startCrashHandlerWithError:."); } } if (onCompletion) { diff --git a/Sources/Sentry/SentryCrashScopeObserver.m b/Sources/Sentry/SentryCrashScopeObserver.m index e7ffef45896..2c609667794 100644 --- a/Sources/Sentry/SentryCrashScopeObserver.m +++ b/Sources/Sentry/SentryCrashScopeObserver.m @@ -156,8 +156,7 @@ - (nullable NSData *)toJSONEncodedCString:(id)toSerialize options:SentryCrashJSONEncodeOptionSorted error:&error]; if (error != nil) { - NSString *message = [NSString stringWithFormat:@"Could not serialize %@", error]; - [SentryLog logWithMessage:message andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Could not serialize %@", error); return nil; } } diff --git a/Sources/Sentry/SentryEnvelope.m b/Sources/Sentry/SentryEnvelope.m index 93149553dcd..4389ea8e57e 100644 --- a/Sources/Sentry/SentryEnvelope.m +++ b/Sources/Sentry/SentryEnvelope.m @@ -140,7 +140,7 @@ - (instancetype)initWithUserFeedback:(SentryUserFeedback *)userFeedback error:&error]; if (nil != error) { - [SentryLog logWithMessage:@"Couldn't serialize user feedback." andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Couldn't serialize user feedback."); json = [NSData new]; } @@ -158,7 +158,7 @@ - (instancetype)initWithClientReport:(SentryClientReport *)clientReport error:&error]; if (nil != error) { - [SentryLog logWithMessage:@"Couldn't serialize client report." andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Couldn't serialize client report."); json = [NSData new]; } @@ -174,14 +174,11 @@ - (_Nullable instancetype)initWithAttachment:(SentryAttachment *)attachment NSData *data = nil; if (nil != attachment.data) { if (attachment.data.length > maxAttachmentSize) { - NSString *message = - [NSString stringWithFormat:@"Dropping attachment with filename '%@', because the " - @"size of the passed data with %lu bytes is bigger than " - @"the maximum allowed attachment size of %lu bytes.", - attachment.filename, (unsigned long)attachment.data.length, - (unsigned long)maxAttachmentSize]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; - + SENTRY_LOG_DEBUG( + @"Dropping attachment with filename '%@', because the size of the passed data with " + @"%lu bytes is bigger than the maximum allowed attachment size of %lu bytes.", + attachment.filename, (unsigned long)attachment.data.length, + (unsigned long)maxAttachmentSize); return nil; } @@ -194,10 +191,8 @@ - (_Nullable instancetype)initWithAttachment:(SentryAttachment *)attachment [fileManager attributesOfItemAtPath:attachment.path error:&error]; if (nil != error) { - NSString *message = [NSString - stringWithFormat:@"Couldn't check file size of attachment with path: %@. Error: %@", - attachment.path, error.localizedDescription]; - [SentryLog logWithMessage:message andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Couldn't check file size of attachment with path: %@. Error: %@", + attachment.path, error.localizedDescription); return nil; } @@ -205,12 +200,10 @@ - (_Nullable instancetype)initWithAttachment:(SentryAttachment *)attachment unsigned long long fileSize = [attr fileSize]; if (fileSize > maxAttachmentSize) { - NSString *message = [NSString - stringWithFormat: - @"Dropping attachment, because the size of the it located at '%@' with %llu " - @"bytes is bigger than the maximum allowed attachment size of %lu bytes.", - attachment.path, fileSize, (unsigned long)maxAttachmentSize]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"Dropping attachment, because the size of the it located at '%@' with %llu bytes " + @"is bigger than the maximum allowed attachment size of %lu bytes.", + attachment.path, fileSize, (unsigned long)maxAttachmentSize); return nil; } @@ -218,7 +211,7 @@ - (_Nullable instancetype)initWithAttachment:(SentryAttachment *)attachment } if (nil == data) { - [SentryLog logWithMessage:@"Couldn't init Attachment." andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Couldn't init Attachment."); return nil; } diff --git a/Sources/Sentry/SentryFileManager.m b/Sources/Sentry/SentryFileManager.m index dbe24b851d8..02d3f725dd3 100644 --- a/Sources/Sentry/SentryFileManager.m +++ b/Sources/Sentry/SentryFileManager.m @@ -182,9 +182,7 @@ - (BOOL)removeFileAtPath:(NSString *)path @synchronized(self) { [fileManager removeItemAtPath:path error:&error]; if (nil != error) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Couldn't delete file %@: %@", - path, error] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Couldn't delete file %@: %@", path, error); return NO; } } @@ -243,10 +241,8 @@ - (void)handleEnvelopesLimit [self removeFileAtPath:envelopeFilePath]; } - [SentryLog logWithMessage:[NSString stringWithFormat:@"Removed %ld file(s) from <%@>", - (long)numberOfEnvelopesToRemove, - [self.envelopesPath lastPathComponent]] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Removed %ld file(s) from <%@>", (long)numberOfEnvelopesToRemove, + [self.envelopesPath lastPathComponent]); } - (void)storeCurrentSession:(SentrySession *)session @@ -262,8 +258,7 @@ - (void)storeCrashedSession:(SentrySession *)session - (void)storeSession:(SentrySession *)session sessionFilePath:(NSString *)sessionFilePath { NSData *sessionData = [SentrySerialization dataWithSession:session error:nil]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"Writing session: %@", sessionFilePath] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Writing session: %@", sessionFilePath); @synchronized(self.currentSessionFilePath) { [sessionData writeToFile:sessionFilePath options:NSDataWritingAtomic error:nil]; } @@ -281,8 +276,7 @@ - (void)deleteCrashedSession - (void)deleteSession:(NSString *)sessionFilePath { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Deleting session: %@", sessionFilePath] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Deleting session: %@", sessionFilePath); NSFileManager *fileManager = [NSFileManager defaultManager]; @synchronized(self.currentSessionFilePath) { [fileManager removeItemAtPath:sessionFilePath error:nil]; @@ -314,10 +308,8 @@ - (nullable SentrySession *)readSession:(NSString *)sessionFilePath } SentrySession *currentSession = [SentrySerialization sessionWithData:currentData]; if (nil == currentSession) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Data stored in session: " - @"'%@' was not parsed as session.", - sessionFilePath] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR( + @"Data stored in session: '%@' was not parsed as session.", sessionFilePath); return nil; } return currentSession; @@ -326,9 +318,7 @@ - (nullable SentrySession *)readSession:(NSString *)sessionFilePath - (void)storeTimestampLastInForeground:(NSDate *)timestamp { NSString *timestampString = [timestamp sentry_toIso8601String]; - NSString *logMessage = - [NSString stringWithFormat:@"Persisting lastInForeground: %@", timestampString]; - [SentryLog logWithMessage:logMessage andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Persisting lastInForeground: %@", timestampString); @synchronized(self.lastInForegroundFilePath) { [[timestampString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:self.lastInForegroundFilePath @@ -339,9 +329,7 @@ - (void)storeTimestampLastInForeground:(NSDate *)timestamp - (void)deleteTimestampLastInForeground { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Deleting LastInForeground at: %@", - self.lastInForegroundFilePath] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Deleting LastInForeground at: %@", self.lastInForegroundFilePath); NSFileManager *fileManager = [NSFileManager defaultManager]; @synchronized(self.lastInForegroundFilePath) { [fileManager removeItemAtPath:self.lastInForegroundFilePath error:nil]; @@ -350,17 +338,15 @@ - (void)deleteTimestampLastInForeground - (NSDate *_Nullable)readTimestampLastInForeground { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Reading timestamp of last " - @"in foreground at: %@", - self.lastInForegroundFilePath] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"Reading timestamp of last in foreground at: %@", self.lastInForegroundFilePath); NSFileManager *fileManager = [NSFileManager defaultManager]; NSData *lastInForegroundData = nil; @synchronized(self.lastInForegroundFilePath) { lastInForegroundData = [fileManager contentsAtPath:self.lastInForegroundFilePath]; } if (nil == lastInForegroundData) { - [SentryLog logWithMessage:@"No lastInForeground found." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"No lastInForeground found."); return nil; } NSString *timestampString = [[NSString alloc] initWithData:lastInForegroundData @@ -372,8 +358,7 @@ - (NSString *)storeData:(NSData *)data toPath:(NSString *)path { @synchronized(self) { NSString *finalPath = [path stringByAppendingPathComponent:[self uniqueAcendingJsonName]]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"Writing to file: %@", finalPath] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Writing to file: %@", finalPath); [data writeToFile:finalPath options:NSDataWritingAtomic error:nil]; return finalPath; } @@ -393,10 +378,8 @@ - (void)storeAppState:(SentryAppState *)appState NSData *data = [SentrySerialization dataWithJSONObject:[appState serialize] error:&error]; if (nil != error) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Failed to store app state, because " - @"of an error in serialization: %@", - error] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR( + @"Failed to store app state, because of an error in serialization: %@", error); return; } @@ -441,14 +424,14 @@ - (void)deleteAppState - (NSNumber *_Nullable)readTimezoneOffset { - [SentryLog logWithMessage:@"Reading timezone offset" andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Reading timezone offset"); NSFileManager *fileManager = [NSFileManager defaultManager]; NSData *timezoneOffsetData = nil; @synchronized(self.timezoneOffsetFilePath) { timezoneOffsetData = [fileManager contentsAtPath:self.timezoneOffsetFilePath]; } if (nil == timezoneOffsetData) { - [SentryLog logWithMessage:@"No timezone offset found." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"No timezone offset found."); return nil; } NSString *timezoneOffsetString = [[NSString alloc] initWithData:timezoneOffsetData @@ -464,9 +447,7 @@ - (void)storeTimezoneOffset:(NSInteger)offset { NSError *error = nil; NSString *timezoneOffsetString = [NSString stringWithFormat:@"%zd", offset]; - NSString *logMessage = - [NSString stringWithFormat:@"Persisting timezone offset: %@", timezoneOffsetString]; - [SentryLog logWithMessage:logMessage andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Persisting timezone offset: %@", timezoneOffsetString); @synchronized(self.timezoneOffsetFilePath) { [[timezoneOffsetString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:self.timezoneOffsetFilePath @@ -474,10 +455,7 @@ - (void)storeTimezoneOffset:(NSInteger)offset error:&error]; if (error != nil) { - [SentryLog - logWithMessage:[NSString - stringWithFormat:@"Failed to store timezone offset: %@", error] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Failed to store timezone offset: %@", error); } } } diff --git a/Sources/Sentry/SentryHttpTransport.m b/Sources/Sentry/SentryHttpTransport.m index f123ead5030..c8ef20b62ab 100644 --- a/Sources/Sentry/SentryHttpTransport.m +++ b/Sources/Sentry/SentryHttpTransport.m @@ -79,8 +79,7 @@ - (void)sendEnvelope:(SentryEnvelope *)envelope envelope = [self.envelopeRateLimit removeRateLimitedItems:envelope]; if (envelope.items.count == 0) { - [SentryLog logWithMessage:@"RateLimit is active for all envelope items." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"RateLimit is active for all envelope items."); return; } diff --git a/Sources/Sentry/SentryHub.m b/Sources/Sentry/SentryHub.m index cde4543239f..d5dafe8de98 100644 --- a/Sources/Sentry/SentryHub.m +++ b/Sources/Sentry/SentryHub.m @@ -122,8 +122,7 @@ - (void)endSessionWithTimestamp:(NSDate *)timestamp } if (nil == currentSession) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"No session to end with timestamp."] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"No session to end with timestamp."); return; } @@ -146,15 +145,15 @@ - (void)closeCachedSessionWithTimestamp:(nullable NSDate *)timestamp SentryFileManager *fileManager = [_client fileManager]; SentrySession *session = [fileManager readCurrentSession]; if (nil == session) { - [SentryLog logWithMessage:@"No cached session to close." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"No cached session to close."); return; } - [SentryLog logWithMessage:@"A cached session was found." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"A cached session was found."); // Make sure there's a client bound. SentryClient *client = _client; if (nil == client) { - [SentryLog logWithMessage:@"No client bound." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"No client bound."); return; } @@ -162,17 +161,13 @@ - (void)closeCachedSessionWithTimestamp:(nullable NSDate *)timestamp // out more. if (!self.crashWrapper.crashedLastLaunch) { if (nil == timestamp) { - [SentryLog - logWithMessage:[NSString stringWithFormat:@"No timestamp to close session " - @"was provided. Closing as abnormal. " - "Using session's start time %@", - session.started] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"No timestamp to close session was provided. Closing as abnormal. " + @"Using session's start time %@", + session.started); timestamp = session.started; [session endSessionAbnormalWithTimestamp:timestamp]; } else { - [SentryLog logWithMessage:@"Closing cached session as exited." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Closing cached session as exited."); [session endSessionExitedWithTimestamp:timestamp]; } [self deleteCurrentSession]; @@ -494,9 +489,7 @@ - (void)addBreadcrumb:(SentryBreadcrumb *)crumb crumb = callback(crumb); } if (nil == crumb) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Discarded Breadcrumb " - @"in `beforeBreadcrumb`"] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Discarded Breadcrumb in `beforeBreadcrumb`"); return; } [self.scope addBreadcrumb:crumb]; diff --git a/Sources/Sentry/SentryNSDataTracker.m b/Sources/Sentry/SentryNSDataTracker.m index 2c4eb875707..43a492847a6 100644 --- a/Sources/Sentry/SentryNSDataTracker.m +++ b/Sources/Sentry/SentryNSDataTracker.m @@ -163,17 +163,13 @@ - (NSData *)measureNSDataFromURL:(NSURL *)url }]; if (ioSpan == nil) { - [SentryLog logWithMessage:@"No transaction bound to scope. Won't track file IO operation." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"No transaction bound to scope. Won't track file IO operation."); return nil; } - [SentryLog - logWithMessage: - [NSString stringWithFormat:@"SentryNSDataTracker automatically " - @"started a new span with description: %@, operation: %@", - ioSpan.description, operation] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"SentryNSDataTracker automatically started a new span with description: %@, operation: %@", + ioSpan.description, operation); [ioSpan setDataValue:path forKey:@"file.path"]; @@ -221,10 +217,7 @@ - (void)finishTrackingNSData:(NSData *)data span:(id)span [span setDataValue:[NSNumber numberWithUnsignedInteger:data.length] forKey:@"file.size"]; [span finish]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"SentryNSDataTracker automatically " - @"finished span %@", - span.description] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SentryNSDataTracker automatically finished span %@", span.description); } - (BOOL)ignoreFile:(NSString *)path diff --git a/Sources/Sentry/SentryNSURLRequest.m b/Sources/Sentry/SentryNSURLRequest.m index b9ce1ac6b16..7cb40d722a1 100644 --- a/Sources/Sentry/SentryNSURLRequest.m +++ b/Sources/Sentry/SentryNSURLRequest.m @@ -41,14 +41,10 @@ - (_Nullable instancetype)initStoreRequestWithDsn:(SentryDsn *)dsn } if ([SentrySDK.currentHub getClient].options.debug == YES) { - [SentryLog logWithMessage:@"Sending JSON -------------------------------" - andLevel:kSentryLevelDebug]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"%@", - [[NSString alloc] initWithData:jsonData - encoding:NSUTF8StringEncoding]] - andLevel:kSentryLevelDebug]; - [SentryLog logWithMessage:@"--------------------------------------------" - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Sending JSON -------------------------------"); + SENTRY_LOG_DEBUG( + @"%@", [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]); + SENTRY_LOG_DEBUG(@"--------------------------------------------"); } return [self initStoreRequestWithDsn:dsn andData:jsonData didFailWithError:error]; } diff --git a/Sources/Sentry/SentryNetworkTracker.m b/Sources/Sentry/SentryNetworkTracker.m index 78d546f3bec..e7ebafb8f14 100644 --- a/Sources/Sentry/SentryNetworkTracker.m +++ b/Sources/Sentry/SentryNetworkTracker.m @@ -188,8 +188,7 @@ - (void)urlSessionTask:(NSURLSessionTask *)sessionTask setState:(NSURLSessionTas [netSpan setDataValue:@"fetch" forKey:@"type"]; [netSpan finishWithStatus:[self statusForSessionTask:sessionTask state:newState]]; - [SentryLog logWithMessage:@"SentryNetworkTracker finished HTTP span for sessionTask" - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SentryNetworkTracker finished HTTP span for sessionTask"); } - (void)addBreadcrumbForSessionTask:(NSURLSessionTask *)sessionTask diff --git a/Sources/Sentry/SentryNetworkTrackingIntegration.m b/Sources/Sentry/SentryNetworkTrackingIntegration.m index eeff63ab3c4..aa0850beb29 100644 --- a/Sources/Sentry/SentryNetworkTrackingIntegration.m +++ b/Sources/Sentry/SentryNetworkTrackingIntegration.m @@ -90,9 +90,8 @@ + (void)swizzleNSURLSessionConfiguration Method method = class_getInstanceMethod(classToSwizzle, selector); if (method == nil) { - [SentryLog logWithMessage:@"SentryNetworkSwizzling: Didn't find HTTPAdditionalHeaders on " - @"NSURLSessionConfiguration. Won't add Sentry Trace HTTP headers." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SentryNetworkSwizzling: Didn't find HTTPAdditionalHeaders on " + @"NSURLSessionConfiguration. Won't add Sentry Trace HTTP headers."); return; } diff --git a/Sources/Sentry/SentryOptions.m b/Sources/Sentry/SentryOptions.m index 08bc02677d3..e4445e1e11f 100644 --- a/Sources/Sentry/SentryOptions.m +++ b/Sources/Sentry/SentryOptions.m @@ -128,10 +128,9 @@ - (_Nullable instancetype)initWithDict:(NSDictionary *)options - (void)setIntegrations:(NSArray *)integrations { - [SentryLog logWithMessage: - @"Setting `SentryOptions.integrations` is deprecated. Integrations should be " - @"enabled or disabled using their respective `SentryOptions.enable*` property." - andLevel:kSentryLevelWarning]; + SENTRY_LOG_WARN( + @"Setting `SentryOptions.integrations` is deprecated. Integrations should be enabled or " + @"disabled using their respective `SentryOptions.enable*` property."); _integrations = integrations; } @@ -143,8 +142,7 @@ - (void)setDsn:(NSString *)dsn if (nil == error) { _dsn = dsn; } else { - NSString *errorMessage = [NSString stringWithFormat:@"Could not parse the DSN: %@.", error]; - [SentryLog logWithMessage:errorMessage andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Could not parse the DSN: %@.", error); } } diff --git a/Sources/Sentry/SentryOutOfMemoryTracker.m b/Sources/Sentry/SentryOutOfMemoryTracker.m index ca84947797a..c19d1331c2d 100644 --- a/Sources/Sentry/SentryOutOfMemoryTracker.m +++ b/Sources/Sentry/SentryOutOfMemoryTracker.m @@ -96,8 +96,7 @@ - (void)start }]; #else - [SentryLog logWithMessage:@"NO UIKit -> SentryOutOfMemoryTracker will not track OOM." - andLevel:kSentryLevelInfo]; + SENTRY_LOG_INFO(@"NO UIKit -> SentryOutOfMemoryTracker will not track OOM."); return; #endif } diff --git a/Sources/Sentry/SentryPerformanceTracker.m b/Sources/Sentry/SentryPerformanceTracker.m index 5861dc0a863..520f5b74b3e 100644 --- a/Sources/Sentry/SentryPerformanceTracker.m +++ b/Sources/Sentry/SentryPerformanceTracker.m @@ -81,8 +81,7 @@ - (SentrySpanId *)startSpanWithName:(NSString *)name operation:(NSString *)opera self.spans[spanId] = newSpan; } } else { - [SentryLog logWithMessage:@"startSpanWithName:operation: spanId is nil." - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"startSpanWithName:operation: spanId is nil."); return [SentrySpanId empty]; } diff --git a/Sources/Sentry/SentryPerformanceTrackingIntegration.m b/Sources/Sentry/SentryPerformanceTrackingIntegration.m index 2ea01f8be96..c15122d8593 100644 --- a/Sources/Sentry/SentryPerformanceTrackingIntegration.m +++ b/Sources/Sentry/SentryPerformanceTrackingIntegration.m @@ -42,9 +42,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options [self.swizzling start]; return YES; #else - [SentryLog logWithMessage:@"NO UIKit -> [SentryPerformanceTrackingIntegration " - @"start] does nothing." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"NO UIKit -> [SentryPerformanceTrackingIntegration start] does nothing."); return NO; #endif } diff --git a/Sources/Sentry/SentryProfiler.mm b/Sources/Sentry/SentryProfiler.mm index 86dd4b29603..de58a0802f6 100644 --- a/Sources/Sentry/SentryProfiler.mm +++ b/Sources/Sentry/SentryProfiler.mm @@ -105,8 +105,7 @@ @implementation SentryProfiler { - (instancetype)init { if (![NSThread isMainThread]) { - [SentryLog logWithMessage:@"SentryProfiler must be initialized on the main thread" - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"SentryProfiler must be initialized on the main thread"); return nil; } if (self = [super init]) { @@ -123,8 +122,7 @@ - (void)start // https://github.com/envoyproxy/envoy/issues/2561 # if defined(__has_feature) # if __has_feature(thread_sanitizer) - [SentryLog logWithMessage:@"Disabling profiling when running with TSAN" - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Disabling profiling when running with TSAN"); return; # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wunreachable-code" diff --git a/Sources/Sentry/SentryQueueableRequestManager.m b/Sources/Sentry/SentryQueueableRequestManager.m index be5918516cb..fada462bca0 100644 --- a/Sources/Sentry/SentryQueueableRequestManager.m +++ b/Sources/Sentry/SentryQueueableRequestManager.m @@ -39,9 +39,7 @@ - (void)addRequest:(NSURLRequest *)request initWithSession:self.session request:request completionHandler:^(NSHTTPURLResponse *_Nullable response, NSError *_Nullable error) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Queued requests: %@", - @(self.queue.operationCount - 1)] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Queued requests: %@", @(self.queue.operationCount - 1)); if (completionHandler) { completionHandler(response, error); } diff --git a/Sources/Sentry/SentryRequestOperation.m b/Sources/Sentry/SentryRequestOperation.m index c6324f924c4..5ed3ac6be80 100644 --- a/Sources/Sentry/SentryRequestOperation.m +++ b/Sources/Sentry/SentryRequestOperation.m @@ -24,37 +24,30 @@ - (instancetype)initWithSession:(NSURLSession *)session self = [super init]; if (self) { self.request = request; - self.task = [session - dataTaskWithRequest:self.request - completionHandler:^(NSData *_Nullable data, NSURLResponse *_Nullable response, - NSError *_Nullable error) { - NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; - NSInteger statusCode = [httpResponse statusCode]; + self.task = [session dataTaskWithRequest:self.request + completionHandler:^(NSData *_Nullable data, + NSURLResponse *_Nullable response, NSError *_Nullable error) { + NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; + NSInteger statusCode = [httpResponse statusCode]; - // We only have these if's here because of performance reasons - [SentryLog logWithMessage:[NSString stringWithFormat:@"Request status: %ld", - (long)statusCode] - andLevel:kSentryLevelDebug]; - if ([SentrySDK.currentHub getClient].options.debug == YES) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Request response: %@", - [[NSString alloc] - initWithData:data - encoding:NSUTF8StringEncoding]] - andLevel:kSentryLevelDebug]; - } + // We only have these if's here because of performance reasons + SENTRY_LOG_DEBUG(@"Request status: %ld", (long)statusCode); + if ([SentrySDK.currentHub getClient].options.debug == YES) { + SENTRY_LOG_DEBUG(@"Request response: %@", + [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]); + } - if (nil != error) { - [SentryLog - logWithMessage:[NSString stringWithFormat:@"Request failed: %@", error] - andLevel:kSentryLevelError]; - } + if (nil != error) { + SENTRY_LOG_ERROR(@"Request failed: %@", error); + } - if (completionHandler) { - completionHandler(httpResponse, error); - } + if (completionHandler) { + completionHandler(httpResponse, error); + } - [self completeOperation]; - }]; + [self completeOperation]; + }]; } return self; } diff --git a/Sources/Sentry/SentrySDK.m b/Sources/Sentry/SentrySDK.m index 185c43c578b..a7b2a6f719b 100644 --- a/Sources/Sentry/SentrySDK.m +++ b/Sources/Sentry/SentrySDK.m @@ -134,9 +134,8 @@ + (void)startWithOptions:(NSDictionary *)optionsDict SentryOptions *options = [[SentryOptions alloc] initWithDict:optionsDict didFailWithError:&error]; if (nil != error) { - [SentryLog logWithMessage:@"Error while initializing the SDK" andLevel:kSentryLevelError]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"%@", error] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Error while initializing the SDK"); + SENTRY_LOG_ERROR(@"%@", error); } else { [SentrySDK startWithOptionsObject:options]; } @@ -151,9 +150,7 @@ + (void)startWithOptionsObject:(SentryOptions *)options // The Hub needs to be initialized with a client so that closing a session // can happen. [SentrySDK setCurrentHub:[[SentryHub alloc] initWithClient:newClient andScope:nil]]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"SDK initialized! Version: %@", - SentryMeta.versionString] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SDK initialized! Version: %@", SentryMeta.versionString); [SentrySDK installIntegrations]; } @@ -374,25 +371,20 @@ + (void)installIntegrations for (NSString *integrationName in [SentrySDK.currentHub getClient].options.integrations) { Class integrationClass = NSClassFromString(integrationName); if (nil == integrationClass) { - NSString *logMessage = [NSString stringWithFormat:@"[SentryHub doInstallIntegrations] " - @"couldn't find \"%@\" -> skipping.", - integrationName]; - [SentryLog logWithMessage:logMessage andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"[SentryHub doInstallIntegrations] " + @"couldn't find \"%@\" -> skipping.", + integrationName); continue; } else if ([SentrySDK.currentHub isIntegrationInstalled:integrationClass]) { - NSString *logMessage = - [NSString stringWithFormat:@"[SentryHub doInstallIntegrations] already " - @"installed \"%@\" -> skipping.", - integrationName]; - [SentryLog logWithMessage:logMessage andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR( + @"[SentryHub doInstallIntegrations] already installed \"%@\" -> skipping.", + integrationName); continue; } id integrationInstance = [[integrationClass alloc] init]; BOOL shouldInstall = [integrationInstance installWithOptions:options]; if (shouldInstall) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Integration installed: %@", - integrationName] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Integration installed: %@", integrationName); [SentrySDK.currentHub.installedIntegrations addObject:integrationInstance]; [SentrySDK.currentHub.installedIntegrationNames addObject:integrationName]; } @@ -423,7 +415,7 @@ + (void)close [SentryDependencyContainer reset]; - [SentryLog logWithMessage:@"SDK closed!" andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"SDK closed!"); } #ifndef __clang_analyzer__ diff --git a/Sources/Sentry/SentryScope.m b/Sources/Sentry/SentryScope.m index 64d092a72f8..48f3b4fe41a 100644 --- a/Sources/Sentry/SentryScope.m +++ b/Sources/Sentry/SentryScope.m @@ -125,8 +125,7 @@ - (void)addBreadcrumb:(SentryBreadcrumb *)crumb if (self.maxBreadcrumbs < 1) { return; } - [SentryLog logWithMessage:[NSString stringWithFormat:@"Add breadcrumb: %@", crumb] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Add breadcrumb: %@", crumb); @synchronized(_breadcrumbArray) { [_breadcrumbArray addObject:crumb]; if ([_breadcrumbArray count] > self.maxBreadcrumbs) { diff --git a/Sources/Sentry/SentrySerialization.m b/Sources/Sentry/SentrySerialization.m index 6dc7dcb7fd1..e5216fc068d 100644 --- a/Sources/Sentry/SentrySerialization.m +++ b/Sources/Sentry/SentrySerialization.m @@ -21,8 +21,7 @@ + (NSData *_Nullable)dataWithJSONObject:(NSDictionary *)dictionary if ([NSJSONSerialization isValidJSONObject:dictionary] != NO) { data = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:error]; } else { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Invalid JSON."] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Invalid JSON."); if (error) { *error = NSErrorFromSentryError( kSentryErrorJsonConversionError, @"Event cannot be converted to JSON"); @@ -54,9 +53,7 @@ + (NSData *_Nullable)dataWithEnvelope:(SentryEnvelope *)envelope NSData *header = [SentrySerialization dataWithJSONObject:serializedData error:error]; if (nil == header) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Envelope header cannot " - @"be converted to JSON."] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Envelope header cannot be converted to JSON."); if (error) { *error = NSErrorFromSentryError( kSentryErrorJsonConversionError, @"Envelope header cannot be converted to JSON"); @@ -90,9 +87,7 @@ + (NSData *_Nullable)dataWithEnvelope:(SentryEnvelope *)envelope NSData *itemHeader = [SentrySerialization dataWithJSONObject:serializedItemHeaderData error:error]; if (nil == itemHeader) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Envelope item header cannot " - @"be converted to JSON."] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Envelope item header cannot be converted to JSON."); if (error) { *error = NSErrorFromSentryError(kSentryErrorJsonConversionError, @"Envelope item header cannot be converted to JSON"); @@ -172,18 +167,14 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data #ifdef DEBUG NSString *headerString = [[NSString alloc] initWithData:headerData encoding:NSUTF8StringEncoding]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"Header %@", headerString] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Header %@", headerString); #endif NSError *error = nil; NSDictionary *headerDictionary = [NSJSONSerialization JSONObjectWithData:headerData options:0 error:&error]; if (nil != error) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Failed to parse " - @"envelope header %@", - error] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Failed to parse envelope header %@", error); } else { SentryId *eventId = nil; NSString *eventIdAsString = headerDictionary[@"event_id"]; @@ -211,8 +202,7 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data } if (nil == envelopeHeader) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Invalid envelope. No header found."] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Invalid envelope. No header found."); return nil; } @@ -292,8 +282,7 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data [SentryEnvelopeItemTypeSession isEqual:type]) { NSString *event = [[NSString alloc] initWithData:itemBody encoding:NSUTF8StringEncoding]; - [SentryLog logWithMessage:[NSString stringWithFormat:@"Event %@", event] - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Event %@", event); } #endif SentryEnvelopeItem *envelopeItem = [[SentryEnvelopeItem alloc] initWithHeader:itemHeader @@ -304,8 +293,7 @@ + (SentryEnvelope *_Nullable)envelopeWithData:(NSData *)data } if (items.count == 0) { - [SentryLog logWithMessage:[NSString stringWithFormat:@"Envelope has no items."] - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Envelope has no items."); return nil; } @@ -335,8 +323,7 @@ + (SentrySession *_Nullable)sessionWithData:(NSData *)sessionData SentrySession *session = [[SentrySession alloc] initWithJSONObject:sessionDictionary]; if (nil == session) { - [SentryLog logWithMessage:@"Failed to initialize session from dictionary. Dropping it." - andLevel:kSentryLevelError]; + SENTRY_LOG_ERROR(@"Failed to initialize session from dictionary. Dropping it."); return nil; } diff --git a/Sources/Sentry/SentrySessionTracker.m b/Sources/Sentry/SentrySessionTracker.m index b3fad0d2608..7e48bd3efc6 100644 --- a/Sources/Sentry/SentrySessionTracker.m +++ b/Sources/Sentry/SentrySessionTracker.m @@ -61,9 +61,7 @@ - (void)start NSNotificationName willResignActiveNotificationName = NSApplicationWillResignActiveNotification; NSNotificationName willTerminateNotificationName = NSApplicationWillTerminateNotification; #else - [SentryLog logWithMessage:@"NO UIKit -> SentrySessionTracker will not " - @"track sessions automatically." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"NO UIKit -> SentrySessionTracker will not track sessions automatically."); #endif #if SENTRY_HAS_UIKIT || TARGET_OS_OSX || TARGET_OS_MACCATALYST diff --git a/Sources/Sentry/SentryStacktrace.m b/Sources/Sentry/SentryStacktrace.m index f5d911a2fbc..49e6211da91 100644 --- a/Sources/Sentry/SentryStacktrace.m +++ b/Sources/Sentry/SentryStacktrace.m @@ -33,8 +33,7 @@ - (void)fixDuplicateFrames NSMutableArray *copyFrames = self.frames.mutableCopy; [copyFrames removeObjectAtIndex:self.frames.count - 2]; self.frames = copyFrames; - [SentryLog logWithMessage:@"Found duplicate frame, removing one with link register" - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Found duplicate frame, removing one with link register"); } } diff --git a/Sources/Sentry/SentrySubClassFinder.m b/Sources/Sentry/SentrySubClassFinder.m index 0bf53a8f99c..6ff6b670c7c 100644 --- a/Sources/Sentry/SentrySubClassFinder.m +++ b/Sources/Sentry/SentrySubClassFinder.m @@ -30,8 +30,7 @@ - (void)actOnSubclassesOfViewControllerInImage:(NSString *)imageName block:(void [self.dispatchQueue dispatchAsyncWithBlock:^{ Class viewControllerClass = NSClassFromString(@"UIViewController"); if (viewControllerClass == nil) { - [SentryLog logWithMessage:@"UIViewController class not found." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewController class not found."); return; } diff --git a/Sources/Sentry/SentrySystemEventBreadcrumbs.m b/Sources/Sentry/SentrySystemEventBreadcrumbs.m index fc09e5003f2..f1ec4a6274e 100644 --- a/Sources/Sentry/SentrySystemEventBreadcrumbs.m +++ b/Sources/Sentry/SentrySystemEventBreadcrumbs.m @@ -36,8 +36,7 @@ - (void)start UIDevice *currentDevice = [UIDevice currentDevice]; [self start:currentDevice]; #else - [SentryLog logWithMessage:@"NO iOS -> [SentrySystemEventsBreadcrumbs.start] does nothing." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"NO iOS -> [SentrySystemEventsBreadcrumbs.start] does nothing."); #endif } @@ -59,9 +58,8 @@ - (void)start:(UIDevice *)currentDevice [self initBatteryObserver:currentDevice]; [self initOrientationObserver:currentDevice]; } else { - [SentryLog logWithMessage:@"currentDevice is null, it won't be able to record breadcrumbs " - @"for device battery and orientation." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"currentDevice is null, it won't be able to record breadcrumbs for " + @"device battery and orientation."); } [self initKeyboardVisibilityObserver]; [self initScreenshotObserver]; @@ -122,7 +120,7 @@ - (void)batteryStateChanged:(NSNotification *)notification float w3cLevel = (currentLevel * 100); batteryData[@"level"] = @(w3cLevel); } else { - [SentryLog logWithMessage:@"batteryLevel is unknown." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"batteryLevel is unknown."); } batteryData[@"plugged"] = @(isPlugged); @@ -152,7 +150,7 @@ - (void)orientationChanged:(NSNotification *)notification // Ignore changes in device orientation if unknown, face up, or face down. if (!UIDeviceOrientationIsValidInterfaceOrientation(currentOrientation)) { - [SentryLog logWithMessage:@"currentOrientation is unknown." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"currentOrientation is unknown."); return; } diff --git a/Sources/Sentry/SentryTracer.m b/Sources/Sentry/SentryTracer.m index 596400f2eb2..ac017d9c06a 100644 --- a/Sources/Sentry/SentryTracer.m +++ b/Sources/Sentry/SentryTracer.m @@ -179,7 +179,7 @@ - (instancetype)initWithTransactionContext:(SentryTransactionContext *)transacti [profilerLock lock]; if (profiler == nil) { profiler = [[SentryProfiler alloc] init]; - [SentryLog logWithMessage:@"Starting profiler." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Starting profiler."); # if SENTRY_HAS_UIKIT framesTracker.currentTracer = self; [framesTracker resetProfilingTimestamps]; @@ -457,7 +457,7 @@ - (void)finishInternal #if SENTRY_TARGET_PROFILING_SUPPORTED SentryScreenFrames *frameInfo; if (_profilesSamplerDecision.decision == kSentrySampleDecisionYes) { - [SentryLog logWithMessage:@"Stopping profiler." andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Stopping profiler."); [profilerLock lock]; [profiler stop]; # if SENTRY_HAS_UIKIT @@ -503,11 +503,9 @@ - (void)finishInternal NSTimeInterval transactionDuration = [self.timestamp timeIntervalSinceDate:self.startTimestamp]; if ([self isAutoGeneratedTransaction] && transactionDuration >= SENTRY_AUTO_TRANSACTION_MAX_DURATION) { - NSString *message = - [NSString stringWithFormat:@"Auto generated transaction exceeded the max duration of " - @"%f seconds. Not capturing transaction.", - SENTRY_AUTO_TRANSACTION_MAX_DURATION]; - [SentryLog logWithMessage:message andLevel:kSentryLevelInfo]; + SENTRY_LOG_INFO(@"Auto generated transaction exceeded the max duration of %f seconds. Not " + @"capturing transaction.", + SENTRY_AUTO_TRANSACTION_MAX_DURATION); return; } @@ -718,10 +716,8 @@ - (void)addMeasurements:(SentryTransaction *)transaction [transaction setMeasurementValue:@{ valueKey : @(frozenFrames) } forKey:@"frames_frozen"]; - NSString *message = [NSString - stringWithFormat:@"Frames for transaction \"%@\" Total:%ld Slow:%ld Frozen:%ld", - self.context.operation, (long)totalFrames, (long)slowFrames, (long)frozenFrames]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"Frames for transaction \"%@\" Total:%ld Slow:%ld Frozen:%ld", + self.context.operation, (long)totalFrames, (long)slowFrames, (long)frozenFrames); } } #endif diff --git a/Sources/Sentry/SentryUIViewControllerSwizzling.m b/Sources/Sentry/SentryUIViewControllerSwizzling.m index 533d013af7c..c83f5da9f56 100644 --- a/Sources/Sentry/SentryUIViewControllerSwizzling.m +++ b/Sources/Sentry/SentryUIViewControllerSwizzling.m @@ -72,11 +72,9 @@ - (void)start // twice. We could also use objc_getClassList to lookup sub classes of UIViewController, but // the lookup can take around 60ms, which is not acceptable. if (![self swizzleRootViewControllerFromUIApplication:app]) { - NSString *message - = @"UIViewControllerSwizziling: Failed to find root UIViewController from " - @"UIApplicationDelegate. Trying to use UISceneWillConnectNotification " - @"notification."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Failed to find root UIViewController " + @"from UIApplicationDelegate. Trying to use " + @"UISceneWillConnectNotification notification."); if (@available(iOS 13.0, tvOS 13.0, *)) { [NSNotificationCenter.defaultCenter @@ -85,12 +83,9 @@ - (void)start name:UISceneWillConnectNotification object:nil]; } else { - message - = @"UIViewControllerSwizziling: iOS version older then 13." - @"There is no UISceneWillConnectNotification notification. Could not find a " - @"rootViewController"; - - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: iOS version older then 13. There is " + @"no UISceneWillConnectNotification notification. Could not find " + @"a rootViewController"); } } @@ -103,17 +98,15 @@ - (void)start - (id)findApp { if (![UIApplication respondsToSelector:@selector(sharedApplication)]) { - NSString *message = @"UIViewControllerSwizziling: UIApplication doesn't respond to " - @"sharedApplication."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"UIViewControllerSwizziling: UIApplication doesn't respond to sharedApplication."); return nil; } UIApplication *app = [UIApplication performSelector:@selector(sharedApplication)]; if (app == nil) { - NSString *message = @"UIViewControllerSwizziling: UIApplication.sharedApplication is nil. "; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: UIApplication.sharedApplication is nil."); return nil; } @@ -123,9 +116,8 @@ - (void)start - (void)swizzleAllSubViewControllersInApp:(id)app { if (app.delegate == nil) { - NSString *message = @"UIViewControllerSwizzling: App delegate is nil. Skipping " - @"swizzling UIViewControllers in the app image."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: App delegate is nil. Skipping swizzling " + @"UIViewControllers in the app image."); return; } @@ -135,24 +127,19 @@ - (void)swizzleAllSubViewControllersInApp:(id)app - (void)swizzleUIViewControllersOfClassesInImageOf:(Class)class { if (class == NULL) { - [SentryLog logWithMessage:@"UIViewControllerSwizzling: class is NULL. Skipping swizzling " - @"of classes in same image." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: class is NULL. Skipping swizzling of classes " + @"in same image."); return; } - NSString *message = [NSString - stringWithFormat:@"UIViewControllerSwizzling: Class to get the image name: %@", class]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizzling: Class to get the image name: %@", class); const char *imageNameAsCharArray = [self.objcRuntimeWrapper class_getImageName:class]; if (imageNameAsCharArray == NULL) { - NSString *message = [NSString - stringWithFormat:@"UIViewControllerSwizziling: Wasn't able to get image name of the " - @"class: %@. Skipping swizzling of classes in same image.", - class]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Wasn't able to get image name of the class: " + @"%@. Skipping swizzling of classes in same image.", + class); return; } @@ -160,27 +147,22 @@ - (void)swizzleUIViewControllersOfClassesInImageOf:(Class)class encoding:NSUTF8StringEncoding]; if (imageName == nil || imageName.length == 0) { - NSString *message = - [NSString stringWithFormat:@"UIViewControllerSwizziling: Wasn't able to get the app " - @"image name of the app delegate " - @"class: %@. Skipping swizzling of classes in same image.", - class]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"UIViewControllerSwizziling: Wasn't able to get the app image name of the app " + @"delegate class: %@. Skipping swizzling of classes in same image.", + class); return; } if ([imageName containsString:@"UIKitCore"]) { - NSString *message = @"UIViewControllerSwizziling: Skipping UIKitCore."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Skipping UIKitCore."); return; } if ([self.imagesActedOnSubclassesOfUIViewControllers containsObject:imageName]) { - NSString *message = [NSString - stringWithFormat: - @"UIViewControllerSwizziling: Already swizzled UIViewControllers in image: %@.", - imageName]; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"UIViewControllerSwizziling: Already swizzled UIViewControllers in image: %@.", + imageName); return; } @@ -222,19 +204,16 @@ - (void)swizzleRootViewControllerFromSceneDelegateNotification:(NSNotification * // The object of a UISceneWillConnectNotification should be a NSWindowScene if (![notification.object respondsToSelector:@selector(windows)]) { - NSString *message - = @"UIViewControllerSwizziling: Failed to find root UIViewController from " - @"UISceneWillConnectNotification. Notification object has no windows property"; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"UIViewControllerSwizziling: Failed to find root UIViewController from " + @"UISceneWillConnectNotification. Notification object has no windows property"); return; } id windows = [notification.object performSelector:@selector(windows)]; if (![windows isKindOfClass:[NSArray class]]) { - NSString *message - = @"UIViewControllerSwizziling: Failed to find root UIViewController from " - @"UISceneWillConnectNotification. Windows is not an array"; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Failed to find root UIViewController " + @"from UISceneWillConnectNotification. Windows is not an array"); return; } @@ -245,11 +224,9 @@ - (void)swizzleRootViewControllerFromSceneDelegateNotification:(NSNotification * [self swizzleRootViewControllerAndDescendant:((UIWindow *)window).rootViewController]; } else { - NSString *message - = @"UIViewControllerSwizziling: Failed to find root UIViewController from " - @"UISceneWillConnectNotification. Window is not a UIWindow class or the " - @"rootViewController is nil"; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: Failed to find root " + @"UIViewController from UISceneWillConnectNotification. Window is " + @"not a UIWindow class or the rootViewController is nil"); } } } @@ -258,33 +235,29 @@ - (void)swizzleRootViewControllerFromSceneDelegateNotification:(NSNotification * - (BOOL)swizzleRootViewControllerFromUIApplication:(id)app { if (app.delegate == nil) { - NSString *message = @"UIViewControllerSwizziling: App delegate is nil. Skipping " - @"swizzleRootViewControllerFromAppDelegate."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: App delegate is nil. Skipping " + @"swizzleRootViewControllerFromAppDelegate."); return NO; } // Check if delegate responds to window, which it doesn't have to. if (![app.delegate respondsToSelector:@selector(window)]) { - NSString *message = @"UIViewControllerSwizziling: UIApplicationDelegate.window is nil. " - @"Skipping swizzleRootViewControllerFromAppDelegate."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: UIApplicationDelegate.window is nil. " + @"Skipping swizzleRootViewControllerFromAppDelegate."); return NO; } if (app.delegate.window == nil) { - NSString *message = @"UIViewControllerSwizziling: UIApplicationDelegate.window is nil. " - @"Skipping swizzleRootViewControllerFromAppDelegate."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling: UIApplicationDelegate.window is nil. " + @"Skipping swizzleRootViewControllerFromAppDelegate."); return NO; } UIViewController *rootViewController = app.delegate.window.rootViewController; if (rootViewController == nil) { - NSString *message = @"UIViewControllerSwizziling: " - @"UIApplicationDelegate.window.rootViewController is nil. " - @"Skipping swizzleRootViewControllerFromAppDelegate."; - [SentryLog logWithMessage:message andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG( + @"UIViewControllerSwizziling: UIApplicationDelegate.window.rootViewController is nil. " + @"Skipping swizzleRootViewControllerFromAppDelegate."); return NO; } @@ -301,9 +274,7 @@ - (void)swizzleRootViewControllerAndDescendant:(UIViewController *)rootViewContr for (UIViewController *viewController in allViewControllers) { Class viewControllerClass = [viewController class]; if (viewControllerClass != nil) { - [SentryLog - logWithMessage:@"UIViewControllerSwizziling Calling swizzleRootViewController." - andLevel:kSentryLevelDebug]; + SENTRY_LOG_DEBUG(@"UIViewControllerSwizziling Calling swizzleRootViewController."); [self swizzleViewControllerSubClass:viewControllerClass]; // We can't get the image name with the app delegate class for some apps. Therefore, we From eebebf7a5a87825e8145c59d6f2e47a9cc32b638 Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Thu, 15 Sep 2022 21:57:06 -0800 Subject: [PATCH 09/54] test: show SDK logs when running tests (#2046) --- Sources/Sentry/SentryLog.m | 24 +++++++++++++++---- Tests/SentryTests/Helper/SentryLog+TestInit.h | 10 ++++++++ Tests/SentryTests/Helper/SentryLogTests.swift | 20 ++++++++++++---- .../SentryBaseIntegrationTests.swift | 12 ++++++---- .../TestUtils/SentryTestObserver.m | 8 ++++++- 5 files changed, 60 insertions(+), 14 deletions(-) diff --git a/Sources/Sentry/SentryLog.m b/Sources/Sentry/SentryLog.m index 8e5b4a51fd8..7352f562b49 100644 --- a/Sources/Sentry/SentryLog.m +++ b/Sources/Sentry/SentryLog.m @@ -31,14 +31,30 @@ + (void)logWithMessage:(NSString *)message andLevel:(SentryLevel)level } } -/** - * Internal and only needed for testing. - */ -+ (void)setLogOutput:(nullable SentryLogOutput *)output +// Internal and only needed for testing. ++ (void)setLogOutput:(SentryLogOutput *)output { logOutput = output; } +// Internal and only needed for testing. ++ (SentryLogOutput *)logOutput +{ + return logOutput; +} + +// Internal and only needed for testing. ++ (BOOL)isDebug +{ + return isDebug; +} + +// Internal and only needed for testing. ++ (SentryLevel)diagnosticLevel +{ + return diagnosticLevel; +} + @end NS_ASSUME_NONNULL_END diff --git a/Tests/SentryTests/Helper/SentryLog+TestInit.h b/Tests/SentryTests/Helper/SentryLog+TestInit.h index 015bac77a4a..38a89f25007 100644 --- a/Tests/SentryTests/Helper/SentryLog+TestInit.h +++ b/Tests/SentryTests/Helper/SentryLog+TestInit.h @@ -8,8 +8,18 @@ NS_ASSUME_NONNULL_BEGIN @interface SentryLog (TestInit) +/** Internal and only needed for testing. */ + (void)setLogOutput:(nullable SentryLogOutput *)output; +/** Internal and only needed for testing. */ ++ (SentryLogOutput *)logOutput; + +/** Internal and only needed for testing. */ ++ (BOOL)isDebug; + +/** Internal and only needed for testing. */ ++ (SentryLevel)diagnosticLevel; + @end NS_ASSUME_NONNULL_END diff --git a/Tests/SentryTests/Helper/SentryLogTests.swift b/Tests/SentryTests/Helper/SentryLogTests.swift index ece6b764786..b1383a9f317 100644 --- a/Tests/SentryTests/Helper/SentryLogTests.swift +++ b/Tests/SentryTests/Helper/SentryLogTests.swift @@ -1,17 +1,27 @@ import XCTest class SentryLogTests: XCTestCase { - + var oldDebug: Bool! + var oldLevel: SentryLevel! + var oldOutput: SentryLogOutput! + + override func setUp() { + super.setUp() + oldDebug = SentryLog.isDebug() + oldLevel = SentryLog.diagnosticLevel() + oldOutput = SentryLog.logOutput() + } + override func tearDown() { super.tearDown() - // Set back to default - SentryLog.configure(true, diagnosticLevel: SentryLevel.error) - SentryLog.setLogOutput(nil) + SentryLog.configure(oldDebug, diagnosticLevel: oldLevel) + SentryLog.setLogOutput(oldOutput) } func testDefault_PrintsFatalAndError() { let logOutput = TestLogOutput() SentryLog.setLogOutput(logOutput) + SentryLog.configure(true, diagnosticLevel: .error) SentryLog.log(withMessage: "0", andLevel: SentryLevel.fatal) SentryLog.log(withMessage: "1", andLevel: SentryLevel.error) @@ -60,7 +70,7 @@ class SentryLogTests: XCTestCase { } class TestLogOutput: SentryLogOutput { - + var loggedMessages: [String] = [] override func log(_ message: String) { loggedMessages.append(message) diff --git a/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift b/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift index fe0cd4e5910..573aebeeaab 100644 --- a/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/SentryBaseIntegrationTests.swift @@ -9,20 +9,24 @@ class MyTestIntegration: SentryBaseIntegration { class SentryBaseIntegrationTests: XCTestCase { var logOutput: TestLogOutput! + var oldDebug: Bool! + var oldLevel: SentryLevel! + var oldOutput: SentryLogOutput! override func setUp() { super.setUp() + oldDebug = SentryLog.isDebug() + oldLevel = SentryLog.diagnosticLevel() + oldOutput = SentryLog.logOutput() SentryLog.configure(true, diagnosticLevel: SentryLevel.debug) - logOutput = TestLogOutput() SentryLog.setLogOutput(logOutput) } override func tearDown() { super.tearDown() - // Set back to default - SentryLog.configure(true, diagnosticLevel: SentryLevel.error) - SentryLog.setLogOutput(nil) + SentryLog.configure(oldDebug, diagnosticLevel: oldLevel) + SentryLog.setLogOutput(oldOutput) } func testIntegrationName() { diff --git a/Tests/SentryTests/TestUtils/SentryTestObserver.m b/Tests/SentryTests/TestUtils/SentryTestObserver.m index e3935591dbd..a4fb1f95073 100644 --- a/Tests/SentryTests/TestUtils/SentryTestObserver.m +++ b/Tests/SentryTests/TestUtils/SentryTestObserver.m @@ -6,6 +6,7 @@ #import "SentryCurrentDate.h" #import "SentryDefaultCurrentDateProvider.h" #import "SentryHub.h" +#import "SentryLog+TestInit.h" #import "SentryOptions.h" #import "SentryScope.h" #import "SentrySdk+Private.h" @@ -26,12 +27,17 @@ @implementation SentryTestObserver -#if TESTCI +#if defined(TESTCI) + (void)load { [[XCTestObservationCenter sharedTestObservationCenter] addTestObserver:[[SentryTestObserver alloc] init]]; } +#elif defined(TEST) ++ (void)load +{ + [SentryLog configure:YES diagnosticLevel:kSentryLevelDebug]; +} #endif - (instancetype)init From 201a488d58224485df6ba3eb9649eaedcb8f9338 Mon Sep 17 00:00:00 2001 From: Andrew McKnight Date: Thu, 15 Sep 2022 23:20:00 -0800 Subject: [PATCH 10/54] Fix some random typos (#2174) --- Sources/Sentry/Public/SentryAppStartMeasurement.h | 2 +- Sources/Sentry/Public/SentryDefines.h | 2 +- Sources/Sentry/Public/SentryEvent.h | 2 +- Sources/Sentry/SentryANRTracker.m | 6 +++--- Sources/Sentry/SentryMigrateSessionInit.m | 2 +- Sources/Sentry/SentryTracer.m | 2 +- Sources/Sentry/include/SentryCrashReportConverter.h | 2 +- .../Recording/Monitors/SentryCrashMonitorContext.h | 2 +- .../Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift | 2 +- .../Performance/Network/SentryNetworkTrackerTests.swift | 4 ++-- .../SentryConcurrentRateLimitsDictionaryTests.swift | 2 +- .../SentryTests/Networking/SentryHttpDateParserTests.swift | 2 +- Tests/SentryTests/Networking/SentryHttpTransportTests.swift | 2 +- Tests/SentryTests/Performance/SentryTracer+Test.h | 2 +- Tests/SentryTests/Performance/SentryTracerTests.swift | 6 +++--- Tests/SentryTests/Protocol/SentryUserTests.swift | 2 +- Tests/SentryTests/SentryHubTests.swift | 2 +- Tests/SentryTests/SentrySDKTests.swift | 4 ++-- Tests/SentryTests/SentryScopeSwiftTests.swift | 2 +- 19 files changed, 25 insertions(+), 25 deletions(-) diff --git a/Sources/Sentry/Public/SentryAppStartMeasurement.h b/Sources/Sentry/Public/SentryAppStartMeasurement.h index 02b0a5a7499..bab0f21b9e0 100644 --- a/Sources/Sentry/Public/SentryAppStartMeasurement.h +++ b/Sources/Sentry/Public/SentryAppStartMeasurement.h @@ -45,7 +45,7 @@ SENTRY_NO_INIT @property (readonly, nonatomic, assign) NSTimeInterval duration; /** - * The timestamp when the app started, which is is the proces start timestamp. + * The timestamp when the app started, which is the process start timestamp. */ @property (readonly, nonatomic, strong) NSDate *appStartTimestamp; diff --git a/Sources/Sentry/Public/SentryDefines.h b/Sources/Sentry/Public/SentryDefines.h index 036e0f65bbf..48a7698048e 100644 --- a/Sources/Sentry/Public/SentryDefines.h +++ b/Sources/Sentry/Public/SentryDefines.h @@ -32,7 +32,7 @@ typedef void (^SentryRequestFinished)(NSError *_Nullable error); /** * Block used for request operation finished, shouldDiscardEvent is YES if event - * should be deleted regardless if an error ocured or not + * should be deleted regardless if an error occurred or not */ typedef void (^SentryRequestOperationFinished)( NSHTTPURLResponse *_Nullable response, NSError *_Nullable error); diff --git a/Sources/Sentry/Public/SentryEvent.h b/Sources/Sentry/Public/SentryEvent.h index 4818151212c..83a7f067565 100644 --- a/Sources/Sentry/Public/SentryEvent.h +++ b/Sources/Sentry/Public/SentryEvent.h @@ -29,7 +29,7 @@ NS_SWIFT_NAME(Event) @property (nonatomic, copy) NSError *_Nullable error; /** - * NSDate of when the event occured + * NSDate of when the event occurred */ @property (nonatomic, strong) NSDate *_Nullable timestamp; diff --git a/Sources/Sentry/SentryANRTracker.m b/Sources/Sentry/SentryANRTracker.m index c4446533237..7c785b98416 100644 --- a/Sources/Sentry/SentryANRTracker.m +++ b/Sources/Sentry/SentryANRTracker.m @@ -52,8 +52,8 @@ - (void)detectANRs __block NSInteger ticksSinceUiUpdate = 0; __block BOOL reported = NO; - NSInteger reportTreshold = 5; - NSTimeInterval sleepInterval = self.timeoutInterval / reportTreshold; + NSInteger reportThreshold = 5; + NSTimeInterval sleepInterval = self.timeoutInterval / reportThreshold; while (![self.thread isCancelled]) { NSDate *blockDeadline = @@ -86,7 +86,7 @@ - (void)detectANRs continue; } - if (ticksSinceUiUpdate >= reportTreshold && !reported) { + if (ticksSinceUiUpdate >= reportThreshold && !reported) { reported = YES; if (![self.crashWrapper isApplicationInForeground]) { diff --git a/Sources/Sentry/SentryMigrateSessionInit.m b/Sources/Sentry/SentryMigrateSessionInit.m index c366c1eb373..e9aa074d7d7 100644 --- a/Sources/Sentry/SentryMigrateSessionInit.m +++ b/Sources/Sentry/SentryMigrateSessionInit.m @@ -47,7 +47,7 @@ + (BOOL)setInitFlagOnNextEnvelopeWithSameSessionId:(SentrySession *)session NSString *envelopePath = [envelopesDirPath stringByAppendingPathComponent:envelopeFilePath]; NSData *envelopeData = [fileManager contentsAtPath:envelopePath]; - // Some error occured while getting the envelopeData + // Some error occurred while getting the envelopeData if (nil == envelopeData) { continue; } diff --git a/Sources/Sentry/SentryTracer.m b/Sources/Sentry/SentryTracer.m index ac017d9c06a..a8df60d05d1 100644 --- a/Sources/Sentry/SentryTracer.m +++ b/Sources/Sentry/SentryTracer.m @@ -771,7 +771,7 @@ - (NSDictionary *)serialize /** * Internal. Only needed for testing. */ -+ (void)resetAppStartMeasurmentRead ++ (void)resetAppStartMeasurementRead { @synchronized(appStartMeasurementLock) { appStartMeasurementRead = NO; diff --git a/Sources/Sentry/include/SentryCrashReportConverter.h b/Sources/Sentry/include/SentryCrashReportConverter.h index 5c95b263e0e..d94ecfb903e 100644 --- a/Sources/Sentry/include/SentryCrashReportConverter.h +++ b/Sources/Sentry/include/SentryCrashReportConverter.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN /** * Converts the report to an SentryEvent. * - * @return The converted event or nil if an error occured during the conversion. + * @return The converted event or nil if an error occurred during the conversion. */ - (SentryEvent *_Nullable)convertReportToEvent; diff --git a/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitorContext.h b/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitorContext.h index 6b554930740..68c2d9de094 100644 --- a/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitorContext.h +++ b/Sources/SentryCrash/Recording/Monitors/SentryCrashMonitorContext.h @@ -121,7 +121,7 @@ typedef struct SentryCrash_MonitorContext { /** The exception name. */ const char *name; - /** The language the exception occured in. */ + /** The language the exception occurred in. */ const char *language; /** The line of code where the exception occurred. Can be NULL. */ diff --git a/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift b/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift index b20b87343ac..2b1f8818d41 100644 --- a/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift +++ b/Tests/SentryTests/Integrations/Breadcrumbs/SentrySystemEventBreadcrumbsTest.swift @@ -252,7 +252,7 @@ class SentrySystemEventBreadcrumbsTest: XCTestCase { } } - func testTimezoneChangeNoticiationBreadcrumb() { + func testTimezoneChangeNotificationBreadcrumb() { let scope = Scope() sut = fixture.getSut(scope: scope, currentDevice: nil) diff --git a/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerTests.swift b/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerTests.swift index 8cb2cd2a9c4..49c6823c301 100644 --- a/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerTests.swift +++ b/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerTests.swift @@ -502,7 +502,7 @@ class SentryNetworkTrackerTests: XCTestCase { XCTAssertEqual(headers?.count, 0) } - // Altough we only run this test above the below specified versions, we exped the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe @available(tvOS 10.0, *) @available(OSX 10.12, *) @@ -530,7 +530,7 @@ class SentryNetworkTrackerTests: XCTestCase { assertOneSpanCreated(transaction) } - // Altough we only run this test above the below specified versions, we exped the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe @available(tvOS 10.0, *) @available(OSX 10.12, *) diff --git a/Tests/SentryTests/Networking/RateLimits/SentryConcurrentRateLimitsDictionaryTests.swift b/Tests/SentryTests/Networking/RateLimits/SentryConcurrentRateLimitsDictionaryTests.swift index 5de32928070..b531544798e 100644 --- a/Tests/SentryTests/Networking/RateLimits/SentryConcurrentRateLimitsDictionaryTests.swift +++ b/Tests/SentryTests/Networking/RateLimits/SentryConcurrentRateLimitsDictionaryTests.swift @@ -30,7 +30,7 @@ class SentryConcurrentRateLimitsDictionaryTests: XCTestCase { sut.addRateLimit(SentryDataCategory.attachment, validUntil: dateB) XCTAssertEqual(dateB, self.sut.getRateLimit(for: SentryDataCategory.attachment)) } - // Altough we only run this test above the below specified versions, we exped the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe @available(tvOS 10.0, *) @available(OSX 10.12, *) diff --git a/Tests/SentryTests/Networking/SentryHttpDateParserTests.swift b/Tests/SentryTests/Networking/SentryHttpDateParserTests.swift index 5dad257d907..f559ba65036 100644 --- a/Tests/SentryTests/Networking/SentryHttpDateParserTests.swift +++ b/Tests/SentryTests/Networking/SentryHttpDateParserTests.swift @@ -20,7 +20,7 @@ class SentryHttpDateParserTests: XCTestCase { XCTAssertEqual(expected, actual) } - // Altough we only run this test above the below specified versions, we exped the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe @available(iOS 10.0, *) @available(tvOS 10.0, *) diff --git a/Tests/SentryTests/Networking/SentryHttpTransportTests.swift b/Tests/SentryTests/Networking/SentryHttpTransportTests.swift index f0b9c05162f..43ab72ec406 100644 --- a/Tests/SentryTests/Networking/SentryHttpTransportTests.swift +++ b/Tests/SentryTests/Networking/SentryHttpTransportTests.swift @@ -1,7 +1,7 @@ import Sentry import XCTest -// Altough we only run this test above the below specified versions, we exped the +// Although we only run this test above the below specified versions, we expect the // implementation to be thread safe @available(tvOS 10.0, *) @available(OSX 10.12, *) diff --git a/Tests/SentryTests/Performance/SentryTracer+Test.h b/Tests/SentryTests/Performance/SentryTracer+Test.h index bd9b7fccb97..7f21306daec 100644 --- a/Tests/SentryTests/Performance/SentryTracer+Test.h +++ b/Tests/SentryTests/Performance/SentryTracer+Test.h @@ -6,7 +6,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SentryTracer (Test) -+ (void)resetAppStartMeasurmentRead; ++ (void)resetAppStartMeasurementRead; @end diff --git a/Tests/SentryTests/Performance/SentryTracerTests.swift b/Tests/SentryTests/Performance/SentryTracerTests.swift index 04b51e6e82d..4462c56eaeb 100644 --- a/Tests/SentryTests/Performance/SentryTracerTests.swift +++ b/Tests/SentryTests/Performance/SentryTracerTests.swift @@ -83,13 +83,13 @@ class SentryTracerTests: XCTestCase { override func setUp() { super.setUp() fixture = Fixture() - SentryTracer.resetAppStartMeasurmentRead() + SentryTracer.resetAppStartMeasurementRead() } override func tearDown() { super.tearDown() clearTestState() - SentryTracer.resetAppStartMeasurmentRead() + SentryTracer.resetAppStartMeasurementRead() #if os(iOS) || os(tvOS) || targetEnvironment(macCatalyst) SentryFramesTracker.sharedInstance().resetFrames() SentryFramesTracker.sharedInstance().stop() @@ -697,7 +697,7 @@ class SentryTracerTests: XCTestCase { XCTAssertNil(SentrySDK.getAppStartMeasurement()) } - func testNegativeFramesAmount_NoMeasurmentAdded() { + func testNegativeFramesAmount_NoMeasurementAdded() { fixture.displayLinkWrapper.givenFrames(10, 10, 10) let sut = fixture.getSut() diff --git a/Tests/SentryTests/Protocol/SentryUserTests.swift b/Tests/SentryTests/Protocol/SentryUserTests.swift index 9414d54e82e..a309c193b2b 100644 --- a/Tests/SentryTests/Protocol/SentryUserTests.swift +++ b/Tests/SentryTests/Protocol/SentryUserTests.swift @@ -84,7 +84,7 @@ class SentryUserTests: XCTestCase { XCTAssertEqual(TestData.user, copiedUser) } - // Altough we only run this test above the below specified versions, we exped the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe // With this test we test if modifications from multiple threads don't lead to a crash. @available(tvOS 10.0, *) diff --git a/Tests/SentryTests/SentryHubTests.swift b/Tests/SentryTests/SentryHubTests.swift index 597bd063373..549becaadf1 100644 --- a/Tests/SentryTests/SentryHubTests.swift +++ b/Tests/SentryTests/SentryHubTests.swift @@ -632,7 +632,7 @@ class SentryHubTests: XCTestCase { }) } - // Altough we only run this test above the below specified versions, we expect the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe @available(tvOS 10.0, *) @available(OSX 10.12, *) diff --git a/Tests/SentryTests/SentrySDKTests.swift b/Tests/SentryTests/SentrySDKTests.swift index 688712a0b6d..cf51e50851e 100644 --- a/Tests/SentryTests/SentrySDKTests.swift +++ b/Tests/SentryTests/SentrySDKTests.swift @@ -482,12 +482,12 @@ class SentrySDKTests: XCTestCase { XCTAssertNotEqual(first, second) } - // Altough we only run this test above the below specified versions, we exped the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe @available(tvOS 10.0, *) @available(OSX 10.12, *) @available(iOS 10.0, *) - func testSetpAppStartMeasurmentConcurrently_() { + func testSetpAppStartMeasurementConcurrently_() { func setAppStartMeasurement(_ queue: DispatchQueue, _ i: Int) { group.enter() queue.async { diff --git a/Tests/SentryTests/SentryScopeSwiftTests.swift b/Tests/SentryTests/SentryScopeSwiftTests.swift index 03e05bb067b..ee36b86426c 100644 --- a/Tests/SentryTests/SentryScopeSwiftTests.swift +++ b/Tests/SentryTests/SentryScopeSwiftTests.swift @@ -286,7 +286,7 @@ class SentryScopeSwiftTests: XCTestCase { } } - // Altough we only run this test above the below specified versions, we exped the + // Although we only run this test above the below specified versions, we expect the // implementation to be thread safe // With this test we test if modifications from multiple threads don't lead to a crash. @available(tvOS 10.0, *) From b91c155263132da7c4707ddc610654538665f027 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Fri, 16 Sep 2022 09:20:35 +0200 Subject: [PATCH 11/54] build: bump fastlane to 2.210.0 (#2176) --- Gemfile.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 959d96cf2e1..1f6e5efa3da 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -17,8 +17,8 @@ GEM artifactory (3.0.15) atomos (0.1.3) aws-eventstream (1.2.0) - aws-partitions (1.625.0) - aws-sdk-core (3.139.0) + aws-partitions (1.631.0) + aws-sdk-core (3.148.0) aws-eventstream (~> 1, >= 1.0.2) aws-partitions (~> 1, >= 1.525.0) aws-sigv4 (~> 1.1) @@ -116,7 +116,7 @@ GEM faraday_middleware (1.2.0) faraday (~> 1.0) fastimage (2.2.6) - fastlane (2.209.1) + fastlane (2.210.0) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.8, < 3.0.0) artifactory (~> 3.0) @@ -161,9 +161,9 @@ GEM fourflusher (2.3.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) - google-apis-androidpublisher_v3 (0.25.0) + google-apis-androidpublisher_v3 (0.26.0) google-apis-core (>= 0.7, < 2.a) - google-apis-core (0.7.0) + google-apis-core (0.7.2) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.16.2, < 2.a) httpclient (>= 2.8.1, < 3.a) @@ -183,8 +183,8 @@ GEM google-cloud-errors (~> 1.0) google-cloud-env (1.6.0) faraday (>= 0.17.3, < 3.0) - google-cloud-errors (1.2.0) - google-cloud-storage (1.39.0) + google-cloud-errors (1.3.0) + google-cloud-storage (1.40.0) addressable (~> 2.8) digest-crc (~> 0.4) google-apis-iamcredentials_v1 (~> 0.1) @@ -296,4 +296,4 @@ DEPENDENCIES xcpretty BUNDLED WITH - 2.3.15 + 2.3.21 From ba31d083747db50e9201b3c54f68717dae841c29 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Fri, 16 Sep 2022 09:21:51 +0200 Subject: [PATCH 12/54] ci: Fix fastlane bundle version mismatch (#2177) The upload to Testflight via Fastlane failed with error: The CFBundleVersion of an App Clip ('1') must match that of its containing parent app ('817'). This is fixed now by using increment_build_number instead of using set_info_plist_value. --- .github/workflows/testflight.yml | 10 +++++----- fastlane/Fastfile | 14 ++++---------- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/.github/workflows/testflight.yml b/.github/workflows/testflight.yml index 4e54dd39dde..0d156a6a219 100644 --- a/.github/workflows/testflight.yml +++ b/.github/workflows/testflight.yml @@ -21,14 +21,14 @@ jobs: - run: bundle install # We upload a new version to TestFlight on every commit on Master - # So we need to bump the bundle version each time - - name: Bump Bundle Version + # So we need to bump the build number each time + - name: Bump Build Version env: - FASTLANE_BUNDLE_VERSION: ${{ github.run_number }} - run: fastlane bump_bundle_version + FASTLANE_BUILD_NUMBER: ${{ github.run_number }} + run: bundle exec fastlane bump_build_number - name: Remove preview version suffixes - run: fastlane remove_preview_version_suffixes + run: bundle exec fastlane remove_preview_version_suffixes - name: Run Fastlane env: diff --git a/fastlane/Fastfile b/fastlane/Fastfile index 51e86c9288e..3a9063b012b 100644 --- a/fastlane/Fastfile +++ b/fastlane/Fastfile @@ -4,16 +4,10 @@ platform :ios do ios_swift_infoplist_path = "./Samples/iOS-Swift/iOS-Swift/Info.plist" ios_swift_clip_infoplist_path = "./Samples/iOS-Swift/iOS-SwiftClip/Info.plist" - lane :bump_bundle_version do - set_info_plist_value( - path: ios_swift_infoplist_path, - key: "CFBundleVersion", - value: ENV["FASTLANE_BUNDLE_VERSION"] - ) - set_info_plist_value( - path: ios_swift_clip_infoplist_path, - key: "CFBundleVersion", - value: ENV["FASTLANE_BUNDLE_VERSION"] + lane :bump_build_number do + increment_build_number( + build_number: ENV["FASTLANE_BUILD_NUMBER"], + xcodeproj: "./Samples/iOS-Swift/iOS-Swift.xcodeproj" ) end From 4e17cffc4d6449c42d0a2df73f7aaabf2204b4d5 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Fri, 16 Sep 2022 10:56:30 +0200 Subject: [PATCH 13/54] meta: Update Changelog (#2178) The change in https://github.com/getsentry/sentry-cocoa/pull/2151 doesn't fix anything, see https://github.com/getsentry/sentry-cocoa/pull/2151#issuecomment-1247796012. Instead, the PR is only a performance improvement. Update the Changelog to clarify expectation. --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b4b0bbcc9a..7bb5723c681 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 7.25.1 -### Fixes +### Performance Improvements - Prewarmed app start detection (#2151) From 23a718c9f4c15baf3585a818cda32174d105e0cc Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Fri, 16 Sep 2022 11:06:49 +0200 Subject: [PATCH 14/54] fix: Use the `component` name source for SentryPerformanceTracker (#2168) --- CHANGELOG.md | 6 +++ Sentry.xcodeproj/project.pbxproj | 4 ++ Sources/Sentry/SentryPerformanceTracker.m | 46 +++++++++++++++++-- ...SentryUIViewControllerPerformanceTracker.m | 12 ++++- .../SentryPerformanceTracker+Private.h | 21 +++++++++ ...iewControllerPerformanceTrackerTests.swift | 2 +- 6 files changed, 86 insertions(+), 5 deletions(-) create mode 100644 Sources/Sentry/include/SentryPerformanceTracker+Private.h diff --git a/CHANGELOG.md b/CHANGELOG.md index 7bb5723c681..3701a0b20ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Fixes + +- Use the `component` name source for SentryPerformanceTracker (#2168) + ## 7.25.1 ### Performance Improvements diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index a325b9099fa..5790fe1cd5d 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -46,6 +46,7 @@ 0A2D8D9828997887008720F6 /* NSLocale+Sentry.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A2D8D9728997887008720F6 /* NSLocale+Sentry.h */; }; 0A2D8DA8289BC905008720F6 /* SentryViewHierarchy.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A2D8DA6289BC905008720F6 /* SentryViewHierarchy.h */; }; 0A2D8DA9289BC905008720F6 /* SentryViewHierarchy.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A2D8DA7289BC905008720F6 /* SentryViewHierarchy.m */; }; + 0A4EDEA928D3461B00FA67CB /* SentryPerformanceTracker+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A4EDEA828D3461B00FA67CB /* SentryPerformanceTracker+Private.h */; }; 0A5370A128A3EC2400B2DCDE /* SentryViewHierarchyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A5370A028A3EC2400B2DCDE /* SentryViewHierarchyTests.swift */; }; 0A56DA5F28ABA01B00C400D5 /* SentryTransactionContext+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 0A56DA5E28ABA01B00C400D5 /* SentryTransactionContext+Private.h */; }; 0A6EEADD28A657970076B469 /* UIViewRecursiveDescriptionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A6EEADC28A657970076B469 /* UIViewRecursiveDescriptionTests.swift */; }; @@ -740,6 +741,7 @@ 0A2D8D9728997887008720F6 /* NSLocale+Sentry.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "NSLocale+Sentry.h"; path = "include/NSLocale+Sentry.h"; sourceTree = ""; }; 0A2D8DA6289BC905008720F6 /* SentryViewHierarchy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryViewHierarchy.h; path = include/SentryViewHierarchy.h; sourceTree = ""; }; 0A2D8DA7289BC905008720F6 /* SentryViewHierarchy.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryViewHierarchy.m; sourceTree = ""; }; + 0A4EDEA828D3461B00FA67CB /* SentryPerformanceTracker+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryPerformanceTracker+Private.h"; path = "include/SentryPerformanceTracker+Private.h"; sourceTree = ""; }; 0A5370A028A3EC2400B2DCDE /* SentryViewHierarchyTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryViewHierarchyTests.swift; sourceTree = ""; }; 0A56DA5E28ABA01B00C400D5 /* SentryTransactionContext+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryTransactionContext+Private.h"; path = "include/SentryTransactionContext+Private.h"; sourceTree = ""; }; 0A6EEADC28A657970076B469 /* UIViewRecursiveDescriptionTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIViewRecursiveDescriptionTests.swift; sourceTree = ""; }; @@ -2486,6 +2488,7 @@ 8EAE9804261E87120073B6B3 /* SentryUIViewControllerPerformanceTracker.m */, 8EAE9809261E9F530073B6B3 /* SentryPerformanceTracker.h */, 8EBF870726140D37001A6853 /* SentryPerformanceTracker.m */, + 0A4EDEA828D3461B00FA67CB /* SentryPerformanceTracker+Private.h */, ); name = UIViewController; sourceTree = ""; @@ -2907,6 +2910,7 @@ 7BFC169B2524995700FF6266 /* SentryMessage.h in Headers */, 03F84D1E27DD414C008FE43F /* SentryBacktrace.hpp in Headers */, 63AA76991EB9C1C200D153DE /* SentryDefines.h in Headers */, + 0A4EDEA928D3461B00FA67CB /* SentryPerformanceTracker+Private.h in Headers */, 0A8F0A392886CC70000B15F6 /* SentryPermissionsObserver.h in Headers */, 63FE70CF20DA4C1000CDBAE8 /* SentryCrashMonitor_User.h in Headers */, 7B2A70DB27D607CF008B0D15 /* SentryThreadWrapper.h in Headers */, diff --git a/Sources/Sentry/SentryPerformanceTracker.m b/Sources/Sentry/SentryPerformanceTracker.m index 520f5b74b3e..b785c9f4cc8 100644 --- a/Sources/Sentry/SentryPerformanceTracker.m +++ b/Sources/Sentry/SentryPerformanceTracker.m @@ -40,6 +40,15 @@ - (instancetype)init } - (SentrySpanId *)startSpanWithName:(NSString *)name operation:(NSString *)operation +{ + return [self startSpanWithName:name + nameSource:kSentryTransactionNameSourceCustom + operation:operation]; +} + +- (SentrySpanId *)startSpanWithName:(NSString *)name + nameSource:(SentryTransactionNameSource)source + operation:(NSString *)operation { id activeSpan; @synchronized(self.activeSpanStack) { @@ -51,7 +60,9 @@ - (SentrySpanId *)startSpanWithName:(NSString *)name operation:(NSString *)opera newSpan = [activeSpan startChildWithOperation:operation description:name]; } else { SentryTransactionContext *context = - [[SentryTransactionContext alloc] initWithName:name operation:operation]; + [[SentryTransactionContext alloc] initWithName:name + nameSource:source + operation:operation]; [SentrySDK.currentHub.scope useSpan:^(id span) { BOOL bindToScope = true; @@ -92,7 +103,20 @@ - (void)measureSpanWithDescription:(NSString *)description operation:(NSString *)operation inBlock:(void (^)(void))block { - SentrySpanId *spanId = [self startSpanWithName:description operation:operation]; + [self measureSpanWithDescription:description + nameSource:kSentryTransactionNameSourceCustom + operation:operation + inBlock:block]; +} + +- (void)measureSpanWithDescription:(NSString *)description + nameSource:(SentryTransactionNameSource)source + operation:(NSString *)operation + inBlock:(void (^)(void))block +{ + SentrySpanId *spanId = [self startSpanWithName:description + nameSource:source + operation:operation]; [self pushActiveSpan:spanId]; block(); [self popActiveSpan]; @@ -103,10 +127,26 @@ - (void)measureSpanWithDescription:(NSString *)description operation:(NSString *)operation parentSpanId:(SentrySpanId *)parentSpanId inBlock:(void (^)(void))block +{ + [self measureSpanWithDescription:description + nameSource:kSentryTransactionNameSourceCustom + operation:operation + parentSpanId:parentSpanId + inBlock:block]; +} + +- (void)measureSpanWithDescription:(NSString *)description + nameSource:(SentryTransactionNameSource)source + operation:(NSString *)operation + parentSpanId:(SentrySpanId *)parentSpanId + inBlock:(void (^)(void))block { [self activateSpan:parentSpanId duringBlock:^{ - [self measureSpanWithDescription:description operation:operation inBlock:block]; + [self measureSpanWithDescription:description + nameSource:source + operation:operation + inBlock:block]; }]; } diff --git a/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m b/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m index 59f41950606..c5ee506b561 100644 --- a/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m +++ b/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m @@ -1,6 +1,7 @@ #import "SentryUIViewControllerPerformanceTracker.h" #import "SentryHub.h" #import "SentryLog.h" +#import "SentryPerformanceTracker+Private.h" #import "SentryPerformanceTracker.h" #import "SentrySDK+Private.h" #import "SentryScope.h" @@ -89,7 +90,9 @@ - (void)createTransaction:(UIViewController *)controller // and override the previous id stored. if (spanId == nil) { NSString *name = [SentryUIViewControllerSanitizer sanitizeViewControllerName:controller]; - spanId = [self.tracker startSpanWithName:name operation:SentrySpanOperationUILoad]; + spanId = [self.tracker startSpanWithName:name + nameSource:kSentryTransactionNameSourceComponent + operation:SentrySpanOperationUILoad]; // Use the target itself to store the spanId to avoid using a global mapper. objc_setAssociatedObject(controller, &SENTRY_UI_PERFORMANCE_TRACKER_SPAN_ID, spanId, @@ -113,11 +116,13 @@ - (void)viewControllerViewWillAppear:(UIViewController *)controller void (^duringBlock)(void) = ^{ [self.tracker measureSpanWithDescription:@"viewWillAppear" + nameSource:kSentryTransactionNameSourceComponent operation:SentrySpanOperationUILoad inBlock:callbackToOrigin]; SentrySpanId *viewAppearingId = [self.tracker startSpanWithName:@"viewAppearing" + nameSource:kSentryTransactionNameSourceComponent operation:SentrySpanOperationUILoad]; objc_setAssociatedObject(controller, @@ -190,6 +195,7 @@ - (void)finishTransaction:(UIViewController *)controller } [self.tracker measureSpanWithDescription:lifecycleMethod + nameSource:kSentryTransactionNameSourceComponent operation:SentrySpanOperationUILoad inBlock:callbackToOrigin]; }; @@ -224,11 +230,13 @@ - (void)viewControllerViewWillLayoutSubViews:(UIViewController *)controller void (^duringBlock)(void) = ^{ [self.tracker measureSpanWithDescription:@"viewWillLayoutSubviews" + nameSource:kSentryTransactionNameSourceComponent operation:SentrySpanOperationUILoad inBlock:callbackToOrigin]; SentrySpanId *layoutSubViewId = [self.tracker startSpanWithName:@"layoutSubViews" + nameSource:kSentryTransactionNameSourceComponent operation:SentrySpanOperationUILoad]; objc_setAssociatedObject(controller, @@ -267,6 +275,7 @@ - (void)viewControllerViewDidLayoutSubViews:(UIViewController *)controller } [self.tracker measureSpanWithDescription:@"viewDidLayoutSubviews" + nameSource:kSentryTransactionNameSourceComponent operation:SentrySpanOperationUILoad inBlock:callbackToOrigin]; @@ -327,6 +336,7 @@ - (void)measurePerformance:(NSString *)description callbackToOrigin(); } else { [self.tracker measureSpanWithDescription:description + nameSource:kSentryTransactionNameSourceComponent operation:SentrySpanOperationUILoad parentSpanId:spanId inBlock:callbackToOrigin]; diff --git a/Sources/Sentry/include/SentryPerformanceTracker+Private.h b/Sources/Sentry/include/SentryPerformanceTracker+Private.h new file mode 100644 index 00000000000..d58ef221026 --- /dev/null +++ b/Sources/Sentry/include/SentryPerformanceTracker+Private.h @@ -0,0 +1,21 @@ +#import "SentryPerformanceTracker.h" + +@interface +SentryPerformanceTracker (Private) + +- (SentrySpanId *)startSpanWithName:(NSString *)name + nameSource:(SentryTransactionNameSource)source + operation:(NSString *)operation; + +- (void)measureSpanWithDescription:(NSString *)description + nameSource:(SentryTransactionNameSource)source + operation:(NSString *)operation + inBlock:(void (^)(void))block; + +- (void)measureSpanWithDescription:(NSString *)description + nameSource:(SentryTransactionNameSource)source + operation:(NSString *)operation + parentSpanId:(SentrySpanId *)parentSpanId + inBlock:(void (^)(void))block; + +@end diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift index a92295afe8b..928cd33d793 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryUIViewControllerPerformanceTrackerTests.swift @@ -113,7 +113,7 @@ class SentryUIViewControllerPerformanceTrackerTests: XCTestCase { callbackExpectation.fulfill() } XCTAssertEqual((transactionSpan as! SentryTracer?)!.transactionContext.name, fixture.viewControllerName) - XCTAssertEqual((transactionSpan as! SentryTracer?)!.transactionContext.nameSource, .custom) + XCTAssertEqual((transactionSpan as! SentryTracer?)!.transactionContext.nameSource, .component) XCTAssertFalse(transactionSpan.isFinished) sut.viewControllerViewDidLoad(viewController) { From 718f1a79479552d738c5ae6a75b3ea4053d96e17 Mon Sep 17 00:00:00 2001 From: Kevin Renskers Date: Mon, 19 Sep 2022 08:50:17 +0200 Subject: [PATCH 15/54] fix: Make testAsyncStacktraces pass again (#2165) See https://github.com/getsentry/sentry-cocoa/pull/2142#discussion_r969392752 #skip-changelog --- Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme | 3 --- .../SentryCrash/SentryStacktraceBuilderTests.swift | 8 ++------ 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme index 9629e068f43..c45165f8334 100644 --- a/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme +++ b/Sentry.xcodeproj/xcshareddata/xcschemes/Sentry.xcscheme @@ -61,9 +61,6 @@ - - diff --git a/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift b/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift index c1521bbbf97..3c2ac60b926 100644 --- a/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift +++ b/Tests/SentryTests/SentryCrash/SentryStacktraceBuilderTests.swift @@ -67,9 +67,6 @@ class SentryStacktraceBuilderTests: XCTestCase { XCTAssertTrue(filteredFrames.count == 1, "The frames must be ordered from caller to callee, or oldest to youngest.") } - /** - * Disabled for now, because this test is flaky. - */ func testAsyncStacktraces() throws { SentrySDK.start { options in options.dsn = TestConstants.dsnAsString(username: "SentryStacktraceBuilderTests") @@ -103,14 +100,13 @@ class SentryStacktraceBuilderTests: XCTestCase { let filteredFrames = actual.frames.filter { frame in return frame.function?.contains("testAsyncStacktraces") ?? false || frame.function?.contains("asyncFrame1") ?? false || - frame.function?.contains("asyncFrame2") ?? false || - frame.function?.contains("asyncAssertion") ?? false + frame.function?.contains("asyncFrame2") ?? false } let startFrames = actual.frames.filter { frame in return frame.stackStart?.boolValue ?? false } - XCTAssertTrue(filteredFrames.count >= 4, "The Stacktrace must include the async callers.") + XCTAssertTrue(filteredFrames.count >= 3, "The Stacktrace must include the async callers.") XCTAssertTrue(startFrames.count >= 3, "The Stacktrace must have async continuation markers.") expect.fulfill() From 925fe413f7ed6fbc8ed5c530b714b4ce9b4a3159 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 19 Sep 2022 10:10:20 +0200 Subject: [PATCH 16/54] ref: Make SentryTime available for all platforms (#2169) We need SentryTime also on tvOS so we can make it available everywhere. --- Sources/Sentry/SentryMachLogging.cpp | 4 -- Sources/Sentry/SentryTime.mm | 16 +++--- Sources/Sentry/include/SentryMachLogging.hpp | 53 +++++++++----------- Sources/Sentry/include/SentryTime.h | 9 +--- 4 files changed, 31 insertions(+), 51 deletions(-) diff --git a/Sources/Sentry/SentryMachLogging.cpp b/Sources/Sentry/SentryMachLogging.cpp index bad8c96325a..a35dce1214d 100644 --- a/Sources/Sentry/SentryMachLogging.cpp +++ b/Sources/Sentry/SentryMachLogging.cpp @@ -1,7 +1,5 @@ #include "SentryMachLogging.hpp" -#if SENTRY_TARGET_PROFILING_SUPPORTED - namespace sentry { namespace profiling { @@ -212,5 +210,3 @@ namespace profiling { } // namespace profiling } // namespace sentry - -#endif diff --git a/Sources/Sentry/SentryTime.mm b/Sources/Sentry/SentryTime.mm index a4a6cc7895c..6df4fde6396 100644 --- a/Sources/Sentry/SentryTime.mm +++ b/Sources/Sentry/SentryTime.mm @@ -1,17 +1,15 @@ #import "SentryTime.h" -#if SENTRY_TARGET_PROFILING_SUPPORTED +#import +#import +#import -# import -# import -# import - -# import "SentryMachLogging.hpp" +#import "SentryMachLogging.hpp" uint64_t getAbsoluteTime(void) { - if (@available(macOS 10.12, iOS 10.0, *)) { + if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)) { return clock_gettime_nsec_np(CLOCK_UPTIME_RAW); } return mach_absolute_time(); @@ -22,7 +20,7 @@ { assert(endTimestamp >= startTimestamp); uint64_t duration = endTimestamp - startTimestamp; - if (@available(macOS 10.12, iOS 10.0, *)) { + if (@available(macOS 10.12, iOS 10.0, tvOS 10.0, watchOS 3.0, *)) { return duration; } @@ -33,5 +31,3 @@ duration /= info.denom; return duration; } - -#endif diff --git a/Sources/Sentry/include/SentryMachLogging.hpp b/Sources/Sentry/include/SentryMachLogging.hpp index efb0ac0186c..39ce68186c3 100644 --- a/Sources/Sentry/include/SentryMachLogging.hpp +++ b/Sources/Sentry/include/SentryMachLogging.hpp @@ -1,13 +1,9 @@ #pragma once #include "SentryProfilingConditionals.h" - -#if SENTRY_TARGET_PROFILING_SUPPORTED - -# include "SentryProfilingLogging.hpp" - -# include -# include +#include "SentryProfilingLogging.hpp" +#include +#include namespace sentry { namespace profiling { @@ -33,26 +29,23 @@ namespace profiling { } // namespace profiling } // namespace sentry -# define SENTRY_PROF_LOG_KERN_RETURN(statement) \ - ({ \ - const kern_return_t __log_kr = statement; \ - if (__log_kr != KERN_SUCCESS) { \ - SENTRY_PROF_LOG_ERROR("%s failed with kern return code: %d, description: %s", \ - #statement, __log_kr, \ - sentry::profiling::kernelReturnCodeDescription(__log_kr)); \ - } \ - __log_kr; \ - }) - -# define SENTRY_PROF_LOG_MACH_MSG_RETURN(statement) \ - ({ \ - const mach_msg_return_t __log_mr = statement; \ - if (__log_mr != MACH_MSG_SUCCESS) { \ - SENTRY_PROF_LOG_ERROR("%s failed with mach_msg return code: %d, description: %s", \ - #statement, __log_mr, \ - sentry::profiling::machMessageReturnCodeDescription(__log_mr)); \ - } \ - __log_mr; \ - }) - -#endif +#define SENTRY_PROF_LOG_KERN_RETURN(statement) \ + ({ \ + const kern_return_t __log_kr = statement; \ + if (__log_kr != KERN_SUCCESS) { \ + SENTRY_PROF_LOG_ERROR("%s failed with kern return code: %d, description: %s", \ + #statement, __log_kr, sentry::profiling::kernelReturnCodeDescription(__log_kr)); \ + } \ + __log_kr; \ + }) + +#define SENTRY_PROF_LOG_MACH_MSG_RETURN(statement) \ + ({ \ + const mach_msg_return_t __log_mr = statement; \ + if (__log_mr != MACH_MSG_SUCCESS) { \ + SENTRY_PROF_LOG_ERROR("%s failed with mach_msg return code: %d, description: %s", \ + #statement, __log_mr, \ + sentry::profiling::machMessageReturnCodeDescription(__log_mr)); \ + } \ + __log_mr; \ + }) diff --git a/Sources/Sentry/include/SentryTime.h b/Sources/Sentry/include/SentryTime.h index 3949021fe5e..2f5860793f8 100644 --- a/Sources/Sentry/include/SentryTime.h +++ b/Sources/Sentry/include/SentryTime.h @@ -1,9 +1,6 @@ +#import "SentryCompiler.h" #import "SentryProfilingConditionals.h" - -#if SENTRY_TARGET_PROFILING_SUPPORTED - -# import "SentryCompiler.h" -# import +#import SENTRY_EXTERN_C_BEGIN @@ -19,5 +16,3 @@ uint64_t getAbsoluteTime(void); uint64_t getDurationNs(uint64_t startTimestamp, uint64_t endTimestamp); SENTRY_EXTERN_C_END - -#endif From 9ef5c6d64b9d938bc178bb315ef6ab251f20e012 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 19 Sep 2022 11:15:55 +0200 Subject: [PATCH 17/54] test: Update vapor to 4.65.2 (#2179) Update vapor in test server to latest version. --- test-server/Package.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test-server/Package.swift b/test-server/Package.swift index ad20e335884..f327b4d003c 100644 --- a/test-server/Package.swift +++ b/test-server/Package.swift @@ -8,7 +8,7 @@ let package = Package( ], dependencies: [ // 💧 A server-side Swift web framework. - .package(url: "https://github.com/vapor/vapor.git", from: "4.0.0") + .package(url: "https://github.com/vapor/vapor.git", from: "4.65.2") ], targets: [ .target( From 58787e674dd35a0afe8c27940c3e3f1a09e143ef Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 19 Sep 2022 13:09:03 +0200 Subject: [PATCH 18/54] ci: Compile test-server once (#2180) Compiles the test server only once and stores it as an artifact. This allows us to run the SentryNetworkTrackerIntegrationTests on iOS 12. --- .github/workflows/test.yml | 58 +++++++++++++++++++++++--------------- scripts/xcode-test.sh | 1 - 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dec143ede69..7b66ec2d7b9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,10 +18,40 @@ on: - 'scripts/xcode-test.sh' jobs: + build-test-server: + name: Build test server + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + - name: Cache for Test Server + id: cache_test_server + uses: actions/cache@v3 + with: + path: ./test-server/.build + key: test-server-${{ runner.os }}-spm-${{ hashFiles('./test-server/Package.resolved') }} + + - name: Build Test Server + if: steps.cache_test_server.outputs.cache-hit != 'true' + working-directory: test-server + run: >- + swift build -c release + + - name: Copy exec + working-directory: test-server + run: cp $(swift build --show-bin-path -c release)/Run test-server-exec + + - name: Archiving DerivedData + uses: actions/upload-artifact@v3 + with: + name: test-server + path: | + ./test-server/test-server-exec + unit-tests: name: Unit ${{matrix.platform}} - Xcode ${{matrix.xcode}} - OS ${{matrix.test-destination-os}} runs-on: ${{matrix.runs-on}} timeout-minutes: 20 + needs: build-test-server strategy: fail-fast: false @@ -98,31 +128,13 @@ jobs: steps: - uses: actions/checkout@v3 - - # As we use swift-tools-version:5.5 the test server only compiles with Xcode 13. - # macos-10.15 doesn't have Xcode 13 and macos-11 doesn't have a simulator with - # iOS 12. Ideally, we would compile the test-server on macos-11 and use it on - # macos-10.15. For now, disable the tests on iOS 12 requiring the test server in - # xcode-test.sh - - name: Cache for Test Server - id: cache_test_server - if: matrix.runs-on == 'macos-11' || matrix.runs-on == 'macos-12' - uses: actions/cache@v3 + - uses: actions/download-artifact@v3 with: - path: ./test-server/.build - key: ${{ runner.os }}-spm-${{ hashFiles('./test-server/Package.resolved') }}-Xcode-${{matrix.xcode}} - - - name: Build Test Server - if: steps.cache_test_server.outputs.cache-hit != 'true' && ( matrix.runs-on == 'macos-11' || matrix.runs-on == 'macos-12' ) - run: swift build - working-directory: test-server - - - name: Run Test Server in Background - if: matrix.runs-on == 'macos-11' || matrix.runs-on == 'macos-12' - run: swift run & - working-directory: test-server + name: test-server + - name: Allow test-server to run + run: chmod +x ./test-server-exec + - run: ./test-server-exec & - # Select Xcode after starting server, because the server needs Xcode 13 - run: ./scripts/ci-select-xcode.sh ${{matrix.xcode}} # Only Xcode 10.3 has an iOS 12.4 simulator. As we have a reference to MacCatalyst in our unit tests diff --git a/scripts/xcode-test.sh b/scripts/xcode-test.sh index cd6fcf44bcd..ee75c9e3834 100755 --- a/scripts/xcode-test.sh +++ b/scripts/xcode-test.sh @@ -60,7 +60,6 @@ if [ $PLATFORM == "iOS" -a $OS == "12.4" ]; then env NSUnbufferedIO=YES xcodebuild -workspace Sentry.xcworkspace \ -scheme Sentry -configuration $CONFIGURATION \ GCC_GENERATE_TEST_COVERAGE_FILES=YES GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES -destination "$DESTINATION" \ - -skip-testing:"SentryTests/SentryNetworkTrackerIntegrationTests/testGetRequest_SpanCreatedAndTraceHeaderAdded" \ -skip-testing:"SentryTests/SentrySDKTests/testMemoryFootprintOfAddingBreadcrumbs" \ -skip-testing:"SentryTests/SentrySDKTests/testMemoryFootprintOfTransactions" \ test | tee raw-test-output.log | xcpretty -t && exit ${PIPESTATUS[0]} From 8d4d03924057f9a199018c50af60634775885450 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 19 Sep 2022 13:15:42 +0200 Subject: [PATCH 19/54] ci: Use major OS versions for SauceLabs (#2182) Don't pin specific OS versions for test suites, as when SauceLabs updates devices, the tests start to fail. --- .sauce/benchmarking-config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.sauce/benchmarking-config.yml b/.sauce/benchmarking-config.yml index 359c95075ba..deb4049363e 100644 --- a/.sauce/benchmarking-config.yml +++ b/.sauce/benchmarking-config.yml @@ -15,12 +15,12 @@ suites: - name: "High-end device" devices: - name: "iPad Pro 12.9 2021" - platformVersion: "15.6.1" + platformVersion: "15" - name: "Mid-range device" devices: - name: "iPhone 8" - platformVersion: "14.8" + platformVersion: "14" - name: "Low-end device" devices: - name: "iPhone 6S" - platformVersion: "15.3.1" + platformVersion: "15" From 66a03a4e96d2f66c3fe3bf46ba9e5d80e996ed7f Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 19 Sep 2022 13:15:57 +0200 Subject: [PATCH 20/54] docs: How to find SauceLabs available devices (#2183) --- develop-docs/README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/develop-docs/README.md b/develop-docs/README.md index 89d083228d0..ae1b04d770c 100644 --- a/develop-docs/README.md +++ b/develop-docs/README.md @@ -28,6 +28,10 @@ To run the unit tests with the thread sanitizer enabled in Xcode click on edit s CI runs UI tests on simulators via the `test.yml` workflow, and on devices via `saucelabs-UI-tests.yml`. All are run for each PR, and Sauce Labs tests also run on a nightly cron schedule. +### Saucelabs + +You can find the available devices on [their website](https://saucelabs.com/platform/supported-browsers-devices). Another way to check their available devices is to go to [live app testing](https://app.saucelabs.com/live/app-testing), go to iOS-Swift and click on choose device. This brings the full list of devices with more details. + ### Performance benchmarking Once daily and for every PR via [Github action](../.github/workflows/benchmarking.yml), the benchmark runs in Sauce Labs, on a [high-end device](https://github.com/getsentry/sentry/blob/8986f81e19f63ee370b1649e08630c9b946c87ed/src/sentry/profiles/device.py#L43-L49) we categorize. Benchmarks run from an XCUITest (`PerformanceBenchmarks` target) using the iOS-Swift sample app, under the `iOS-Swift-Benchmarking` scheme. [`PerformanceViewController`](../Samples/iOS-Swift/iOS-Swift/ViewControllers/PerformanceViewController.swift) provides a start and stop button for controlling when the benchmarking runs, and a text field to marshal observations from within the test harness app into the test runner app. There, we assert that the P90 of all trials remains under 5%. We also print the raw results to the test runner's console logs for postprocessing into reports with `//scripts/process-benchmark-raw-results.py`. @@ -109,4 +113,3 @@ We could create the crash report first, write it to disk and then call Objective Related links: - https://github.com/getsentry/sentry-cocoa/pull/1751 - From d2198342af80c963d62a2557dd74d73944ec6011 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 19 Sep 2022 13:16:14 +0200 Subject: [PATCH 21/54] ci: Update saucectl from 0.99.4 to 0.107.2 (#2181) --- .github/workflows/benchmarking.yml | 2 +- .github/workflows/profile-data-generator.yml | 2 +- .github/workflows/saucelabs-UI-tests.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/benchmarking.yml b/.github/workflows/benchmarking.yml index f71b7fbe0f2..9160e42bba0 100644 --- a/.github/workflows/benchmarking.yml +++ b/.github/workflows/benchmarking.yml @@ -81,7 +81,7 @@ jobs: - uses: actions/download-artifact@v3 with: name: DerivedData-Xcode - - run: npm install -g saucectl@0.99.4 + - run: npm install -g saucectl@0.107.2 - name: Run Benchmarks in SauceLab env: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} diff --git a/.github/workflows/profile-data-generator.yml b/.github/workflows/profile-data-generator.yml index b5e87d0d428..934960dc334 100644 --- a/.github/workflows/profile-data-generator.yml +++ b/.github/workflows/profile-data-generator.yml @@ -87,7 +87,7 @@ jobs: - uses: actions/download-artifact@v3 with: name: data-generator-build-products - - run: npm install -g saucectl@0.99.4 + - run: npm install -g saucectl@0.107.2 - name: Run Tests in Sauce Labs env: SAUCE_USERNAME: ${{ secrets.SAUCE_USERNAME }} diff --git a/.github/workflows/saucelabs-UI-tests.yml b/.github/workflows/saucelabs-UI-tests.yml index 2a63f1239ec..5dfe9fd7eb0 100644 --- a/.github/workflows/saucelabs-UI-tests.yml +++ b/.github/workflows/saucelabs-UI-tests.yml @@ -119,7 +119,7 @@ jobs: with: name: DerivedData-Xcode-${{matrix.xcode}} - - run: npm install -g saucectl@0.99.4 + - run: npm install -g saucectl@0.107.2 # As Sauce Labs is a bit flaky we retry 5 times - name: Run Tests in SauceLab From bb940ad661a2f3d3e1272a98b5a6703cc5843ff3 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Mon, 19 Sep 2022 14:04:01 +0200 Subject: [PATCH 22/54] feat: Add flush (#2140) Add blocking flush to send out all envelope items. Fixes GH-1013 --- CHANGELOG.md | 4 + .../iOS-Swift/Base.lproj/Main.storyboard | 36 +++--- .../iOS-Swift/iOS-Swift/ViewController.swift | 5 + Sentry.xcodeproj/project.pbxproj | 4 + Sources/Sentry/Public/SentryClient.h | 9 ++ Sources/Sentry/Public/SentryHub.h | 9 ++ Sources/Sentry/Public/SentrySDK.h | 9 ++ Sources/Sentry/SentryClient.m | 5 + Sources/Sentry/SentryHttpTransport.m | 65 +++++++++- Sources/Sentry/SentryHub.m | 8 ++ Sources/Sentry/SentrySDK.m | 5 + Sources/Sentry/SentryTransportAdapter.m | 5 + Sources/Sentry/include/SentryTransport.h | 2 + .../Sentry/include/SentryTransportAdapter.h | 2 + .../Networking/SentryHttpTransportTests.swift | 112 +++++++++++++++++- .../Networking/TestTransport.swift | 8 +- Tests/SentryTests/SentrySDKTests.swift | 16 +++ .../SentryTests/SentryTests-Bridging-Header.h | 1 + .../TestUtils/TestExtensions.swift | 13 ++ 19 files changed, 299 insertions(+), 19 deletions(-) create mode 100644 Tests/SentryTests/TestUtils/TestExtensions.swift diff --git a/CHANGELOG.md b/CHANGELOG.md index 3701a0b20ce..609daf03a7b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## Unreleased +### Features + +- Add flush (#2140) + ### Fixes - Use the `component` name source for SentryPerformanceTracker (#2168) diff --git a/Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard b/Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard index b0c25e84c46..0ed14a09aba 100644 --- a/Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard +++ b/Samples/iOS-Swift/iOS-Swift/Base.lproj/Main.storyboard @@ -18,10 +18,10 @@ - + - + @@ -108,31 +108,31 @@ - + + - +