Skip to content

Commit 30f4e4c

Browse files
authored
feat(v9): Mark deprecated APIs as deprecated (#5599)
1 parent 5d4b9f2 commit 30f4e4c

16 files changed

+81
-6
lines changed

Sources/Sentry/Profiling/SentryLaunchProfiling.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,9 +164,12 @@
164164
return sentry_launchShouldHaveContinuousProfilingV2(options);
165165
}
166166

167+
# pragma clang diagnostic push
168+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
167169
if ([options isContinuousProfilingEnabled]) {
168170
return (SentryLaunchProfileConfig) { options.enableAppLaunchProfiling, nil, nil };
169171
}
172+
# pragma clang diagnostic pop
170173

171174
return sentry_launchShouldHaveTransactionProfiling(options);
172175
}

Sources/Sentry/Public/SentryOptions.h

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,9 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
543543
* @c SentryProfileOptions.startOnAppStart and @c SentryProfileOptions.lifecycle .
544544
* @note Profiling is automatically disabled if a thread sanitizer is attached.
545545
*/
546-
@property (nonatomic, assign) BOOL enableAppLaunchProfiling;
546+
@property (nonatomic, assign) BOOL enableAppLaunchProfiling DEPRECATED_MSG_ATTRIBUTE(
547+
"This property is deprecated and will be removed in a future version of the SDK. See "
548+
"SentryProfileOptions.startOnAppStart and SentryProfileOptions.lifecycle");
547549

548550
/**
549551
* @note Profiling is not supported on watchOS or tvOS.
@@ -570,7 +572,9 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
570572
* @warning This property is deprecated and will be removed in a future version of the SDK. See
571573
* @c SentryProfileOptions.sessionSampleRate.
572574
*/
573-
@property (nullable, nonatomic, strong) NSNumber *profilesSampleRate;
575+
@property (nullable, nonatomic, strong) NSNumber *profilesSampleRate DEPRECATED_MSG_ATTRIBUTE(
576+
"This property is deprecated and will be removed in a future version of the SDK. See "
577+
"SentryProfileOptions.sessionSampleRate");
574578

575579
/**
576580
* @note Profiling is not supported on watchOS or tvOS.
@@ -584,7 +588,11 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
584588
* @warning This property is deprecated and will be removed in a future version of the SDK. See
585589
* @c SentryProfileOptions.sessionSampleRate .
586590
*/
587-
@property (nullable, nonatomic) SentryTracesSamplerCallback profilesSampler NS_SWIFT_SENDABLE;
591+
@property (nullable, nonatomic)
592+
SentryTracesSamplerCallback profilesSampler NS_SWIFT_SENDABLE DEPRECATED_MSG_ATTRIBUTE(
593+
"This property is deprecated and will be removed in a future version of the SDK. See "
594+
"SentryProfileOptions.sessionSampleRate");
595+
;
588596

589597
/**
590598
* If profiling should be enabled or not.
@@ -597,7 +605,8 @@ typedef void (^SentryProfilingConfigurationBlock)(SentryProfileOptions *_Nonnull
597605
* @note Profiling is automatically disabled if a thread sanitizer is attached.
598606
* @warning This property is deprecated and will be removed in a future version of the SDK.
599607
*/
600-
@property (nonatomic, assign, readonly) BOOL isProfilingEnabled;
608+
@property (nonatomic, assign, readonly) BOOL isProfilingEnabled DEPRECATED_MSG_ATTRIBUTE(
609+
"This property is deprecated and will be removed in a future version of the SDK");
601610

