-
-
Notifications
You must be signed in to change notification settings - Fork 344
feat(core): Exclude Dev Server and Sentry Dsn request from Breadcrumbs #4240
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 59 commits
Commits
Show all changes
62 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 87bdc77
Filter out DevServer and DSN related breadcrumbs
antonis 2d68620
Adds changelog
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 ff7ca33
Revert "Filter out DevServer and DSN related breadcrumbs"
antonis 5121c83
Merge branch 'antonis/add-breadcrumb-origin' into antonis/3105-exclud…
antonis 3811047
Passes development server url as an option to the native sdks
antonis c3da88b
Filter out Dev Server and Sentry Dsn breadcrumbs on Android
antonis d67de6c
Filter out Dev Server and Sentry Dsn breadcrumbs on iOS
antonis 6ddc665
Filter out Dev Server and Sentry Dsn breadcrumbs on JS
antonis af02c03
Adds Java tests
antonis 7ae568a
Adds Cocoa tests
antonis 575821e
Adds JS tests
antonis efa3871
Sets correct spacing in import
antonis 709b8df
Fixes changelog typo
antonis fef13ca
Handles undefined dev server urls
antonis 96f3b5d
Handles undefined dsns
antonis ccaa502
Adds tests for undefined dev servers and dsns
antonis 06ff84c
Handles undefined dev server urls in native code
antonis a213332
Updates test cases
antonis a69d5e8
Uses the url from the passed dsn to filter breadcrumbs
antonis e451c06
Handles nil dsn though this state should never be reached due to Sent…
antonis eae86ad
Use startsWith to check url matching
antonis c05c3c2
Check url with prefix instead of contains for efficiency
antonis 48034dc
Fix comment typo
antonis 3381a9e
Fix comment typo
antonis 1f7891e
Fix comment typo
antonis 5f23d48
Merge branch 'main' into antonis/3105-exclude-dsn-and-devserver
krystofwoldrich 848aaa3
Update CHANGELOG.md
krystofwoldrich 41ac85a
Safely parses dsn url
antonis bfc7c33
Merge branch 'main' into antonis/3105-exclude-dsn-and-devserver
antonis b6191be
Adds test case for url exception
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
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 |
---|---|---|
|
@@ -8,12 +8,14 @@ import com.facebook.react.bridge.Promise | |
import com.facebook.react.bridge.ReactApplicationContext | ||
import com.facebook.react.bridge.WritableMap | ||
import com.facebook.react.common.JavascriptException | ||
import io.sentry.Breadcrumb | ||
import io.sentry.ILogger | ||
import io.sentry.SentryLevel | ||
import io.sentry.android.core.SentryAndroidOptions | ||
import org.junit.After | ||
import org.junit.Assert.assertEquals | ||
import org.junit.Assert.assertFalse | ||
import org.junit.Assert.assertNull | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Before | ||
import org.junit.Test | ||
|
@@ -134,4 +136,109 @@ class RNSentryModuleImplTest { | |
module.getSentryAndroidOptions(actualOptions, JavaOnlyMap.of(), logger) | ||
assertTrue(actualOptions.ignoredExceptionsForType.contains(JavascriptException::class.java)) | ||
} | ||
|
||
@Test | ||
fun `beforeBreadcrumb callback filters out Sentry DSN requests breadcrumbs`() { | ||
val options = SentryAndroidOptions() | ||
val rnOptions = JavaOnlyMap.of( | ||
"dsn", "https://[email protected]/1234567", | ||
"devServerUrl", "http://localhost:8081", | ||
) | ||
module.getSentryAndroidOptions(options, rnOptions, logger) | ||
|
||
val breadcrumb = Breadcrumb().apply { | ||
type = "http" | ||
setData("url", "https://def.ingest.sentry.io/1234567") | ||
} | ||
|
||
val result = options.beforeBreadcrumb?.execute(breadcrumb, mock()) | ||
|
||
assertNull("Breadcrumb should be filtered out", result) | ||
} | ||
|
||
@Test | ||
fun `beforeBreadcrumb callback filters out dev server breadcrumbs`() { | ||
val mockDevServerUrl = "http://localhost:8081" | ||
val options = SentryAndroidOptions() | ||
val rnOptions = JavaOnlyMap.of( | ||
"dsn", "https://[email protected]/1234567", | ||
"devServerUrl", mockDevServerUrl, | ||
) | ||
module.getSentryAndroidOptions(options, rnOptions, logger) | ||
|
||
val breadcrumb = Breadcrumb().apply { | ||
type = "http" | ||
setData("url", mockDevServerUrl) | ||
} | ||
|
||
val result = options.beforeBreadcrumb?.execute(breadcrumb, mock()) | ||
|
||
assertNull("Breadcrumb should be filtered out", result) | ||
} | ||
|
||
@Test | ||
fun `beforeBreadcrumb callback does not filter out non dev server or dsn breadcrumbs`() { | ||
val options = SentryAndroidOptions() | ||
val rnOptions = JavaOnlyMap.of( | ||
"dsn", "https://[email protected]/1234567", | ||
"devServerUrl", "http://localhost:8081", | ||
) | ||
module.getSentryAndroidOptions(options, rnOptions, logger) | ||
|
||
val breadcrumb = Breadcrumb().apply { | ||
type = "http" | ||
setData("url", "http://testurl.com/service") | ||
} | ||
|
||
val result = options.beforeBreadcrumb?.execute(breadcrumb, mock()) | ||
|
||
assertEquals(breadcrumb, result) | ||
} | ||
|
||
@Test | ||
fun `the breadcrumb is not filtered out when the dev server url and dsn are not passed`() { | ||
val options = SentryAndroidOptions() | ||
module.getSentryAndroidOptions(options, JavaOnlyMap(), logger) | ||
|
||
val breadcrumb = Breadcrumb().apply { | ||
type = "http" | ||
setData("url", "http://testurl.com/service") | ||
} | ||
|
||
val result = options.beforeBreadcrumb?.execute(breadcrumb, mock()) | ||
|
||
assertEquals(breadcrumb, result) | ||
} | ||
|
||
@Test | ||
fun `the breadcrumb is not filtered out when the dev server url is not passed and the dsn does not match`() { | ||
val options = SentryAndroidOptions() | ||
val rnOptions = JavaOnlyMap.of("dsn", "https://[email protected]/1234567") | ||
module.getSentryAndroidOptions(options, rnOptions, logger) | ||
|
||
val breadcrumb = Breadcrumb().apply { | ||
type = "http" | ||
setData("url", "http://testurl.com/service") | ||
} | ||
|
||
val result = options.beforeBreadcrumb?.execute(breadcrumb, mock()) | ||
|
||
assertEquals(breadcrumb, result) | ||
} | ||
|
||
@Test | ||
fun `the breadcrumb is not filtered out when the dev server url does not match and the dsn is not passed`() { | ||
val options = SentryAndroidOptions() | ||
val rnOptions = JavaOnlyMap.of("devServerUrl", "http://localhost:8081") | ||
module.getSentryAndroidOptions(options, rnOptions, logger) | ||
|
||
val breadcrumb = Breadcrumb().apply { | ||
type = "http" | ||
setData("url", "http://testurl.com/service") | ||
} | ||
|
||
val result = options.beforeBreadcrumb?.execute(breadcrumb, mock()) | ||
|
||
assertEquals(breadcrumb, result) | ||
} | ||
} |
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 |
---|---|---|
|
@@ -238,6 +238,85 @@ - (void)testPassesErrorOnWrongDsn | |
XCTAssertNotNil(error, @"Did not created error on invalid dsn"); | ||
} | ||
|
||
- (void)testBeforeBreadcrumbsCallbackFiltersOutSentryDsnRequestBreadcrumbs | ||
{ | ||
RNSentry *rnSentry = [[RNSentry alloc] init]; | ||
NSError *error = nil; | ||
|
||
NSDictionary *_Nonnull mockedDictionary = @{ | ||
@"dsn" : @"https://[email protected]/1234567", | ||
@"devServerUrl" : @"http://localhost:8081" | ||
}; | ||
SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; | ||
|
||
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; | ||
breadcrumb.type = @"http"; | ||
breadcrumb.data = @{ @"url" : @"https://def.ingest.sentry.io/1234567" }; | ||
|
||
SentryBreadcrumb *result = options.beforeBreadcrumb(breadcrumb); | ||
|
||
XCTAssertNil(result, @"Breadcrumb should be filtered out"); | ||
} | ||
|
||
- (void)testBeforeBreadcrumbsCallbackFiltersOutDevServerRequestBreadcrumbs | ||
{ | ||
RNSentry *rnSentry = [[RNSentry alloc] init]; | ||
NSError *error = nil; | ||
|
||
NSString *mockDevServer = @"http://localhost:8081"; | ||
|
||
NSDictionary *_Nonnull mockedDictionary = | ||
@{ @"dsn" : @"https://[email protected]/1234567", @"devServerUrl" : mockDevServer }; | ||
SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; | ||
|
||
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; | ||
breadcrumb.type = @"http"; | ||
breadcrumb.data = @{ @"url" : mockDevServer }; | ||
|
||
SentryBreadcrumb *result = options.beforeBreadcrumb(breadcrumb); | ||
|
||
XCTAssertNil(result, @"Breadcrumb should be filtered out"); | ||
} | ||
|
||
- (void)testBeforeBreadcrumbsCallbackDoesNotFiltersOutNonDevServerOrDsnRequestBreadcrumbs | ||
{ | ||
RNSentry *rnSentry = [[RNSentry alloc] init]; | ||
NSError *error = nil; | ||
|
||
NSDictionary *_Nonnull mockedDictionary = @{ | ||
@"dsn" : @"https://[email protected]/1234567", | ||
@"devServerUrl" : @"http://localhost:8081" | ||
}; | ||
SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; | ||
|
||
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; | ||
breadcrumb.type = @"http"; | ||
breadcrumb.data = @{ @"url" : @"http://testurl.com/service" }; | ||
|
||
SentryBreadcrumb *result = options.beforeBreadcrumb(breadcrumb); | ||
|
||
XCTAssertEqual(breadcrumb, result); | ||
} | ||
|
||
- (void)testBeforeBreadcrumbsCallbackKeepsBreadcrumbWhenDevServerUrlIsNotPassedAndDsnDoesNotMatch | ||
{ | ||
RNSentry *rnSentry = [[RNSentry alloc] init]; | ||
NSError *error = nil; | ||
|
||
NSDictionary *_Nonnull mockedDictionary = @{ // dsn is always validated in SentryOptions initialization | ||
@"dsn" : @"https://[email protected]/1234567" | ||
}; | ||
SentryOptions *options = [rnSentry createOptionsWithDictionary:mockedDictionary error:&error]; | ||
|
||
SentryBreadcrumb *breadcrumb = [[SentryBreadcrumb alloc] init]; | ||
breadcrumb.type = @"http"; | ||
breadcrumb.data = @{ @"url" : @"http://testurl.com/service" }; | ||
|
||
SentryBreadcrumb *result = options.beforeBreadcrumb(breadcrumb); | ||
|
||
XCTAssertEqual(breadcrumb, result); | ||
} | ||
|
||
- (void)testEventFromSentryCocoaReactNativeHasOriginAndEnvironmentTags | ||
{ | ||
RNSentry *rnSentry = [[RNSentry alloc] init]; | ||
|
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.