Skip to content

Commit 4fb4ca3

Browse files
kumaviskamilogorek
authored andcommitted
feat: Capture breadcrumbs on failed fetch request (#1293)
1 parent 68373be commit 4fb4ca3

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/raven.js

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,17 +1368,30 @@ Raven.prototype = {
13681368
status_code: null
13691369
};
13701370

1371-
return origFetch.apply(this, args).then(function(response) {
1372-
fetchData.status_code = response.status;
1371+
return origFetch
1372+
.apply(this, args)
1373+
.then(function(response) {
1374+
fetchData.status_code = response.status;
13731375

1374-
self.captureBreadcrumb({
1375-
type: 'http',
1376-
category: 'fetch',
1377-
data: fetchData
1378-
});
1376+
self.captureBreadcrumb({
1377+
type: 'http',
1378+
category: 'fetch',
1379+
data: fetchData
1380+
});
13791381

1380-
return response;
1381-
});
1382+
return response;
1383+
})
1384+
['catch'](function(err) {
1385+
// if there is an error performing the request
1386+
self.captureBreadcrumb({
1387+
type: 'http',
1388+
category: 'fetch',
1389+
data: fetchData,
1390+
level: 'error'
1391+
});
1392+
1393+
throw err;
1394+
});
13821395
};
13831396
},
13841397
wrappedBuiltIns

0 commit comments

Comments
 (0)