File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change 7
7
* var Raven = require('raven-js');
8
8
* require('raven-js/plugins/react-native')(Raven);
9
9
*/
10
+
11
+ var DEVICE_PATH_RE = / ^ \/ v a r \/ m o b i l e \/ C o n t a i n e r s \/ B u n d l e \/ A p p l i c a t i o n \/ [ ^ \/ ] + \/ [ ^ \. ] + \. a p p / ;
12
+ function normalizeUrl ( url ) {
13
+ "use strict" ;
14
+
15
+ return url
16
+ . replace ( / f i l e \: \/ \/ / , '' )
17
+ . replace ( DEVICE_PATH_RE , '' ) ;
18
+ }
19
+
10
20
module . exports = function ( Raven ) {
11
21
"use strict" ;
12
22
@@ -47,5 +57,19 @@ module.exports = function (Raven) {
47
57
// transport - use XMLHttpRequest instead
48
58
Raven . setTransport ( xhrTransport ) ;
49
59
60
+
61
+ // Use data callback to strip device-specific paths from stack traces
62
+ Raven . setDataCallback ( function ( data ) {
63
+ if ( data . culprit ) {
64
+ data . culprit = normalizeUrl ( data . culprit ) ;
65
+ }
66
+
67
+ if ( data . stacktrace && data . stacktrace . frames && data . stacktrace . frames . length ) {
68
+ data . stacktrace . frames . forEach ( function ( frame ) {
69
+ frame . filename = normalizeUrl ( frame . filename ) ;
70
+ } ) ;
71
+ }
72
+ } ) ;
73
+
50
74
ErrorUtils . setGlobalHandler ( Raven . captureException ) ;
51
75
} ;
You can’t perform that action at this time.
0 commit comments