Skip to content

Commit ff34dd4

Browse files
committed
ref: Create file io tracker Swift interface
1 parent d8ceea3 commit ff34dd4

12 files changed

+53
-16
lines changed

Sentry.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,7 @@
10891089
FA7206DF2E0B37850072FDD4 /* SentryProfileCollector.h in Headers */ = {isa = PBXBuildFile; fileRef = FA7206DE2E0B37780072FDD4 /* SentryProfileCollector.h */; };
10901090
FA7206E12E0B37C80072FDD4 /* SentryProfileCollector.mm in Sources */ = {isa = PBXBuildFile; fileRef = FA7206E02E0B37C60072FDD4 /* SentryProfileCollector.mm */; };
10911091
FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */; };
1092+
FA8AFCEF2E843903007A0E18 /* SentryFileIOTracking.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8AFCEE2E8438FF007A0E18 /* SentryFileIOTracking.swift */; };
10921093
FA8E58F12E0AD4270049F69D /* SentryDispatchQueueWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA8E58F02E0AD4220049F69D /* SentryDispatchQueueWrapper.swift */; };
10931094
FA90FAA82E06614E008CAAE8 /* SentryExtraPackages.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAA72E06614B008CAAE8 /* SentryExtraPackages.swift */; };
10941095
FA90FAFD2E070A3B008CAAE8 /* SentryURLRequestFactory.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */; };
@@ -2433,6 +2434,7 @@
24332434
FA7206DE2E0B37780072FDD4 /* SentryProfileCollector.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SentryProfileCollector.h; sourceTree = "<group>"; };
24342435
FA7206E02E0B37C60072FDD4 /* SentryProfileCollector.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SentryProfileCollector.mm; sourceTree = "<group>"; };
24352436
FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = "<group>"; };
2437+
FA8AFCEE2E8438FF007A0E18 /* SentryFileIOTracking.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryFileIOTracking.swift; sourceTree = "<group>"; };
24362438
FA8E58F02E0AD4220049F69D /* SentryDispatchQueueWrapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryDispatchQueueWrapper.swift; sourceTree = "<group>"; };
24372439
FA90FAA72E06614B008CAAE8 /* SentryExtraPackages.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryExtraPackages.swift; sourceTree = "<group>"; };
24382440
FA90FAFC2E070A3B008CAAE8 /* SentryURLRequestFactory.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryURLRequestFactory.swift; sourceTree = "<group>"; };
@@ -4252,6 +4254,7 @@
42524254
D468C0602D36699700964230 /* IO */ = {
42534255
isa = PBXGroup;
42544256
children = (
4257+
FA8AFCEE2E8438FF007A0E18 /* SentryFileIOTracking.swift */,
42554258
D4EDF9832D0B2A1D0071E7B3 /* Data+SentryTracing.swift */,
42564259
D473ACD62D8090FC000F1CC6 /* FileManager+SentryTracing.swift */,
42574260
D468C0612D3669A200964230 /* SentryFileIOTracker+SwiftHelpers.swift */,
@@ -5623,6 +5626,7 @@
56235626
03F84D3727DD4191008FE43F /* SentrySamplingProfiler.cpp in Sources */,
56245627
8453421628BE8A9500C22EEC /* SentrySpanStatus.m in Sources */,
56255628
6292585B2DAFA5F70049388F /* SentryCrashCxaThrowSwapper.c in Sources */,
5629+
FA8AFCEF2E843903007A0E18 /* SentryFileIOTracking.swift in Sources */,
56265630
92D957732E05A44600E20E66 /* SentryAsyncLog.m in Sources */,
56275631
7B08A3472924CF9C0059603A /* SentryMetricKitIntegration.m in Sources */,
56285632
623FD9022D3FA5E000803EDA /* SentryFrameCodable.swift in Sources */,

Sources/Sentry/SentryDependencyContainer.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,13 @@
6161
@interface SentryFileManager () <SentryFileManagerProtocol>
6262
@end
6363

64+
@interface SentryFileIOTracker () <SentryFileIOTracking>
65+
@end
66+
6467
@interface SentryDependencyContainer ()
6568

6669
@property (nonatomic, strong) id<SentryANRTracker> anrTracker;
70+
@property (nonatomic, strong) SentryFileIOTracker *fileIOTracker;
6771

6872
@end
6973

@@ -221,6 +225,11 @@ - (SentryThreadInspector *)threadInspector SENTRY_THREAD_SANITIZER_DOUBLE_CHECKE
221225
[[SentryThreadInspector alloc] initWithOptions:SentrySDKInternal.options]);
222226
}
223227

