Skip to content

Commit e725aa9

Browse files
committed
ios breadcrumb converter
1 parent fb1bb90 commit e725aa9

File tree

4 files changed

+50
-1
lines changed

4 files changed

+50
-1
lines changed

RNSentry.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ is_new_arch_enabled = ENV["RCT_NEW_ARCH_ENABLED"] == "1"
1414
is_using_hermes = (ENV['USE_HERMES'] == nil && is_hermes_default) || ENV['USE_HERMES'] == '1'
1515
new_arch_enabled_flag = (is_new_arch_enabled ? folly_compiler_flags + " -DRCT_NEW_ARCH_ENABLED" : "")
1616
sentry_profiling_supported_flag = (is_profiling_supported ? " -DSENTRY_PROFILING_SUPPORTED=1" : "")
17-
other_cflags = "$(inherited)" + new_arch_enabled_flag + sentry_profiling_supported_flag
17+
other_cflags = "$(inherited) -fcxx-modules -fmodules" + new_arch_enabled_flag + sentry_profiling_supported_flag
1818

1919
Pod::Spec.new do |s|
2020
s.name = 'RNSentry'

ios/RNSentry.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636

3737
#import "RNSentryEvents.h"
3838
#import "RNSentryDependencyContainer.h"
39+
#import "RNSentryBreadcrumbConverter.h"
3940

4041
#if SENTRY_HAS_UIKIT
4142
#import "RNSentryRNSScreen.h"
@@ -90,6 +91,9 @@ + (BOOL)requiresMainQueueSetup {
9091

9192
[SentrySDK startWithOptions:sentryOptions];
9293

94+
RNSentryBreadcrumbConverter* breadcrumbConverter = [[RNSentryBreadcrumbConverter alloc] init];
95+
[PrivateSentrySDKOnly configureSessionReplayWith: breadcrumbConverter screenshotProvider: nil];
96+
9397
#if TARGET_OS_IPHONE || TARGET_OS_MACCATALYST
9498
BOOL appIsActive = [[UIApplication sharedApplication] applicationState] == UIApplicationStateActive;
9599
#else

ios/RNSentryBreadcrumbConverter.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@import Sentry;
2+
3+
@class SentryRRWebEvent;
4+
5+
@interface RNSentryBreadcrumbConverter
6+
: NSObject <SentryReplayBreadcrumbConverter>
7+
8+
- (NSArray<SentryRRWebEvent *> *_Nonnull)
9+
convertWithBreadcrumbs:(NSArray<SentryBreadcrumb *> *_Nonnull)breadcrumbs
10+
from:(NSDate *_Nonnull)from
11+
until:(NSDate *_Nonnull)until;
12+
13+
@end

ios/RNSentryBreadcrumbConverter.m

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#import "RNSentryBreadcrumbConverter.h"
2+
3+
@implementation RNSentryBreadcrumbConverter {
4+
}
5+
6+
- (NSArray<SentryRRWebEvent *> *_Nonnull)
7+
convertWithBreadcrumbs:(NSArray<SentryBreadcrumb *> *_Nonnull)breadcrumbs
8+
from:(NSDate *_Nonnull)from
9+
until:(NSDate *_Nonnull)until {
10+
NSMutableArray<SentryRRWebEvent *> *outBreadcrumbs = [NSMutableArray array];
11+
for (SentryBreadcrumb *breadcrumb in breadcrumbs) {
12+
if (breadcrumb.timestamp &&
13+
[breadcrumb.timestamp compare:from] != NSOrderedAscending &&
14+
[breadcrumb.timestamp compare:until] != NSOrderedDescending) {
15+
if ([breadcrumb.category isEqualToString:@"touch"]) {
16+
SentryRRWebBreadcrumbEvent *rrwebBreadcrumb =
17+
[[SentryRRWebBreadcrumbEvent alloc]
18+
initWithTimestamp:breadcrumb.timestamp
19+
category:@"ui.tap"
20+
message:breadcrumb.data ? [breadcrumb.data valueForKey:@"target"] : nil
21+
level:breadcrumb.level
22+
data:breadcrumb.data];
23+
[outBreadcrumbs addObject:rrwebBreadcrumb];
24+
} else {
25+
// TODO delegate to the default breadcrumb converter
26+
}
27+
}
28+
}
29+
return outBreadcrumbs;
30+
}
31+
32+
@end

0 commit comments

Comments
 (0)