-
Notifications
You must be signed in to change notification settings - Fork 253
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
Convert @bugsnag/plugin-browser-request to TypeScript #2236
Merged
AnastasiiaSvietlova
merged 11 commits into
integration/typescript
from
PLAT-12162-plugin-browser-request
Oct 28, 2024
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
56341da
refactor: :recycle: convert plugin-window-onerror to typescript
gingerbenw f3a6653
update rollup configuration
gingerbenw 9fee052
Convert plugin-browser-request to TypeScript
AnastasiiaSvietlova b6d953c
changed tsconfig
AnastasiiaSvietlova a975010
fix: :adhesive_bandage: update main entry from ts to js
gingerbenw 2ec0b08
fix: :adhesive_bandage: add missing external dependencies to rollup c…
gingerbenw e9769e4
chore: :label: update types and remove ts-expect-error comments
gingerbenw 3c3d2ae
remove unnecessary rollup config
gingerbenw 6df580b
chore: :label: fix types
gingerbenw 1c97da8
chore: :fire: remove IE8 workaround code
gingerbenw 7377476
fix: :adhesive_bandage: fix RN init command
gingerbenw 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 |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import createRollupConfig from "../../.rollup/index.mjs"; | ||
|
||
export default createRollupConfig({ | ||
input: "src/request.ts", | ||
external: ['@bugsnag/core/lib/es-utils/assign'] | ||
}); |
6 changes: 4 additions & 2 deletions
6
packages/plugin-browser-request/request.js → ...ges/plugin-browser-request/src/request.ts
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 |
---|---|---|
@@ -1,13 +1,15 @@ | ||
const assign = require('@bugsnag/core/lib/es-utils/assign') | ||
import { Plugin } from '@bugsnag/core' | ||
import assign from '@bugsnag/core/lib/es-utils/assign' | ||
|
||
/* | ||
* Sets the event request: { url } to be the current href | ||
*/ | ||
module.exports = (win = window) => ({ | ||
export default (win = window): Plugin => ({ | ||
load: (client) => { | ||
client.addOnError(event => { | ||
if (event.request && event.request.url) return | ||
event.request = assign({}, event.request, { url: win.location.href }) | ||
// @ts-expect-error second parameter is private API | ||
}, true) | ||
} | ||
}) |
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 |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"include": ["src/**/*.ts"], | ||
"compilerOptions": { | ||
"target": "ES2020" | ||
} | ||
} |
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ | |
"access": "public" | ||
}, | ||
"files": [ | ||
"*.js" | ||
"dist" | ||
], | ||
"author": "Bugsnag", | ||
"license": "MIT", | ||
|
3 changes: 2 additions & 1 deletion
3
packages/plugin-window-unhandled-rejection/rollup.config.npm.mjs
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 |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import createRollupConfig from '../../.rollup/index.mjs' | ||
|
||
export default createRollupConfig({ | ||
input: 'src/unhandled-rejection.ts' | ||
input: 'src/unhandled-rejection.ts', | ||
external: ['@bugsnag/core/lib/iserror', '@bugsnag/core/lib/es-utils/map'] | ||
}) |
29 changes: 29 additions & 0 deletions
29
packages/plugin-window-unhandled-rejection/src/fix-bluebird-stacktrace.ts
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,29 @@ | ||
import { Stackframe } from 'packages/core/types' | ||
|
||
// The stack parser on bluebird stacks in FF get a suprious first frame: | ||
// | ||
// Error: derp | ||
// b@http://localhost:5000/bluebird.html:22:24 | ||
// a@http://localhost:5000/bluebird.html:18:9 | ||
// @http://localhost:5000/bluebird.html:14:9 | ||
// | ||
// results in | ||
// […] | ||
// 0: Object { file: "Error: derp", method: undefined, lineNumber: undefined, … } | ||
// 1: Object { file: "http://localhost:5000/bluebird.html", method: "b", lineNumber: 22, … } | ||
// 2: Object { file: "http://localhost:5000/bluebird.html", method: "a", lineNumber: 18, … } | ||
// 3: Object { file: "http://localhost:5000/bluebird.html", lineNumber: 14, columnNumber: 9, … } | ||
// | ||
// so the following reduce/accumulator function removes such frames | ||
// | ||
// Bluebird pads method names with spaces so trim that too… | ||
|
||
// https://github.com/petkaantonov/bluebird/blob/b7f21399816d02f979fe434585334ce901dcaf44/src/debuggability.js#L568-L571 | ||
const fixBluebirdStacktrace = (error: PromiseRejectionEvent['reason']) => (frame: Stackframe) => { | ||
if (frame.file === error.toString()) return | ||
if (frame.method) { | ||
frame.method = frame.method.replace(/^\s+/, '') | ||
} | ||
} | ||
|
||
export default fixBluebirdStacktrace |
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
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
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.
@tomlongridge have we officially dropped support for IE8 now? this block can go if so 🔥