Skip to content

Commit

Permalink
Merge 6547ab5 into 61a1a2b
Browse files Browse the repository at this point in the history
  • Loading branch information
brustolin authored Mar 1, 2024
2 parents 61a1a2b + 6547ab5 commit 85c4ec2
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 11 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 11 additions & 9 deletions Sources/Sentry/SentryDependencyContainer.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
#import "SentryThreadInspector.h"
#import "SentryUIDeviceWrapper.h"
#import <SentryAppStateManager.h>
#import <SentryClient+Private.h>
#import <SentryCrash.h>
#import <SentryCrashWrapper.h>
#import <SentryDebugImageProvider.h>
#import <SentryDependencyContainer.h>
#import <SentryHub.h>
#import <SentryNSNotificationCenterWrapper.h>
#import <SentrySDK+Private.h>
#import <SentrySwift.h>
#import <SentrySwizzleWrapper.h>
#import <SentrySysctl.h>
#import <SentryThreadWrapper.h>
#import <SentryTracer.h>
#import "SentryFileManager.h"
#import "SentryOptions+Private.h"
#import "SentrySDK+Private.h"

#if SENTRY_HAS_UIKIT
# import "SentryFramesTracker.h"
Expand Down Expand Up @@ -93,7 +94,11 @@ - (SentryFileManager *)fileManager
{
@synchronized(sentryDependencyContainerLock) {
if (_fileManager == nil) {
_fileManager = [[[SentrySDK currentHub] getClient] fileManager];
NSError * error;
_fileManager = [[SentryFileManager alloc] initWithOptions:SentrySDK.options error:&error];
if (_fileManager == nil) {
SENTRY_LOG_DEBUG(@"Could not create file manager - %@", error);
}
}
return _fileManager;
}
Expand All @@ -103,9 +108,8 @@ - (SentryAppStateManager *)appStateManager
{
@synchronized(sentryDependencyContainerLock) {
if (_appStateManager == nil) {
SentryOptions *options = [[[SentrySDK currentHub] getClient] options];
_appStateManager =
[[SentryAppStateManager alloc] initWithOptions:options
[[SentryAppStateManager alloc] initWithOptions:SentrySDK.options
crashWrapper:self.crashWrapper
fileManager:self.fileManager
dispatchQueueWrapper:self.dispatchQueueWrapper
Expand All @@ -132,8 +136,7 @@ - (SentryCrash *)crashReporter
if (_crashReporter == nil) {
@synchronized(sentryDependencyContainerLock) {
if (_crashReporter == nil) {
SentryOptions *options = [[[SentrySDK currentHub] getClient] options];
_crashReporter = [[SentryCrash alloc] initWithBasePath:options.cacheDirectoryPath];
_crashReporter = [[SentryCrash alloc] initWithBasePath:SentrySDK.options.cacheDirectoryPath];
}
}
}
Expand All @@ -157,8 +160,7 @@ - (SentryThreadInspector *)threadInspector
if (_threadInspector == nil) {
@synchronized(sentryDependencyContainerLock) {
if (_threadInspector == nil) {
SentryOptions *options = [[[SentrySDK currentHub] getClient] options];
_threadInspector = [[SentryThreadInspector alloc] initWithOptions:options];
_threadInspector = [[SentryThreadInspector alloc] initWithOptions:SentrySDK.options];
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion Sources/Sentry/SentrySDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ @implementation SentrySDK
static SentryAppStartMeasurement *sentrySDKappStartMeasurement;
static NSObject *sentrySDKappStartMeasurementLock;
static BOOL _detectedStartUpCrash;
static SentryOptions *_Nullable startOption;

/**
* @brief We need to keep track of the number of times @c +[startWith...] is called, because our OOM
Expand Down Expand Up @@ -77,7 +78,7 @@ + (SentryHub *)currentHub
+ (nullable SentryOptions *)options
{
@synchronized(self) {
return [[currentHub getClient] options];
return startOption;
}
}

Expand All @@ -86,6 +87,7 @@ + (void)setCurrentHub:(nullable SentryHub *)hub
{
@synchronized(self) {
currentHub = hub;
startOption = hub.client.options;
}
}

Expand Down Expand Up @@ -166,6 +168,7 @@ + (void)setStartTimestamp:(NSDate *)value

+ (void)startWithOptions:(SentryOptions *)options
{
startOption = options;
[SentryLog configure:options.debug diagnosticLevel:options.diagnosticLevel];

// We accept the tradeoff that the SDK might not be fully initialized directly after
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
@class SentrySystemWrapper;
@class SentryThreadWrapper;
@class SentryThreadInspector;
@class SentryOptions;
@protocol SentryRandom;

#if SENTRY_HAS_METRIC_KIT
Expand Down
3 changes: 3 additions & 0 deletions Sources/Sentry/include/SentrySDK+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ SentrySDK ()

+ (SentryHub *)currentHub;

/**
* The option used to start the SDK
*/
@property (nonatomic, nullable, readonly, class) SentryOptions *options;

/**
Expand Down

0 comments on commit 85c4ec2

Please sign in to comment.