@@ -51,9 +51,14 @@ - (BOOL)installWithOptions:(SentryOptions *)options
5151 }
5252
5353#if SENTRY_HAS_UIKIT
54+ # if SDK_V9
55+ BOOL isV2Enabled = YES ;
56+ # else
57+ BOOL isV2Enabled = options.enableAppHangTrackingV2 ;
58+ # endif // SDK_V9
5459 self.tracker =
5560 [SentryDependencyContainer.sharedInstance getANRTracker: options.appHangTimeoutInterval
56- isV2Enabled: options.enableAppHangTrackingV2 ];
61+ isV2Enabled: isV2Enabled ];
5762#else
5863 self.tracker =
5964 [SentryDependencyContainer.sharedInstance getANRTracker: options.appHangTimeoutInterval];
@@ -157,9 +162,15 @@ - (void)anrDetectedWithType:(enum SentryANRType)type
157162 event.debugMeta = [self .debugImageProvider getDebugImagesFromCacheForThreads: event.threads];
158163
159164#if SENTRY_HAS_UIKIT
165+ # if SDK_V9
166+ BOOL isV2Enabled = YES ;
167+ # else
168+ BOOL isV2Enabled = self.options .enableAppHangTrackingV2 ;
169+ # endif // SDK_V9
170+
160171 // We only measure app hang duration for V2.
161172 // For V1, we directly capture the app hang event.
162- if (self. options . enableAppHangTrackingV2 ) {
173+ if (isV2Enabled ) {
163174 // We only temporarily store the app hang duration info, so we can change the error message
164175 // when either sending a normal or fatal app hang event. Otherwise, we would have to rely on
165176 // string parsing to retrieve the app hang duration info from the error message.
@@ -187,9 +198,11 @@ - (void)anrStoppedWithResult:(SentryANRStoppedResult *_Nullable)result
187198{
188199#if SENTRY_HAS_UIKIT
189200 // We only measure app hang duration for V2, and therefore ignore V1.
201+ # if !SDK_V9
190202 if (!self.options .enableAppHangTrackingV2 ) {
191203 return ;
192204 }
205+ # endif // !SDK_V9
193206
194207 if (result == nil ) {
195208 SENTRY_LOG_WARN (@" ANR stopped for V2 but result was nil." )
0 commit comments