Skip to content

Commit ecb08a9

Browse files
committed
Rename
1 parent 2c7422a commit ecb08a9

File tree

7 files changed

+69
-17
lines changed

7 files changed

+69
-17
lines changed

SentryTestUtils/Headers/SentryHub+Test.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
@class SentryCrashWrapper;
55
@class SentryDispatchQueueWrapper;
66
@class SentryClientInternal;
7-
@protocol SentryBaseIntegrationProtocol;
7+
@protocol SentryIntegrationProtocol;
88
NS_ASSUME_NONNULL_BEGIN
99

1010
/** Expose the internal test init for testing. */
@@ -15,7 +15,7 @@ NS_ASSUME_NONNULL_BEGIN
1515
andCrashWrapper:(SentryCrashWrapper *)crashAdapter
1616
andDispatchQueue:(SentryDispatchQueueWrapper *)dispatchQueue;
1717

18-
- (NSArray<id<SentryBaseIntegrationProtocol>> *)installedIntegrations;
18+
- (NSArray<id<SentryIntegrationProtocol>> *)installedIntegrations;
1919
- (NSSet<NSString *> *)installedIntegrationNames;
2020

2121
- (BOOL)eventContainsOnlyHandledErrors:(NSDictionary *)eventDictionary;

Sources/Sentry/SentryHub.m

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ - (void)configureScope:(void (^)(SentryScope *scope))callback
621621
- (BOOL)isIntegrationInstalled:(Class)integrationClass
622622
{
623623
@synchronized(_integrationsLock) {
624-
for (id<SentryBaseIntegrationProtocol> item in _installedIntegrations) {
624+
for (id<SentryIntegrationProtocol> item in _installedIntegrations) {
625625
if ([item isKindOfClass:integrationClass]) {
626626
return YES;
627627
}
@@ -630,10 +630,10 @@ - (BOOL)isIntegrationInstalled:(Class)integrationClass
630630
}
631631
}
632632

633-
- (nullable id<SentryBaseIntegrationProtocol>)getInstalledIntegration:(Class)integrationClass
633+
- (nullable id<SentryIntegrationProtocol>)getInstalledIntegration:(Class)integrationClass
634634
{
635635
@synchronized(_integrationsLock) {
636-
for (id<SentryBaseIntegrationProtocol> item in _installedIntegrations) {
636+
for (id<SentryIntegrationProtocol> item in _installedIntegrations) {
637637
if ([item isKindOfClass:integrationClass]) {
638638
return item;
639639
}
@@ -651,7 +651,7 @@ - (BOOL)hasIntegration:(NSString *)integrationName
651651
}
652652
}
653653

654-
- (void)addInstalledIntegration:(id<SentryBaseIntegrationProtocol>)integration name:(NSString *)name
654+
- (void)addInstalledIntegration:(id<SentryIntegrationProtocol>)integration name:(NSString *)name
655655
{
656656
@synchronized(_integrationsLock) {
657657
[_installedIntegrations addObject:integration];
@@ -661,7 +661,7 @@ - (void)addInstalledIntegration:(id<SentryBaseIntegrationProtocol>)integration n
661661

662662
- (void)removeAllIntegrations
663663
{
664-
for (NSObject<SentryBaseIntegrationProtocol> *integration in self.installedIntegrations) {
664+
for (NSObject<SentryIntegrationProtocol> *integration in self.installedIntegrations) {
665665
if ([integration respondsToSelector:@selector(uninstall)]) {
666666
[integration uninstall];
667667
}
@@ -672,7 +672,7 @@ - (void)removeAllIntegrations
672672
}
673673
}
674674

675-
- (NSArray<id<SentryBaseIntegrationProtocol>> *)installedIntegrations
675+
- (NSArray<id<SentryIntegrationProtocol>> *)installedIntegrations
676676
{
677677
@synchronized(_integrationsLock) {
678678
return _installedIntegrations.copy;

Sources/Sentry/include/HybridPublic/SentryBaseIntegration.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ typedef NS_OPTIONS(NSUInteger, SentryIntegrationOption) {
3434

3535
@class SentryOptions;
3636

37-
@interface SentryBaseIntegration : NSObject <SentryIntegrationProtocol>
37+
@interface SentryBaseIntegration : NSObject <SentryObjCIntegrationProtocol>
3838

3939
- (NSString *)integrationName;
4040
- (BOOL)installWithOptions:(SentryOptions *)options;

Sources/Sentry/include/HybridPublic/SentryIntegrationProtocol.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ NS_ASSUME_NONNULL_BEGIN
44

55
@class SentryOptions;
66

7-
@protocol SentryBaseIntegrationProtocol <NSObject>
7+
// All Integrations conform to this protocol so that the SDK
8+
// can uninstall them when the SDK is closed.
9+
@protocol SentryIntegrationProtocol <NSObject>
810

911
/**
1012
* Uninstalls the integration.
@@ -13,7 +15,11 @@ NS_ASSUME_NONNULL_BEGIN
1315

1416
@end
1517

16-
@protocol SentryIntegrationProtocol <SentryBaseIntegrationProtocol>
18+
// ObjC integrations conform to this protocol. This should not be used for new
19+
// integrations. New ones should be written in Swift and use the `Sentry.Integration`
20+
// protocol. The main difference is that the ObjC protocol does not inject dependencies
21+
// so conformers need to access the singleton.
22+
@protocol SentryObjCIntegrationProtocol <SentryIntegrationProtocol>
1723

1824
/**
1925
* Installs the integration and returns YES if successful.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#import <Foundation/Foundation.h>
2+
#import "SentryIntegrationProtocol.h"
3+
4+
NS_ASSUME_NONNULL_BEGIN
5+
6+
typedef NS_OPTIONS(NSUInteger, SentryIntegrationOption) {
7+
kIntegrationOptionNone = 0,
8+
kIntegrationOptionEnableAutoSessionTracking = 1 << 0,
9+
kIntegrationOptionEnableWatchdogTerminationTracking = 1 << 1,
10+
kIntegrationOptionEnableAutoPerformanceTracing = 1 << 2,
11+
kIntegrationOptionEnableUIViewControllerTracing = 1 << 3,
12+
kIntegrationOptionAttachScreenshot = 1 << 4,
13+
kIntegrationOptionEnableUserInteractionTracing = 1 << 5,
14+
kIntegrationOptionEnableAppHangTracking = 1 << 6,
15+
kIntegrationOptionEnableNetworkTracking = 1 << 7,
16+
kIntegrationOptionEnableFileIOTracing = 1 << 8,
17+
kIntegrationOptionEnableNetworkBreadcrumbs = 1 << 9,
18+
kIntegrationOptionEnableCoreDataTracing = 1 << 10,
19+
kIntegrationOptionEnableSwizzling = 1 << 11,
20+
kIntegrationOptionEnableAutoBreadcrumbTracking = 1 << 12,
21+
kIntegrationOptionIsTracingEnabled = 1 << 13,
22+
kIntegrationOptionDebuggerNotAttached = 1 << 14,
23+
kIntegrationOptionAttachViewHierarchy = 1 << 15,
24+
kIntegrationOptionEnableCrashHandler = 1 << 16,
25+
kIntegrationOptionEnableMetricKit = 1 << 17,
26+
kIntegrationOptionEnableReplay = 1 << 18,
27+
kIntegrationOptionStartFramesTracker = 1 << 19,
28+
};
29+
30+
@class SentryOptions;
31+
32+
@interface SentryBaseIntegration : NSObject <SentryIntegrationProtocol>
33+
34+
- (NSString *)integrationName;
35+
- (BOOL)installWithOptions:(SentryOptions *)options;
36+
- (void)logWithOptionName:(NSString *)optionName;
37+
- (void)logWithReason:(NSString *)reason;
38+
- (BOOL)shouldBeEnabledWithOptions:(SentryOptions *)options;
39+
- (SentryIntegrationOption)integrationOptions;
40+
- (void)uninstall;
41+
@end
42+
43+
NS_ASSUME_NONNULL_END

Sources/Sentry/include/SentryHub+Private.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@class SentryReplayEvent;
1313
@class SentryAttachment;
1414
@class SentryReplayRecording;
15-
@protocol SentryBaseIntegrationProtocol;
15+
@protocol SentryIntegrationProtocol;
1616

1717
NS_ASSUME_NONNULL_BEGIN
1818

@@ -28,7 +28,7 @@ NS_ASSUME_NONNULL_BEGIN
2828
@property (nullable, nonatomic, strong) SentrySession *session;
2929

3030
@property (nonatomic, strong)
31-
NSMutableArray<id<SentryBaseIntegrationProtocol>> *installedIntegrations;
31+
NSMutableArray<id<SentryIntegrationProtocol>> *installedIntegrations;
3232

3333
@property (nonatomic, readonly, strong) NSObject *_swiftLogger;
3434

@@ -38,7 +38,7 @@ NS_ASSUME_NONNULL_BEGIN
3838
*/
3939
- (NSArray<NSString *> *)trimmedInstalledIntegrationNames;
4040

41-
- (void)addInstalledIntegration:(id<SentryBaseIntegrationProtocol>)integration
41+
- (void)addInstalledIntegration:(id<SentryIntegrationProtocol>)integration
4242
name:(NSString *)name;
4343
- (void)removeAllIntegrations;
4444

@@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN
8686

8787
- (void)registerSessionListener:(id<SentrySessionListener>)listener;
8888
- (void)unregisterSessionListener:(id<SentrySessionListener>)listener;
89-
- (nullable id<SentryBaseIntegrationProtocol>)getInstalledIntegration:(Class)integrationClass;
89+
- (nullable id<SentryIntegrationProtocol>)getInstalledIntegration:(Class)integrationClass;
9090
- (NSSet<NSString *> *)installedIntegrationNames;
9191

9292
#if SENTRY_TARGET_REPLAY_SUPPORTED

Sources/Swift/Core/Integrations/Integrations.swift

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
@_implementationOnly import _SentryPrivate
22

3-
protocol Integration: SentryBaseIntegrationProtocol {
3+
// The Swift counterpart to `SentryObjcIntegrationProtocol`. This protocol allows
4+
// injecting the dependencies in a way that does not require the Integration to
5+
// depend on SentryDependencyContainer.
6+
protocol Integration: SentryIntegrationProtocol {
47
// The dependencies required for the integration. The easiest way to satisfy this requirement when migrating from ObjC
58
// is to define it as `SentryDependencyContainer` with a typealias. However, a generic Swift class that has a protocol
69
// constraint on the `Dependencies` type can make it easier to test and to use without a direct dependency on all
@@ -16,7 +19,7 @@ protocol Integration: SentryBaseIntegrationProtocol {
1619

1720
// Type erases the `Integration` so that it can be stored in an array and used for `addInstalledIntegration`
1821
private struct AnyIntegration {
19-
let start: (Options, SentryDependencyContainer) -> SentryBaseIntegrationProtocol?
22+
let start: (Options, SentryDependencyContainer) -> SentryIntegrationProtocol?
2023
let name: String
2124

2225
init<I: Integration>(_ integration: I.Type) where I.Dependencies == SentryDependencyContainer {

0 commit comments

Comments
 (0)