diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index bf60da1ba58..53f1a37e089 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -189,7 +189,7 @@ 639FCF981EBC7B9700778193 /* SentryEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCF961EBC7B9700778193 /* SentryEvent.h */; settings = {ATTRIBUTES = (Public, ); }; }; 639FCF991EBC7B9700778193 /* SentryEvent.m in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF971EBC7B9700778193 /* SentryEvent.m */; }; 639FCF9C1EBC7F9500778193 /* SentryThread.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCF9A1EBC7F9500778193 /* SentryThread.h */; settings = {ATTRIBUTES = (Public, ); }; }; - 639FCF9D1EBC7F9500778193 /* SentryThread.m in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF9B1EBC7F9500778193 /* SentryThread.m */; }; + 639FCF9D1EBC7F9500778193 /* SentryThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF9B1EBC7F9500778193 /* SentryThread.mm */; }; 639FCFA01EBC804600778193 /* SentryException.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCF9E1EBC804600778193 /* SentryException.h */; settings = {ATTRIBUTES = (Public, ); }; }; 639FCFA11EBC804600778193 /* SentryException.m in Sources */ = {isa = PBXBuildFile; fileRef = 639FCF9F1EBC804600778193 /* SentryException.m */; }; 639FCFA41EBC809A00778193 /* SentryStacktrace.h in Headers */ = {isa = PBXBuildFile; fileRef = 639FCFA21EBC809A00778193 /* SentryStacktrace.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -783,7 +783,7 @@ 8ECC674725C23A20000E2BF6 /* SentrySpanContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */; }; 8ECC674825C23A20000E2BF6 /* SentryTransaction.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */; }; 8ECC674925C23A20000E2BF6 /* SentrySpanId.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674525C23A20000E2BF6 /* SentrySpanId.m */; }; - 8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */; }; + 8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */; }; 8ED3D306264DFE700049393B /* SwiftDescriptorTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */; }; 8EE017A126704CD500470616 /* SentryUIViewControllerPerformanceTrackerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8EA1ED0E2669152F00E62B98 /* SentryUIViewControllerPerformanceTrackerTests.swift */; }; 8F0D6AA22B04115A00D048B1 /* SentryInstallation+Test.h in Sources */ = {isa = PBXBuildFile; fileRef = 8F0D6AA12B040A0100D048B1 /* SentryInstallation+Test.h */; }; @@ -1035,6 +1035,7 @@ FA67DD172DDBD4EA00896B02 /* SentryLogOutput.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCEC2DDBD4EA00896B02 /* SentryLogOutput.swift */; }; FA67DD182DDBD4EA00896B02 /* UIImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCED2DDBD4EA00896B02 /* UIImageHelper.swift */; }; FA67DD192DDBD4EA00896B02 /* SwizzleClassNameExclude.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCD52DDBD4EA00896B02 /* SwizzleClassNameExclude.swift */; }; + FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -1307,7 +1308,7 @@ 639FCF961EBC7B9700778193 /* SentryEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryEvent.h; path = Public/SentryEvent.h; sourceTree = ""; }; 639FCF971EBC7B9700778193 /* SentryEvent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryEvent.m; sourceTree = ""; }; 639FCF9A1EBC7F9500778193 /* SentryThread.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryThread.h; path = Public/SentryThread.h; sourceTree = ""; }; - 639FCF9B1EBC7F9500778193 /* SentryThread.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryThread.m; sourceTree = ""; }; + 639FCF9B1EBC7F9500778193 /* SentryThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryThread.mm; sourceTree = ""; }; 639FCF9E1EBC804600778193 /* SentryException.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryException.h; path = Public/SentryException.h; sourceTree = ""; }; 639FCF9F1EBC804600778193 /* SentryException.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryException.m; sourceTree = ""; }; 639FCFA21EBC809A00778193 /* SentryStacktrace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryStacktrace.h; path = Public/SentryStacktrace.h; sourceTree = ""; }; @@ -1974,7 +1975,7 @@ 8ECC674325C23A1F000E2BF6 /* SentrySpanContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySpanContext.m; sourceTree = ""; }; 8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryTransaction.m; sourceTree = ""; }; 8ECC674525C23A20000E2BF6 /* SentrySpanId.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySpanId.m; sourceTree = ""; }; - 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryTransactionContext.mm; sourceTree = ""; }; + 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryTransactionContext.m; sourceTree = ""; }; 8ED3D305264DFE700049393B /* SwiftDescriptorTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptorTests.swift; sourceTree = ""; }; 8F0D6AA12B040A0100D048B1 /* SentryInstallation+Test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentryInstallation+Test.h"; sourceTree = ""; }; 8F73BC302B02B87E00C3CEF4 /* SentryInstallationTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryInstallationTests.swift; sourceTree = ""; }; @@ -2248,6 +2249,7 @@ FA67DCEF2DDBD4EA00896B02 /* URLSessionTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelper.swift; sourceTree = ""; }; FA67DCF12DDBD4EA00896B02 /* SentryExperimentalOptions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExperimentalOptions.swift; sourceTree = ""; }; FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = ""; }; + FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -2478,7 +2480,7 @@ 639FCFA21EBC809A00778193 /* SentryStacktrace.h */, 639FCFA31EBC809A00778193 /* SentryStacktrace.m */, 639FCF9A1EBC7F9500778193 /* SentryThread.h */, - 639FCF9B1EBC7F9500778193 /* SentryThread.m */, + 639FCF9B1EBC7F9500778193 /* SentryThread.mm */, 639FCFAA1EBC811400778193 /* SentryUser.h */, 639FCFAB1EBC811400778193 /* SentryUser.m */, 843FB3212D0CD04D00558F18 /* SentryUserAccess.h */, @@ -3839,6 +3841,7 @@ 8ECC673625C23936000E2BF6 /* Transaction */ = { isa = PBXGroup; children = ( + FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */, D8603DD7284F894C000E1227 /* SentryBaggage.h */, D8603DD4284F8497000E1227 /* SentryBaggage.m */, 620379DA2AFE1415005AC0C1 /* SentryBuildAppStartSpans.h */, @@ -3885,7 +3888,7 @@ 8E4E7C6B25DAAAFE006AB9E2 /* SentryTransaction.h */, 8ECC674425C23A1F000E2BF6 /* SentryTransaction.m */, 8ECC673B25C23996000E2BF6 /* SentryTransactionContext.h */, - 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.mm */, + 8ECC674625C23A20000E2BF6 /* SentryTransactionContext.m */, 0A56DA5E28ABA01B00C400D5 /* SentryTransactionContext+Private.h */, ); name = Transaction; @@ -4738,6 +4741,7 @@ 7BA61CB9247BC57B00C130A8 /* SentryCrashDefaultBinaryImageProvider.h in Headers */, 8E4E7C7D25DAB287006AB9E2 /* SentryTracer.h in Headers */, 7BC8523724588115005A70F0 /* SentryDataCategory.h in Headers */, + FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */, 62A456E32B0370AA003F19A1 /* SentryUIEventTrackerTransactionMode.h in Headers */, 63FE714B20DA4C1100CDBAE8 /* SentryCrashString.h in Headers */, 7BCFBD6D2681D0A900BC27D8 /* SentryCrashScopeObserver.h in Headers */, @@ -5119,7 +5123,7 @@ D8ACE3C82762187200F5A213 /* SentryFileIOTracker.m in Sources */, 7BE3C77D2446112C00A38442 /* SentryRateLimitParser.m in Sources */, D8B088B729C9E3FF00213258 /* SentryTracerConfiguration.m in Sources */, - 8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.mm in Sources */, + 8ECC674A25C23A20000E2BF6 /* SentryTransactionContext.m in Sources */, 03BCC38C27E1C01A003232C7 /* SentryTime.mm in Sources */, A8F17B342902870300990B25 /* SentryHttpStatusCodeRange.m in Sources */, 62C97D3A2CC64E6B00DDA204 /* SentryUncaughtNSExceptions.m in Sources */, @@ -5351,7 +5355,7 @@ 63FE712D20DA4C1100CDBAE8 /* SentryCrashJSONCodecObjC.m in Sources */, 7BBD18932449BEDD00427C76 /* SentryDefaultRateLimits.m in Sources */, 7BD729982463E93500EA3610 /* SentryDateUtil.m in Sources */, - 639FCF9D1EBC7F9500778193 /* SentryThread.m in Sources */, + 639FCF9D1EBC7F9500778193 /* SentryThread.mm in Sources */, D88B30A92D48D8C3008DE513 /* SentryMaskingPreviewView.swift in Sources */, 849B8F992C6E906900148E1F /* SentryUserFeedbackFormConfiguration.swift in Sources */, 8E8C57A225EEFC07001CEEFA /* SentrySampling.m in Sources */, diff --git a/Sources/Sentry/PrivateSentrySDKOnly.mm b/Sources/Sentry/PrivateSentrySDKOnly.mm index 822f0920bf0..fad43352990 100644 --- a/Sources/Sentry/PrivateSentrySDKOnly.mm +++ b/Sources/Sentry/PrivateSentrySDKOnly.mm @@ -13,7 +13,6 @@ #import "SentrySDK+Private.h" #import "SentrySerialization.h" #import "SentrySessionReplayIntegration+Private.h" -#import "SentrySwift.h" #import "SentryThreadHandle.hpp" #import "SentryUser+Private.h" #import "SentryViewHierarchy.h" @@ -31,6 +30,10 @@ # import "SentryTraceProfiler.h" #endif // SENTRY_TARGET_PROFILING_SUPPORTED +#if SENTRY_TARGET_PROFILING_SUPPORTED || SENTRY_TARGET_REPLAY_SUPPORTED +# import "SentrySwift.h" +#endif // SENTRY_TARGET_PROFILING_SUPPORTED || SENTRY_TARGET_REPLAY_SUPPORTED + @implementation PrivateSentrySDKOnly static SentryOnAppStartMeasurementAvailable _onAppStartMeasurementAvailable; diff --git a/Sources/Sentry/SentryThread.m b/Sources/Sentry/SentryThread.mm similarity index 69% rename from Sources/Sentry/SentryThread.m rename to Sources/Sentry/SentryThread.mm index b5b254334ff..e7254f301fa 100644 --- a/Sources/Sentry/SentryThread.m +++ b/Sources/Sentry/SentryThread.mm @@ -1,7 +1,12 @@ #import "SentryThread.h" #import "NSMutableDictionary+Sentry.h" +#include "SentryProfilingConditionals.h" #import "SentryStacktrace.h" +#if SENTRY_TARGET_PROFILING_SUPPORTED +# include "SentryThreadHandle.hpp" +#endif // SENTRY_TARGET_PROFILING_SUPPORTED + NS_ASSUME_NONNULL_BEGIN @implementation SentryThread @@ -28,6 +33,16 @@ - (instancetype)initWithThreadId:(NSNumber *)threadId return serializedData; } +#if SENTRY_TARGET_PROFILING_SUPPORTED + ++ (SentryThread *)threadInfo +{ + const auto threadID = sentry::profiling::ThreadHandle::current()->tid(); + return [[SentryThread alloc] initWithThreadId:@(threadID)]; +} + +#endif // SENTRY_TARGET_PROFILING_SUPPORTED + @end NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/SentryTransactionContext.mm b/Sources/Sentry/SentryTransactionContext.m similarity index 96% rename from Sources/Sentry/SentryTransactionContext.mm rename to Sources/Sentry/SentryTransactionContext.m index 32a51e87841..aadf1d3982b 100644 --- a/Sources/Sentry/SentryTransactionContext.mm +++ b/Sources/Sentry/SentryTransactionContext.m @@ -3,14 +3,14 @@ #include "SentryProfilingConditionals.h" #import "SentrySpanContext+Private.h" #import "SentrySwift.h" +#import "SentryThread+Private.h" #import "SentryThread.h" -#include "SentryThreadHandle.hpp" #import "SentryTraceOrigin.h" #import "SentryTransactionContext+Private.h" NS_ASSUME_NONNULL_BEGIN -static const auto kSentryDefaultSamplingDecision = kSentrySampleDecisionUndecided; +static const NSUInteger kSentryDefaultSamplingDecision = kSentrySampleDecisionUndecided; @implementation SentryTransactionContext @@ -197,8 +197,7 @@ - (instancetype)initWithName:(NSString *)name - (void)getThreadInfo { #if SENTRY_TARGET_PROFILING_SUPPORTED - const auto threadID = sentry::profiling::ThreadHandle::current()->tid(); - self.threadInfo = [[SentryThread alloc] initWithThreadId:@(threadID)]; + self.threadInfo = [SentryThread threadInfo]; #endif } diff --git a/Sources/Sentry/include/SentryThread+Private.h b/Sources/Sentry/include/SentryThread+Private.h new file mode 100644 index 00000000000..0ac1522b438 --- /dev/null +++ b/Sources/Sentry/include/SentryThread+Private.h @@ -0,0 +1,17 @@ +#include "SentryProfilingConditionals.h" +#include "SentryThread.h" +#import + +#if SENTRY_TARGET_PROFILING_SUPPORTED + +NS_ASSUME_NONNULL_BEGIN + +@interface SentryThread () + ++ (SentryThread *)threadInfo; + +@end + +NS_ASSUME_NONNULL_END + +#endif