Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref: only declare conformance on SentryBaseIntegration superclass #2941

Closed
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
1 change: 1 addition & 0 deletions Sources/Sentry/PrivateSentrySDKOnly.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "SentryViewHierarchy.h"
#import <SentryDependencyContainer.h>
#import <SentryFramesTracker.h>
#import <SentryOptions.h>
#import <SentryScreenshot.h>

@implementation PrivateSentrySDKOnly
Expand Down
1 change: 0 additions & 1 deletion Sources/Sentry/Public/SentryHub.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import "SentryDefines.h"
#import "SentryIntegrationProtocol.h"
#import "SentrySpanProtocol.h"

@class SentryEvent, SentryClient, SentryScope, SentryUser, SentryBreadcrumb, SentryId,
Expand Down
6 changes: 3 additions & 3 deletions Sources/Sentry/Public/SentryIntegrationProtocol.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#import "SentryDefines.h"
#import <Foundation/Foundation.h>

#import "SentryDefines.h"
#import "SentryOptions.h"
@class SentryOptions;

NS_ASSUME_NONNULL_BEGIN

@protocol SentryIntegrationProtocol <NSObject>

/**
* Installs the integration and returns YES if successful.
* Installs the integration and returns @c YES if successful.
*/
- (BOOL)installWithOptions:(SentryOptions *)options;

Expand Down
9 changes: 5 additions & 4 deletions Sources/Sentry/SentryHub.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#import "SentryHub.h"
#import "SentryBaseIntegration.h"
#import "SentryClient+Private.h"
#import "SentryCrashWrapper.h"
#import "SentryCurrentDateProvider.h"
Expand Down Expand Up @@ -36,7 +37,7 @@
@property (nonatomic, strong) SentryTracesSampler *tracesSampler;
@property (nonatomic, strong) SentryProfilesSampler *profilesSampler;
@property (nonatomic, strong) id<SentryCurrentDateProvider> currentDateProvider;
@property (nonatomic, strong) NSMutableArray<id<SentryIntegrationProtocol>> *installedIntegrations;
@property (nonatomic, strong) NSMutableArray<SentryBaseIntegration *> *installedIntegrations;
@property (nonatomic, strong) NSMutableSet<NSString *> *installedIntegrationNames;
@property (nonatomic) NSUInteger errorsBeforeSession;

