File tree Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Expand file tree Collapse file tree 2 files changed +31
-3
lines changed Original file line number Diff line number Diff line change @@ -23,10 +23,18 @@ export class RewriteFrames implements Integration {
23
23
/**
24
24
* @inheritDoc
25
25
*/
26
- public constructor ( options : { root ?: string ; iteratee ?: StackFrameIteratee } = { } ) {
26
+ private readonly _prefix : string = 'app:///' ;
27
+
28
+ /**
29
+ * @inheritDoc
30
+ */
31
+ public constructor ( options : { root ?: string ; prefix ?: string ; iteratee ?: StackFrameIteratee } = { } ) {
27
32
if ( options . root ) {
28
33
this . _root = options . root ;
29
34
}
35
+ if ( options . prefix ) {
36
+ this . _prefix = options . prefix ;
37
+ }
30
38
if ( options . iteratee ) {
31
39
this . _iteratee = options . iteratee ;
32
40
}
@@ -75,7 +83,7 @@ export class RewriteFrames implements Integration {
75
83
. replace ( / \\ / g, '/' ) // replace all `\\` instances with `/`
76
84
: frame . filename ;
77
85
const base = this . _root ? relative ( this . _root , filename ) : basename ( filename ) ;
78
- frame . filename = `app:/// ${ base } ` ;
86
+ frame . filename = `${ this . _prefix } ${ base } ` ;
79
87
}
80
88
return frame ;
81
89
} ;
Original file line number Diff line number Diff line change @@ -78,12 +78,32 @@ describe('RewriteFrames', () => {
78
78
} ) ;
79
79
} ) ;
80
80
81
+ describe ( 'default iteratee prepends custom prefix to basename if frame starts with `/`' , ( ) => {
82
+ beforeEach ( ( ) => {
83
+ rewriteFrames = new RewriteFrames ( {
84
+ prefix : 'foobar/' ,
85
+ } ) ;
86
+ } ) ;
87
+
88
+ it ( 'transforms messageEvent frames' , ( ) => {
89
+ const event = rewriteFrames . process ( messageEvent ) ;
90
+ expect ( event . stacktrace ! . frames ! [ 0 ] . filename ) . toEqual ( 'foobar/file1.js' ) ;
91
+ expect ( event . stacktrace ! . frames ! [ 1 ] . filename ) . toEqual ( 'foobar/file2.js' ) ;
92
+ } ) ;
93
+
94
+ it ( 'transforms exceptionEvent frames' , ( ) => {
95
+ const event = rewriteFrames . process ( exceptionEvent ) ;
96
+ expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 0 ] . filename ) . toEqual ( 'foobar/file1.js' ) ;
97
+ expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] . filename ) . toEqual ( 'foobar/file2.js' ) ;
98
+ } ) ;
99
+ } ) ;
100
+
81
101
describe ( 'default iteratee appends basename to `app:///` if frame starts with `C:\\`' , ( ) => {
82
102
beforeEach ( ( ) => {
83
103
rewriteFrames = new RewriteFrames ( ) ;
84
104
} ) ;
85
105
86
- it ( 'trasforms windowsExceptionEvent frames' , ( ) => {
106
+ it ( 'transforms windowsExceptionEvent frames' , ( ) => {
87
107
const event = rewriteFrames . process ( windowsExceptionEvent ) ;
88
108
expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 0 ] . filename ) . toEqual ( 'app:///file1.js' ) ;
89
109
expect ( event . exception ! . values ! [ 0 ] . stacktrace ! . frames ! [ 1 ] . filename ) . toEqual ( 'app:///file2.js' ) ;
You can’t perform that action at this time.
0 commit comments