diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b0a9093c7..4c550ad418 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ ### Internal - Change macros TEST and TESTCI to SENTRY_TEST and SENTRY_TEST_CI (#4712) +- Convert constants SentrySpanOperation to Swift (#4718) ## 8.43.1-beta.0 diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index 5fb5bd8c36..4351452114 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -369,7 +369,6 @@ 7B3B473025D6CBFC00D01640 /* SentryNSError.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B3B472F25D6CBFC00D01640 /* SentryNSError.h */; settings = {ATTRIBUTES = (Public, ); }; }; 7B3B473825D6CC7E00D01640 /* SentryNSError.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B3B473725D6CC7E00D01640 /* SentryNSError.m */; }; 7B3B473E25D6CEA500D01640 /* SentryNSErrorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B3B473D25D6CEA500D01640 /* SentryNSErrorTests.swift */; }; - 7B3B83722833832B0001FDEB /* SentrySpanOperations.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B3B83712833832B0001FDEB /* SentrySpanOperations.h */; }; 7B4260342630315C00B36EDD /* SampleError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7B4260332630315C00B36EDD /* SampleError.swift */; }; 7B42C48027E08F33009B58C2 /* SentryDependencyContainer.h in Headers */ = {isa = PBXBuildFile; fileRef = 7B42C47F27E08F33009B58C2 /* SentryDependencyContainer.h */; settings = {ATTRIBUTES = (Private, ); }; }; 7B42C48227E08F4B009B58C2 /* SentryDependencyContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 7B42C48127E08F4B009B58C2 /* SentryDependencyContainer.m */; }; @@ -789,6 +788,9 @@ A8AFFCD42907E0CA00967CD7 /* SentryRequestTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = A8AFFCD32907E0CA00967CD7 /* SentryRequestTests.swift */; }; A8F17B2E2901765900990B25 /* SentryRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B2D2901765900990B25 /* SentryRequest.m */; }; A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */ = {isa = PBXBuildFile; fileRef = A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */; }; + D48724DD2D354939005DE483 /* SentrySpanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DC2D354934005DE483 /* SentrySpanOperation.swift */; }; + D48724E02D3549CA005DE483 /* SentrySpanOperationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */; }; + D48E8B9D2D3E82AC0032E35E /* SentrySpanOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */; }; D4AF00212D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AF00202D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m */; }; D4AF00232D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h in Headers */ = {isa = PBXBuildFile; fileRef = D4AF00222D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h */; }; D4AF00252D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D4AF00242D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m */; }; @@ -1410,7 +1412,6 @@ 7B3B472F25D6CBFC00D01640 /* SentryNSError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSError.h; path = Public/SentryNSError.h; sourceTree = ""; }; 7B3B473725D6CC7E00D01640 /* SentryNSError.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSError.m; sourceTree = ""; }; 7B3B473D25D6CEA500D01640 /* SentryNSErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSErrorTests.swift; sourceTree = ""; }; - 7B3B83712833832B0001FDEB /* SentrySpanOperations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySpanOperations.h; path = include/SentrySpanOperations.h; sourceTree = ""; }; 7B4260332630315C00B36EDD /* SampleError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleError.swift; sourceTree = ""; }; 7B42C47F27E08F33009B58C2 /* SentryDependencyContainer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDependencyContainer.h; path = include/HybridPublic/SentryDependencyContainer.h; sourceTree = ""; }; 7B42C48127E08F4B009B58C2 /* SentryDependencyContainer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDependencyContainer.m; sourceTree = ""; }; @@ -1889,6 +1890,9 @@ A8AFFCD32907E0CA00967CD7 /* SentryRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRequestTests.swift; sourceTree = ""; }; A8F17B2D2901765900990B25 /* SentryRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryRequest.m; sourceTree = ""; }; A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryHttpStatusCodeRange.m; sourceTree = ""; }; + D48724DC2D354934005DE483 /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = ""; }; + D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperationTests.swift; sourceTree = ""; }; + D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = ""; }; D4AF00202D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSFileManagerSwizzling.m; sourceTree = ""; }; D4AF00222D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSFileManagerSwizzling.h; path = include/SentryNSFileManagerSwizzling.h; sourceTree = ""; }; D4AF00242D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSFileManagerSwizzlingTests.m; sourceTree = ""; }; @@ -2359,7 +2363,6 @@ 6304360C1EC05CEF00C4D3FA /* Frameworks */, 6327C5D41EB8A783004E799B /* Products */, 7D826E3C2390840E00EED93D /* Utils */, - 8459FCC62BD86C9E0038E9C9 /* Recovered References */, ); indentWidth = 4; sourceTree = ""; @@ -2558,6 +2561,7 @@ 63AA75931EB8AEDB00D153DE /* SentryTests */ = { isa = PBXGroup; children = ( + D48724DE2D3549C1005DE483 /* Transactions */, D4F2B5332D0C69CC00649E42 /* Recording */, 62872B602BA1B84400A4FA7D /* Swift */, 7B3878E92490D90400EBDEA2 /* SentryClient+TestInit.h */, @@ -3572,13 +3576,6 @@ path = Feedback; sourceTree = ""; }; - 8459FCC62BD86C9E0038E9C9 /* Recovered References */ = { - isa = PBXGroup; - children = ( - ); - name = "Recovered References"; - sourceTree = ""; - }; 847B1A002C618ACA002CB1F3 /* UserFeedback */ = { isa = PBXGroup; children = ( @@ -3633,7 +3630,6 @@ 8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */, 622C08D929E554B9002571D4 /* SentrySpanContext+Private.h */, 8E4E7C7325DAAB49006AB9E2 /* SentrySpanProtocol.h */, - 7B3B83712833832B0001FDEB /* SentrySpanOperations.h */, 622C08D729E546F4002571D4 /* SentryTraceOrigins.h */, 8E4E7C6C25DAAAFE006AB9E2 /* SentrySpan.h */, 84A789092C0E9F5800FF0803 /* SentrySpan+Private.h */, @@ -3677,6 +3673,22 @@ name = Transaction; sourceTree = ""; }; + D48724D92D35258A005DE483 /* Transactions */ = { + isa = PBXGroup; + children = ( + D48724DC2D354934005DE483 /* SentrySpanOperation.swift */, + ); + path = Transactions; + sourceTree = ""; + }; + D48724DE2D3549C1005DE483 /* Transactions */ = { + isa = PBXGroup; + children = ( + D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */, + ); + path = Transactions; + sourceTree = ""; + }; D4F2B5332D0C69CC00649E42 /* Recording */ = { isa = PBXGroup; children = ( @@ -3688,6 +3700,7 @@ D800942328F82E8D005D3943 /* Swift */ = { isa = PBXGroup; children = ( + D48724D92D35258A005DE483 /* Transactions */, D8CAC02D2BA0663E00E38F34 /* Integrations */, 621D9F2D2B9B030E003D94DE /* Helper */, D8F016B42B962533007B9AFB /* Extensions */, @@ -3762,6 +3775,7 @@ D8199DB529376ECC0074249E /* SentrySwiftUI.h */, D88D25E92B8E0BAC0073C3D5 /* module.modulemap */, D8199DB629376ECC0074249E /* SentryTracedView.swift */, + D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */, D8A65B5C2C98656000974B74 /* SentryReplayView.swift */, ); path = SentrySwiftUI; @@ -4308,7 +4322,6 @@ 7BD4BD4127EB0F0D0071F4FF /* SentryDiscardReason.h in Headers */, 622C08DB29E554B9002571D4 /* SentrySpanContext+Private.h in Headers */, D8AB40DB2806EC1900E5E9F7 /* SentryScreenshotIntegration.h in Headers */, - 7B3B83722833832B0001FDEB /* SentrySpanOperations.h in Headers */, 7BF9EF722722A84800B5BBEF /* SentryClassRegistrator.h in Headers */, 63FE715520DA4C1100CDBAE8 /* SentryCrashStackCursor_MachineContext.h in Headers */, 62E081A929ED4260000F69FC /* SentryBreadcrumbDelegate.h in Headers */, @@ -4662,6 +4675,7 @@ 624688192C048EF10006179C /* SentryBaggageSerialization.swift in Sources */, D81988C92BEC19200020E36C /* SentryRRWebBreadcrumbEvent.swift in Sources */, 0A2D8D9628997845008720F6 /* NSLocale+Sentry.m in Sources */, + D48724DD2D354939005DE483 /* SentrySpanOperation.swift in Sources */, 620203B22C59025E0008317C /* SentryFileContents.swift in Sources */, 7B0DC730288698F70039995F /* NSMutableDictionary+Sentry.m in Sources */, 7BD4BD4527EB29F50071F4FF /* SentryClientReport.m in Sources */, @@ -5217,6 +5231,7 @@ 7BBD18B32451805500427C76 /* SentryRateLimitsParserTests.swift in Sources */, 7B82722B27A3220A00F4BFF4 /* SentryFileIoTrackingUnitTests.swift in Sources */, 7BF9EF7A2722B58900B5BBEF /* SentrySubClassFinderTests.swift in Sources */, + D48724E02D3549CA005DE483 /* SentrySpanOperationTests.swift in Sources */, 7B59398224AB47650003AAD2 /* SentrySessionTrackerTests.swift in Sources */, 7B05A61824A4D14A00EF211D /* SentrySessionGeneratorTests.swift in Sources */, D8CB742B294B1DD000A5F964 /* SentryUIApplicationTests.swift in Sources */, @@ -5290,6 +5305,7 @@ buildActionMask = 2147483647; files = ( D8199DC129376EEC0074249E /* SentryTracedView.swift in Sources */, + D48E8B9D2D3E82AC0032E35E /* SentrySpanOperation.swift in Sources */, D8199DBF29376EE20074249E /* SentryInternal.m in Sources */, D8A65B5D2C98656800974B74 /* SentryReplayView.swift in Sources */, ); diff --git a/Sources/Sentry/Profiling/SentryLaunchProfiling.m b/Sources/Sentry/Profiling/SentryLaunchProfiling.m index 78e4e311e2..59b713ec4a 100644 --- a/Sources/Sentry/Profiling/SentryLaunchProfiling.m +++ b/Sources/Sentry/Profiling/SentryLaunchProfiling.m @@ -98,7 +98,7 @@ SentryTransactionContext *context = [[SentryTransactionContext alloc] initWithName:@"launch" nameSource:kSentryTransactionNameSourceCustom - operation:@"app.lifecycle" + operation:SentrySpanOperation.appLifecycle origin:SentryTraceOriginAutoAppStartProfile sampled:kSentrySampleDecisionYes]; context.sampleRate = tracesRate; diff --git a/Sources/Sentry/SentryCoreDataTracker.m b/Sources/Sentry/SentryCoreDataTracker.m index fcfe95990f..716e75c252 100644 --- a/Sources/Sentry/SentryCoreDataTracker.m +++ b/Sources/Sentry/SentryCoreDataTracker.m @@ -39,7 +39,7 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context { __block id fetchSpan; [SentrySDK.currentHub.scope useSpan:^(id _Nullable span) { - fetchSpan = [span startChildWithOperation:SENTRY_COREDATA_FETCH_OPERATION + fetchSpan = [span startChildWithOperation:SentrySpanOperation.coredataFetchOperation description:[self descriptionFromRequest:request]]; fetchSpan.origin = SentryTraceOriginAutoDBCoreData; }]; @@ -77,7 +77,7 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context [self groupEntitiesOperations:context]; [SentrySDK.currentHub.scope useSpan:^(id _Nullable span) { - saveSpan = [span startChildWithOperation:SENTRY_COREDATA_SAVE_OPERATION + saveSpan = [span startChildWithOperation:SentrySpanOperation.coredataSaveOperation description:[self descriptionForOperations:operations inContext:context]]; saveSpan.origin = SentryTraceOriginAutoDBCoreData; diff --git a/Sources/Sentry/SentryFileIOTracker.m b/Sources/Sentry/SentryFileIOTracker.m index b181a5e15d..e371a314d5 100644 --- a/Sources/Sentry/SentryFileIOTracker.m +++ b/Sources/Sentry/SentryFileIOTracker.m @@ -230,7 +230,7 @@ - (void)mainThreadExtraInfo:(id)span - (nullable id)startTrackingWritingNSData:(NSData *)data filePath:(NSString *)path { - return [self spanForPath:path operation:SENTRY_FILE_WRITE_OPERATION size:data.length]; + return [self spanForPath:path operation:SentrySpanOperation.fileWrite size:data.length]; } - (nullable id)startTrackingReadingFilePath:(NSString *)path @@ -245,7 +245,7 @@ - (void)mainThreadExtraInfo:(id)span if (count) return nil; - return [self spanForPath:path operation:SENTRY_FILE_READ_OPERATION size:0]; + return [self spanForPath:path operation:SentrySpanOperation.fileRead size:0]; } - (void)endTrackingFile diff --git a/Sources/Sentry/SentryNetworkTracker.m b/Sources/Sentry/SentryNetworkTracker.m index 049adcaa38..07bec0620a 100644 --- a/Sources/Sentry/SentryNetworkTracker.m +++ b/Sources/Sentry/SentryNetworkTracker.m @@ -187,7 +187,7 @@ - (void)urlSessionTaskResume:(NSURLSessionTask *)sessionTask [SentrySDK.currentHub.scope useSpan:^(id _Nullable innerSpan) { if (innerSpan != nil) { span = innerSpan; - netSpan = [span startChildWithOperation:SENTRY_NETWORK_REQUEST_OPERATION + netSpan = [span startChildWithOperation:SentrySpanOperation.networkRequestOperation description:[NSString stringWithFormat:@"%@ %@", sessionTask.currentRequest.HTTPMethod, safeUrl.sanitizedUrl]]; diff --git a/Sources/Sentry/SentryTimeToDisplayTracker.m b/Sources/Sentry/SentryTimeToDisplayTracker.m index 89136a7556..2e93a31aba 100644 --- a/Sources/Sentry/SentryTimeToDisplayTracker.m +++ b/Sources/Sentry/SentryTimeToDisplayTracker.m @@ -13,7 +13,6 @@ # import "SentrySpan.h" # import "SentrySpanContext.h" # import "SentrySpanId.h" -# import "SentrySpanOperations.h" # import "SentrySwift.h" # import "SentryTraceOrigins.h" # import "SentryTracer.h" @@ -63,14 +62,14 @@ - (BOOL)startForTracer:(SentryTracer *)tracer SENTRY_LOG_DEBUG(@"Starting initial display span"); self.initialDisplaySpan = - [tracer startChildWithOperation:SentrySpanOperationUILoadInitialDisplay + [tracer startChildWithOperation:SentrySpanOperation.uiLoadInitialDisplay description:[NSString stringWithFormat:@"%@ initial display", _name]]; self.initialDisplaySpan.origin = SentryTraceOriginAutoUITimeToDisplay; if (self.waitForFullDisplay) { SENTRY_LOG_DEBUG(@"Starting full display span"); self.fullDisplaySpan = - [tracer startChildWithOperation:SentrySpanOperationUILoadFullDisplay + [tracer startChildWithOperation:SentrySpanOperation.uiLoadFullDisplay description:[NSString stringWithFormat:@"%@ full display", _name]]; self.fullDisplaySpan.origin = SentryTraceOriginManualUITimeToDisplay; diff --git a/Sources/Sentry/SentryTracer.m b/Sources/Sentry/SentryTracer.m index 712e1490b7..2a854a266e 100644 --- a/Sources/Sentry/SentryTracer.m +++ b/Sources/Sentry/SentryTracer.m @@ -33,7 +33,6 @@ #import #import #import -#import #if SENTRY_TARGET_PROFILING_SUPPORTED # import "SentryCaptureTransactionWithProfile.h" @@ -781,7 +780,7 @@ - (nullable SentryAppStartMeasurement *)getAppStartMeasurement SENTRY_DISABLE_TH { // Only send app start measurement for transactions generated by auto performance // instrumentation. - if (![self.operation isEqualToString:SentrySpanOperationUILoad]) { + if (![self.operation isEqualToString:SentrySpanOperation.uiLoad]) { SENTRY_LOG_DEBUG( @"Not returning app start measurements because it's not a ui.load operation."); return nil; diff --git a/Sources/Sentry/SentryUIEventTracker.m b/Sources/Sentry/SentryUIEventTracker.m index 4218250132..fa3567b815 100644 --- a/Sources/Sentry/SentryUIEventTracker.m +++ b/Sources/Sentry/SentryUIEventTracker.m @@ -5,7 +5,6 @@ # import "SentrySwizzleWrapper.h" # import # import -# import # import NS_ASSUME_NONNULL_BEGIN @@ -100,10 +99,10 @@ - (NSString *)getOperation:(id)sender [senderClass isSubclassOfClass:[UIBarButtonItem class]] || [senderClass isSubclassOfClass:[UISegmentedControl class]] || [senderClass isSubclassOfClass:[UIPageControl class]]) { - return SentrySpanOperationUIActionClick; + return SentrySpanOperation.uiActionClick; } - return SentrySpanOperationUIAction; + return SentrySpanOperation.uiAction; } /** @@ -132,10 +131,10 @@ - (NSString *)getTransactionName:(NSString *)action target:(NSString *)target + (BOOL)isUIEventOperation:(NSString *)operation { - if ([operation isEqualToString:SentrySpanOperationUIAction]) { + if ([operation isEqualToString:SentrySpanOperation.uiAction]) { return YES; } - if ([operation isEqualToString:SentrySpanOperationUIActionClick]) { + if ([operation isEqualToString:SentrySpanOperation.uiActionClick]) { return YES; } return NO; diff --git a/Sources/Sentry/SentryUIEventTrackerTransactionMode.m b/Sources/Sentry/SentryUIEventTrackerTransactionMode.m index f96838f891..ef1958a2d2 100644 --- a/Sources/Sentry/SentryUIEventTrackerTransactionMode.m +++ b/Sources/Sentry/SentryUIEventTrackerTransactionMode.m @@ -9,7 +9,6 @@ # import # import # import -# import # import # import # import @@ -72,10 +71,10 @@ - (void)handleUIEvent:(NSString *)action __block SentryTracer *transaction; [SentrySDK.currentHub.scope useSpan:^(id _Nullable span) { BOOL ongoingScreenLoadTransaction - = span != nil && [span.operation isEqualToString:SentrySpanOperationUILoad]; + = span != nil && [span.operation isEqualToString:SentrySpanOperation.uiLoad]; BOOL ongoingManualTransaction = span != nil - && ![span.operation isEqualToString:SentrySpanOperationUILoad] - && ![span.operation containsString:SentrySpanOperationUIAction]; + && ![span.operation isEqualToString:SentrySpanOperation.uiLoad] + && ![span.operation containsString:SentrySpanOperation.uiAction]; BOOL bindToScope = !ongoingScreenLoadTransaction && !ongoingManualTransaction; diff --git a/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m b/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m index 3e788d3dc7..91a38dee02 100644 --- a/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m +++ b/Sources/Sentry/SentryUIViewControllerPerformanceTracker.m @@ -14,7 +14,6 @@ # import "SentryTraceOrigins.h" # import "SentryTracer.h" # import -# import # import # import @@ -129,7 +128,7 @@ - (void)startRootSpanFor:(UIViewController *)controller NSString *name = [SwiftDescriptor getViewControllerClassName:controller]; spanId = [self.tracker startSpanWithName:name nameSource:kSentryTransactionNameSourceComponent - operation:SentrySpanOperationUILoad + operation:SentrySpanOperation.uiLoad origin:SentryTraceOriginAutoUIViewController]; // Use the target itself to store the spanId to avoid using a global mapper. @@ -228,7 +227,7 @@ - (void)viewControllerViewWillAppear:(UIViewController *)controller SENTRY_LOG_DEBUG(@"Tracking UIViewController.viewWillAppear"); [self.tracker measureSpanWithDescription:@"viewWillAppear" nameSource:kSentryTransactionNameSourceComponent - operation:SentrySpanOperationUILoad + operation:SentrySpanOperation.uiLoad origin:SentryTraceOriginAutoUIViewController inBlock:callbackToOrigin]; }; @@ -294,7 +293,7 @@ - (void)finishTransaction:(UIViewController *)controller void (^duringBlock)(void) = ^{ [self.tracker measureSpanWithDescription:lifecycleMethod nameSource:kSentryTransactionNameSourceComponent - operation:SentrySpanOperationUILoad + operation:SentrySpanOperation.uiLoad origin:SentryTraceOriginAutoUIViewController inBlock:callbackToOrigin]; }; @@ -338,14 +337,14 @@ - (void)viewControllerViewWillLayoutSubViews:(UIViewController *)controller void (^duringBlock)(void) = ^{ [self.tracker measureSpanWithDescription:@"viewWillLayoutSubviews" nameSource:kSentryTransactionNameSourceComponent - operation:SentrySpanOperationUILoad + operation:SentrySpanOperation.uiLoad origin:SentryTraceOriginAutoUIViewController inBlock:callbackToOrigin]; SentrySpanId *layoutSubViewId = [self.tracker startSpanWithName:@"layoutSubViews" nameSource:kSentryTransactionNameSourceComponent - operation:SentrySpanOperationUILoad + operation:SentrySpanOperation.uiLoad origin:SentryTraceOriginAutoUIViewController]; objc_setAssociatedObject(controller, @@ -395,7 +394,7 @@ - (void)viewControllerViewDidLayoutSubViews:(UIViewController *)controller [self.tracker measureSpanWithDescription:@"viewDidLayoutSubviews" nameSource:kSentryTransactionNameSourceComponent - operation:SentrySpanOperationUILoad + operation:SentrySpanOperation.uiLoad origin:SentryTraceOriginAutoUIViewController inBlock:callbackToOrigin]; @@ -458,7 +457,7 @@ - (void)measurePerformance:(NSString *)description } else { [self.tracker measureSpanWithDescription:description nameSource:kSentryTransactionNameSourceComponent - operation:SentrySpanOperationUILoad + operation:SentrySpanOperation.uiLoad origin:SentryTraceOriginAutoUIViewController parentSpanId:spanId inBlock:callbackToOrigin]; diff --git a/Sources/Sentry/include/SentryCoreDataTracker.h b/Sources/Sentry/include/SentryCoreDataTracker.h index 8e6961ffc1..5b4e415cc3 100644 --- a/Sources/Sentry/include/SentryCoreDataTracker.h +++ b/Sources/Sentry/include/SentryCoreDataTracker.h @@ -3,9 +3,6 @@ NS_ASSUME_NONNULL_BEGIN -static NSString *const SENTRY_COREDATA_FETCH_OPERATION = @"db.sql.query"; -static NSString *const SENTRY_COREDATA_SAVE_OPERATION = @"db.sql.transaction"; - @class SentryNSProcessInfoWrapper; @class SentryThreadInspector; diff --git a/Sources/Sentry/include/SentryFileIOTracker.h b/Sources/Sentry/include/SentryFileIOTracker.h index 131baded28..3f6e5f9f9a 100644 --- a/Sources/Sentry/include/SentryFileIOTracker.h +++ b/Sources/Sentry/include/SentryFileIOTracker.h @@ -2,9 +2,6 @@ #import NS_ASSUME_NONNULL_BEGIN -static NSString *const SENTRY_FILE_WRITE_OPERATION = @"file.write"; - -static NSString *const SENTRY_FILE_READ_OPERATION = @"file.read"; @class SentryNSProcessInfoWrapper; @class SentryThreadInspector; diff --git a/Sources/Sentry/include/SentryNetworkTracker.h b/Sources/Sentry/include/SentryNetworkTracker.h index e24ef161cc..c5f12a8a1c 100644 --- a/Sources/Sentry/include/SentryNetworkTracker.h +++ b/Sources/Sentry/include/SentryNetworkTracker.h @@ -4,7 +4,6 @@ NS_ASSUME_NONNULL_BEGIN @class SentryOptions; -static NSString *const SENTRY_NETWORK_REQUEST_OPERATION = @"http.client"; static NSString *const SENTRY_NETWORK_REQUEST_TRACKER_SPAN = @"SENTRY_NETWORK_REQUEST_TRACKER_SPAN"; static NSString *const SENTRY_NETWORK_REQUEST_START_DATE = @"SENTRY_NETWORK_REQUEST_START_DATE"; static NSString *const SENTRY_NETWORK_REQUEST_TRACKER_BREADCRUMB diff --git a/Sources/Sentry/include/SentrySpanOperations.h b/Sources/Sentry/include/SentrySpanOperations.h deleted file mode 100644 index 57eb606c98..0000000000 --- a/Sources/Sentry/include/SentrySpanOperations.h +++ /dev/null @@ -1,7 +0,0 @@ -#import - -static NSString *const SentrySpanOperationUILoad = @"ui.load"; -static NSString *const SentrySpanOperationUILoadInitialDisplay = @"ui.load.initial_display"; -static NSString *const SentrySpanOperationUILoadFullDisplay = @"ui.load.full_display"; -static NSString *const SentrySpanOperationUIAction = @"ui.action"; -static NSString *const SentrySpanOperationUIActionClick = @"ui.action.click"; diff --git a/Sources/SentrySwiftUI/SentrySpanOperation.swift b/Sources/SentrySwiftUI/SentrySpanOperation.swift new file mode 100644 index 0000000000..10eebeae6e --- /dev/null +++ b/Sources/SentrySwiftUI/SentrySpanOperation.swift @@ -0,0 +1,21 @@ +// This file is a subset of the fields defined in `Sources/Swift/Transactions/SentrySpanOperation.swift`. +// +// As the main file is internal in `Sentry`, it can not be exposed to the `SentrySwiftUI` module. +// This file is a workaround to expose the `SentrySpanOperation` class to the `SentrySwiftUI` module. +// +// ATTENTION: This file should be kept in sync with the main file. +// Please add new fields or methods in the main file if possible. +// +// Discarded Approach 1: +// - Define `@interface SentrySpanOperation` in `SentryInternal.h` +// - Swift class is exposed to Objective-C in auto-generated `Sentry-Swift.h` +// - Conflict: Duplicate interface definition +// +// Discarded Approach 2: +// - Declare Swift class `SentrySpanOperation` in main file as `public`. +// - Auto-generated `Sentry-Swift.h` is manually imported to `SentrySwift.h` +// - Issue: Internal class is public for SDK users, which is not desired + +class SentrySpanOperation { + static let uiLoad = "ui.load" +} diff --git a/Sources/Swift/Transactions/SentrySpanOperation.swift b/Sources/Swift/Transactions/SentrySpanOperation.swift new file mode 100644 index 0000000000..30ccf342ea --- /dev/null +++ b/Sources/Swift/Transactions/SentrySpanOperation.swift @@ -0,0 +1,21 @@ +import Foundation + +@objcMembers @objc(SentrySpanOperation) +class SentrySpanOperation: NSObject { + static let appLifecycle = "app.lifecycle" + + static let coredataFetchOperation = "db.sql.query" + static let coredataSaveOperation = "db.sql.transaction" + + static let fileRead = "file.read" + static let fileWrite = "file.write" + + static let networkRequestOperation = "http.client" + + static let uiAction = "ui.action" + static let uiActionClick = "ui.action.click" + + static let uiLoad = "ui.load" + static let uiLoadInitialDisplay = "ui.load.initial_display" + static let uiLoadFullDisplay = "ui.load.full_display" +} diff --git a/Tests/SentryProfilerTests/SentryProfileTestFixture.swift b/Tests/SentryProfilerTests/SentryProfileTestFixture.swift index 2616e0a9eb..4050e592a1 100644 --- a/Tests/SentryProfilerTests/SentryProfileTestFixture.swift +++ b/Tests/SentryProfilerTests/SentryProfileTestFixture.swift @@ -92,7 +92,7 @@ class SentryProfileTestFixture { /// Advance the mock date provider, start a new transaction and return its handle. func newTransaction(testingAppLaunchSpans: Bool = false, automaticTransaction: Bool = false, idleTimeout: TimeInterval? = nil) throws -> SentryTracer { - let operation = testingAppLaunchSpans ? SentrySpanOperationUILoad : transactionOperation + let operation = testingAppLaunchSpans ? SentrySpanOperation.uiLoad : transactionOperation if automaticTransaction { return hub.startTransaction( diff --git a/Tests/SentryTests/Integrations/Performance/CoreData/SentryCoreDataTrackerTest.swift b/Tests/SentryTests/Integrations/Performance/CoreData/SentryCoreDataTrackerTest.swift index bce1efd382..a7e462976d 100644 --- a/Tests/SentryTests/Integrations/Performance/CoreData/SentryCoreDataTrackerTest.swift +++ b/Tests/SentryTests/Integrations/Performance/CoreData/SentryCoreDataTrackerTest.swift @@ -1,4 +1,5 @@ import CoreData +@testable import Sentry import SentryTestUtils import XCTest @@ -48,12 +49,6 @@ class SentryCoreDataTrackerTests: XCTestCase { clearTestState() } - func testConstants() { - //Test constants to make sure we don't accidentally change it - XCTAssertEqual(SENTRY_COREDATA_FETCH_OPERATION, "db.sql.query") - XCTAssertEqual(SENTRY_COREDATA_SAVE_OPERATION, "db.sql.transaction") - } - func testFetchRequest() throws { let fetch = NSFetchRequest(entityName: "TestEntity") try assertRequest(fetch, expectedDescription: "SELECT 'TestEntity'") @@ -307,7 +302,12 @@ private extension SentryCoreDataTrackerTests { let dbSpan = try XCTUnwrap(transaction.children.first) - assertDataAndFrames(dbSpan: dbSpan, expectedOperation: SENTRY_COREDATA_SAVE_OPERATION, expectedDescription: expectedDescription, mainThread: mainThread) + assertDataAndFrames( + dbSpan: dbSpan, + expectedOperation: SentrySpanOperation.coredataSaveOperation, + expectedDescription: expectedDescription, + mainThread: mainThread + ) } func assertRequest(_ fetch: NSFetchRequest, expectedDescription: String, mainThread: Bool = true) throws { @@ -327,7 +327,12 @@ private extension SentryCoreDataTrackerTests { let dbSpan = try XCTUnwrap(transaction.children.first) XCTAssertEqual(dbSpan.data["read_count"] as? Int, 1) - assertDataAndFrames(dbSpan: dbSpan, expectedOperation: SENTRY_COREDATA_FETCH_OPERATION, expectedDescription: expectedDescription, mainThread: mainThread) + assertDataAndFrames( + dbSpan: dbSpan, + expectedOperation: SentrySpanOperation.coredataFetchOperation, + expectedDescription: expectedDescription, + mainThread: mainThread + ) } func assertDataAndFrames(dbSpan: Span, expectedOperation: String, expectedDescription: String, mainThread: Bool) { diff --git a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackerTests.swift b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackerTests.swift index 72e1ff5c1a..ec7eeb4970 100644 --- a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackerTests.swift +++ b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackerTests.swift @@ -1,3 +1,4 @@ +@testable import Sentry import SentryTestUtils import XCTest @@ -46,8 +47,8 @@ class SentryFileIOTrackerTests: XCTestCase { func testConstants() { //A test to ensure this constants don't accidentally change - XCTAssertEqual("file.read", SENTRY_FILE_READ_OPERATION) - XCTAssertEqual("file.write", SENTRY_FILE_WRITE_OPERATION) + XCTAssertEqual("file.read", SentrySpanOperation.fileRead) + XCTAssertEqual("file.write", SentrySpanOperation.fileWrite) } func testWritePathAtomically() { @@ -116,7 +117,7 @@ class SentryFileIOTrackerTests: XCTestCase { } assertSpanDuration(span: span, expectedDuration: 4) - assertDataSpan(span, path: fixture.filePath, operation: SENTRY_FILE_WRITE_OPERATION, size: fixture.data.count) + assertDataSpan(span, path: fixture.filePath, operation: SentrySpanOperation.fileWrite, size: fixture.data.count) } func testWriteAtomically_CheckTransaction_DebugImages() { @@ -175,7 +176,7 @@ class SentryFileIOTrackerTests: XCTestCase { } self.assertSpanDuration(span: span, expectedDuration: 4) - self.assertDataSpan(span, path: self.fixture.filePath, operation: SENTRY_FILE_WRITE_OPERATION, size: self.fixture.data.count, mainThread: false) + self.assertDataSpan(span, path: self.fixture.filePath, operation: SentrySpanOperation.fileWrite, size: self.fixture.data.count, mainThread: false) expect.fulfill() } @@ -195,7 +196,7 @@ class SentryFileIOTrackerTests: XCTestCase { } assertSpanDuration(span: span, expectedDuration: 3) - assertDataSpan(span, path: fixture.filePath, operation: SENTRY_FILE_WRITE_OPERATION, size: fixture.data.count) + assertDataSpan(span, path: fixture.filePath, operation: SentrySpanOperation.fileWrite, size: fixture.data.count) } func testDontTrackSentryFilesWrites() { @@ -229,7 +230,7 @@ class SentryFileIOTrackerTests: XCTestCase { XCTAssertEqual(usedPath, fixture.filePath) XCTAssertEqual(data?.count, fixture.data.count) - assertDataSpan(span, path: fixture.filePath, operation: SENTRY_FILE_READ_OPERATION, size: fixture.data.count) + assertDataSpan(span, path: fixture.filePath, operation: SentrySpanOperation.fileRead, size: fixture.data.count) } func testReadFromStringOptionsError() { @@ -250,7 +251,7 @@ class SentryFileIOTrackerTests: XCTestCase { XCTAssertEqual(data?.count, fixture.data.count) XCTAssertEqual(usedOptions, .uncached) - assertDataSpan(span, path: fixture.filePath, operation: SENTRY_FILE_READ_OPERATION, size: fixture.data.count) + assertDataSpan(span, path: fixture.filePath, operation: SentrySpanOperation.fileRead, size: fixture.data.count) } func testReadFromURLOptionsError() { @@ -272,7 +273,7 @@ class SentryFileIOTrackerTests: XCTestCase { XCTAssertEqual(data?.count, fixture.data.count) XCTAssertEqual(usedOptions, .uncached) - assertDataSpan(span, path: url.path, operation: SENTRY_FILE_READ_OPERATION, size: fixture.data.count) + assertDataSpan(span, path: url.path, operation: SentrySpanOperation.fileRead, size: fixture.data.count) } func testCreateFile() { @@ -303,7 +304,7 @@ class SentryFileIOTrackerTests: XCTestCase { XCTAssertEqual(methodAttributes?[FileAttributeKey.size] as? Int, 123) assertSpanDuration(span: span, expectedDuration: 4) - assertDataSpan(span, path: fixture.filePath, operation: SENTRY_FILE_WRITE_OPERATION, size: fixture.data.count) + assertDataSpan(span, path: fixture.filePath, operation: SentrySpanOperation.fileWrite, size: fixture.data.count) } func testDontTrackSentryFilesRead() { @@ -347,7 +348,7 @@ class SentryFileIOTrackerTests: XCTestCase { let lastComponent = (path as NSString).lastPathComponent - if operation == SENTRY_FILE_READ_OPERATION { + if operation == SentrySpanOperation.fileRead { XCTAssertEqual(span?.spanDescription, lastComponent) } else { let bytesDescription = SentryByteCountFormatter.bytesCountDescription( UInt(size)) diff --git a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationObjCTests.m b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationObjCTests.m index b2dcb66745..fd435815cd 100644 --- a/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationObjCTests.m +++ b/Tests/SentryTests/Integrations/Performance/IO/SentryFileIOTrackingIntegrationObjCTests.m @@ -70,7 +70,7 @@ - (void)tearDown - (void)test_dataWithContentsOfFile { - [self assertTransactionForOperation:SENTRY_FILE_READ_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileRead block:^{ [self assertData:[NSData dataWithContentsOfFile:self->filePath]]; @@ -80,7 +80,7 @@ - (void)test_dataWithContentsOfFile - (void)test_dataWithContentsOfFileOptionsError { [self - assertTransactionForOperation:SENTRY_FILE_READ_OPERATION + assertTransactionForOperation:SentrySpanOperation.fileRead block:^{ [self assertData:[NSData @@ -93,7 +93,7 @@ - (void)test_dataWithContentsOfFileOptionsError - (void)test_dataWithContentsOfURL { [self - assertTransactionForOperation:SENTRY_FILE_READ_OPERATION + assertTransactionForOperation:SentrySpanOperation.fileRead block:^{ [self assertData:[NSData dataWithContentsOfURL:self->fileUrl]]; }]; @@ -102,7 +102,7 @@ - (void)test_dataWithContentsOfURL - (void)test_dataWithContentsOfURLOptionsError { [self - assertTransactionForOperation:SENTRY_FILE_READ_OPERATION + assertTransactionForOperation:SentrySpanOperation.fileRead block:^{ [self assertData:[NSData dataWithContentsOfURL:self->fileUrl @@ -113,7 +113,7 @@ - (void)test_dataWithContentsOfURLOptionsError - (void)test_initWithContentsOfURL { - [self assertTransactionForOperation:SENTRY_FILE_READ_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileRead block:^{ [self assertData:[[NSData alloc] initWithContentsOfURL:self->fileUrl]]; @@ -122,7 +122,7 @@ - (void)test_initWithContentsOfURL - (void)test_initWithContentsOfFile { - [self assertTransactionForOperation:SENTRY_FILE_READ_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileRead block:^{ [self assertData:[[NSData alloc] initWithContentsOfFile:self->filePath]]; @@ -131,7 +131,7 @@ - (void)test_initWithContentsOfFile - (void)test_writeToFileAtomically { - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite block:^{ [self->someData writeToFile:self->filePath atomically:true]; }]; @@ -140,7 +140,7 @@ - (void)test_writeToFileAtomically - (void)test_writeToUrlAtomically { - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite block:^{ [self->someData writeToURL:self->fileUrl atomically:true]; }]; @@ -149,7 +149,7 @@ - (void)test_writeToUrlAtomically - (void)test_writeToFileOptionsError { - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite block:^{ [self->someData writeToFile:self->filePath options:NSDataWritingAtomic @@ -160,7 +160,7 @@ - (void)test_writeToFileOptionsError - (void)test_writeToUrlOptionsError { - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite block:^{ [self->someData writeToURL:self->fileUrl options:NSDataWritingAtomic @@ -171,7 +171,7 @@ - (void)test_writeToUrlOptionsError - (void)test_NSFileManagerContentAtPath { - [self assertTransactionForOperation:SENTRY_FILE_READ_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileRead block:^{ [self assertData:[NSFileManager.defaultManager contentsAtPath:self->filePath]]; @@ -180,7 +180,7 @@ - (void)test_NSFileManagerContentAtPath - (void)test_NSFileManagerCreateFile { - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite block:^{ [NSFileManager.defaultManager createFileAtPath:self->filePath contents:self->someData @@ -219,7 +219,7 @@ - (void)assertTransactionForOperation:(NSString *)operation block:(void (^)(void NSString *filename = filePath.lastPathComponent; - if ([operation isEqualToString:SENTRY_FILE_READ_OPERATION]) { + if ([operation isEqualToString:SentrySpanOperation.fileRead]) { XCTAssertEqualObjects(ioSpan.spanDescription, filename); } else { NSString *expectedString = [NSString stringWithFormat:@"%@ (%@)", filename, diff --git a/Tests/SentryTests/Integrations/Performance/IO/SentryNSFileManagerSwizzlingTests.m b/Tests/SentryTests/Integrations/Performance/IO/SentryNSFileManagerSwizzlingTests.m index 7dc199e3ea..76aac408a5 100644 --- a/Tests/SentryTests/Integrations/Performance/IO/SentryNSFileManagerSwizzlingTests.m +++ b/Tests/SentryTests/Integrations/Performance/IO/SentryNSFileManagerSwizzlingTests.m @@ -82,7 +82,7 @@ - (void)testNSFileManagerCreateFile_preiOS18macOS15tvOS18_experimentalFlagDisabl XCTSkip("Test only targets pre iOS 18, macOS 15, tvOS 18"); } [self setUpNSFileManagerSwizzlingWithEnabledFlag:NO]; - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite spanCount:0 block:^{ [NSFileManager.defaultManager createFileAtPath:self->filePath @@ -98,7 +98,7 @@ - (void)testNSFileManagerCreateFile_preiOS18macOS15tvOS18_experimentalFlagEnable XCTSkip("Test only targets pre iOS 18, macOS 15, tvOS 18"); } [self setUpNSFileManagerSwizzlingWithEnabledFlag:YES]; - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite spanCount:0 block:^{ [NSFileManager.defaultManager createFileAtPath:self->filePath @@ -117,7 +117,7 @@ - (void)testNSFileManagerCreateFile_preiOS18macOS15tvOS18_experimentalFlagEnable XCTSkip("Test only targets iOS 18, macOS 15, tvOS 18 or later"); } [self setUpNSFileManagerSwizzlingWithEnabledFlag:NO]; - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite spanCount:0 block:^{ [NSFileManager.defaultManager createFileAtPath:self->filePath @@ -135,7 +135,7 @@ - (void)testNSFileManagerCreateFile_iOS18macOS15tvOS18OrLater_experimentalFlagEn XCTSkip("Test only targets iOS 18, macOS 15, tvOS 18 or later"); } [self setUpNSFileManagerSwizzlingWithEnabledFlag:YES]; - [self assertTransactionForOperation:SENTRY_FILE_WRITE_OPERATION + [self assertTransactionForOperation:SentrySpanOperation.fileWrite spanCount:1 block:^{ [NSFileManager.defaultManager createFileAtPath:self->filePath @@ -178,7 +178,7 @@ - (void)assertTransactionForOperation:(NSString *)operation NSString *filename = filePath.lastPathComponent; - if ([operation isEqualToString:SENTRY_FILE_READ_OPERATION]) { + if ([operation isEqualToString:SentrySpanOperation.fileRead]) { XCTAssertEqualObjects(ioSpan.spanDescription, filename); } else { NSString *expectedString = [NSString stringWithFormat:@"%@ (%@)", filename, diff --git a/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerIntegrationTests.swift b/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerIntegrationTests.swift index d4054c3c36..770a9fdfba 100644 --- a/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerIntegrationTests.swift +++ b/Tests/SentryTests/Integrations/Performance/Network/SentryNetworkTrackerIntegrationTests.swift @@ -1,4 +1,4 @@ -import Sentry +@testable import Sentry import SentryTestUtils import SwiftUI import XCTest @@ -178,7 +178,7 @@ class SentryNetworkTrackerIntegrationTests: XCTestCase { XCTAssertEqual(children?.count, 1) //Span was created in task resume swizzle. let networkSpan = try XCTUnwrap(children?.first) XCTAssertTrue(networkSpan.isFinished) //Span was finished in task setState swizzle. - XCTAssertEqual(SENTRY_NETWORK_REQUEST_OPERATION, networkSpan.operation) + XCTAssertEqual(SentrySpanOperation.networkRequestOperation, networkSpan.operation) XCTAssertEqual("GET \(SentryNetworkTrackerIntegrationTests.testBaggageURL)", networkSpan.spanDescription) XCTAssertEqual("200", networkSpan.data["http.response.status_code"] as? String) diff --git a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift index 865e5e4559..07577c4ec4 100644 --- a/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift +++ b/Tests/SentryTests/Integrations/Performance/UIViewController/SentryTimeToDisplayTrackerTest.swift @@ -1,5 +1,5 @@ import Foundation -import Sentry +@testable import Sentry import SentryTestUtils import XCTest @@ -90,7 +90,7 @@ class SentryTimeToDisplayTrackerTest: XCTestCase { XCTAssertEqual(ttidSpan.timestamp, fixture.dateProvider.date()) XCTAssertEqual(ttidSpan.isFinished, true) XCTAssertEqual(ttidSpan.spanDescription, "UIViewController initial display") - XCTAssertEqual(ttidSpan.operation, SentrySpanOperationUILoadInitialDisplay) + XCTAssertEqual(ttidSpan.operation, SentrySpanOperation.uiLoadInitialDisplay) XCTAssertEqual(ttidSpan.origin, "auto.ui.time_to_display") assertMeasurement(tracer: tracer, name: "time_to_initial_display", duration: 2_000) @@ -174,7 +174,7 @@ class SentryTimeToDisplayTrackerTest: XCTestCase { XCTAssertEqual(sut.fullDisplaySpan?.status, .ok) XCTAssertEqual(sut.fullDisplaySpan?.spanDescription, "UIViewController full display") - XCTAssertEqual(sut.fullDisplaySpan?.operation, SentrySpanOperationUILoadFullDisplay) + XCTAssertEqual(sut.fullDisplaySpan?.operation, SentrySpanOperation.uiLoadFullDisplay) XCTAssertEqual(sut.fullDisplaySpan?.origin, "manual.ui.time_to_display") assertMeasurement(tracer: tracer, name: "time_to_full_display", duration: 3_000) @@ -296,7 +296,7 @@ class SentryTimeToDisplayTrackerTest: XCTestCase { XCTAssertEqual(ttfdSpan?.timestamp, ttidSpan?.timestamp) XCTAssertEqual(ttfdSpan?.status, .deadlineExceeded) XCTAssertEqual(ttfdSpan?.spanDescription, "UIViewController full display - Deadline Exceeded") - XCTAssertEqual(ttfdSpan?.operation, SentrySpanOperationUILoadFullDisplay) + XCTAssertEqual(ttfdSpan?.operation, SentrySpanOperation.uiLoadFullDisplay) XCTAssertEqual(ttfdSpan?.origin, "manual.ui.time_to_display") assertMeasurement(tracer: tracer, name: "time_to_full_display", duration: 1_000) @@ -440,7 +440,7 @@ class SentryTimeToDisplayTrackerTest: XCTestCase { XCTAssertEqual(sut.fullDisplaySpan?.status, .deadlineExceeded) XCTAssertEqual(sut.fullDisplaySpan?.spanDescription, "UIViewController full display - Deadline Exceeded") - XCTAssertEqual(sut.fullDisplaySpan?.operation, SentrySpanOperationUILoadFullDisplay) + XCTAssertEqual(sut.fullDisplaySpan?.operation, SentrySpanOperation.uiLoadFullDisplay) XCTAssertEqual(sut.fullDisplaySpan?.origin, "manual.ui.time_to_display") assertMeasurement(tracer: tracer, name: "time_to_full_display", duration: 1_000) @@ -477,7 +477,7 @@ class SentryTimeToDisplayTrackerTest: XCTestCase { XCTAssertEqual(fullDisplaySpan.status, .deadlineExceeded) XCTAssertEqual(fullDisplaySpan.spanDescription, "UIViewController full display - Deadline Exceeded") - XCTAssertEqual(fullDisplaySpan.operation, SentrySpanOperationUILoadFullDisplay) + XCTAssertEqual(fullDisplaySpan.operation, SentrySpanOperation.uiLoadFullDisplay) XCTAssertEqual(fullDisplaySpan.origin, "manual.ui.time_to_display") assertMeasurement(tracer: tracer, name: "time_to_full_display", duration: 1_000) diff --git a/Tests/SentryTests/Networking/RateLimits/SentryEnvelopeRateLimitTests.swift b/Tests/SentryTests/Networking/RateLimits/SentryEnvelopeRateLimitTests.swift index 8c6a55c676..7f9977c0dd 100644 --- a/Tests/SentryTests/Networking/RateLimits/SentryEnvelopeRateLimitTests.swift +++ b/Tests/SentryTests/Networking/RateLimits/SentryEnvelopeRateLimitTests.swift @@ -1,3 +1,4 @@ +@testable import Sentry import XCTest class SentryEnvelopeRateLimitTests: XCTestCase { diff --git a/Tests/SentryTests/SentryTests-Bridging-Header.h b/Tests/SentryTests/SentryTests-Bridging-Header.h index 782623d2d8..320eb26038 100644 --- a/Tests/SentryTests/SentryTests-Bridging-Header.h +++ b/Tests/SentryTests/SentryTests-Bridging-Header.h @@ -199,7 +199,6 @@ #import "SentrySessionTracker.h" #import "SentrySpan.h" #import "SentrySpanId.h" -#import "SentrySpanOperations.h" #import "SentrySpotlightTransport.h" #import "SentryStacktrace.h" #import "SentryStacktraceBuilder.h" diff --git a/Tests/SentryTests/Transactions/SentrySpanOperationTests.swift b/Tests/SentryTests/Transactions/SentrySpanOperationTests.swift new file mode 100644 index 0000000000..f6e45bb3c4 --- /dev/null +++ b/Tests/SentryTests/Transactions/SentrySpanOperationTests.swift @@ -0,0 +1,48 @@ +@testable import Sentry +import XCTest + +class SentrySpanOperationTests: XCTestCase { + func testAppLifecycle_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.appLifecycle, "app.lifecycle") + } + + func testCoredataFetchOperation_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.coredataFetchOperation, "db.sql.query") + } + + func testCoredataSaveOperation_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.coredataSaveOperation, "db.sql.transaction") + } + + func testFileRead_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.fileRead, "file.read") + } + + func testFileWrite_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.fileWrite, "file.write") + } + + func testNetworkRequestOperation_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.networkRequestOperation, "http.client") + } + + func testUILoad_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.uiLoad, "ui.load") + } + + func testUILoadInitialDisplay_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.uiLoadInitialDisplay, "ui.load.initial_display") + } + + func testUILoadFullDisplay_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.uiLoadFullDisplay, "ui.load.full_display") + } + + func testUIAction_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.uiAction, "ui.action") + } + + func testUIActionClick_shouldBeExpectedValue() { + XCTAssertEqual(SentrySpanOperation.uiActionClick, "ui.action.click") + } +}