-
-
Notifications
You must be signed in to change notification settings - Fork 343
fix(core): Breadcrumbs added on forked context are now captured #4124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 33 commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
494a619
Adds breadcrumb origin in RNSentryBreadcrumb dictionary parsing
antonis cc0b364
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis a636be5
Use 8.38.0-beta.1 Cocoa SDK that has the new origin field
antonis 522897a
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 197f863
Adds changelog
antonis 9bee5c9
Fixes sentry-java breaking changes
antonis 6268a43
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 6095218
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 0e43c5d
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 8832cf9
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 7a108ee
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis aff18bf
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 611cd97
Adds origin native tests
antonis 37553f2
Adds Capture exception with breadcrumb in the sample
antonis 24a527b
Set react native as event origin
antonis fabf052
Filter out events with react-native origin from the native layer
antonis d0b1633
Merge event breadcrumbs with native context
antonis 5d2711c
Lint: removes empty line
antonis fb0057d
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 78c24f0
Use predicate to filter breadcrumbs
antonis 6fcd93d
Respect max breadcrumbs limit
antonis 80add4f
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 44e02ec
Updates changelog
antonis a2d29de
Update test names
antonis 52c9e54
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 81a11c3
Fixes lint issue
antonis f828fc7
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 67bd716
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis c4246d7
Keep the last maxBreadcrumbs (default 100) when merging native and js…
antonis 17e2201
Use client from function parameter
antonis fef2173
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis 76285fa
Refactor and test RNSentryModuleImpl.fetchNativeDeviceContexts (#4253)
antonis 6ea1fe1
Merge branch 'main' into antonis/add-breadcrumb-origin
antonis af1ab5a
Move changelog to unreleased section
antonis File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
86 changes: 86 additions & 0 deletions
86
.../RNSentryAndroidTester/app/src/androidTest/java/io/sentry/react/RNSentryModuleImplTest.kt
This file contains hidden or 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,86 @@ | ||
package io.sentry.react | ||
|
||
import android.content.Context | ||
import androidx.test.platform.app.InstrumentationRegistry | ||
import com.facebook.react.bridge.PromiseImpl | ||
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.WritableMap | ||
import com.facebook.soloader.SoLoader | ||
import io.sentry.Breadcrumb | ||
import io.sentry.Scope | ||
import io.sentry.SentryOptions | ||
import io.sentry.android.core.SentryAndroidOptions | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.fail | ||
import org.junit.Before | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.JUnit4 | ||
|
||
@RunWith(JUnit4::class) | ||
class RNSentryModuleImplTest { | ||
|
||
private lateinit var module: RNSentryModuleImpl | ||
private lateinit var context: Context | ||
|
||
@Before | ||
fun setUp() { | ||
context = InstrumentationRegistry.getInstrumentation().targetContext | ||
SoLoader.init(context, false) | ||
val reactContext = ReactApplicationContext(context) | ||
module = RNSentryModuleImpl(reactContext) | ||
} | ||
|
||
@Test | ||
fun fetchNativeDeviceContextsWithNullContext() { | ||
val options = SentryAndroidOptions() | ||
val scope = Scope(options) | ||
val promise = PromiseImpl({ | ||
assertEquals(1, it.size) | ||
assertEquals(null, it[0]) | ||
}, { | ||
fail("Promise was rejected unexpectedly") | ||
}) | ||
module.fetchNativeDeviceContexts(promise, options, null, scope) | ||
} | ||
|
||
@Test | ||
fun fetchNativeDeviceContextsWithInvalidSentryOptions() { | ||
class NotAndroidSentryOptions : SentryOptions() | ||
|
||
val options = NotAndroidSentryOptions() | ||
val scope = Scope(options) | ||
val promise = PromiseImpl({ | ||
assertEquals(1, it.size) | ||
assertEquals(null, it[0]) | ||
}, { | ||
fail("Promise was rejected unexpectedly") | ||
}) | ||
module.fetchNativeDeviceContexts(promise, options, context, scope) | ||
} | ||
|
||
@Test | ||
fun fetchNativeDeviceContextsFiltersBreadcrumbs() { | ||
val options = SentryAndroidOptions().apply { maxBreadcrumbs = 5 } | ||
val scope = Scope(options) | ||
scope.addBreadcrumb(Breadcrumb("Breadcrumb1-RN").apply { origin = "react-native" }) | ||
scope.addBreadcrumb(Breadcrumb("Breadcrumb2-Native")) | ||
scope.addBreadcrumb(Breadcrumb("Breadcrumb3-Native").apply { origin = "java" }) | ||
scope.addBreadcrumb(Breadcrumb("Breadcrumb2-RN").apply { origin = "react-native" }) | ||
scope.addBreadcrumb(Breadcrumb("Breadcrumb2-RN").apply { origin = "react-native" }) | ||
|
||
val promise = PromiseImpl({ | ||
assertEquals(1, it.size) | ||
assertEquals(true, it[0] is WritableMap) | ||
val actual = it[0] as WritableMap | ||
val breadcrumbs = actual.getArray("breadcrumbs") | ||
assertEquals(2, breadcrumbs?.size()) | ||
assertEquals("Breadcrumb2-Native", breadcrumbs?.getMap(0)?.getString("message")) | ||
assertEquals("Breadcrumb3-Native", breadcrumbs?.getMap(1)?.getString("message")) | ||
}, { | ||
fail("Promise was rejected unexpectedly") | ||
}) | ||
|
||
module.fetchNativeDeviceContexts(promise, options, context, scope) | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.