From a1546a5228efd8efcbbe59109047f1b8a19a75a5 Mon Sep 17 00:00:00 2001 From: CPunisher <1343316114@qq.com> Date: Tue, 16 Jun 2020 16:37:40 +0800 Subject: [PATCH] GA --- src/containers/app/PartDownloadViewer.js | 6 +++--- src/utils/gaHelper.js | 13 ++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/containers/app/PartDownloadViewer.js b/src/containers/app/PartDownloadViewer.js index 337e230..b221997 100644 --- a/src/containers/app/PartDownloadViewer.js +++ b/src/containers/app/PartDownloadViewer.js @@ -3,7 +3,7 @@ import PartDownload from "../../components/app/PartDownload"; import {saveImg, saveSvg} from "../../utils/downloader"; import {getDownloadCount, increaseDownloadData, recordDownloadDetail} from "../../api/db"; import {getParamDetailedValue, outerHtml} from "../../utils/util"; -import {handleDownloadEvent} from "../../utils/gaHelper"; +import {handleDownloadJpg, handleDownloadSvg} from "../../utils/gaHelper"; function saveDB(state, type, updateDownloadData) { return new Promise(resolve => { @@ -42,13 +42,13 @@ const mapStateToProps = (state, ownProps) => ({ onSvgDownload: () => { saveSvg(state.value, outerHtml(state.selectedIndex)); saveDB(state, 'svg', ownProps.updateDownloadData); - handleDownloadEvent(state.value, 0); + handleDownloadSvg(state.value); }, onJpgDownload: () => { return new Promise(resolve => { saveImg(state.value, outerHtml(state.selectedIndex), 1500, 1500).then((res) => { saveDB(state, 'jpg', ownProps.updateDownloadData).then(() => { - handleDownloadEvent(state.value, 1); + handleDownloadJpg(state.value); resolve(res) }); }); diff --git a/src/utils/gaHelper.js b/src/utils/gaHelper.js index fc41e63..36c8042 100644 --- a/src/utils/gaHelper.js +++ b/src/utils/gaHelper.js @@ -8,12 +8,19 @@ export function handleStyle(rendererName) { }); } -export function handleDownloadEvent(rendererName, value) { +export function handleDownloadSvg(rendererName) { ReactGA.event({ category: 'Style', - action: 'Download', + action: 'DownloadSvg', + label: rendererName, + }); +} + +export function handleDownloadJpg(rendererName) { + ReactGA.event({ + category: 'Style', + action: 'DownloadJpg', label: rendererName, - value: value }); }