diff --git a/frontend/src/App.vue b/frontend/src/App.vue index 975a627f..06a41cce 100644 --- a/frontend/src/App.vue +++ b/frontend/src/App.vue @@ -29,9 +29,11 @@ export default { localStorage.setItem('useStats', value) document.querySelector('.el-message__closeBtn').click() if (value === 1) { - window._hmt.push(['_trackPageview', '/allow_stats']) + this.$st.sendPv('/allow_stats') + this.$st.sendEv('全局', '允许/禁止统计', 'value', 'allow') } else { - window._hmt.push(['_trackPageview', '/disallow_stats']) + this.$st.sendPv('/disallow_stats') + this.$st.sendEv('全局', '允许/禁止统计', 'value', 'disallow') } } diff --git a/frontend/src/components/Config/ConfigList.vue b/frontend/src/components/Config/ConfigList.vue index 1b0e9d58..c964d57b 100644 --- a/frontend/src/components/Config/ConfigList.vue +++ b/frontend/src/components/Config/ConfigList.vue @@ -159,6 +159,7 @@ export default { this.spiderForm.crawl_type = value }, onSave () { + this.$st.sendEv('爬虫详情-配置', '保存') return new Promise((resolve, reject) => { this.saveLoading = true this.$store.dispatch('spider/updateSpiderFields') @@ -203,6 +204,7 @@ export default { .finally(() => { this.previewLoading = false }) + this.$st.sendEv('爬虫详情-配置', '预览') }) }, onCrawl () { @@ -215,6 +217,7 @@ export default { .then(() => { this.$message.success(this.$t(`Spider task has been scheduled`)) }) + this.$st.sendEv('爬虫详情-配置', '运行') }) }, onExtractFields () { @@ -235,6 +238,7 @@ export default { .finally(() => { this.extractFieldsLoading = false }) + this.$st.sendEv('爬虫详情-配置', '提取字段') }) } }, diff --git a/frontend/src/components/Environment/EnvironmentList.vue b/frontend/src/components/Environment/EnvironmentList.vue index 9e0b1413..a46432c0 100644 --- a/frontend/src/components/Environment/EnvironmentList.vue +++ b/frontend/src/components/Environment/EnvironmentList.vue @@ -49,10 +49,11 @@ export default { name: '', value: '' }) - console.log(this.spiderForm) + this.$st.sendEv('爬虫详情-环境', '添加') }, deleteEnv (index) { this.spiderForm.envs.splice(index, 1) + this.$st.sendEv('爬虫详情-环境', '删除') }, save () { this.$store.dispatch('spider/updateSpiderEnvs') @@ -62,6 +63,7 @@ export default { .catch(error => { this.$message.error(error) }) + this.$st.sendEv('爬虫详情-环境', '保存') } } } diff --git a/frontend/src/components/InfoView/NodeInfoView.vue b/frontend/src/components/InfoView/NodeInfoView.vue index 69a3601a..bc6e687a 100644 --- a/frontend/src/components/InfoView/NodeInfoView.vue +++ b/frontend/src/components/InfoView/NodeInfoView.vue @@ -55,6 +55,7 @@ export default { }) } }) + this.$st.sendEv('节点详情', '保存') } } } diff --git a/frontend/src/components/InfoView/SpiderInfoView.vue b/frontend/src/components/InfoView/SpiderInfoView.vue index e896bbc0..d095f81a 100644 --- a/frontend/src/components/InfoView/SpiderInfoView.vue +++ b/frontend/src/components/InfoView/SpiderInfoView.vue @@ -127,6 +127,7 @@ export default { .then(() => { this.$message.success(this.$t(`Spider task has been scheduled`)) }) + this.$st.sendEv('爬虫详情-概览', '运行') }) } }) @@ -149,6 +150,7 @@ export default { .then(() => { this.$message.success(this.$t(`Spider has been deployed`)) }) + this.$st.sendEv('爬虫详情-概览', '部署') }) } }) @@ -165,6 +167,7 @@ export default { }) } }) + this.$st.sendEv('爬虫详情-概览', '保存') }, fetchSiteSuggestions (keyword, callback) { this.$request.get('/sites', { diff --git a/frontend/src/components/Overview/TaskOverview.vue b/frontend/src/components/Overview/TaskOverview.vue index d306bb41..603f28ef 100644 --- a/frontend/src/components/Overview/TaskOverview.vue +++ b/frontend/src/components/Overview/TaskOverview.vue @@ -52,9 +52,11 @@ export default { methods: { onClickNodeTitle () { this.$router.push(`/nodes/${this.nodeForm._id}`) + this.$st.sendEv('任务详情-概览', '点击节点详情') }, onClickSpiderTitle () { this.$router.push(`/spiders/${this.spiderForm._id}`) + this.$st.sendEv('任务详情-概览', '点击爬虫详情') } }, created () { diff --git a/frontend/src/components/TableView/FieldsTableView.vue b/frontend/src/components/TableView/FieldsTableView.vue index ab2376f7..836a8f49 100644 --- a/frontend/src/components/TableView/FieldsTableView.vue +++ b/frontend/src/components/TableView/FieldsTableView.vue @@ -109,14 +109,17 @@ export default { type: 'css', extract_type: 'text' }) + this.$st.sendEv('爬虫详情-配置', '添加字段') }, deleteField (index) { this.fields.splice(index, 1) + this.$st.sendEv('爬虫详情-配置', '删除字段') }, onNameChange (row) { if (this.fields.filter(d => d.name === row.name).length > 1) { this.$message.error(this.$t(`Duplicated field names for ${row.name}`)) } + this.$st.sendEv('爬虫详情-配置', '更改字段') }, onCheck (row) { this.fields.forEach(d => { @@ -124,6 +127,7 @@ export default { this.$set(d, 'is_detail', false) } }) + this.$st.sendEv('爬虫详情-配置', '设置详情页URL') } } } diff --git a/frontend/src/router/index.js b/frontend/src/router/index.js index acd85b4a..0bfae74f 100644 --- a/frontend/src/router/index.js +++ b/frontend/src/router/index.js @@ -226,9 +226,7 @@ router.beforeEach((to, from, next) => { router.afterEach((to, from, next) => { if (to.path) { - if (localStorage.getItem('useStats') !== '0') { - stats.sendPv(to.path) - } + stats.sendPv(to.path) } }) diff --git a/frontend/src/utils/stats.js b/frontend/src/utils/stats.js index 0029bff0..f2fa0186 100644 --- a/frontend/src/utils/stats.js +++ b/frontend/src/utils/stats.js @@ -1,8 +1,12 @@ export default { sendPv (page) { - window._hmt.push(['_trackPageview', page]) + if (localStorage.getItem('useStats') !== '0') { + window._hmt.push(['_trackPageview', page]) + } }, - sendEv (ev) { - window._hmt.push(['_trackCustomEvent', ev]) + sendEv (category, eventName, optLabel, optValue) { + if (localStorage.getItem('useStats') !== '0') { + window._hmt.push(['_trackEvent', category, eventName, optLabel, optValue]) + } } } diff --git a/frontend/src/views/deploy/DeployList.vue b/frontend/src/views/deploy/DeployList.vue index 5cc6d118..16c8d319 100644 --- a/frontend/src/views/deploy/DeployList.vue +++ b/frontend/src/views/deploy/DeployList.vue @@ -134,6 +134,7 @@ export default { }, onRefresh () { this.$store.dispatch('deploy/getDeployList') + this.$st.sendEv('部署', '刷新') }, onView (row) { this.$router.push(`/deploys/${row._id}`) diff --git a/frontend/src/views/layout/components/Navbar.vue b/frontend/src/views/layout/components/Navbar.vue index 5b1f97f8..eae27a91 100644 --- a/frontend/src/views/layout/components/Navbar.vue +++ b/frontend/src/views/layout/components/Navbar.vue @@ -57,6 +57,8 @@ export default { window.localStorage.setItem('lang', lang) this.$i18n.locale = lang this.$store.commit('lang/SET_LANG', lang) + + this.$st.sendEv('全局', '切换中英文', 'lang', lang) } } } diff --git a/frontend/src/views/node/NodeDetail.vue b/frontend/src/views/node/NodeDetail.vue index e95eb472..7de7a677 100644 --- a/frontend/src/views/node/NodeDetail.vue +++ b/frontend/src/views/node/NodeDetail.vue @@ -47,6 +47,7 @@ export default { }, onNodeChange (id) { this.$router.push(`/nodes/${id}`) + this.$st.sendEv('节点详情', '切换节点') } }, created () { diff --git a/frontend/src/views/node/NodeList.vue b/frontend/src/views/node/NodeList.vue index 35dc7d18..be916f44 100644 --- a/frontend/src/views/node/NodeList.vue +++ b/frontend/src/views/node/NodeList.vue @@ -123,8 +123,7 @@ export default { } }, methods: { - onSearch (value) { - console.log(value) + onSearch () { }, onAdd () { this.$store.commit('node/SET_NODE_FORM', []) @@ -133,6 +132,7 @@ export default { }, onRefresh () { this.$store.dispatch('node/getNodeList') + this.$st.sendEv('节点', '刷新') }, onSubmit () { const vm = this @@ -159,7 +159,6 @@ export default { this.dialogVisible = false }, onEdit (row) { - console.log(row) this.isEditMode = true this.$store.commit('node/SET_NODE_FORM', row) this.dialogVisible = true @@ -177,10 +176,13 @@ export default { message: 'Deleted successfully' }) }) + this.$st.sendEv('节点', '删除', 'id', row._id) }) }, onView (row) { this.$router.push(`/nodes/${row._id}`) + + this.$st.sendEv('节点', '查看', 'id', row._id) }, onPageChange () { this.$store.dispatch('node/getNodeList') diff --git a/frontend/src/views/schedule/ScheduleList.vue b/frontend/src/views/schedule/ScheduleList.vue index e9fe0bce..7a1fc9ba 100644 --- a/frontend/src/views/schedule/ScheduleList.vue +++ b/frontend/src/views/schedule/ScheduleList.vue @@ -160,6 +160,7 @@ export default { this.isEdit = false this.dialogVisible = true this.$store.commit('schedule/SET_SCHEDULE_FORM', {}) + this.$st.sendEv('定时任务', '添加') }, onAddSubmit () { this.$refs.scheduleForm.validate(res => { @@ -179,6 +180,7 @@ export default { }) } }) + this.$st.sendEv('定时任务', '提交') }, isShowRun () { }, @@ -186,6 +188,7 @@ export default { this.$store.commit('schedule/SET_SCHEDULE_FORM', row) this.dialogVisible = true this.isEdit = true + this.$st.sendEv('定时任务', '修改', 'id', row._id) }, onRemove (row) { this.$store.dispatch('schedule/removeSchedule', row._id) @@ -195,6 +198,7 @@ export default { this.$message.success(`Schedule "${row.name}" has been removed`) }, 100) }) + this.$st.sendEv('定时任务', '删除', 'id', row._id) }, onCrawl () { } diff --git a/frontend/src/views/site/SiteList.vue b/frontend/src/views/site/SiteList.vue index 98fa1365..450ec16b 100644 --- a/frontend/src/views/site/SiteList.vue +++ b/frontend/src/views/site/SiteList.vue @@ -8,11 +8,11 @@ v-model="keyword"> + clearable filterable @change="onSelectMainCategory"> + clearable filterable @change="onSelectCategory"> @@ -84,7 +85,7 @@