From dcd1f4cb7208b770d1e08a6ec349eb91458cf311 Mon Sep 17 00:00:00 2001 From: Jurie-Jan Botha Date: Tue, 3 Feb 2015 11:51:52 +0200 Subject: [PATCH] Switched to using callback for determining if error should be sent --- src/raven.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/raven.js b/src/raven.js index da9d4274c570..248f80106073 100644 --- a/src/raven.js +++ b/src/raven.js @@ -687,17 +687,23 @@ function send(data) { data = globalOptions.dataCallback(data); } - // Check if the request should be filtered or not - if (isFunction(globalOptions.shouldSendCallback) && !globalOptions.shouldSendCallback(data)) { - return; + var shouldSend = function (should) { + if (should) { + // Send along an event_id if not explicitly passed. + // This event_id can be used to reference the error within Sentry itself. + // Set lastEventId after we know the error should actually be sent + lastEventId = data.event_id || (data.event_id = uuid4()); + + makeRequest(data); + } } - // Send along an event_id if not explicitly passed. - // This event_id can be used to reference the error within Sentry itself. - // Set lastEventId after we know the error should actually be sent - lastEventId = data.event_id || (data.event_id = uuid4()); - - makeRequest(data); + // Check if the request should be filtered or not + if (isFunction(globalOptions.shouldSendCallback)) { + globalOptions.shouldSendCallback(data, shouldSend); + } else { + shouldSend(true); + } }