Skip to content

Commit b3dcfa5

Browse files
committed
ref: SentryClient and SentryHub in Swift
1 parent 86eb6d5 commit b3dcfa5

File tree

93 files changed

+4304
-4126
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+4304
-4126
lines changed

Samples/iOS-Swift/iOS-Swift/Tools/SentryExposure.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#import <Sentry/SentryScope.h>
33
#import <UIKit/UIKit.h>
44

5-
@class SentryHub;
5+
@class SentryOptions;
66

77
NS_ASSUME_NONNULL_BEGIN
88

@@ -13,11 +13,23 @@ NS_ASSUME_NONNULL_BEGIN
1313

1414
@end
1515

16+
@interface SentryClientInternal : NSObject
17+
18+
@property (nonatomic) SentryOptions *options;
19+
20+
@end
21+
22+
@interface SentryHubInternal : NSObject
23+
24+
- (nullable SentryClientInternal *)getClient;
25+
26+
@end
27+
1628
@interface SentrySDKInternal : NSObject
1729

1830
+ (nullable NSArray<NSString *> *)relevantViewControllersNames;
1931

20-
+ (SentryHub *)currentHub;
32+
+ (SentryHubInternal *)currentHub;
2133

2234
@end
2335

Sentry.xcodeproj/project.pbxproj

Lines changed: 28 additions & 24 deletions
Large diffs are not rendered by default.

SentryTestUtils/SentryHub+Test.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
@class SentryClient;
44
@class SentryCrashWrapper;
55
@class SentryDispatchQueueWrapper;
6+
@class SentryClientInternal;
67
@protocol SentryIntegrationProtocol;
78
NS_ASSUME_NONNULL_BEGIN
89

910
/** Expose the internal test init for testing. */
10-
@interface SentryHub ()
11+
@interface SentryHubInternal ()
1112

12-
- (instancetype)initWithClient:(SentryClient *_Nullable)client
13+
- (instancetype)initWithClient:(SentryClientInternal *_Nullable)client
1314
andScope:(SentryScope *_Nullable)scope
1415
andCrashWrapper:(SentryCrashWrapper *)crashAdapter
1516
andDispatchQueue:(SentryDispatchQueueWrapper *)dispatchQueue;

SentryTestUtils/TestClient.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _SentryPrivate
22
import Foundation
33
@_spi(Private) import Sentry
44

