Skip to content

Commit 2c97c64

Browse files
nicinaboxbenvinegar
authored andcommitted
Support CodePush paths in culprit and frame filename (#683)
1 parent 380d7d0 commit 2c97c64

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

plugins/react-native.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
// Example React Native path format (iOS):
2323
// /var/containers/Bundle/Application/{DEVICE_ID}/HelloWorld.app/main.jsbundle
2424

25-
var PATH_STRIP_RE = /^.*\/[^\.]+\.app/;
25+
var PATH_STRIP_RE = /^.*\/[^\.]+(\.app|CodePush)/;
2626

2727
var FATAL_ERROR_KEY = '--rn-fatal--';
2828
var ASYNC_STORAGE_KEY = '--raven-js-global-error-payload--';

test/plugins/react-native.test.js

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ describe('React Native plugin', function () {
1717
});
1818

1919
describe('_normalizeData()', function () {
20-
it('should normalize culprit and frame filenames/URLs', function () {
20+
it('should normalize culprit and frame filenames/URLs from app', function () {
2121
var data = {
2222
project: '2',
2323
logger: 'javascript',
@@ -52,6 +52,42 @@ describe('React Native plugin', function () {
5252
assert.equal(frames[0].filename, '/file1.js');
5353
assert.equal(frames[1].filename, '/file2.js');
5454
});
55+
56+
it('should normalize culprit and frame filenames/URLs from CodePush', function () {
57+
var data = {
58+
project: '2',
59+
logger: 'javascript',
60+
platform: 'javascript',
61+
62+
culprit: 'file:///var/mobile/Containers/Data/Application/ABC/Library/Application%20Support/CodePush/CDE/CodePush/app.js',
63+
message: 'Error: crap',
64+
exception: {
65+
type: 'Error',
66+
values: [{
67+
stacktrace: {
68+
frames: [{
69+
filename: 'file:///var/mobile/Containers/Data/Application/ABC/Library/Application%20Support/CodePush/CDE/CodePush/file1.js',
70+
lineno: 10,
71+
colno: 11,
72+
'function': 'broken'
73+
74+
}, {
75+
filename: 'file:///var/mobile/Containers/Data/Application/ABC/Library/Application%20Support/CodePush/CDE/CodePush/file2.js',
76+
lineno: 12,
77+
colno: 13,
78+
'function': 'lol'
79+
}]
80+
}
81+
}],
82+
}
83+
};
84+
reactNativePlugin._normalizeData(data);
85+
86+
assert.equal(data.culprit, '/app.js');
87+
var frames = data.exception.values[0].stacktrace.frames;
88+
assert.equal(frames[0].filename, '/file1.js');
89+
assert.equal(frames[1].filename, '/file2.js');
90+
});
5591
});
5692

5793
describe('_transport()', function () {

0 commit comments

Comments
 (0)