-
-
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.
fix(frames): remove non absolute non url frame.abs_path coming from d…
…efault stack parser (#2891)
- Loading branch information
1 parent
8a53c0d
commit 15c80ab
Showing
4 changed files
with
756 additions
and
25 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
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,34 @@ | ||
import { RewriteFrames } from '@sentry/integrations'; | ||
import type { StackFrame } from '@sentry/types'; | ||
|
||
/** | ||
* Creates React Native default rewrite frames integration | ||
* which appends app:// to the beginning of the filename | ||
* and removes file://, 'address at' prefixes and CodePush postfix. | ||
*/ | ||
export function createReactNativeRewriteFrames(): RewriteFrames { | ||
return new RewriteFrames({ | ||
iteratee: (frame: StackFrame) => { | ||
if (frame.filename) { | ||
frame.filename = frame.filename | ||
.replace(/^file:\/\//, '') | ||
.replace(/^address at /, '') | ||
.replace(/^.*\/[^.]+(\.app|CodePush|.*(?=\/))/, ''); | ||
|
||
if ( | ||
frame.filename !== '[native code]' && | ||
frame.filename !== 'native' | ||
) { | ||
const appPrefix = 'app://'; | ||
// We always want to have a triple slash | ||
frame.filename = | ||
frame.filename.indexOf('/') === 0 | ||
? `${appPrefix}${frame.filename}` | ||
: `${appPrefix}/${frame.filename}`; | ||
} | ||
delete frame.abs_path; | ||
} | ||
return frame; | ||
}, | ||
}); | ||
} |
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.