Skip to content

Commit

Permalink
#977 Add untested carrotquest object loading
Browse files Browse the repository at this point in the history
  • Loading branch information
duker33 committed Sep 29, 2019
1 parent 77991fd commit 2c342f8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion front/js/components/orderCall.es6
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
server.sendOrderCall(phone, time, url)
.then(() => {
DOM.$timeText.text(DOM.$timeTag.val());
mediator.publish('onBackCallSend');
mediator.publish('onBackCallSend', phone);
});
}

Expand Down
5 changes: 3 additions & 2 deletions front/js/components/product.es6
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion front/js/shared/mediator.es6
Original file line number Diff line number Diff line change
@@ -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 = {
Expand Down
14 changes: 12 additions & 2 deletions front/js/shared/tracking.es6
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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);
Expand Down

0 comments on commit 2c342f8

Please sign in to comment.