From 3e0f30d210cbf96f9cbe531cd9a73ed348d0b4b9 Mon Sep 17 00:00:00 2001 From: Soulter <905617992@qq.com> Date: Mon, 28 Oct 2024 23:27:43 +0800 Subject: [PATCH] perf: upload metrics --- frontend/src/pages/index.vue | 4 ++-- frontend/src/store/index.js | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/frontend/src/pages/index.vue b/frontend/src/pages/index.vue index 61a3f55..93b7299 100644 --- a/frontend/src/pages/index.vue +++ b/frontend/src/pages/index.vue @@ -101,16 +101,16 @@ export default { this.$store.commit('initMetadata', 'post_rules') this.$store.commit('initMetadata', 'beianhao') this.$store.commit('fetchPublicObject', this.$bus) + this.$store.commit('uploadMetrics') }, methods: { - logout() { Cookies.remove("access-token"); // reload window.location.reload() }, - } + }, } diff --git a/frontend/src/store/index.js b/frontend/src/store/index.js index 467b6cf..69b92da 100644 --- a/frontend/src/store/index.js +++ b/frontend/src/store/index.js @@ -76,6 +76,24 @@ export default createStore({ } }) }, + uploadMetrics() { + // this method is used to upload metrics to our server to analyze the product usage, + // so that we can improve the product in the future. + fetch("https://tickstats.idoknow.top/api/metric/c91cd32d", { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify({ + metrics_data: { + "os_name": window.navigator.platform, + "browser": window.navigator.userAgent, + "host": window.location.host, + "tick": 1, + } + }), + }); + }, getVersion(state) { axios.get(this.state.base_url + '/v1/misc/get-version') .then(res => {