Skip to content
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
16 changes: 14 additions & 2 deletions Samples/iOS-Swift/iOS-Swift/Tools/SentryExposure.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#import <Sentry/SentryScope.h>
#import <UIKit/UIKit.h>

@class SentryHub;
@class SentryOptions;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -13,11 +13,23 @@ NS_ASSUME_NONNULL_BEGIN

@end

@interface SentryClientInternal : NSObject

@property (nonatomic) SentryOptions *options;

@end

@interface SentryHubInternal : NSObject

- (nullable SentryClientInternal *)getClient;

@end

@interface SentrySDKInternal : NSObject

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

+ (SentryHub *)currentHub;
+ (SentryHubInternal *)currentHub;

@end

Expand Down
44 changes: 24 additions & 20 deletions Sentry.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions SentryTestUtils/SentryHub+Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,14 @@
@class SentryClient;
@class SentryCrashWrapper;
@class SentryDispatchQueueWrapper;
@class SentryClientInternal;
@protocol SentryIntegrationProtocol;
NS_ASSUME_NONNULL_BEGIN

/** Expose the internal test init for testing. */
@interface SentryHub ()
@interface SentryHubInternal ()

- (instancetype)initWithClient:(SentryClient *_Nullable)client
- (instancetype)initWithClient:(SentryClientInternal *_Nullable)client
andScope:(SentryScope *_Nullable)scope
andCrashWrapper:(SentryCrashWrapper *)crashAdapter
andDispatchQueue:(SentryDispatchQueueWrapper *)dispatchQueue;
Expand Down
2 changes: 1 addition & 1 deletion SentryTestUtils/TestClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _SentryPrivate
import Foundation
@_spi(Private) import Sentry

