diff --git a/packages/@uppy/transloadit/src/Client.js b/packages/@uppy/transloadit/src/Client.js index 7f6227f51..520ace9a5 100644 --- a/packages/@uppy/transloadit/src/Client.js +++ b/packages/@uppy/transloadit/src/Client.js @@ -46,7 +46,7 @@ module.exports = class Client { } return assembly - }).catch((err) => this._reportError(err, { url })) + }).catch((err) => this._reportError(err, { url, type: 'API_ERROR' })) } /** @@ -60,7 +60,7 @@ module.exports = class Client { const url = `${assembly.assembly_ssl_url}/reserve_file?size=${size}` return fetch(url, { method: 'post' }) .then((response) => response.json()) - .catch((err) => this._reportError(err, { assembly, file, url })) + .catch((err) => this._reportError(err, { assembly, file, url, type: 'API_ERROR' })) } /** @@ -82,7 +82,7 @@ module.exports = class Client { const url = `${assembly.assembly_ssl_url}/add_file?${qs}` return fetch(url, { method: 'post' }) .then((response) => response.json()) - .catch((err) => this._reportError(err, { assembly, file, url })) + .catch((err) => this._reportError(err, { assembly, file, url, type: 'API_ERROR' })) } /** @@ -91,8 +91,10 @@ module.exports = class Client { * @param {object} assembly */ cancelAssembly (assembly) { - return fetch(assembly.assembly_ssl_url, { method: 'delete' }) + const url = assembly.assembly_ssl_url + return fetch(url, { method: 'delete' }) .then((response) => response.json()) + .catch((err) => this._reportError(err, { url, type: 'API_ERROR' })) } /** @@ -103,7 +105,7 @@ module.exports = class Client { getAssemblyStatus (url) { return fetch(url) .then((response) => response.json()) - .catch((err) => this._reportError(err, { url })) + .catch((err) => this._reportError(err, { url, type: 'STATUS_ERROR' })) } submitError (err, { endpoint, instance, assembly }) { @@ -123,12 +125,14 @@ module.exports = class Client { }).then((response) => response.json()) } - _reportError (err, params = {}) { + _reportError (err, params) { if (this.opts.errorReporting === false) { throw err } - const opts = {} + const opts = { + type: params.type + } if (params.assembly) { opts.assembly = params.assembly.assembly_id opts.instance = params.assembly.instance diff --git a/packages/@uppy/transloadit/src/index.js b/packages/@uppy/transloadit/src/index.js index 4f0c61c25..12ca6b6b8 100644 --- a/packages/@uppy/transloadit/src/index.js +++ b/packages/@uppy/transloadit/src/index.js @@ -676,7 +676,7 @@ module.exports = class Transloadit extends Plugin { const url = err.originalRequest && err.originalRequest.responseURL ? err.originalRequest.responseURL : null - this.client.submitError(err, { url }).then((_) => { + this.client.submitError(err, { url, type: 'TUS_ERROR' }).then((_) => { // if we can't report the error that sucks }) }