diff --git a/front/js/components/orderCall.es6 b/front/js/components/orderCall.es6 index 07da1dbe..7a73631c 100644 --- a/front/js/components/orderCall.es6 +++ b/front/js/components/orderCall.es6 @@ -39,7 +39,7 @@ server.sendOrderCall(phone, time, url) .then(() => { DOM.$timeText.text(DOM.$timeTag.val()); - mediator.publish('onBackCallSend'); + mediator.publish('onBackCallSend', phone); }); } diff --git a/front/js/components/product.es6 b/front/js/components/product.es6 index 8585a4d2..3ed47c8e 100644 --- a/front/js/components/product.es6 +++ b/front/js/components/product.es6 @@ -96,9 +96,10 @@ helpers.setDisabledState(DOM.$oneClick, 'Ожидайте...'); const { id, quantity } = getProductData(); - server.oneClickBuy(id, quantity, DOM.$phone.val()) + const phone = DOM.$phone.val(); + server.oneClickBuy(id, quantity, phone) .then(() => { - mediator.publish('onOneClickBuy'); + mediator.publish('onOneClickBuy', phone); // Set timeout to wait handling of onOneClickBuy setTimeout(() => { window.location.href = configs.hrefs.orderSuccess; diff --git a/front/js/shared/mediator.es6 b/front/js/shared/mediator.es6 index 9739a01c..17c3f0e1 100644 --- a/front/js/shared/mediator.es6 +++ b/front/js/shared/mediator.es6 @@ -1,5 +1,5 @@ /** - * We implements mediator pattern via jQuery's global events + * We implement mediator pattern via jQuery's global events * on empty object (it could be a window or a documents, also) */ const mediator = { diff --git a/front/js/shared/tracking.es6 b/front/js/shared/tracking.es6 index 1f4485a4..fc413819 100644 --- a/front/js/shared/tracking.es6 +++ b/front/js/shared/tracking.es6 @@ -32,9 +32,16 @@ }; function setUpListeners() { - mediator.subscribe('onOneClickBuy', () => { + mediator.subscribe('onOneClickBuy', (_, phone) => { reachGoal('CMN_BUY_SEND'); reachGoal('FAST_BUY_SEND'); + // @todo #977:120m Create some lazy() wrapper for counters. + // `lazy(my_counter).reachGoal()` should asynchronous delay reaching + // until my_counter object won't be fully loaded. + + // @todo #977:30m Create mock class for carrotquest. + // Fill it's methods with console logs. + carrotquest.identify({'$phone': phone}); }); mediator.subscribe('onOrderSend', () => { reachGoal('CMN_BUY_SEND'); @@ -52,7 +59,10 @@ yaTracker.remove([data]); }); mediator.subscribe('onProductDetail', (_, data) => yaTracker.detail([data])); - mediator.subscribe('onBackCallSend', () => reachGoal('BACK_CALL_SEND')); + mediator.subscribe('onBackCallSend', (_, phone) => { + reachGoal('BACK_CALL_SEND'); + carrotquest.identify({'$phone': phone}); + }); mediator.subscribe('onSuccessOrder', (_, orderPositions, orderData) => { yaTracker.purchase(orderPositions, orderData); gaTracker.purchase(orderPositions, orderData);