@@ -45,14 +45,8 @@ - (BOOL)installWithOptions:(SentryOptions *)options
4545 }
4646
4747#if SENTRY_HAS_UIKIT
48- # if SDK_V9
49- BOOL isV2Enabled = YES ;
50- # else
51- BOOL isV2Enabled = options.enableAppHangTrackingV2 ;
52- # endif // SDK_V9
5348 self.tracker =
54- [SentryDependencyContainer.sharedInstance getANRTracker: options.appHangTimeoutInterval
55- isV2Enabled: isV2Enabled];
49+ [SentryDependencyContainer.sharedInstance getANRTracker: options.appHangTimeoutInterval];
5650#else
5751 self.tracker =
5852 [SentryDependencyContainer.sharedInstance getANRTracker: options.appHangTimeoutInterval];
@@ -157,48 +151,29 @@ - (void)anrDetectedWithType:(enum SentryANRType)type
157151 getDebugImagesFromCacheForThreads: SENTRY_UNWRAP_NULLABLE (NSArray , event.threads)];
158152
159153#if SENTRY_HAS_UIKIT
160- # if SDK_V9
161- BOOL isV2Enabled = YES ;
162- # else
163- BOOL isV2Enabled = self.options .enableAppHangTrackingV2 ;
164- # endif // SDK_V9
165-
166- // We only measure app hang duration for V2.
167- // For V1, we directly capture the app hang event.
168- if (isV2Enabled) {
169- // We only temporarily store the app hang duration info, so we can change the error message
170- // when either sending a normal or fatal app hang event. Otherwise, we would have to rely on
171- // string parsing to retrieve the app hang duration info from the error message.
172- mechanism.data = @{ SentryANRMechanismDataAppHangDuration : appHangDurationInfo };
173-
174- // We need to apply the scope now because if the app hang turns into a fatal one,
175- // we would lose the scope. Furthermore, we want to know in which state the app was when the
176- // app hang started.
177- SentryScope *scope = [SentrySDKInternal currentHub ].scope ;
178- SentryOptions *options = SentrySDKInternal.options ;
179- if (scope != nil && options != nil ) {
180- [scope applyToEvent: event maxBreadcrumb: options.maxBreadcrumbs];
181- }
182-
183- [self .fileManager storeAppHangEvent: event];
184- } else {
185- #endif // SENTRY_HAS_UIKIT
186- [SentrySDK captureEvent: event];
187- #if SENTRY_HAS_UIKIT
154+ // We only temporarily store the app hang duration info, so we can change the error message
155+ // when either sending a normal or fatal app hang event. Otherwise, we would have to rely on
156+ // string parsing to retrieve the app hang duration info from the error message.
157+ mechanism.data = @{ SentryANRMechanismDataAppHangDuration : appHangDurationInfo };
158+
159+ // We need to apply the scope now because if the app hang turns into a fatal one,
160+ // we would lose the scope. Furthermore, we want to know in which state the app was when the
161+ // app hang started.
162+ SentryScope *scope = [SentrySDKInternal currentHub ].scope ;
163+ SentryOptions *options = SentrySDKInternal.options ;
164+ if (scope != nil && options != nil ) {
165+ [scope applyToEvent: event maxBreadcrumb: options.maxBreadcrumbs];
188166 }
189- #endif // SENTRY_UIKIT_AVAILABLE
167+
168+ [self .fileManager storeAppHangEvent: event];
169+ #else
170+ [SentrySDK captureEvent: event];
171+ #endif
190172}
191173
192174- (void )anrStoppedWithResult : (SentryANRStoppedResult *_Nullable)result
193175{
194176#if SENTRY_HAS_UIKIT
195- // We only measure app hang duration for V2, and therefore ignore V1.
196- # if !SDK_V9
197- if (!self.options .enableAppHangTrackingV2 ) {
198- return ;
199- }
200- # endif // !SDK_V9
201-
202177 if (result == nil ) {
203178 SENTRY_LOG_WARN (@" ANR stopped for V2 but result was nil." )
204179 return ;
0 commit comments