Skip to content

Commit ede2a89

Browse files
authored
Merge 686b6f8 into 2b89ce9
2 parents 2b89ce9 + 686b6f8 commit ede2a89

File tree

3 files changed

+50
-11
lines changed

3 files changed

+50
-11
lines changed

packages/core/ios/RNSentry.mm

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#import <Sentry/SentryFormatter.h>
3030
#import <Sentry/SentryOptions.h>
3131
#import <Sentry/SentryOptionsInternal.h>
32-
#import <Sentry/SentryScreenFrames.h>
3332
#import <Sentry/SentryUser.h>
3433

3534
// This guard prevents importing Hermes in JSC apps
@@ -57,6 +56,7 @@
5756
#import "RNSentryExperimentalOptions.h"
5857
#import "RNSentryVersion.h"
5958
#import "SentrySDKWrapper.h"
59+
#import "SentryScreenFramesWrapper.h"
6060

6161
static bool hasFetchedAppStart;
6262

@@ -580,21 +580,15 @@ - (void)stopObserving
580580

581581
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
582582
if (PrivateSentrySDKOnly.isFramesTrackingRunning) {
583-
SentryScreenFrames *frames = PrivateSentrySDKOnly.currentScreenFrames;
584-
585-
if (frames == nil) {
583+
if (![SentryScreenFramesWrapper canTrackFrames]) {
586584
resolve(nil);
587585
return;
588586
}
589587

590-
NSNumber *total = [NSNumber numberWithLong:frames.total];
591-
NSNumber *frozen = [NSNumber numberWithLong:frames.frozen];
592-
NSNumber *slow = [NSNumber numberWithLong:frames.slow];
593-
594588
resolve(@ {
595-
@"totalFrames" : total,
596-
@"frozenFrames" : frozen,
597-
@"slowFrames" : slow,
589+
@"totalFrames" : [SentryScreenFramesWrapper totalFrames],
590+
@"frozenFrames" : [SentryScreenFramesWrapper frozenFrames],
591+
@"slowFrames" : [SentryScreenFramesWrapper slowFrames],
598592
});
599593
} else {
600594
resolve(nil);
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#import <Foundation/Foundation.h>
2+
3+
@interface SentryScreenFramesWrapper : NSObject
4+
5+
+ (BOOL)canTrackFrames;
6+
+ (NSNumber *)totalFrames;
7+
+ (NSNumber *)frozenFrames;
8+
+ (NSNumber *)slowFrames;
9+
10+
@end
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#import "SentryScreenFramesWrapper.h"
2+
@import Sentry;
3+
4+
@implementation SentryScreenFramesWrapper
5+
6+
+ (BOOL)canTrackFrames
7+
{
8+
return PrivateSentrySDKOnly.currentScreenFrames != nil;
9+
}
10+
11+
+ (NSNumber *)totalFrames
12+
{
13+
if (![self canTrackFrames]) {
14+
return nil;
15+
}
16+
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.total];
17+
}
18+
19+
+ (NSNumber *)frozenFrames
20+
{
21+
if (![self canTrackFrames]) {
22+
return nil;
23+
}
24+
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.frozen];
25+
}
26+
27+
+ (NSNumber *)slowFrames
28+
{
29+
if (![self canTrackFrames]) {
30+
return nil;
31+
}
32+
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.slow];
33+
}
34+
35+
@end

0 commit comments

Comments
 (0)