Skip to content

Commit 4806cf2

Browse files
itaybreantonis
andauthored
fix: Fixes SentryScreenFrames use after being converted to Swift (#5153)
* fix: Fixes SentryScreenFrames use after being converted to Swift * Fix build --------- Co-authored-by: Antonis Lilis <antonis.lilis@sentry.io>
1 parent f92df85 commit 4806cf2

File tree

3 files changed

+58
-11
lines changed

3 files changed

+58
-11
lines changed

packages/core/ios/RNSentry.mm

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#import <Sentry/SentryException.h>
2727
#import <Sentry/SentryFormatter.h>
2828
#import <Sentry/SentryGeo.h>
29-
#import <Sentry/SentryScreenFrames.h>
3029
#import <Sentry/SentryUser.h>
3130

3231
// This guard prevents importing Hermes in JSC apps
@@ -54,6 +53,7 @@
5453
#import "RNSentryExperimentalOptions.h"
5554
#import "RNSentryVersion.h"
5655
#import "SentrySDKWrapper.h"
56+
#import "SentryScreenFramesWrapper.h"
5757

5858
static bool hasFetchedAppStart;
5959

@@ -486,21 +486,15 @@ - (void)stopObserving
486486

487487
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
488488
if (PrivateSentrySDKOnly.isFramesTrackingRunning) {
489-
SentryScreenFrames *frames = PrivateSentrySDKOnly.currentScreenFrames;
490-
491-
if (frames == nil) {
489+
if (![SentryScreenFramesWrapper canTrackFrames]) {
492490
resolve(nil);
493491
return;
494492
}
495493

496-
NSNumber *total = [NSNumber numberWithLong:frames.total];
497-
NSNumber *frozen = [NSNumber numberWithLong:frames.frozen];
498-
NSNumber *slow = [NSNumber numberWithLong:frames.slow];
499-
500494
resolve(@ {
501-
@"totalFrames" : total,
502-
@"frozenFrames" : frozen,
503-
@"slowFrames" : slow,
495+
@"totalFrames" : [SentryScreenFramesWrapper totalFrames],
496+
@"frozenFrames" : [SentryScreenFramesWrapper frozenFrames],
497+
@"slowFrames" : [SentryScreenFramesWrapper slowFrames],
504498
});
505499
} else {
506500
resolve(nil);
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#import <Foundation/Foundation.h>
2+
3+
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
4+
5+
@interface SentryScreenFramesWrapper : NSObject
6+
7+
+ (BOOL)canTrackFrames;
8+
+ (NSNumber *)totalFrames;
9+
+ (NSNumber *)frozenFrames;
10+
+ (NSNumber *)slowFrames;
11+
12+
@end
13+
14+
#endif // TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#import "SentryScreenFramesWrapper.h"
2+
@import Sentry;
3+
4+
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
5+
6+
@implementation SentryScreenFramesWrapper
7+
8+
+ (BOOL)canTrackFrames
9+
{
10+
return PrivateSentrySDKOnly.currentScreenFrames != nil;
11+
}
12+
13+
+ (NSNumber *)totalFrames
14+
{
15+
if (![self canTrackFrames]) {
16+
return nil;
17+
}
18+
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.total];
19+
}
20+
21+
+ (NSNumber *)frozenFrames
22+
{
23+
if (![self canTrackFrames]) {
24+
return nil;
25+
}
26+
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.frozen];
27+
}
28+
29+
+ (NSNumber *)slowFrames
30+
{
31+
if (![self canTrackFrames]) {
32+
return nil;
33+
}
34+
return [NSNumber numberWithLong:PrivateSentrySDKOnly.currentScreenFrames.slow];
35+
}
36+
37+
@end
38+
39+
#endif // TARGET_OS_IPHONE || TARGET_OS_MACCATALYST

0 commit comments

Comments
 (0)