From 03ad2b91981012d87ce7f33ab577edceed2c1af5 Mon Sep 17 00:00:00 2001 From: Donald Pipowitch Date: Mon, 7 Dec 2020 17:03:33 +0100 Subject: [PATCH 1/2] fixes #142 --- src/amplitude-client.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/amplitude-client.js b/src/amplitude-client.js index f7aaf23a..23d156d0 100644 --- a/src/amplitude-client.js +++ b/src/amplitude-client.js @@ -1281,6 +1281,9 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert return eventId; } catch (e) { utils.log.error(e); + if (type(callback) === 'function') { + callback(0, 'No request sent', {reason: 'Request failed (e.g. it was blocked).'}); + } } }; From 8fa9f84943a9228338357f41fc5eeb7c9cec9e82 Mon Sep 17 00:00:00 2001 From: Donald Pipowitch Date: Thu, 10 Dec 2020 15:54:55 +0100 Subject: [PATCH 2/2] fix error handling --- src/amplitude-client.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/amplitude-client.js b/src/amplitude-client.js index 23d156d0..65343e3e 100644 --- a/src/amplitude-client.js +++ b/src/amplitude-client.js @@ -1281,9 +1281,6 @@ AmplitudeClient.prototype._logEvent = function _logEvent(eventType, eventPropert return eventId; } catch (e) { utils.log.error(e); - if (type(callback) === 'function') { - callback(0, 'No request sent', {reason: 'Request failed (e.g. it was blocked).'}); - } } }; @@ -1597,6 +1594,7 @@ AmplitudeClient.prototype.sendEvents = function sendEvents() { // here. // } } catch (e) { + scope.removeEvents(Infinity, Infinity, 0, 'No request sent', {reason: 'Request failed (e.g. it was blocked).'}); // utils.log('failed upload'); } });