File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 1
1
/*global ErrorUtils:false*/
2
2
3
+ "use strict" ;
4
+
3
5
/**
4
6
* react-native plugin for Raven
5
7
*
6
8
* Usage:
7
9
* var Raven = require('raven-js');
8
10
* require('raven-js/plugins/react-native')(Raven);
9
11
*/
10
- module . exports = function ( Raven ) {
11
- "use strict" ;
12
12
13
+ 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 / ;
14
+ function normalizeUrl ( url ) {
15
+ return url
16
+ . replace ( / f i l e \: \/ \/ / , '' )
17
+ . replace ( DEVICE_PATH_RE , '' ) ;
18
+ }
19
+
20
+ module . exports = function ( Raven ) {
13
21
function urlencode ( obj ) {
14
22
var pairs = [ ] ;
15
23
for ( var key in obj ) {
@@ -47,5 +55,19 @@ module.exports = function (Raven) {
47
55
// transport - use XMLHttpRequest instead
48
56
Raven . setTransport ( xhrTransport ) ;
49
57
58
+
59
+ // Use data callback to strip device-specific paths from stack traces
60
+ Raven . setDataCallback ( function ( data ) {
61
+ if ( data . culprit ) {
62
+ data . culprit = normalizeUrl ( data . culprit ) ;
63
+ }
64
+
65
+ if ( data . stacktrace && data . stacktrace . frames && data . stacktrace . frames . length ) {
66
+ data . stacktrace . frames . forEach ( function ( frame ) {
67
+ frame . filename = normalizeUrl ( frame . filename ) ;
68
+ } ) ;
69
+ }
70
+ } ) ;
71
+
50
72
ErrorUtils . setGlobalHandler ( Raven . captureException ) ;
51
73
} ;
You can’t perform that action at this time.
0 commit comments