Skip to content

Commit b4aaa68

Browse files
feat(replay): Filter Sentry event breadcrumbs (#3925)
1 parent 5f3a5c8 commit b4aaa68

File tree

6 files changed

+53
-3
lines changed

6 files changed

+53
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Improve touch event component info if annotated with [`@sentry/babel-plugin-component-annotate`](https://www.npmjs.com/package/@sentry/babel-plugin-component-annotate) ([#3899](https://github.com/getsentry/sentry-react-native/pull/3899))
88
- Add replay breadcrumbs for touch & navigation events ([#3846](https://github.com/getsentry/sentry-react-native/pull/3846))
99
- Add network data to Session Replays ([#3912](https://github.com/getsentry/sentry-react-native/pull/3912))
10+
- Filter Sentry Event Breadcrumbs from Mobile Replays ([#3925](https://github.com/getsentry/sentry-react-native/pull/3925))
1011

1112
### Dependencies
1213

RNSentryAndroidTester/app/src/test/java/io/sentry/rnsentryandroidtester/RNSentryReplayBreadcrumbConverterTest.kt

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.sentry.rnsentryandroidtester
22

3+
import io.sentry.Breadcrumb
34
import io.sentry.react.RNSentryReplayBreadcrumbConverter
45
import org.junit.Assert.assertEquals
56
import org.junit.Test
@@ -9,6 +10,24 @@ import org.junit.runners.JUnit4
910
@RunWith(JUnit4::class)
1011
class RNSentryReplayBreadcrumbConverterTest {
1112

13+
@Test
14+
fun doesNotConvertSentryEventBreadcrumb() {
15+
val converter = RNSentryReplayBreadcrumbConverter()
16+
val testBreadcrumb = Breadcrumb();
17+
testBreadcrumb.category = "sentry.event"
18+
val actual = converter.convert(testBreadcrumb)
19+
assertEquals(null, actual)
20+
}
21+
22+
@Test
23+
fun doesNotConvertSentryTransactionBreadcrumb() {
24+
val converter = RNSentryReplayBreadcrumbConverter()
25+
val testBreadcrumb = Breadcrumb();
26+
testBreadcrumb.category = "sentry.transaction"
27+
val actual = converter.convert(testBreadcrumb)
28+
assertEquals(null, actual)
29+
}
30+
1231
@Test
1332
fun doesNotConvertNullPath() {
1433
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(null)
@@ -52,4 +71,4 @@ class RNSentryReplayBreadcrumbConverterTest {
5271
mapOf("name" to "name7")))
5372
assertEquals("label5(element5, file5) > label4(file4) > label3(element3) > label2", actual)
5473
}
55-
}
74+
}

RNSentryCocoaTester/RNSentryCocoaTesterTests/RNSentryReplayBreadcrumbConverterTests.swift

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@ import XCTest
22

33
final class RNSentryReplayBreadcrumbConverterTests: XCTestCase {
44

5+
func testNotConvertSentryEventBreadcrumb() {
6+
let converter = RNSentryReplayBreadcrumbConverter()
7+
let testBreadcrumb = Breadcrumb()
8+
testBreadcrumb.category = "sentry.event"
9+
let actual = converter.convert(from: testBreadcrumb)
10+
XCTAssertNil(actual)
11+
}
12+
13+
func testNotConvertSentryTransactionBreadcrumb() {
14+
let converter = RNSentryReplayBreadcrumbConverter()
15+
let testBreadcrumb = Breadcrumb()
16+
testBreadcrumb.category = "sentry.transaction"
17+
let actual = converter.convert(from: testBreadcrumb)
18+
XCTAssertNil(actual)
19+
}
20+
521
func testTouchMessageReturnsNilOnEmptyArray() throws {
6-
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: [])
22+
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: [])
723
XCTAssertEqual(actual, nil);
824
}
925

1026
func testTouchMessageReturnsNilOnNilArray() throws {
11-
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: nil as [Any]?)
27+
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: nil as [Any]?)
1228
XCTAssertEqual(actual, nil);
1329
}
1430

android/src/main/java/io/sentry/react/RNSentryReplayBreadcrumbConverter.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ public RNSentryReplayBreadcrumbConverter() {
2424
return null;
2525
}
2626

27+
// Do not add Sentry Event breadcrumbs to replay
28+
if (breadcrumb.getCategory().equals("sentry.event") ||
29+
breadcrumb.getCategory().equals("sentry.transaction")) {
30+
return null;
31+
}
32+
2733
if (breadcrumb.getCategory().equals("touch")) {
2834
return convertTouchBreadcrumb(breadcrumb);
2935
}

ios/RNSentryReplayBreadcrumbConverter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,7 @@
1010

1111
+ (NSString* _Nullable) getTouchPathMessageFrom:(NSArray* _Nullable) path;
1212

13+
- (id<SentryRRWebEvent> _Nullable)convertFrom:(SentryBreadcrumb *_Nonnull) breadcrumb;
14+
1315
@end
1416
#endif

ios/RNSentryReplayBreadcrumbConverter.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ - (instancetype _Nonnull)init {
2020
(SentryBreadcrumb *_Nonnull)breadcrumb {
2121
assert(breadcrumb.timestamp != nil);
2222

23+
if ([breadcrumb.category isEqualToString:@"sentry.event"] ||
24+
[breadcrumb.category isEqualToString:@"sentry.transaction"]) {
25+
// Do not add Sentry Event breadcrumbs to replay
26+
return nil;
27+
}
28+
2329
if ([breadcrumb.category isEqualToString:@"http"]) {
2430
// Drop native network breadcrumbs to avoid duplicates
2531
return nil;

0 commit comments

Comments
 (0)