Report error and success events to Matomo
This commit is contained in:
parent
a84c923fed
commit
83f581de5d
@ -29,10 +29,12 @@ function checkAccountStatus(callback) {
|
||||
// the user wants to try a different one.
|
||||
removeFromStorage("accountnumber");
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Account", "Couldn't check account status", resp.msg);
|
||||
}
|
||||
}, function (err) {
|
||||
}, function (xhr, status, error) {
|
||||
router.back();
|
||||
app.dialog.alert("Something went wrong. Try again later.", "Error");
|
||||
sendErrorReport("Account", "Couldn't check account status", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
});
|
||||
} else {
|
||||
callback(false);
|
||||
@ -85,13 +87,16 @@ function verifyCode(code) {
|
||||
if (resp.status == "OK") {
|
||||
setStorage("accountkey", resp.authkey);
|
||||
app.dialog.alert("This device has been successfully linked to your Helena Express account.", "Account verified!");
|
||||
sendActionReport("Account", "Device linked OK");
|
||||
displayAccountInfo();
|
||||
} else if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Account", "Device linking", resp.msg);
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Account", "Couldn't verify account code", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
});
|
||||
}
|
||||
|
||||
@ -129,8 +134,9 @@ function displayAccountInfo() {
|
||||
$("#loyaltyBalanceBox").addClass("display-none");
|
||||
$("#loyaltyErrorMessage").text("Error: " + success.msg);
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
$("#loyaltyErrorMessage").text("Error: Couldn't get your account info. Try again later.");
|
||||
sendErrorReport("Account", "Couldn't display account info", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
}, "GET");
|
||||
}
|
||||
|
||||
@ -167,14 +173,17 @@ $("body").on("click", "#setupAccountBtn", function () {
|
||||
|
||||
if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Account", "Couldn't register account", resp.msg);
|
||||
return;
|
||||
} else {
|
||||
setStorage("accountnumber", resp.accountnumber);
|
||||
sendActionReport("Account", "Account created");
|
||||
router.refreshPage();
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Account", "Couldn't register account", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
});
|
||||
});
|
||||
|
||||
@ -209,16 +218,19 @@ $("body").on("click", "#updateAccountBtn", function () {
|
||||
|
||||
if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Account", "Couldn't update account", resp.msg);
|
||||
return;
|
||||
} else {
|
||||
app.popup.close("#accountUpdatePopup", true);
|
||||
setStorage("accountnumber", resp.accountnumber);
|
||||
sendActionReport("Account", "Account updated");
|
||||
router.refreshPage();
|
||||
app.dialog.alert("Account details updated.", "Account Updated");
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Account", "Couldn't update account", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
});
|
||||
});
|
||||
|
||||
@ -292,4 +304,6 @@ function openCheckoutWindowToSaveCard(onaccountpage) {
|
||||
setTimeout(initAccountPage, 1000 * 40);
|
||||
setTimeout(initAccountPage, 1000 * 50);
|
||||
setTimeout(initAccountPage, 1000 * 60);
|
||||
setTimeout(initAccountPage, 1000 * 90);
|
||||
setTimeout(initAccountPage, 1000 * 120);
|
||||
}
|
@ -42,12 +42,15 @@ function sendPickupCode(code) {
|
||||
app.dialog.close();
|
||||
if (resp.status == "OK") {
|
||||
app.dialog.alert("Thank you for using Helena Express! You'll get an emailed receipt after we pick up and process your package(s).", "Pickup Requested!");
|
||||
sendActionReport("Pickup", "Drop and Send", "Pickup requested");
|
||||
} else if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Pickup", "Drop and Send", resp.msg);
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Pickup", "Drop and Send", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
});
|
||||
}
|
||||
|
||||
@ -135,6 +138,8 @@ $("body").on("popup:open", "#dasLocationMapPopup", function () {
|
||||
} else {
|
||||
// Fall back to something
|
||||
}
|
||||
|
||||
trackPageView("/dropandsend/locations_popup", $("#dasLocationMapPopup .navbar .navbar-inner .title").first().text());
|
||||
});
|
||||
|
||||
$("body").on("popup:open", "#dasHowItWorksPopup", function () {
|
||||
@ -142,4 +147,6 @@ $("body").on("popup:open", "#dasHowItWorksPopup", function () {
|
||||
if (inStorage("accountnumber") && inStorage("accountkey")) {
|
||||
$("#dasHowItWorksAccountNumber").text(" (yours is " + getStorage("accountnumber") + ")");
|
||||
}
|
||||
|
||||
trackPageView("/dropandsend/howitworks_popup", $("#dasHowItWorksPopup .navbar .navbar-inner .title").first().text());
|
||||
});
|
@ -97,14 +97,7 @@ $(document).keyup(function (e) {
|
||||
|
||||
router.on("routeChange", function (newRoute) {
|
||||
console.log("Info", "Navigating to ", newRoute.path);
|
||||
if (getStorage("analytics") !== "false") {
|
||||
try {
|
||||
_paq.push(['setCustomUrl', newRoute.path]);
|
||||
_paq.push(['trackPageView']);
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
}
|
||||
trackPageView(newRoute.path, $("#view-main .page-current .navbar .navbar-inner .title").first().text());
|
||||
});
|
||||
|
||||
function setAppTheme(theme) {
|
||||
|
@ -37,11 +37,14 @@ function requestPickup() {
|
||||
app.dialog.close();
|
||||
if (success.status == "OK") {
|
||||
app.dialog.alert(success.msg, "Pickup Requested!");
|
||||
sendActionReport("Pickup", "Pickup requested");
|
||||
} else {
|
||||
app.dialog.alert(success.msg, "Error");
|
||||
sendErrorReport("Pickup", "Pickup request", success.msg);
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Pickup", "Couldn't request pickup", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
}, "POST");
|
||||
}
|
@ -128,8 +128,10 @@ function getRates() {
|
||||
}
|
||||
$("#rateResultPopup").html(compiledPages.rateresult(resp));
|
||||
app.popup.open("#rateResultPopup");
|
||||
sendActionReport("Rates", "Got rates", $("#from_zip").val() + " -> " + $("#to_zip").val());
|
||||
} else {
|
||||
app.dialog.alert(resp.message, "Error");
|
||||
sendErrorReport("Rates", "Couldn't get rates", resp.message);
|
||||
}
|
||||
},
|
||||
function (xhr) {
|
||||
@ -138,11 +140,14 @@ function getRates() {
|
||||
var error = $.parseJSON(xhr.responseText);
|
||||
if (error && typeof error.msg != 'undefined') {
|
||||
app.dialog.alert(error.msg, "Error");
|
||||
sendErrorReport("Rates", "Couldn't get rates", error.msg);
|
||||
} else {
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Rates", "Couldn't get rates", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
}
|
||||
} catch (ex) {
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Rates", "Couldn't get rates", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
}
|
||||
}, "GET");
|
||||
}
|
46
www/assets/js/reporting.js
Normal file
46
www/assets/js/reporting.js
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
|
||||
function sendErrorReport(category, error, errordata) {
|
||||
if (getStorage("analytics") !== "false") {
|
||||
try {
|
||||
if (typeof errordata == "undefined") {
|
||||
_paq.push(['trackEvent', 'Error', category, error]);
|
||||
} else {
|
||||
_paq.push(['trackEvent', 'Error', category, error, errordata]);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function sendActionReport(category, action, data) {
|
||||
if (getStorage("analytics") !== "false") {
|
||||
try {
|
||||
if (typeof data == "undefined") {
|
||||
_paq.push(['trackEvent', 'User Action', category, action]);
|
||||
} else {
|
||||
_paq.push(['trackEvent', 'User Action', category, action, data]);
|
||||
}
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function trackPageView(url, title) {
|
||||
if (getStorage("analytics") !== "false") {
|
||||
try {
|
||||
_paq.push(['setCustomUrl', "https://app.helena.express" + url]);
|
||||
_paq.push(['setDocumentTitle', title]);
|
||||
_paq.push(['trackPageView']);
|
||||
} catch (ex) {
|
||||
console.error(ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -27,6 +27,7 @@ function loadShopPage( {resolve, reject}) {
|
||||
}, function (error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("Couldn't open the shop right now. Try again later.", "Whoops!");
|
||||
sendErrorReport("Shop", "Opening shop");
|
||||
reject();
|
||||
});
|
||||
}
|
||||
@ -65,6 +66,8 @@ function addToCart(sku, qty) {
|
||||
destroyOnClose: true
|
||||
});
|
||||
updateCart();
|
||||
|
||||
sendActionReport("Shop", "Add to cart", sku + ", " + qty);
|
||||
}
|
||||
|
||||
function removeFromCart(sku, qty) {
|
||||
@ -79,6 +82,7 @@ function removeFromCart(sku, qty) {
|
||||
delete shoppingcart[sku];
|
||||
}
|
||||
updateCart();
|
||||
sendActionReport("Shop", "Remove from cart", sku + ", " + qty);
|
||||
}
|
||||
|
||||
function emptyShoppingCart() {
|
||||
@ -201,16 +205,20 @@ function placeOrder(deliverymethod, ordertotal) {
|
||||
app.dialog.close();
|
||||
if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Shop", "Order not placed", "Server error: " + resp.msg);
|
||||
return;
|
||||
} else {
|
||||
emptyShoppingCart();
|
||||
app.dialog.alert("Your order has been received.", "Order placed!");
|
||||
app.popup.close();
|
||||
|
||||
sendActionReport("Shop", "Order placed", "$" + (ordertotal * 1.0).toFixed(2));
|
||||
return;
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("Your order might not have gone through due to a network error. If you don't get a confirmation email, try again.", "Whoops!");
|
||||
sendErrorReport("Shop", "Order not placed", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
})
|
||||
console.log(deliverymethod);
|
||||
console.log(shoppingcart);
|
||||
|
@ -18,11 +18,14 @@ function sendTelegram() {
|
||||
app.dialog.close();
|
||||
if (resp.status == "OK") {
|
||||
app.dialog.alert(resp.msg, "Telegram Sent!");
|
||||
sendActionReport("Telegram", "Telegram sent");
|
||||
} else if (resp.status == "ERROR") {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Telegram", "Couldn't send telegram", resp.msg);
|
||||
}
|
||||
}, function (error) {
|
||||
}, function (xhr, status, error) {
|
||||
app.dialog.close();
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Telegram", "Couldn't send telegram", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
});
|
||||
}
|
@ -113,11 +113,13 @@ function trackOpenAsync( {to, resolve, reject}) {
|
||||
context.events = false;
|
||||
}
|
||||
|
||||
sendActionReport("Tracking", "Tracked package");
|
||||
resolve({
|
||||
content: compiledPages.trackresult(context)
|
||||
});
|
||||
} else {
|
||||
app.dialog.alert(resp.msg, "Error");
|
||||
sendErrorReport("Tracking", "Couldn't get tracking", resp.msg);
|
||||
reject();
|
||||
}
|
||||
},
|
||||
@ -127,11 +129,14 @@ function trackOpenAsync( {to, resolve, reject}) {
|
||||
var error = $.parseJSON(xhr.responseText);
|
||||
if (error && typeof error.msg != 'undefined') {
|
||||
app.dialog.alert(error.msg, "Error");
|
||||
sendErrorReport("Tracking", "Couldn't get tracking", error.msg);
|
||||
} else {
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Tracking", "Couldn't get tracking", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
}
|
||||
} catch (ex) {
|
||||
app.dialog.alert("There's a server or network problem. Check your Internet connection or try again later.", "Error");
|
||||
sendErrorReport("Tracking", "Couldn't get tracking", "Server/network problem: " + xhr.status + ": " + xhr.statusText);
|
||||
}
|
||||
reject();
|
||||
}, "GET");
|
||||
|
@ -50,6 +50,7 @@
|
||||
|
||||
<script src="assets/js/platform.js"></script>
|
||||
|
||||
<script src="assets/js/reporting.js"></script>
|
||||
<script src="assets/js/map_maplibre.js"></script>
|
||||
<script src="assets/js/MapControl.class.js"></script>
|
||||
<script src="assets/js/map.js"></script>
|
||||
|
Loading…
x
Reference in New Issue
Block a user