-
-
Notifications
You must be signed in to change notification settings - Fork 342
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
fix(core): Use makeDsn from core to extract the URL from DSN for filtering breadcrumbs #4395
Merged
Merged
Changes from 3 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
350cb37
Use regex to extract URL from DSN for filtering breadcrumbs
antonis 486c8f7
Merge branch 'main' into antonis/extract-url-with-regex
antonis aada963
Merge branch 'main' into antonis/extract-url-with-regex
antonis a1ecb49
Use makeDsn from core
antonis 10a7091
Merge branch 'main' into antonis/extract-url-with-regex
antonis de712e8
Adds port tests
antonis 8e47f4f
Merge branch 'main' into antonis/extract-url-with-regex
antonis c3b187f
Fix test case naming
antonis aff4dff
Merge branch 'main' into antonis/extract-url-with-regex
krystofwoldrich 32943e9
Adds changelog
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 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 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 |
---|---|---|
|
@@ -345,21 +345,15 @@ describe('Tests the SDK functionality', () => { | |
expect(result).toBeNull(); | ||
}); | ||
|
||
it('should keep breadcrumbs matching dsn if the url parsing fails for dsn', () => { | ||
it('should keep breadcrumbs if the url parsing fails for dsn', () => { | ||
(getDevServer as jest.Mock).mockReturnValue({ url: 'http://localhost:8081' }); | ||
|
||
const mockBeforeBreadcrumb = (breadcrumb: Breadcrumb, _hint?: BreadcrumbHint) => { | ||
return breadcrumb; | ||
}; | ||
|
||
// Mock the URL constructor to throw an exception for this test case | ||
const originalURL = (global as any).URL; | ||
jest.spyOn(global as any, 'URL').mockImplementationOnce(() => { | ||
throw new Error('Failed to parse DSN URL'); | ||
}); | ||
|
||
const passedOptions = { | ||
dsn: 'https://[email protected]/1234567', | ||
dsn: 'invalid-dsn', | ||
beforeBreadcrumb: mockBeforeBreadcrumb, | ||
}; | ||
|
||
|
@@ -373,9 +367,6 @@ describe('Tests the SDK functionality', () => { | |
const result = usedOptions()?.beforeBreadcrumb!(breadcrumb); | ||
|
||
expect(result).toEqual(breadcrumb); | ||
|
||
// Restore the original URL constructor | ||
(global as any).URL = originalURL; | ||
}); | ||
|
||
it('should keep non dev server or dsn breadcrumbs', () => { | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've missed that in the original review as well, but let's use the
makeDsn
function fromsentry/core
. It already uses regex and is used in the client impl, so it 100% works with RN.https://github.com/getsentry/sentry-javascript/blob/6f56d063e479f90ce07a5ddc0636dc0bc3b3bb2e/packages/core/src/utils-hoist/dsn.ts#L122
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea @krystofwoldrich 👍
Updated with a1ecb49 to use the
makeDsn
function.