Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Convert constants SentrySpanOperations to Swift #4718

Merged
merged 9 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
40 changes: 28 additions & 12 deletions Sentry.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand Down Expand Up @@ -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 */; };
Expand Down Expand Up @@ -1410,7 +1412,6 @@
7B3B472F25D6CBFC00D01640 /* SentryNSError.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSError.h; path = Public/SentryNSError.h; sourceTree = "<group>"; };
7B3B473725D6CC7E00D01640 /* SentryNSError.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSError.m; sourceTree = "<group>"; };
7B3B473D25D6CEA500D01640 /* SentryNSErrorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryNSErrorTests.swift; sourceTree = "<group>"; };
7B3B83712833832B0001FDEB /* SentrySpanOperations.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentrySpanOperations.h; path = include/SentrySpanOperations.h; sourceTree = "<group>"; };
7B4260332630315C00B36EDD /* SampleError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SampleError.swift; sourceTree = "<group>"; };
7B42C47F27E08F33009B58C2 /* SentryDependencyContainer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryDependencyContainer.h; path = include/HybridPublic/SentryDependencyContainer.h; sourceTree = "<group>"; };
7B42C48127E08F4B009B58C2 /* SentryDependencyContainer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryDependencyContainer.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1889,6 +1890,9 @@
A8AFFCD32907E0CA00967CD7 /* SentryRequestTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryRequestTests.swift; sourceTree = "<group>"; };
A8F17B2D2901765900990B25 /* SentryRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryRequest.m; sourceTree = "<group>"; };
A8F17B332902870300990B25 /* SentryHttpStatusCodeRange.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryHttpStatusCodeRange.m; sourceTree = "<group>"; };
D48724DC2D354934005DE483 /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = "<group>"; };
D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperationTests.swift; sourceTree = "<group>"; };
D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentrySpanOperation.swift; sourceTree = "<group>"; };
D4AF00202D2E92FD00F5F3D7 /* SentryNSFileManagerSwizzling.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSFileManagerSwizzling.m; sourceTree = "<group>"; };
D4AF00222D2E931000F5F3D7 /* SentryNSFileManagerSwizzling.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSFileManagerSwizzling.h; path = include/SentryNSFileManagerSwizzling.h; sourceTree = "<group>"; };
D4AF00242D2E93C400F5F3D7 /* SentryNSFileManagerSwizzlingTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryNSFileManagerSwizzlingTests.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2359,7 +2363,6 @@
6304360C1EC05CEF00C4D3FA /* Frameworks */,
6327C5D41EB8A783004E799B /* Products */,
7D826E3C2390840E00EED93D /* Utils */,
8459FCC62BD86C9E0038E9C9 /* Recovered References */,
);
indentWidth = 4;
sourceTree = "<group>";
Expand Down Expand Up @@ -2558,6 +2561,7 @@
63AA75931EB8AEDB00D153DE /* SentryTests */ = {
isa = PBXGroup;
children = (
D48724DE2D3549C1005DE483 /* Transactions */,
D4F2B5332D0C69CC00649E42 /* Recording */,
62872B602BA1B84400A4FA7D /* Swift */,
7B3878E92490D90400EBDEA2 /* SentryClient+TestInit.h */,
Expand Down Expand Up @@ -3572,13 +3576,6 @@
path = Feedback;
sourceTree = "<group>";
};
8459FCC62BD86C9E0038E9C9 /* Recovered References */ = {
isa = PBXGroup;
children = (
);
name = "Recovered References";
sourceTree = "<group>";
};
847B1A002C618ACA002CB1F3 /* UserFeedback */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -3677,6 +3673,22 @@
name = Transaction;
sourceTree = "<group>";
};
D48724D92D35258A005DE483 /* Transactions */ = {
isa = PBXGroup;
children = (
D48724DC2D354934005DE483 /* SentrySpanOperation.swift */,
);
path = Transactions;
sourceTree = "<group>";
};
D48724DE2D3549C1005DE483 /* Transactions */ = {
isa = PBXGroup;
children = (
D48724DF2D3549C6005DE483 /* SentrySpanOperationTests.swift */,
);
path = Transactions;
sourceTree = "<group>";
};
D4F2B5332D0C69CC00649E42 /* Recording */ = {
isa = PBXGroup;
children = (
Expand All @@ -3688,6 +3700,7 @@
D800942328F82E8D005D3943 /* Swift */ = {
isa = PBXGroup;
children = (
D48724D92D35258A005DE483 /* Transactions */,
D8CAC02D2BA0663E00E38F34 /* Integrations */,
621D9F2D2B9B030E003D94DE /* Helper */,
D8F016B42B962533007B9AFB /* Extensions */,
Expand Down Expand Up @@ -3762,6 +3775,7 @@
D8199DB529376ECC0074249E /* SentrySwiftUI.h */,
D88D25E92B8E0BAC0073C3D5 /* module.modulemap */,
D8199DB629376ECC0074249E /* SentryTracedView.swift */,
D48E8B9C2D3E82AC0032E35E /* SentrySpanOperation.swift */,
D8A65B5C2C98656000974B74 /* SentryReplayView.swift */,
);
path = SentrySwiftUI;
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
Expand Down Expand Up @@ -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 */,
);
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/Profiling/SentryLaunchProfiling.m
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryCoreDataTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ - (NSArray *)managedObjectContext:(NSManagedObjectContext *)context
{
__block id<SentrySpan> fetchSpan;
[SentrySDK.currentHub.scope useSpan:^(id<SentrySpan> _Nullable span) {
fetchSpan = [span startChildWithOperation:SENTRY_COREDATA_FETCH_OPERATION
fetchSpan = [span startChildWithOperation:SentrySpanOperation.coredataFetchOperation
description:[self descriptionFromRequest:request]];
fetchSpan.origin = SentryTraceOriginAutoDBCoreData;
}];
Expand Down Expand Up @@ -77,7 +77,7 @@ - (BOOL)managedObjectContext:(NSManagedObjectContext *)context
[self groupEntitiesOperations:context];

[SentrySDK.currentHub.scope useSpan:^(id<SentrySpan> _Nullable span) {
saveSpan = [span startChildWithOperation:SENTRY_COREDATA_SAVE_OPERATION
saveSpan = [span startChildWithOperation:SentrySpanOperation.coredataSaveOperation
description:[self descriptionForOperations:operations
inContext:context]];
saveSpan.origin = SentryTraceOriginAutoDBCoreData;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/SentryFileIOTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ - (void)mainThreadExtraInfo:(id<SentrySpan>)span

- (nullable id<SentrySpan>)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<SentrySpan>)startTrackingReadingFilePath:(NSString *)path
Expand All @@ -245,7 +245,7 @@ - (void)mainThreadExtraInfo:(id<SentrySpan>)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
Expand Down
2 changes: 1 addition & 1 deletion Sources/Sentry/SentryNetworkTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ - (void)urlSessionTaskResume:(NSURLSessionTask *)sessionTask
[SentrySDK.currentHub.scope useSpan:^(id<SentrySpan> _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]];
Expand Down
5 changes: 2 additions & 3 deletions Sources/Sentry/SentryTimeToDisplayTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/SentryTracer.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#import <NSMutableDictionary+Sentry.h>
#import <SentryDispatchQueueWrapper.h>
#import <SentryMeasurementValue.h>
#import <SentrySpanOperations.h>

#if SENTRY_TARGET_PROFILING_SUPPORTED
# import "SentryCaptureTransactionWithProfile.h"
Expand Down Expand Up @@ -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;
Expand Down
9 changes: 4 additions & 5 deletions Sources/Sentry/SentryUIEventTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# import "SentrySwizzleWrapper.h"
# import <SentryDependencyContainer.h>
# import <SentryLog.h>
# import <SentrySpanOperations.h>
# import <SentryUIEventTrackerMode.h>

NS_ASSUME_NONNULL_BEGIN
Expand Down Expand Up @@ -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;
}

/**
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 3 additions & 4 deletions Sources/Sentry/SentryUIEventTrackerTransactionMode.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
# import <SentrySDK.h>
# import <SentryScope.h>
# import <SentrySpanId.h>
# import <SentrySpanOperations.h>
# import <SentryTraceOrigins.h>
# import <SentryTracer.h>
# import <SentryTransactionContext+Private.h>
Expand Down Expand Up @@ -72,10 +71,10 @@ - (void)handleUIEvent:(NSString *)action
__block SentryTracer *transaction;
[SentrySDK.currentHub.scope useSpan:^(id<SentrySpan> _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;

Expand Down
Loading
Loading