228+
- (id<SentryFileIOTracking>)fileIOTracking
229+
{
230+
return [self fileIOTracker];
231+
}
232+
224233
- (SentryFileIOTracker *)fileIOTracker SENTRY_THREAD_SANITIZER_DOUBLE_CHECKED_LOCK
225234
{
226235
SENTRY_LAZY_INIT(_fileIOTracker,

Sources/Sentry/SentryFileIOTracker.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,15 @@ @implementation SentryFileIOTracker
3333

3434
NSString *const SENTRY_TRACKING_COUNTER_KEY = @"SENTRY_TRACKING_COUNTER_KEY";
3535

36-
+ (instancetype _Nullable)sharedInstance
36+
+ (id<SentryFileIOTracking> _Nullable)sharedInstance
3737
{
3838
// It is necessary to check if the SDK is enabled because accessing the tracker will otherwise
3939
// initialize the depency container without any configured SDK options. This is a known issue
4040
// and needs to be fixed in general.
4141
if (!SentrySDK.isEnabled) {
4242
return nil;
4343
}
44-
return SentryDependencyContainer.sharedInstance.fileIOTracker;
44+
return SentryDependencyContainer.sharedInstance.fileIOTracking;
4545
}
4646

4747
- (instancetype)initWithThreadInspector:(SentryThreadInspector *)threadInspector

Sources/Sentry/SentryFileIOTrackingIntegration.m

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
#import "SentryFileIOTracker.h"
44
#import "SentryNSDataSwizzling.h"
55
#import "SentryNSFileManagerSwizzling.h"
6+
#import "SentrySwift.h"
67
#import "SentryThreadInspector.h"
78

89
@interface SentryFileIOTrackingIntegration ()
910

10-
@property (nonatomic, strong) SentryFileIOTracker *tracker;
11+
@property (nonatomic, strong) id<SentryFileIOTracking> tracker;
1112

1213
@end
1314

@@ -19,7 +20,7 @@ - (BOOL)installWithOptions:(SentryOptions *)options
1920
return NO;
2021
}
2122

22-
self.tracker = [[SentryDependencyContainer sharedInstance] fileIOTracker];
23+
self.tracker = [[SentryDependencyContainer sharedInstance] fileIOTracking];
2324
[self.tracker enable];
2425

2526
[SentryNSDataSwizzling.shared startWithOptions:options tracker:self.tracker];

Sources/Sentry/SentryNSDataSwizzling.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@interface SentryNSDataSwizzling ()
99

10-
@property (nonatomic, strong) SentryFileIOTracker *tracker;
10+
@property (nonatomic, strong) id<SentryFileIOTracking> tracker;
1111

1212
@end
1313

@@ -21,7 +21,7 @@ + (SentryNSDataSwizzling *)shared
2121
return instance;
2222
}
2323

24-
- (void)startWithOptions:(SentryOptions *)options tracker:(SentryFileIOTracker *)tracker
24+
- (void)startWithOptions:(SentryOptions *)options tracker:(id<SentryFileIOTracking>)tracker
2525
{
2626
self.tracker = tracker;
2727

Sources/Sentry/SentryNSFileManagerSwizzling.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
@interface SentryNSFileManagerSwizzling ()
99

10-
@property (nonatomic, strong) SentryFileIOTracker *tracker;
10+
@property (nonatomic, strong) id<SentryFileIOTracking> tracker;
1111

1212
@end
1313

@@ -21,7 +21,7 @@ + (SentryNSFileManagerSwizzling *)shared
2121
return instance;
2222
}
2323

