From 11a095f6f87510192932ffaca8e192c480104cb7 Mon Sep 17 00:00:00 2001 From: Philipp Hofmann Date: Tue, 6 Aug 2024 14:49:26 +0200 Subject: [PATCH] feat(apple): Add docs for swizzleClassNameExcludes Add docs for the existing option swizzleClassNameExcludes. --- .../apple/common/configuration/swizzling.mdx | 27 +++++++++++++++++++ .../automatic-instrumentation.mdx | 21 +++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/docs/platforms/apple/common/configuration/swizzling.mdx b/docs/platforms/apple/common/configuration/swizzling.mdx index 45d3b298d399e..c861d513d4b05 100644 --- a/docs/platforms/apple/common/configuration/swizzling.mdx +++ b/docs/platforms/apple/common/configuration/swizzling.mdx @@ -47,3 +47,30 @@ SentrySDK.start { options in options.enableSwizzling = NO; }]; ``` + + +## Skip Swizzling for Specific Classes + +To skip swizzling specific classes, you can use the option `swizzleClassNameExcludes`, which is available with Sentry Cocoa SDK version `8.23.0` and above. The SDK checks if the class name of a class to swizzle contains a class name of this option. For example, if you add MyUIViewController to this list, the Sentry Cocoa SDK excludes the following classes from swizzling: + +- YourApp.MyUIViewController, +- YourApp.MyUIViewControllerA +- MyApp.MyUIViewController + + +```swift +SentrySDK.start { options in + options.swizzleClassNameExcludes = [ + "MyUIViewController", + ] +} +``` + +```objc {tabTitle:Objective-C} +[SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.swizzleClassNameExcludes = [NSSet setWithObjects: + @"MyUIViewController", + nil + ]; +}]; +``` diff --git a/docs/platforms/apple/common/tracing/instrumentation/automatic-instrumentation.mdx b/docs/platforms/apple/common/tracing/instrumentation/automatic-instrumentation.mdx index 3623fec2082b6..6de313e5f8003 100644 --- a/docs/platforms/apple/common/tracing/instrumentation/automatic-instrumentation.mdx +++ b/docs/platforms/apple/common/tracing/instrumentation/automatic-instrumentation.mdx @@ -58,8 +58,29 @@ SentrySDK.start { options in }]; ``` +You can disable UIViewController tracing for specific UIViewControllers by using the option `swizzleClassNameExcludes`: + + +```swift +SentrySDK.start { options in + options.swizzleClassNameExcludes = [ + "MyUIViewController", + ] +} +``` + +```objc {tabTitle:Objective-C} +[SentrySDK startWithConfigureOptions:^(SentryOptions *options) { + options.swizzleClassNameExcludes = [NSSet setWithObjects: + @"MyUIViewController", + nil + ]; +}]; +``` + [UIViewController]: https://developer.apple.com/documentation/uikit/uiviewcontroller + ## App Start Tracing This feature is available for iOS, tvOS, and Mac Catalyst.