602611
/**
603612
* @brief Whether to enable the sampling profiler.

Sources/Sentry/SentryOptions.m

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,10 @@ - (instancetype)init
153153
self.tracesSampleRate = nil;
154154
#if SENTRY_TARGET_PROFILING_SUPPORTED
155155
_enableProfiling = NO;
156+
# pragma clang diagnostic push
157+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
156158
self.profilesSampleRate = SENTRY_INITIAL_PROFILES_SAMPLE_RATE;
159+
# pragma clang diagnostic pop
157160
#endif // SENTRY_TARGET_PROFILING_SUPPORTED
158161
self.enableCoreDataTracing = YES;
159162
_enableSwizzling = YES;
@@ -538,12 +541,18 @@ - (BOOL)validateOptions:(NSDictionary<NSString *, id> *)options
538541

539542
#if SENTRY_TARGET_PROFILING_SUPPORTED
540543
if ([options[@"profilesSampleRate"] isKindOfClass:[NSNumber class]]) {
544+
# pragma clang diagnostic push
545+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
541546
self.profilesSampleRate = options[@"profilesSampleRate"];
547+
# pragma clang diagnostic pop
542548
}
543549

550+
# pragma clang diagnostic push
551+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
544552
if ([self isBlock:options[@"profilesSampler"]]) {
545553
self.profilesSampler = options[@"profilesSampler"];
546554
}
555+
# pragma clang diagnostic pop
547556

548557
[self setBool:options[@"enableProfiling"]
549558
block:^(BOOL value) { self->_enableProfiling = value; }];

Sources/Sentry/SentrySampling.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,15 +108,18 @@
108108
forSampleRate:@1.0
109109
withSampleRand:@1.0];
110110
}
111-
# pragma clang diagnostic pop
112111

113112
NSNumber *callbackRate = _sentry_samplerCallbackRate(
114113
options.profilesSampler, context, SENTRY_DEFAULT_PROFILES_SAMPLE_RATE);
114+
# pragma clang diagnostic pop
115115
if (callbackRate != nil) {
116116
return _sentry_calcSample(callbackRate);
117117
}
118118

119+
# pragma clang diagnostic push
120+
# pragma clang diagnostic ignored "-Wdeprecated-declarations"
119121
return _sentry_calcSampleFromNumericalRate(options.profilesSampleRate);
122+
# pragma clang diagnostic pop
120123
}
121124

122125
SentrySamplerDecision *

Sources/Sentry/SentrySdkInfo.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@ + (instancetype)global
2222
- (instancetype)initWithOptions:(SentryOptions *_Nullable)options
2323
{
2424

25+
#pragma clang diagnostic push
26+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
2527
NSArray<NSString *> *features =
2628
[SentryEnabledFeaturesBuilder getEnabledFeaturesWithOptions:options];
29+
#pragma clang diagnostic pop
2730

2831
NSMutableArray<NSString *> *integrations =
2932
[SentrySDK.currentHub trimmedInstalledIntegrationNames];

Sources/Swift/Helper/SentryEnabledFeaturesBuilder.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Foundation
33
@objcMembers @_spi(Private) public class SentryEnabledFeaturesBuilder: NSObject {
44

55
// swiftlint:disable cyclomatic_complexity function_body_length
6+
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
67
public static func getEnabledFeatures(options: Options?) -> [String] {
78
guard let options = options else {
89
return []

Tests/SentryProfilerTests/SentryAppLaunchProfilingTests.swift

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import XCTest
33

44
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst)
5+
@available(*, deprecated, message: "App launch profiling is deprecated in favor of continuous profiling.")
56
final class SentryAppLaunchProfilingTests: XCTestCase {
67
private var fixture: SentryProfileTestFixture!
78

@@ -17,6 +18,7 @@ final class SentryAppLaunchProfilingTests: XCTestCase {
1718
}
1819

1920
// MARK: transaction based profiling
21+
@available(*, deprecated, message: "App launch profiling is deprecated in favor of continuous profiling.")
2022
extension SentryAppLaunchProfilingTests {
2123
// test that the launch trace instance is nil after stopping the launch
2224
// profiler
@@ -95,6 +97,7 @@ extension SentryAppLaunchProfilingTests {
9597

9698
// MARK: transaction based profiling iOS-only
9799
#if !os(macOS)
100+
@available(*, deprecated, message: "App launch profiling is deprecated in favor of continuous profiling.")
98101
extension SentryAppLaunchProfilingTests {
99102
// test that if a launch trace profiler is running and SentryTimeToDisplayTracker reports the app had its initial frame drawn and isn't waiting for full drawing, that the profile is stopped
100103
func testLaunchTraceProfileStoppedOnInitialDisplayWithoutWaitingForFullDisplay() throws {
@@ -145,6 +148,7 @@ extension SentryAppLaunchProfilingTests {
145148
#endif // !os(macOS)
146149

147150
// MARK: continuous profiling v1
151+
@available(*, deprecated, message: "Continuos profiling V1 is deprecated.")
148152
extension SentryAppLaunchProfilingTests {
149153
// test continuous launch profiling configuration
150154
func testContinuousLaunchProfileV1Configuration() throws {
@@ -205,6 +209,7 @@ extension SentryAppLaunchProfilingTests {
205209

206210
// MARK: continuous profiling v1 iOS-only
207211
#if !os(macOS)
212+
@available(*, deprecated, message: "Continuos profiling V1 is deprecated.")
208213
extension SentryAppLaunchProfilingTests {
209214
// test that if a launch continuous profiler is running and SentryTimeToDisplayTracker reports the app is fully drawn, that the profiler continues running
210215
func testLaunchContinuousProfileV1NotStoppedOnFullyDisplayed() throws {
@@ -250,6 +255,7 @@ extension SentryAppLaunchProfilingTests {
250255
#endif // !os(macOS)
251256

252257
// MARK: continuous profiling v2
258+
@available(*, deprecated, message: "This is only deprecated because SentryAppLaunchProfilingTests is deprecated. Once trace based and continuous profiling v1 is removed this deprecation can be removed.")
253259
extension SentryAppLaunchProfilingTests {
254260
func testContinuousLaunchProfileV2TraceLifecycleConfiguration() throws {
255261
// Arrange
@@ -488,6 +494,7 @@ extension SentryAppLaunchProfilingTests {
488494

489495
// MARK: continuous profiling v2 iOS-only
490496
#if !os(macOS)
497+
@available(*, deprecated, message: "This is only deprecated because SentryAppLaunchProfilingTests is deprecated. Once trace based and continuous profiling v1 is removed this deprecation can be removed.")
491498
extension SentryAppLaunchProfilingTests {
492499
func testLaunchContinuousProfileV2TraceLifecycleNotStoppedOnFullyDisplayed() throws {
493500
// Arrange

Tests/SentryProfilerTests/SentryAppStartProfilingConfigurationTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ final class SentryAppStartProfilingConfigurationTests: XCTestCase {
2828
}
2929
}
3030

31+
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
3132
extension SentryAppStartProfilingConfigurationTests {
3233
func testValidCombinations() {
3334
for config in SentryAppStartProfilingConfigurationTests.validConfigurations {
@@ -61,6 +62,7 @@ extension SentryAppStartProfilingConfigurationTests {
6162
}
6263

6364
private extension SentryAppStartProfilingConfigurationTests {
65+
@available(*, deprecated, message: "This is only marked as deprecated because enableAppLaunchProfiling is marked as deprecated. Once that is removed this can be removed.")
6466
private func performTest(expectedOptions: LaunchProfileOptions, shouldProfileLaunch: Bool) {
6567
let actualOptions = Options()
6668
actualOptions.enableAppLaunchProfiling = expectedOptions.enableAppLaunchProfiling

Tests/SentryProfilerTests/SentryContinuousProfilerTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import XCTest
55

66
#if os(iOS) || os(macOS) || targetEnvironment(macCatalyst)
77

8+
@available(*, deprecated, message: "This is only marked as deprecated because profilesSampleRate is marked as deprecated. Once that is removed this can be removed.")
89
final class SentryContinuousProfilerTests: XCTestCase {
910
private var fixture: SentryProfileTestFixture!
1011

@@ -206,6 +207,7 @@ final class SentryContinuousProfilerTests: XCTestCase {
206207
}
207208
}
208209

210+
@available(*, deprecated, message: "This is only marked as deprecated because profilesSampleRate is marked as deprecated. Once that is removed this can be removed.")
209211
private extension SentryContinuousProfilerTests {
210212
func addMockSamples(mockAddresses: [NSNumber]) throws {
211213
let mockThreadMetadata = SentryProfileTestFixture.ThreadMetadata(id: 1, priority: 2, name: "main")

Tests/SentryProfilerTests/SentryProfileTestFixture.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class SentryProfileTestFixture {
3939
lazy var framesTracker = TestFramesTracker(displayLinkWrapper: displayLinkWrapper, dateProvider: currentDateProvider, dispatchQueueWrapper: dispatchQueueWrapper, notificationCenter: notificationCenter, keepDelayedFramesDuration: 0)
4040
#endif // !os(macOS)
4141

42+
@available(*, deprecated, message: "This is only marked as deprecated because profilesSampleRate is marked as deprecated. Once that is removed this can be removed.")
4243
init() {
4344
SentryDependencyContainer.sharedInstance().dispatchQueueWrapper = dispatchQueueWrapper
4445
SentryDependencyContainer.sharedInstance().dateProvider = currentDateProvider

0 commit comments

Comments
 (0)