diff --git a/www/assets/js/account.js b/www/assets/js/account.js
index eb39006..8835c85 100644
--- a/www/assets/js/account.js
+++ b/www/assets/js/account.js
@@ -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);
}
\ No newline at end of file
diff --git a/www/assets/js/dropandsend.js b/www/assets/js/dropandsend.js
index 1af5236..c211959 100644
--- a/www/assets/js/dropandsend.js
+++ b/www/assets/js/dropandsend.js
@@ -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());
});
\ No newline at end of file
diff --git a/www/assets/js/main.js b/www/assets/js/main.js
index 8478a51..d3631ef 100644
--- a/www/assets/js/main.js
+++ b/www/assets/js/main.js
@@ -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) {
diff --git a/www/assets/js/pickup.js b/www/assets/js/pickup.js
index ffe67a1..c4cc970 100644
--- a/www/assets/js/pickup.js
+++ b/www/assets/js/pickup.js
@@ -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");
}
\ No newline at end of file
diff --git a/www/assets/js/rates.js b/www/assets/js/rates.js
index 8d232be..d28192c 100644
--- a/www/assets/js/rates.js
+++ b/www/assets/js/rates.js
@@ -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");
}
\ No newline at end of file
diff --git a/www/assets/js/reporting.js b/www/assets/js/reporting.js
new file mode 100644
index 0000000..a0dfccf
--- /dev/null
+++ b/www/assets/js/reporting.js
@@ -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);
+ }
+ }
+}
\ No newline at end of file
diff --git a/www/assets/js/shop.js b/www/assets/js/shop.js
index e7d745a..96b1fa3 100644
--- a/www/assets/js/shop.js
+++ b/www/assets/js/shop.js
@@ -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);
diff --git a/www/assets/js/telegram.js b/www/assets/js/telegram.js
index 3204fd1..32b7257 100644
--- a/www/assets/js/telegram.js
+++ b/www/assets/js/telegram.js
@@ -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);
});
}
\ No newline at end of file
diff --git a/www/assets/js/track.js b/www/assets/js/track.js
index b14a52d..09ac2b5 100644
--- a/www/assets/js/track.js
+++ b/www/assets/js/track.js
@@ -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");
diff --git a/www/index.html b/www/index.html
index 756aa54..0d3a2b4 100644
--- a/www/index.html
+++ b/www/index.html
@@ -50,6 +50,7 @@
+