Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- 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))
- Add replay breadcrumbs for touch & navigation events ([#3846](https://github.com/getsentry/sentry-react-native/pull/3846))
- Add network data to Session Replays ([#3912](https://github.com/getsentry/sentry-react-native/pull/3912))
- Filter Sentry Event Breadcrumbs from Mobile Replays ([#3925](https://github.com/getsentry/sentry-react-native/pull/3925))

### Dependencies

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.sentry.rnsentryandroidtester

import io.sentry.Breadcrumb
import io.sentry.react.RNSentryReplayBreadcrumbConverter
import org.junit.Assert.assertEquals
import org.junit.Test
Expand All @@ -9,6 +10,24 @@ import org.junit.runners.JUnit4
@RunWith(JUnit4::class)
class RNSentryReplayBreadcrumbConverterTest {

@Test
fun doesNotConvertSentryEventBreadcrumb() {
val converter = RNSentryReplayBreadcrumbConverter()
val testBreadcrumb = Breadcrumb();
testBreadcrumb.category = "sentry.event"
val actual = converter.convert(testBreadcrumb)
assertEquals(null, actual)
}

@Test
fun doesNotConvertSentryTransactionBreadcrumb() {
val converter = RNSentryReplayBreadcrumbConverter()
val testBreadcrumb = Breadcrumb();
testBreadcrumb.category = "sentry.transaction"
val actual = converter.convert(testBreadcrumb)
assertEquals(null, actual)
}

@Test
fun doesNotConvertNullPath() {
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(null)
Expand Down Expand Up @@ -52,4 +71,4 @@ class RNSentryReplayBreadcrumbConverterTest {
mapOf("name" to "name7")))
assertEquals("label5(element5, file5) > label4(file4) > label3(element3) > label2", actual)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,29 @@ import XCTest

final class RNSentryReplayBreadcrumbConverterTests: XCTestCase {

func testNotConvertSentryEventBreadcrumb() {
let converter = RNSentryReplayBreadcrumbConverter()
let testBreadcrumb = Breadcrumb()
testBreadcrumb.category = "sentry.event"
let actual = converter.convert(from: testBreadcrumb)
XCTAssertNil(actual)
}

func testNotConvertSentryTransactionBreadcrumb() {
let converter = RNSentryReplayBreadcrumbConverter()
let testBreadcrumb = Breadcrumb()
testBreadcrumb.category = "sentry.transaction"
let actual = converter.convert(from: testBreadcrumb)
XCTAssertNil(actual)
}

func testTouchMessageReturnsNilOnEmptyArray() throws {
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: [])
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: [])
XCTAssertEqual(actual, nil);
}

func testTouchMessageReturnsNilOnNilArray() throws {
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: nil as [Any]?)
let actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(from: nil as [Any]?)
XCTAssertEqual(actual, nil);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public RNSentryReplayBreadcrumbConverter() {
return null;
}

// Do not add Sentry Event breadcrumbs to replay
if (breadcrumb.getCategory().equals("sentry.event") ||
breadcrumb.getCategory().equals("sentry.transaction")) {
return null;
}

if (breadcrumb.getCategory().equals("touch")) {
return convertTouchBreadcrumb(breadcrumb);
}
Expand Down
2 changes: 2 additions & 0 deletions ios/RNSentryReplayBreadcrumbConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@

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

- (id<SentryRRWebEvent> _Nullable)convertFrom:(SentryBreadcrumb *_Nonnull) breadcrumb;

@end
#endif
6 changes: 6 additions & 0 deletions ios/RNSentryReplayBreadcrumbConverter.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ - (instancetype _Nonnull)init {
(SentryBreadcrumb *_Nonnull)breadcrumb {
assert(breadcrumb.timestamp != nil);

if ([breadcrumb.category isEqualToString:@"sentry.event"] ||
[breadcrumb.category isEqualToString:@"sentry.transaction"]) {
// Do not add Sentry Event breadcrumbs to replay
return nil;
}

if ([breadcrumb.category isEqualToString:@"http"]) {
// Drop native network breadcrumbs to avoid duplicates
return nil;
Expand Down