@@ -136,6 +136,128 @@ describe('React Native plugin', function() {
136136 assert . equal ( frames [ 0 ] . filename , '/file1.js' ) ;
137137 assert . equal ( frames [ 1 ] . filename , '/file2.js' ) ;
138138 } ) ;
139+
140+ it ( 'should normalize transaction and frame filenames/URLs from .app directory' , function ( ) {
141+ var data = {
142+ project : '2' ,
143+ logger : 'javascript' ,
144+ platform : 'javascript' ,
145+
146+ transaction :
147+ 'file:///var/mobile/Containers/Bundle/Application/ABC/123.app/app.js' ,
148+ message : 'Error: crap' ,
149+ exception : {
150+ type : 'Error' ,
151+ values : [
152+ {
153+ stacktrace : {
154+ frames : [
155+ {
156+ filename :
157+ 'file:///var/containers/Bundle/Application/ABC/123.app/file1.js' ,
158+ lineno : 10 ,
159+ colno : 11 ,
160+ function : 'broken'
161+ } ,
162+ {
163+ filename :
164+ 'file:///var/mobile/Containers/Bundle/Application/ABC/123.app/file2.js' ,
165+ lineno : 12 ,
166+ colno : 13 ,
167+ function : 'lol'
168+ }
169+ ]
170+ }
171+ }
172+ ]
173+ }
174+ } ;
175+ reactNativePlugin . _normalizeData ( data ) ;
176+
177+ assert . equal ( data . transaction , '/app.js' ) ;
178+ var frames = data . exception . values [ 0 ] . stacktrace . frames ;
179+ assert . equal ( frames [ 0 ] . filename , '/file1.js' ) ;
180+ assert . equal ( frames [ 1 ] . filename , '/file2.js' ) ;
181+ } ) ;
182+
183+ it ( 'should normalize transaction and frame filenames/URLs from stacktrace interface' , function ( ) {
184+ var data = {
185+ project : '2' ,
186+ logger : 'javascript' ,
187+ platform : 'javascript' ,
188+
189+ transaction :
190+ 'file:///var/mobile/Containers/Bundle/Application/ABC/123.app/app.js' ,
191+ message : 'Error: crap' ,
192+
193+ stacktrace : {
194+ frames : [
195+ {
196+ filename : 'file:///var/containers/Bundle/Application/ABC/123.app/file1.js' ,
197+ lineno : 10 ,
198+ colno : 11 ,
199+ function : 'broken'
200+ } ,
201+ {
202+ filename :
203+ 'file:///var/mobile/Containers/Bundle/Application/ABC/123.app/file2.js' ,
204+ lineno : 12 ,
205+ colno : 13 ,
206+ function : 'lol'
207+ }
208+ ]
209+ }
210+ } ;
211+ reactNativePlugin . _normalizeData ( data ) ;
212+
213+ assert . equal ( data . transaction , '/app.js' ) ;
214+ var frames = data . stacktrace . frames ;
215+ assert . equal ( frames [ 0 ] . filename , '/file1.js' ) ;
216+ assert . equal ( frames [ 1 ] . filename , '/file2.js' ) ;
217+ } ) ;
218+
219+ it ( 'should normalize transaction and frame filenames/URLs from CodePush' , function ( ) {
220+ var data = {
221+ project : '2' ,
222+ logger : 'javascript' ,
223+ platform : 'javascript' ,
224+
225+ transaction :
226+ 'file:///var/mobile/Containers/Data/Application/ABC/Library/Application%20Support/CodePush/CDE/CodePush/app.js' ,
227+ message : 'Error: crap' ,
228+ exception : {
229+ type : 'Error' ,
230+ values : [
231+ {
232+ stacktrace : {
233+ frames : [
234+ {
235+ filename :
236+ 'file:///var/mobile/Containers/Data/Application/ABC/Library/Application%20Support/CodePush/CDE/CodePush/file1.js' ,
237+ lineno : 10 ,
238+ colno : 11 ,
239+ function : 'broken'
240+ } ,
241+ {
242+ filename :
243+ 'file:///var/mobile/Containers/Data/Application/ABC/Library/Application%20Support/CodePush/CDE/CodePush/file2.js' ,
244+ lineno : 12 ,
245+ colno : 13 ,
246+ function : 'lol'
247+ }
248+ ]
249+ }
250+ }
251+ ]
252+ }
253+ } ;
254+ reactNativePlugin . _normalizeData ( data ) ;
255+
256+ assert . equal ( data . transaction , '/app.js' ) ;
257+ var frames = data . exception . values [ 0 ] . stacktrace . frames ;
258+ assert . equal ( frames [ 0 ] . filename , '/file1.js' ) ;
259+ assert . equal ( frames [ 1 ] . filename , '/file2.js' ) ;
260+ } ) ;
139261 } ) ;
140262
141263 describe ( '_transport()' , function ( ) {
0 commit comments