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 77 * var Raven = require('raven-js');
88 * require('raven-js/plugins/react-native')(Raven);
99 */
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+
1020module . exports = function ( Raven ) {
1121 "use strict" ;
1222
@@ -47,5 +57,19 @@ module.exports = function (Raven) {
4757 // transport - use XMLHttpRequest instead
4858 Raven . setTransport ( xhrTransport ) ;
4959
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+
5074 ErrorUtils . setGlobalHandler ( Raven . captureException ) ;
5175} ;
You can’t perform that action at this time.
0 commit comments