Expand Down Expand Up @@ -519,7 +520,7 @@ - (void)configureScope:(void (^)(SentryScope *scope))callback
- (BOOL)isIntegrationInstalled:(Class)integrationClass
{
@synchronized(_integrationsLock) {
for (id<SentryIntegrationProtocol> item in _installedIntegrations) {
for (SentryBaseIntegration *item in _installedIntegrations) {
if ([item isKindOfClass:integrationClass]) {
return YES;
}
Expand All @@ -537,7 +538,7 @@ - (BOOL)hasIntegration:(NSString *)integrationName
}
}

- (void)addInstalledIntegration:(id<SentryIntegrationProtocol>)integration name:(NSString *)name
- (void)addInstalledIntegration:(SentryBaseIntegration *)integration name:(NSString *)name
{
@synchronized(_integrationsLock) {
[_installedIntegrations addObject:integration];
Expand All @@ -553,7 +554,7 @@ - (void)removeAllIntegrations
}
}

- (NSArray<id<SentryIntegrationProtocol>> *)installedIntegrations
- (NSArray<SentryBaseIntegration *> *)installedIntegrations
{
@synchronized(_integrationsLock) {
return _installedIntegrations.copy;
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryNSURLRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#import "SentryHub.h"
#import "SentryLog.h"
#import "SentryMeta.h"
#import "SentryOptions.h"
#import "SentrySDK+Private.h"
#import "SentrySerialization.h"

Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryNetworkTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#import "SentryLog.h"
#import "SentryMechanism.h"
#import "SentryNoOpSpan.h"
#import "SentryOptions.h"
#import "SentryRequest.h"
#import "SentrySDK+Private.h"
#import "SentryScope+Private.h"
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryProfiler.mm
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
# import "SentryMetricProfiler.h"
# import "SentryNSProcessInfoWrapper.h"
# import "SentryNSTimerWrapper.h"
# import "SentryOptions.h"
# import "SentryProfileTimeseries.h"
# import "SentrySamplingProfiler.hpp"
# import "SentryScope+Private.h"
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentryRequestOperation.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#import "SentryError.h"
#import "SentryHub.h"
#import "SentryLog.h"
#import "SentryOptions.h"
#import "SentrySDK+Private.h"

NS_ASSUME_NONNULL_BEGIN
Expand Down
6 changes: 4 additions & 2 deletions Sources/Sentry/SentrySDK.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#import "PrivateSentrySDKOnly.h"
#import "SentryAppStartMeasurement.h"
#import "SentryAppStateManager.h"
#import "SentryBaseIntegration.h"
#import "SentryBreadcrumb.h"
#import "SentryClient+Private.h"
#import "SentryCrash.h"
Expand Down Expand Up @@ -350,7 +351,8 @@ + (void)installIntegrations
integrationName);
continue;
}
id<SentryIntegrationProtocol> integrationInstance = [[integrationClass alloc] init];
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was an especially important change. Because the init is defined in SentryBaseIntegration and not SentryIntegrationProtocol, when I changed it from SentryBaseIntegration.init to SentryBaseIntegration.initWithCrashWrapper:, this line didn't break compilation. It would have gone on to crash at runtime. This is an unsafe code sector in general, so this makes it a little better.

SentryBaseIntegration *integrationInstance = [integrationClass alloc];
integrationInstance = [integrationInstance init];
BOOL shouldInstall = [integrationInstance installWithOptions:options];

if (shouldInstall) {
Expand Down Expand Up @@ -380,7 +382,7 @@ + (void)close
SentryHub *hub = SentrySDK.currentHub;

// Uninstall all the integrations
for (NSObject<SentryIntegrationProtocol> *integration in hub.installedIntegrations) {
for (SentryBaseIntegration *integration in hub.installedIntegrations) {
if ([integration respondsToSelector:@selector(uninstall)]) {
[integration uninstall];
}
Expand Down
1 change: 1 addition & 0 deletions Sources/Sentry/SentrySessionTracker.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#import "SentryInternalNotificationNames.h"
#import "SentryLog.h"
#import "SentryNSNotificationCenterWrapper.h"
#import "SentryOptions.h"
#import "SentrySDK+Private.h"

#if SENTRY_HAS_UIKIT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#import "SentryFramesTracker.h"
#import "SentryHub.h"
#import "SentryLog.h"
#import "SentryOptions.h"
#import "SentryPerformanceTracker.h"
#import "SentrySDK+Private.h"
#import "SentryScope.h"
Expand Down
4 changes: 1 addition & 3 deletions Sources/Sentry/include/SentryANRTrackingIntegration.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
#import "SentryANRTracker.h"
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface SentryANRTrackingIntegration
: SentryBaseIntegration <SentryIntegrationProtocol, SentryANRTrackerDelegate>
@interface SentryANRTrackingIntegration : SentryBaseIntegration <SentryANRTrackerDelegate>

@end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Tracks cold and warm app start time for iOS, tvOS, and Mac Catalyst.
*/
@interface SentryAppStartTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryAppStartTrackingIntegration : SentryBaseIntegration

- (void)stop;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
#import "SentryBaseIntegration.h"
#import "SentryBreadcrumbDelegate.h"
#import "SentryIntegrationProtocol.h"

NS_ASSUME_NONNULL_BEGIN

/**
* This automatically adds breadcrumbs for different user actions.
*/
@interface SentryAutoBreadcrumbTrackingIntegration
: SentryBaseIntegration <SentryIntegrationProtocol, SentryBreadcrumbDelegate>
: SentryBaseIntegration <SentryBreadcrumbDelegate>

@end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

/**
* Automatically tracks session start and end.
*/
@interface SentryAutoSessionTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryAutoSessionTrackingIntegration : SentryBaseIntegration

- (void)stop;

Expand Down
3 changes: 2 additions & 1 deletion Sources/Sentry/include/SentryBaseIntegration.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#import "SentryIntegrationProtocol.h"
#import "SentryOptions.h"
#import <Foundation/Foundation.h>

Expand Down Expand Up @@ -25,7 +26,7 @@ typedef NS_OPTIONS(NSUInteger, SentryIntegrationOption) {
kIntegrationOptionEnableMetricKit = 1 << 17,
};

@interface SentryBaseIntegration : NSObject
@interface SentryBaseIntegration : NSObject <SentryIntegrationProtocol>

- (NSString *)integrationName;
- (BOOL)installWithOptions:(SentryOptions *)options;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface SentryCoreDataTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryCoreDataTrackingIntegration : SentryBaseIntegration

@end

Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/include/SentryCrashIntegration.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -9,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
static NSString *const SentryDeviceContextFreeMemoryKey = @"free_memory";
static NSString *const SentryDeviceContextAppMemoryKey = @"app_memory";

@interface SentryCrashIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryCrashIntegration : SentryBaseIntegration

+ (void)enrichScope:(SentryScope *)scope crashWrapper:(SentryCrashWrapper *)crashWrapper;

Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/include/SentryFileIOTrackingIntegration.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface SentryFileIOTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryFileIOTrackingIntegration : SentryBaseIntegration

@end

Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/include/SentryFramesTrackingIntegration.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface SentryFramesTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryFramesTrackingIntegration : SentryBaseIntegration

- (void)stop;

Expand Down
6 changes: 3 additions & 3 deletions Sources/Sentry/include/SentryHub+Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
#import "SentryTracer.h"

@class SentryEnvelopeItem, SentryId, SentryScope, SentryTransaction, SentryDispatchQueueWrapper,
SentryEnvelope, SentryNSTimerWrapper;
SentryEnvelope, SentryNSTimerWrapper, SentryBaseIntegration;

NS_ASSUME_NONNULL_BEGIN

@interface
SentryHub (Private)

@property (nonatomic, strong) NSArray<id<SentryIntegrationProtocol>> *installedIntegrations;
@property (nonatomic, strong) NSArray<SentryBaseIntegration *> *installedIntegrations;
@property (nonatomic, strong) NSSet<NSString *> *installedIntegrationNames;

- (void)addInstalledIntegration:(id<SentryIntegrationProtocol>)integration name:(NSString *)name;
- (void)addInstalledIntegration:(SentryBaseIntegration *)integration name:(NSString *)name;
- (void)removeAllIntegrations;

- (SentryClient *_Nullable)client;
Expand Down
4 changes: 1 addition & 3 deletions Sources/Sentry/include/SentryMetricKitIntegration.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#import "SentryBaseIntegration.h"
#import "SentryEvent.h"
#import "SentryIntegrationProtocol.h"
#import "SentrySwift.h"
#import <Foundation/Foundation.h>

Expand All @@ -19,8 +18,7 @@ static NSString *const SentryMetricKitHangDiagnosticMechanism = @"mx_hang_diagno

API_AVAILABLE(ios(15.0), macos(12.0), macCatalyst(15.0))
API_UNAVAILABLE(tvos, watchos)
@interface SentryMetricKitIntegration
: SentryBaseIntegration <SentryIntegrationProtocol, SentryMXManagerDelegate>
@interface SentryMetricKitIntegration : SentryBaseIntegration <SentryMXManagerDelegate>

@end

Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/include/SentryNetworkTrackingIntegration.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"

NS_ASSUME_NONNULL_BEGIN

@interface SentryNetworkTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryNetworkTrackingIntegration : SentryBaseIntegration

@end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
Expand All @@ -9,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN
* Automatic UI performance setup can be avoided by setting @c enableAutoPerformanceTracing to @c NO
* in @c SentryOptions during SentrySDK initialization.
*/
@interface SentryPerformanceTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryPerformanceTrackingIntegration : SentryBaseIntegration

@end

Expand Down
4 changes: 1 addition & 3 deletions Sources/Sentry/include/SentryScreenshotIntegration.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
#import "SentryBaseIntegration.h"
#import "SentryClient+Private.h"
#import "SentryIntegrationProtocol.h"
#import "SentryScreenshot.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
#if SENTRY_HAS_UIKIT

@interface SentryScreenshotIntegration
: SentryBaseIntegration <SentryIntegrationProtocol, SentryClientAttachmentProcessor>
@interface SentryScreenshotIntegration : SentryBaseIntegration <SentryClientAttachmentProcessor>

@end

Expand Down
3 changes: 1 addition & 2 deletions Sources/Sentry/include/SentryUIEventTrackingIntegration.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
#if SENTRY_HAS_UIKIT
@interface SentryUIEventTrackingIntegration : SentryBaseIntegration <SentryIntegrationProtocol>
@interface SentryUIEventTrackingIntegration : SentryBaseIntegration

@end
#endif
Expand Down
4 changes: 1 addition & 3 deletions Sources/Sentry/include/SentryViewHierarchyIntegration.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#import "SentryBaseIntegration.h"
#import "SentryClient+Private.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN
#if SENTRY_HAS_UIKIT

@interface SentryViewHierarchyIntegration
: SentryBaseIntegration <SentryIntegrationProtocol, SentryClientAttachmentProcessor>
@interface SentryViewHierarchyIntegration : SentryBaseIntegration <SentryClientAttachmentProcessor>

@end

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#import "SentryANRTracker.h"
#import "SentryBaseIntegration.h"
#import "SentryIntegrationProtocol.h"
#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN

@interface SentryWatchdogTerminationTrackingIntegration
: SentryBaseIntegration <SentryIntegrationProtocol, SentryANRTrackerDelegate>
: SentryBaseIntegration <SentryANRTrackerDelegate>

@end

Expand Down
Loading