public class TestClient: SentryClient {
public class TestClient: SentryClientInternal {
public override init?(options: Options) {
super.init(
options: options,
Expand Down
2 changes: 1 addition & 1 deletion SentryTestUtils/TestHub.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import _SentryPrivate
import Foundation
@_spi(Private) @testable import Sentry

public class TestHub: SentryHub {
public class TestHub: SentryHubInternal {

public var startSessionInvocations: Int = 0
public var closeCachedSessionInvocations: Int = 0
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 @@ -349,7 +349,7 @@
}

void
sentry_stopAndDiscardLaunchProfileTracer(SentryHub *_Nullable hub)
sentry_stopAndDiscardLaunchProfileTracer(SentryHubInternal *_Nullable hub)
{
SENTRY_LOG_DEBUG(@"Finishing launch tracer.");
sentry_launchTracer.hub = hub;
Expand Down
24 changes: 13 additions & 11 deletions Sources/Sentry/Profiling/SentryProfiledTracerConcurrency.mm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
}

void
sentry_discardProfilerCorrelatedToTrace(SentryId *internalTraceId, SentryHub *hub)
sentry_discardProfilerCorrelatedToTrace(SentryId *internalTraceId, SentryHubInternal *hub)
{
std::lock_guard<std::mutex> l(_gStateLock);

Expand Down Expand Up @@ -238,9 +238,9 @@
}

void
sentry_stopProfilerDueToFinishedTransaction(
SentryHub *hub, SentryDispatchQueueWrapper *dispatchQueue, SentryTransaction *transaction,
BOOL isProfiling, NSDate *_Nullable traceStartTimestamp, uint64_t startSystemTime
sentry_stopProfilerDueToFinishedTransaction(SentryHubInternal *hub,
SentryDispatchQueueWrapper *dispatchQueue, SentryTransaction *transaction, BOOL isProfiling,
NSDate *_Nullable traceStartTimestamp, uint64_t startSystemTime
# if SENTRY_HAS_UIKIT
,
SentryAppStartMeasurement *appStartMeasurement
Expand All @@ -256,10 +256,11 @@
return;
}

SentryClient *_Nullable client = hub.getClient;
SentryClientInternal *_Nullable client = hub.getClient;
if (isProfiling && client != nil
&& sentry_isContinuousProfilingEnabled(SENTRY_UNWRAP_NULLABLE(SentryClient, client))
&& sentry_isProfilingCorrelatedToTraces(SENTRY_UNWRAP_NULLABLE(SentryClient, client))) {
&& sentry_isContinuousProfilingEnabled(SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client))
&& sentry_isProfilingCorrelatedToTraces(
SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client))) {
SENTRY_LOG_DEBUG(@"Stopping tracking root span tracer with profilerReferenceId %@",
sentry_stringFromSentryID(transaction.trace.profilerReferenceID));
sentry_stopTrackingRootSpanForContinuousProfilerV2();
Expand Down Expand Up @@ -334,24 +335,25 @@
}

SentryId *_Nullable sentry_startProfilerForTrace(SentryTracerConfiguration *configuration,
SentryHub *_Nullable hub, SentryTransactionContext *transactionContext)
SentryHubInternal *_Nullable hub, SentryTransactionContext *transactionContext)
{
if (sentry_profileConfiguration.profileOptions != nil) {
// launch profile; there's no hub to get options from, so they're read from the launch
// profile config file
return _sentry_startContinuousProfilerV2ForTrace(
sentry_profileConfiguration.profileOptions, transactionContext);
}
SentryClient *_Nullable client = hub.getClient;
SentryClientInternal *_Nullable client = hub.getClient;
if (client != nil
&& sentry_isContinuousProfilingEnabled(SENTRY_UNWRAP_NULLABLE(SentryClient, client))) {
&& sentry_isContinuousProfilingEnabled(
SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client))) {
// non launch profile
if (sentry_getParentSpanID(transactionContext) != nil) {
SENTRY_LOG_DEBUG(@"Not a root span, will not start automatically for trace lifecycle.");
return nil;
}
SentryProfileOptions *_Nullable profilingOptions
= sentry_getProfiling(SENTRY_UNWRAP_NULLABLE(SentryClient, client));
= sentry_getProfiling(SENTRY_UNWRAP_NULLABLE(SentryClientInternal, client));
if (profilingOptions == nil) {
SENTRY_LOG_DEBUG(@"No profiling options found, will not start profiler.");
return nil;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Sentry/Profiling/SentryProfilerSerialization+Test.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# import "SentryProfiler+Private.h"

@class SentryDebugMeta;
@class SentryHub;
@class SentryHubInternal;

NS_ASSUME_NONNULL_BEGIN

Expand All @@ -26,7 +26,7 @@ SENTRY_EXTERN NSString *sentry_profilerTruncationReasonName(SentryProfilerTrunca
SENTRY_EXTERN NSMutableDictionary<NSString *, id> *sentry_serializedTraceProfileData(
NSDictionary<NSString *, id> *profileData, uint64_t startSystemTime, uint64_t endSystemTime,
NSString *truncationReason, NSDictionary<NSString *, id> *serializedMetrics,
NSArray<SentryDebugMeta *> *debugMeta, SentryHub *hub
NSArray<SentryDebugMeta *> *debugMeta, SentryHubInternal *hub
# if SENTRY_HAS_UIKIT
,
SentryScreenFrames *gpuData
Expand Down
9 changes: 5 additions & 4 deletions Sources/Sentry/Profiling/SentryProfilerSerialization.m
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# import "SentryEnvelopeItemHeader.h"
# import "SentryEvent+Private.h"
# import "SentryFormatter.h"
# import "SentryHub.h"
# import "SentryInternalDefines.h"
# import "SentryLogC.h"
# import "SentryMeta.h"
Expand Down Expand Up @@ -110,7 +111,7 @@
sentry_serializedTraceProfileData(
NSDictionary<NSString *, id> *profileData, uint64_t startSystemTime, uint64_t endSystemTime,
NSString *truncationReason, NSDictionary<NSString *, id> *serializedMetrics,
NSArray<SentryDebugMeta *> *debugMeta, SentryHub *hub
NSArray<SentryDebugMeta *> *debugMeta, SentryHubInternal *hub
# if SENTRY_HAS_UIKIT
,
SentryScreenFrames *gpuData
Expand Down Expand Up @@ -222,7 +223,7 @@
NSMutableDictionary<NSString *, id> *
sentry_serializedContinuousProfileChunk(SentryId *profileID, SentryId *chunkID,
NSDictionary<NSString *, id> *profileData, NSDictionary<NSString *, id> *serializedMetrics,
NSArray<SentryDebugMeta *> *debugMeta, SentryHub *hub
NSArray<SentryDebugMeta *> *debugMeta, SentryHubInternal *hub
# if SENTRY_HAS_UIKIT
,
SentryScreenFrames *gpuData
Expand Down Expand Up @@ -358,7 +359,7 @@
# pragma clang diagnostic pop
}

SentryEnvelopeItem *_Nullable sentry_traceProfileEnvelopeItem(SentryHub *hub,
SentryEnvelopeItem *_Nullable sentry_traceProfileEnvelopeItem(SentryHubInternal *hub,
SentryProfiler *profiler, NSDictionary<NSString *, id> *profilingData,
SentryTransaction *transaction, NSDate *startTimestamp)
{
Expand Down Expand Up @@ -414,7 +415,7 @@
}

NSMutableDictionary<NSString *, id> *_Nullable sentry_collectProfileDataHybridSDK(
uint64_t startSystemTime, uint64_t endSystemTime, SentryId *traceId, SentryHub *hub)
uint64_t startSystemTime, uint64_t endSystemTime, SentryId *traceId, SentryHubInternal *hub)
{
SentryProfiler *profiler = sentry_profilerForFinishedTracer(traceId);
if (!profiler) {
Expand Down
7 changes: 4 additions & 3 deletions Sources/Sentry/Profiling/SentryProfilingSwiftHelpers.m
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#import "SentryProfilingSwiftHelpers.h"
#if SENTRY_TARGET_PROFILING_SUPPORTED

# import "SentryClient.h"
# import "SentryLogC.h"
# import "SentryOptions+Private.h"
# import "SentryProfiler+Private.h"
# import "SentrySamplerDecision.h"
# import "SentrySwift.h"

BOOL
sentry_isContinuousProfilingEnabled(SentryClient *client)
sentry_isContinuousProfilingEnabled(SentryClientInternal *client)
{
return [client.options isContinuousProfilingEnabled];
}

BOOL
sentry_isProfilingCorrelatedToTraces(SentryClient *client)
sentry_isProfilingCorrelatedToTraces(SentryClientInternal *client)
{
return [client.options isProfilingCorrelatedToTraces];
}

SentryProfileOptions *_Nullable sentry_getProfiling(SentryClient *client)
SentryProfileOptions *_Nullable sentry_getProfiling(SentryClientInternal *client)
{
return client.options.profiling;
}
Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/Public/Sentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
# import <Sentry/SentryAttachment.h>
# import <Sentry/SentryBaggage.h>
# import <Sentry/SentryBreadcrumb.h>
# import <Sentry/SentryClient.h>
# import <Sentry/SentryCrashExceptionApplication.h>
# import <Sentry/SentryDebugMeta.h>
# import <Sentry/SentryDefines.h>
Expand All @@ -23,7 +22,7 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
# import <Sentry/SentryFrame.h>
# import <Sentry/SentryGeo.h>
# import <Sentry/SentryHttpStatusCodeRange.h>
# import <Sentry/SentryHub.h>
# import <Sentry/SentryId.h>
# import <Sentry/SentryIntegrationProtocol.h>
# import <Sentry/SentryMeasurementUnit.h>
# import <Sentry/SentryMechanism.h>
Expand Down
33 changes: 33 additions & 0 deletions Sources/Sentry/Public/SentryId.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface SentryId : NSObject

/// A @c SentryId with an empty UUID “00000000000000000000000000000000”.
@property (nonatomic, class, readonly, strong) SentryId *_Nonnull empty;
+ (SentryId *_Nonnull)empty __attribute__((warn_unused_result));

/// Returns a 32 lowercase character hexadecimal string description of the @c SentryId, such as
/// “12c2d058d58442709aa2eca08bf20986”.
@property (nonatomic, readonly, copy) NSString *_Nonnull sentryIdString;

/// Creates a @c SentryId with a random UUID.
- (nonnull instancetype)init __attribute__((objc_designated_initializer));

/// Creates a SentryId with the given UUID.
- (nonnull instancetype)initWithUuid:(NSUUID *_Nonnull)uuid
__attribute__((objc_designated_initializer));

/// Creates a @c SentryId from a 32 character hexadecimal string without dashes such as
/// “12c2d058d58442709aa2eca08bf20986” or a 36 character hexadecimal string such as such as
/// “12c2d058-d584-4270-9aa2-eca08bf20986”.
/// @return SentryId.empty for invalid strings.
- (nonnull instancetype)initWithUUIDString:(NSString *_Nonnull)uuidString
__attribute__((objc_designated_initializer));

- (BOOL)isEqual:(id _Nullable)object __attribute__((warn_unused_result));

@end

NS_ASSUME_NONNULL_END
3 changes: 1 addition & 2 deletions Sources/Sentry/Public/SentryWithoutUIKit.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
# import <SentryWithoutUIKit/SentryAttachment.h>
# import <SentryWithoutUIKit/SentryBaggage.h>
# import <SentryWithoutUIKit/SentryBreadcrumb.h>
# import <SentryWithoutUIKit/SentryClient.h>
# import <SentryWithoutUIKit/SentryCrashExceptionApplication.h>
# import <SentryWithoutUIKit/SentryDebugMeta.h>
# import <SentryWithoutUIKit/SentryDefines.h>
Expand All @@ -24,7 +23,7 @@ FOUNDATION_EXPORT const unsigned char SentryVersionString[];
# import <SentryWithoutUIKit/SentryFrame.h>
# import <SentryWithoutUIKit/SentryGeo.h>
# import <SentryWithoutUIKit/SentryHttpStatusCodeRange.h>
# import <SentryWithoutUIKit/SentryHub.h>
# import <SentryWithoutUIKit/SentryId.h>
# import <SentryWithoutUIKit/SentryIntegrationProtocol.h>
# import <SentryWithoutUIKit/SentryMeasurementUnit.h>
# import <SentryWithoutUIKit/SentryMechanism.h>
Expand Down
6 changes: 2 additions & 4 deletions Sources/Sentry/SentryClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
#import "SentryDsn.h"
#import "SentryEvent+Private.h"
#import "SentryException.h"
#import "SentryHub+Private.h"
#import "SentryHub.h"
#import "SentryInstallation.h"
#import "SentryInternalDefines.h"
#import "SentryLogC.h"
Expand Down Expand Up @@ -46,7 +44,7 @@

NS_ASSUME_NONNULL_BEGIN

@interface SentryClient ()
@interface SentryClientInternal ()

@property (nonatomic, strong) SentryTransportAdapter *transportAdapter;
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;
Expand All @@ -58,7 +56,7 @@ @interface SentryClient ()

NSString *const DropSessionLogMessage = @"Session has no release name. Won't send it.";

@implementation SentryClient
@implementation SentryClientInternal

- (_Nullable instancetype)initWithOptions:(SentryOptions *)options
{
Expand Down
11 changes: 3 additions & 8 deletions Sources/Sentry/SentryDependencyContainerSwiftHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -63,26 +63,21 @@ + (void)dispatchSyncOnMainQueue:(void (^)(void))block
[SentryDependencyContainer.sharedInstance.dispatchQueueWrapper dispatchSyncOnMainQueue:block];
}

+ (SentryHub *)currentHub
{
return SentrySDKInternal.currentHub;
}

+ (nullable NSDate *)readTimestampLastInForeground
{
SentryHub *hub = [SentrySDKInternal currentHub];
SentryHubInternal *hub = [SentrySDKInternal currentHub];
return [[[hub getClient] fileManager] readTimestampLastInForeground];
}

+ (void)deleteTimestampLastInForeground
{
SentryHub *hub = [SentrySDKInternal currentHub];
SentryHubInternal *hub = [SentrySDKInternal currentHub];
[[[hub getClient] fileManager] deleteTimestampLastInForeground];
}

+ (void)storeTimestampLastInForeground:(NSDate *)timestamp
{
SentryHub *hub = [SentrySDKInternal currentHub];
SentryHubInternal *hub = [SentrySDKInternal currentHub];
[[[hub getClient] fileManager] storeTimestampLastInForeground:timestamp];
}

Expand Down
12 changes: 0 additions & 12 deletions Sources/Sentry/SentryEnvelopeHeaderHelper.m

This file was deleted.

Loading
Loading