From 9ada35cfb982ca332e9c097e06588bb0e986046f Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Fri, 9 Dec 2016 14:39:31 -0500 Subject: [PATCH] allowing Analytics.increment to have a callback --- src/analytics.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/analytics.js b/src/analytics.js index 6b248057da..9151bd6ce7 100644 --- a/src/analytics.js +++ b/src/analytics.js @@ -20,13 +20,17 @@ new cronJob('*/10 * * * *', function () { Analytics.writeData(); }, null, true); -Analytics.increment = function (keys) { +Analytics.increment = function (keys, callback) { keys = Array.isArray(keys) ? keys : [keys]; keys.forEach(function (key) { counters[key] = counters[key] || 0; ++counters[key]; }); + + if (typeof callback === 'function') { + callback(); + } }; Analytics.pageView = function (payload) {