From 3820e6309550c13f3488456a94410f7368530349 Mon Sep 17 00:00:00 2001 From: bruno Date: Tue, 6 Feb 2024 17:04:56 +0100 Subject: [PATCH] add umami tracking --- assets/script.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/assets/script.js b/assets/script.js index 039c796..d2472a2 100644 --- a/assets/script.js +++ b/assets/script.js @@ -1,3 +1,4 @@ +let UserInfo; async function doAction(url, requestData, successMessage, failureMessage, silent = false) { try { const params = new URLSearchParams(); @@ -134,7 +135,6 @@ function onPageLoad(){ listUsers(); } } - umami.track(); } function navigateTo(site, page){ @@ -147,11 +147,15 @@ function navigateTo(site, page){ localStorage.setItem("currentSite", site); localStorage.setItem("currentPage", page); onPageLoad(); + umami.track(); }); } function softReload(){ - navigateTo(localStorage.getItem("currentSite"), localStorage.getItem("currentPage")); + let currentSite = localStorage.getItem("currentSite"); + let currentPage = localStorage.getItem("currentPage"); + navigateTo(currentSite, currentPage); + umami.track("softReload"); } function refreshNavbar(){ @@ -159,6 +163,7 @@ function refreshNavbar(){ action: "getNavigation", }; doPageAction(data); + umami.track("refreshNavbar"); } function logout() { @@ -169,6 +174,7 @@ function logout() { doAction('/account', data, "Logout Successful!", "Logout failed.").then(() => { refreshNavbar(); navigateTo("", localStorage.getItem("defaultPage")); + umami.track("logout"); }); } @@ -188,6 +194,7 @@ async function doLogin(email, password) { }; await doAction('/account', data, "Login Successful!", "Login failed. Please check your credentials."); + umami.track("login"); } function register() { @@ -211,6 +218,7 @@ function register() { async function doRegister(requestData) { await doAction('/account', requestData, "Registration Successful!", "Registration failed."); + umami.track("register"); } //User settings start @@ -230,6 +238,7 @@ function changePassword() { async function doChangePassword(requestData, successMessage, failureMessage) { await doAction('/account', requestData, successMessage, failureMessage); + umami.track("passwordChange"); } function updateUserProfile() { @@ -247,6 +256,7 @@ function updateUserProfile() { }; doAction('/account', data, "Profile update Successful!", "Profile update failed."); + umami.track("updateUserProfile"); } function updateEmail() { @@ -258,6 +268,7 @@ function updateEmail() { }; doAction('/account', data, "Email update Successful!", "Email update failed."); + umami.track("updateEmail"); } function populateUserInfoFields(userData) { @@ -277,6 +288,7 @@ function getUserInfo() { if (result && result.Status === "Success") { populateUserInfoFields(result.UserInfo); + UserInfo = result.UserInfo; } } @@ -295,6 +307,7 @@ function addActivationCodes() { const result = doAction('/account', data, "Activation codes added Successfully!", "Activation codes addition failed."); displayList(result.ActivationCodes, "codeListTable", deleteActivationCode); + umami.track("addActivationCodes"); } function listUsers() { @@ -327,6 +340,7 @@ function deleteUser(userId) { doAction('/account', data, "User deleted Successfully!", "User deletion failed."); listUsers(); + umami.track("deleteUser"); } function deleteActivationCode(activationCode) { @@ -337,5 +351,6 @@ function deleteActivationCode(activationCode) { doAction('/account', data, "Activation code deleted Successfully!", "Activation code deletion failed."); listActivationCodes(); + umami.track("deleteActivationCode"); } //Admin settings end