5-
public class TestClient: SentryClient {
5+
public class TestClient: SentryClientInternal {
66
public override init?(options: Options) {
77
super.init(
88
options: options,

SentryTestUtils/TestHub.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _SentryPrivate
22
import Foundation
33
@_spi(Private) @testable import Sentry
44

5-
public class TestHub: SentryHub {
5+
public class TestHub: SentryHubInternal {
66

77
public var startSessionInvocations: Int = 0
88
public var closeCachedSessionInvocations: Int = 0

Sources/Resources/Sentry.modulemap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ framework module Sentry {
1111
header "SentryAppStartMeasurement.h"
1212
header "SentryBreadcrumb+Private.h"
1313
header "SentryFormatter.h"
14-
header "SentryOptionsInternal.h"
14+
header "SentryOptionsHelpers.h"
1515
header "SentrySwizzle.h"
1616
header "SentryUser+Private.h"
1717

Sources/Sentry/Profiling/SentryLaunchProfiling.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@
349349
}
350350

351351
void
352-
sentry_stopAndDiscardLaunchProfileTracer(SentryHub *_Nullable hub)
352+
sentry_stopAndDiscardLaunchProfileTracer(SentryHubInternal *_Nullable hub)
353353
{
354354
SENTRY_LOG_DEBUG(@"Finishing launch tracer.");
355355
sentry_launchTracer.hub = hub;

Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
}
168168

169169
void
170-
sentry_discardProfilerCorrelatedToTrace(SentryId *internalTraceId, SentryHub *hub)
170+
sentry_discardProfilerCorrelatedToTrace(SentryId *internalTraceId, SentryHubInternal *hub)
171171
{
172172
std::lock_guard<std::mutex> l(_gStateLock);
173173

@@ -238,9 +238,9 @@
238238
}
239239

240240
void
241-
sentry_stopProfilerDueToFinishedTransaction(
242-
SentryHub *hub, SentryDispatchQueueWrapper *dispatchQueue, SentryTransaction *transaction,
243-
BOOL isProfiling, NSDate *_Nullable traceStartTimestamp, uint64_t startSystemTime
241+
sentry_stopProfilerDueToFinishedTransaction(SentryHubInternal *hub,
242+
SentryDispatchQueueWrapper *dispatchQueue, SentryTransaction *transaction, BOOL isProfiling,
243+
NSDate *_Nullable traceStartTimestamp, uint64_t startSystemTime
244244
# if SENTRY_HAS_UIKIT
245245
,
246246
SentryAppStartMeasurement *appStartMeasurement
@@ -256,10 +256,11 @@
256256
return;
257257
}
258258

259-
SentryClient *_Nullable client = hub.getClient;
259+
SentryClientInternal *_Nullable client = hub.getClient;
260260
if (isProfiling && client != nil
261-
&& sentry_isContinuousProfilingEnabled(SENTRY_UNWRAP_NULLABLE(SentryClient, client))
262-
&& sentry_isProfilingCorrelatedToTraces(SENTRY_UNWRAP_NULLABLE(SentryClient, client))) {
261+
&& sentry_isContinuousProfilingEnabled(SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client))
262+
&& sentry_isProfilingCorrelatedToTraces(
263+
SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client))) {
263264
SENTRY_LOG_DEBUG(@"Stopping tracking root span tracer with profilerReferenceId %@",
264265
sentry_stringFromSentryID(transaction.trace.profilerReferenceID));
265266
sentry_stopTrackingRootSpanForContinuousProfilerV2();
@@ -334,24 +335,25 @@
334335
}
335336

336337
SentryId *_Nullable sentry_startProfilerForTrace(SentryTracerConfiguration *configuration,
337-
SentryHub *_Nullable hub, SentryTransactionContext *transactionContext)
338+
SentryHubInternal *_Nullable hub, SentryTransactionContext *transactionContext)
338339
{
339340
if (sentry_profileConfiguration.profileOptions != nil) {
340341
// launch profile; there's no hub to get options from, so they're read from the launch
341342
// profile config file
342343
return _sentry_startContinuousProfilerV2ForTrace(
343344
sentry_profileConfiguration.profileOptions, transactionContext);
344345
}
345-
SentryClient *_Nullable client = hub.getClient;
346+
SentryClientInternal *_Nullable client = hub.getClient;
346347
if (client != nil
347-
&& sentry_isContinuousProfilingEnabled(SENTRY_UNWRAP_NULLABLE(SentryClient, client))) {
348+
&& sentry_isContinuousProfilingEnabled(
349+
SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client))) {
348350
// non launch profile
349351
if (sentry_getParentSpanID(transactionContext) != nil) {
350352
SENTRY_LOG_DEBUG(@"Not a root span, will not start automatically for trace lifecycle.");
351353
return nil;
352354
}
353355
SentryProfileOptions *_Nullable profilingOptions
354-
= sentry_getProfiling(SENTRY_UNWRAP_NULLABLE(SentryClient, client));
356+
= sentry_getProfiling(SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client));
355357
if (profilingOptions == nil) {
356358
SENTRY_LOG_DEBUG(@"No profiling options found, will not start profiler.");
357359
return nil;

Sources/Sentry/Profiling/SentryProfilerSerialization+Test.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# import "SentryProfiler+Private.h"
99

1010
@class SentryDebugMeta;
11-
@class SentryHub;
11+
@class SentryHubInternal;
1212

1313
NS_ASSUME_NONNULL_BEGIN
1414

@@ -26,7 +26,7 @@ SENTRY_EXTERN NSString *sentry_profilerTruncationReasonName(SentryProfilerTrunca
2626
SENTRY_EXTERN NSMutableDictionary<NSString *, id> *sentry_serializedTraceProfileData(
2727
NSDictionary<NSString *, id> *profileData, uint64_t startSystemTime, uint64_t endSystemTime,
2828
NSString *truncationReason, NSDictionary<NSString *, id> *serializedMetrics,
29-
NSArray<SentryDebugMeta *> *debugMeta, SentryHub *hub
29+
NSArray<SentryDebugMeta *> *debugMeta, SentryHubInternal *hub
3030
# if SENTRY_HAS_UIKIT
3131
,
3232
SentryScreenFrames *gpuData

Sources/Sentry/Profiling/SentryProfilerSerialization.m

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
# import "SentryEnvelopeItemHeader.h"
99
# import "SentryEvent+Private.h"
1010
# import "SentryFormatter.h"
11+
# import "SentryHub.h"
1112
# import "SentryInternalDefines.h"
1213
# import "SentryLogC.h"
1314
# import "SentryMeta.h"
@@ -110,7 +111,7 @@
110111
sentry_serializedTraceProfileData(
111112
NSDictionary<NSString *, id> *profileData, uint64_t startSystemTime, uint64_t endSystemTime,
112113
NSString *truncationReason, NSDictionary<NSString *, id> *serializedMetrics,
113-
NSArray<SentryDebugMeta *> *debugMeta, SentryHub *hub
114+
NSArray<SentryDebugMeta *> *debugMeta, SentryHubInternal *hub
114115
# if SENTRY_HAS_UIKIT
115116
,
116117
SentryScreenFrames *gpuData
@@ -222,7 +223,7 @@
222223
NSMutableDictionary<NSString *, id> *
223224
sentry_serializedContinuousProfileChunk(SentryId *profileID, SentryId *chunkID,
224225
NSDictionary<NSString *, id> *profileData, NSDictionary<NSString *, id> *serializedMetrics,
225-
NSArray<SentryDebugMeta *> *debugMeta, SentryHub *hub
226+
NSArray<SentryDebugMeta *> *debugMeta, SentryHubInternal *hub
226227
# if SENTRY_HAS_UIKIT
227228
,
228229
SentryScreenFrames *gpuData
@@ -358,7 +359,7 @@
358359
# pragma clang diagnostic pop
359360
}
360361

361-
SentryEnvelopeItem *_Nullable sentry_traceProfileEnvelopeItem(SentryHub *hub,
362+
SentryEnvelopeItem *_Nullable sentry_traceProfileEnvelopeItem(SentryHubInternal *hub,
362363
SentryProfiler *profiler, NSDictionary<NSString *, id> *profilingData,
363364
SentryTransaction *transaction, NSDate *startTimestamp)
364365
{
@@ -414,7 +415,7 @@
414415
}
415416

416417
NSMutableDictionary<NSString *, id> *_Nullable sentry_collectProfileDataHybridSDK(
417-
uint64_t startSystemTime, uint64_t endSystemTime, SentryId *traceId, SentryHub *hub)
418+
uint64_t startSystemTime, uint64_t endSystemTime, SentryId *traceId, SentryHubInternal *hub)
418419
{
419420
SentryProfiler *profiler = sentry_profilerForFinishedTracer(traceId);
420421
if (!profiler) {

0 commit comments

Comments
 (0)