24-
- (void)startWithOptions:(SentryOptions *)options tracker:(SentryFileIOTracker *)tracker
24+
- (void)startWithOptions:(SentryOptions *)options tracker:(id<SentryFileIOTracking>)tracker
2525
{
2626
self.tracker = tracker;
2727

Sources/Sentry/include/HybridPublic/SentryDependencyContainer.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
@class SentrySystemWrapper;
2121
@class SentryThreadWrapper;
2222
@class SentryThreadInspector;
23-
@class SentryFileIOTracker;
2423
@class SentryScopePersistentStore;
2524
@class SentryOptions;
2625
@class SentrySessionTracker;
@@ -33,6 +32,7 @@
3332
@protocol SentryApplication;
3433
@protocol SentryProcessInfoSource;
3534
@protocol SentryDispatchQueueProviderProtocol;
35+
@protocol SentryFileIOTracking;
3636
@protocol SentryNSNotificationCenterWrapper;
3737
@protocol SentryObjCRuntimeWrapper;
3838

@@ -108,8 +108,8 @@ SENTRY_NO_INIT
108108

109109
@property (nonatomic, strong, nullable) SentryFileManager *fileManager;
110110
@property (nonatomic, strong) SentryAppStateManager *appStateManager;
111+
- (id<SentryFileIOTracking>)fileIOTracking;
111112
@property (nonatomic, strong) SentryThreadInspector *threadInspector;
112-
@property (nonatomic, strong) SentryFileIOTracker *fileIOTracker;
113113
@property (nonatomic, strong) SentryCrash *crashReporter;
114114
@property (nonatomic, strong) SentryScopePersistentStore *scopePersistentStore;
115115
@property (nonatomic, strong) SentryDebugImageProvider *debugImageProvider;

Sources/Sentry/include/SentryFileIOTracker.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
NS_ASSUME_NONNULL_BEGIN
44

55
@protocol SentryProcessInfoSource;
6+
@protocol SentryFileIOTracking;
67
@class SentryThreadInspector;
78

89
@interface SentryFileIOTracker : NSObject
@@ -16,7 +17,7 @@ SENTRY_NO_INIT
1617
*
1718
* @return The shared instance of the tracker.
1819
*/
19-
+ (instancetype _Nullable)sharedInstance;
20+
+ (SentryFileIOTracker *_Nullable)sharedInstance;
2021

2122
- (instancetype)initWithThreadInspector:(SentryThreadInspector *)threadInspector
2223
processInfoWrapper:(id<SentryProcessInfoSource>)processInfoWrapper;

Sources/Sentry/include/SentryNSDataSwizzling.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#import "SentryDefines.h"
2-
#import "SentryFileIOTracker.h"
32

43
NS_ASSUME_NONNULL_BEGIN
54

65
@class SentryOptions;
76

7+
@protocol SentryFileIOTracking;
8+
89
@interface SentryNSDataSwizzling : NSObject
910
SENTRY_NO_INIT
1011

1112
@property (class, readonly) SentryNSDataSwizzling *shared;
1213

13-
- (void)startWithOptions:(SentryOptions *)options tracker:(SentryFileIOTracker *)tracker;
14+
- (void)startWithOptions:(SentryOptions *)options tracker:(id<SentryFileIOTracking>)tracker;
1415

1516
- (void)stop;
1617

Sources/Sentry/include/SentryNSFileManagerSwizzling.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
#import "SentryDefines.h"
2-
#import "SentryFileIOTracker.h"
32

43
NS_ASSUME_NONNULL_BEGIN
54

65
@class SentryOptions;
76

7+
@protocol SentryFileIOTracking;
8+
89
@interface SentryNSFileManagerSwizzling : NSObject
910
SENTRY_NO_INIT
1011

1112
@property (class, readonly) SentryNSFileManagerSwizzling *shared;
1213

13-
- (void)startWithOptions:(SentryOptions *)options tracker:(SentryFileIOTracker *)tracker;
14+
- (void)startWithOptions:(SentryOptions *)options tracker:(id<SentryFileIOTracking>)tracker;
1415

1516
- (void)stop;
1617

0 commit comments

Comments
 (0)