-
-
Notifications
You must be signed in to change notification settings - Fork 337
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(replay): Add Mobile Replay (#3830)
* feat(replay): Add Mobile Replay Alpha (#3714) * feat(sample): add running indicator (animation overlay) (#3903) * feat(replay): Add breadcrumbs mapping from RN to RRWeb format (#3846) * feat(replay): Add network breadcrumbs (#3912) * fix(replay): Add tests for touch events (#3924) * feat(replay): Filter Sentry event breadcrumbs (#3925) * fix(changelog): Add latest native SDKs details * release: 5.25.0-alpha.2 * misc(samples): Add console anything examples for replay testing (#3928) * feat: Add Sentry Babel Transformer (#3916) * fix(replay): Add app lifecycle breadcrumbs conversion tests (#3932) * chore(deps): bump sentry-android to 7.12.0-alpha.3 * chore(deps): bump sentry-android to 7.12.0-alpha.4 * fix(replay): Mask SVGs from `react-native-svg` when `maskAllVectors=true` (#3930) * fix(replay): Add missing properties to android nav breadcrumbs (#3942) * release: 5.26.0-alpha.3 * misc(replay): Add Mobile Replay Public Beta changelog (#3943) --------- Co-authored-by: Ivan Dlugos <6349682+vaind@users.noreply.github.com> Co-authored-by: Ivan Dlugos <dlugos.ivan@gmail.com> Co-authored-by: getsentry-bot <bot@sentry.io> Co-authored-by: getsentry-bot <bot@getsentry.com> Co-authored-by: Roman Zavarnitsyn <rom4ek93@gmail.com> Co-authored-by: Bruno Garcia <bruno@brunogarcia.com>
- Loading branch information
1 parent
7dc213a
commit 9421616
Showing
63 changed files
with
3,061 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -74,3 +74,6 @@ yalc.lock | |
|
||
# E2E tests | ||
test/react-native/versions | ||
|
||
# Created by Sentry Metro Plugin | ||
.sentry/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
170 changes: 170 additions & 0 deletions
170
...pp/src/test/java/io/sentry/rnsentryandroidtester/RNSentryReplayBreadcrumbConverterTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
package io.sentry.rnsentryandroidtester | ||
|
||
import io.sentry.Breadcrumb | ||
import io.sentry.SentryLevel | ||
import io.sentry.react.RNSentryReplayBreadcrumbConverter | ||
import io.sentry.rrweb.RRWebBreadcrumbEvent | ||
import io.sentry.rrweb.RRWebEventType | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
@RunWith(JUnit4::class) | ||
class RNSentryReplayBreadcrumbConverterTest { | ||
|
||
@Test | ||
fun convertNavigationBreadcrumb() { | ||
val converter = RNSentryReplayBreadcrumbConverter() | ||
val testBreadcrumb = Breadcrumb() | ||
testBreadcrumb.level = SentryLevel.INFO | ||
testBreadcrumb.type = "navigation" | ||
testBreadcrumb.category = "navigation" | ||
testBreadcrumb.setData("from", "HomeScreen") | ||
testBreadcrumb.setData("to", "ProfileScreen") | ||
val actual = converter.convert(testBreadcrumb) as RRWebBreadcrumbEvent | ||
|
||
assertRRWebBreadcrumbDefaults(actual) | ||
assertEquals(SentryLevel.INFO, actual.level) | ||
assertEquals("navigation", actual.category) | ||
assertEquals("HomeScreen", actual.data?.get("from")) | ||
assertEquals("ProfileScreen", actual.data?.get("to")) | ||
} | ||
|
||
@Test | ||
fun convertNavigationBreadcrumbWithOnlyTo() { | ||
val converter = RNSentryReplayBreadcrumbConverter() | ||
val testBreadcrumb = Breadcrumb() | ||
testBreadcrumb.level = SentryLevel.INFO | ||
testBreadcrumb.type = "navigation" | ||
testBreadcrumb.category = "navigation" | ||
testBreadcrumb.setData("to", "ProfileScreen") | ||
val actual = converter.convert(testBreadcrumb) as RRWebBreadcrumbEvent | ||
|
||
assertRRWebBreadcrumbDefaults(actual) | ||
assertEquals(SentryLevel.INFO, actual.level) | ||
assertEquals("navigation", actual.category) | ||
assertEquals(null, actual.data?.get("from")) | ||
assertEquals("ProfileScreen", actual.data?.get("to")) | ||
} | ||
|
||
@Test | ||
fun convertForegroundBreadcrumb() { | ||
val converter = RNSentryReplayBreadcrumbConverter() | ||
val testBreadcrumb = Breadcrumb() | ||
testBreadcrumb.type = "navigation" | ||
testBreadcrumb.category = "app.lifecycle" | ||
testBreadcrumb.setData("state", "foreground"); | ||
val actual = converter.convert(testBreadcrumb) as RRWebBreadcrumbEvent | ||
|
||
assertRRWebBreadcrumbDefaults(actual) | ||
assertEquals("app.foreground", actual.category) | ||
} | ||
|
||
@Test | ||
fun convertBackgroundBreadcrumb() { | ||
val converter = RNSentryReplayBreadcrumbConverter() | ||
val testBreadcrumb = Breadcrumb() | ||
testBreadcrumb.type = "navigation" | ||
testBreadcrumb.category = "app.lifecycle" | ||
testBreadcrumb.setData("state", "background"); | ||
val actual = converter.convert(testBreadcrumb) as RRWebBreadcrumbEvent | ||
|
||
assertRRWebBreadcrumbDefaults(actual) | ||
assertEquals("app.background", actual.category) | ||
} | ||
|
||
@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 convertTouchBreadcrumb() { | ||
val converter = RNSentryReplayBreadcrumbConverter() | ||
val testBreadcrumb = Breadcrumb() | ||
testBreadcrumb.level = SentryLevel.INFO | ||
testBreadcrumb.type = "user" | ||
testBreadcrumb.category = "touch" | ||
testBreadcrumb.message = "this won't be used for replay" | ||
testBreadcrumb.setData( | ||
"path", | ||
arrayListOf(mapOf( | ||
"element" to "element4", | ||
"file" to "file4"))) | ||
val actual = converter.convert(testBreadcrumb) as RRWebBreadcrumbEvent | ||
|
||
assertRRWebBreadcrumbDefaults(actual) | ||
assertEquals(SentryLevel.INFO, actual.level) | ||
assertEquals("ui.tap", actual.category) | ||
assertEquals(1, actual.data?.keys?.size) | ||
assertEquals( | ||
arrayListOf(mapOf( | ||
"element" to "element4", | ||
"file" to "file4")), | ||
actual.data?.get("path")) | ||
} | ||
|
||
@Test | ||
fun doesNotConvertNullPath() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(null) | ||
assertEquals(null, actual) | ||
} | ||
|
||
@Test | ||
fun doesNotConvertPathContainingNull() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(arrayListOf(arrayOfNulls<Any>(1))) | ||
assertEquals(null, actual) | ||
} | ||
|
||
@Test | ||
fun doesNotConvertPathWithValuesMissingNameAndLevel() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(arrayListOf(mapOf( | ||
"element" to "element4", | ||
"file" to "file4"))) | ||
assertEquals(null, actual) | ||
} | ||
|
||
@Test | ||
fun doesConvertValidPathExample1() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(listOf( | ||
mapOf("label" to "label0"), | ||
mapOf("name" to "name1"), | ||
mapOf("name" to "item2", "label" to "label2"), | ||
mapOf("name" to "item3", "label" to "label3", "element" to "element3"), | ||
mapOf("name" to "item4", "label" to "label4", "file" to "file4"), | ||
mapOf("name" to "item5", "label" to "label5", "element" to "element5", "file" to "file5"))) | ||
assertEquals("label3(element3) > label2 > name1 > label0", actual) | ||
} | ||
|
||
@Test | ||
fun doesConvertValidPathExample2() { | ||
val actual = RNSentryReplayBreadcrumbConverter.getTouchPathMessage(listOf( | ||
mapOf("name" to "item2", "label" to "label2"), | ||
mapOf("name" to "item3", "label" to "label3", "element" to "element3"), | ||
mapOf("name" to "item4", "label" to "label4", "file" to "file4"), | ||
mapOf("name" to "item5", "label" to "label5", "element" to "element5", "file" to "file5"), | ||
mapOf("label" to "label6"), | ||
mapOf("name" to "name7"))) | ||
assertEquals("label5(element5, file5) > label4(file4) > label3(element3) > label2", actual) | ||
} | ||
|
||
private fun assertRRWebBreadcrumbDefaults(actual: RRWebBreadcrumbEvent) { | ||
assertEquals("default", actual.breadcrumbType) | ||
assertEquals(actual.breadcrumbTimestamp * 1000, actual.timestamp.toDouble(), 0.05) | ||
assert(actual.breadcrumbTimestamp > 0) | ||
} | ||
} |
Oops, something went wrong.