Browse Source

Also log the POST data

master
Gaëtan Renaudeau 6 years ago
parent
commit
870e8e8a31
No known key found for this signature in database GPG Key ID: 7B66B85F042E5451
  1. 4
      src/api/network.js
  2. 3
      src/logger/logger.js

4
src/api/network.js

@ -6,7 +6,7 @@ import logger from 'logger'
import { LedgerAPIErrorWithMessage, LedgerAPIError, NetworkDown } from 'config/errors' import { LedgerAPIErrorWithMessage, LedgerAPIError, NetworkDown } from 'config/errors'
import anonymizer from 'helpers/anonymizer' import anonymizer from 'helpers/anonymizer'
const userFriendlyError = <A>(p: Promise<A>, { url, method, startTime }): Promise<A> => const userFriendlyError = <A>(p: Promise<A>, { url, method, startTime, ...rest }): Promise<A> =>
p.catch(error => { p.catch(error => {
let errorToThrow let errorToThrow
if (error.response) { if (error.response) {
@ -47,6 +47,7 @@ const userFriendlyError = <A>(p: Promise<A>, { url, method, startTime }): Promis
}) })
} }
logger.networkError({ logger.networkError({
...rest,
status, status,
url, url,
method, method,
@ -80,6 +81,7 @@ let implementation = (arg: Object) => {
const meta = { const meta = {
url: arg.url, url: arg.url,
method: arg.method, method: arg.method,
data: arg.data,
startTime: Date.now(), startTime: Date.now(),
} }
logger.network(meta) logger.network(meta)

3
src/logger/logger.js

@ -273,6 +273,7 @@ export default {
status, status,
error, error,
responseTime, responseTime,
...rest
}: { }: {
method: string, method: string,
url: string, url: string,
@ -285,7 +286,7 @@ export default {
0, 0,
)}ms` )}ms`
if (logNetwork) { if (logNetwork) {
logger.log('info', log, { type: 'network-error', status, method }) logger.log('info', log, { type: 'network-error', status, method, ...rest })
} }
captureBreadcrumb({ captureBreadcrumb({
category: 'network', category: 'network',

Loading…
Cancel
Save