diff --git a/package.json b/package.json index 6506a63..4490d86 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "react": "^16.13.1", "react-color": "^2.18.1", "react-dom": "^16.13.1", + "react-ga": "^3.0.0", "react-github-btn": "^1.2.0", "react-redux": "^7.2.0", "react-scripts": "3.4.1", diff --git a/src/actions/index.js b/src/actions/index.js index b58cc29..57096a3 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -1,14 +1,23 @@ import {actionTypes} from "../constant/ActionTypes"; +import ReactGA from "react-ga"; export const genQRInfo = text => ({ type: actionTypes.GENERATE_QR_INFO, text }) -export const changeStyle = (rendererIndex, rendererType, value) => ({ - type: actionTypes.CHANGE_STYLE, - rendererIndex, rendererType, value -}) +export const changeStyle = (rendererIndex, rendererType, value) => { + ReactGA.event({ + category: 'Style', + action: 'Switch', + value: value + }); + + return { + type: actionTypes.CHANGE_STYLE, + rendererIndex, rendererType, value + } +} export const changeCorrectLevel = (correctLevel) => ({ type: actionTypes.CHANGE_CORRECT_LEVEL, diff --git a/src/components/app/App.js b/src/components/app/App.js index 2d32b07..a979a60 100644 --- a/src/components/app/App.js +++ b/src/components/app/App.js @@ -10,7 +10,9 @@ import PartStylesViewer from "../../containers/app/PartStylesViewer"; import {getDownloadCount, login} from "../../api/db"; import {connect} from 'react-redux'; import {loadDownloadData} from "../../actions"; +import ReactGA from 'react-ga'; +ReactGA.initialize('UA-165845289-1'); function App({ dispatch }) { const updateDownloadData = useCallback((downloadData) => dispatch(loadDownloadData(downloadData)), []); diff --git a/yarn.lock b/yarn.lock index dadf1be..eff20f6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8703,6 +8703,11 @@ react-error-overlay@^6.0.7: resolved "https://registry.npm.taobao.org/react-error-overlay/download/react-error-overlay-6.0.7.tgz#1dcfb459ab671d53f660a991513cb2f0a0553108" integrity sha1-Hc+0WatnHVP2YKmRUTyy8KBVMQg= +react-ga@^3.0.0: + version "3.0.0" + resolved "https://registry.npm.taobao.org/react-ga/download/react-ga-3.0.0.tgz#4d665389cf0c489c36c5fdf97722a7e53efdfc5b" + integrity sha1-TWZTic8MSJw2xf35dyKn5T79/Fs= + react-github-btn@^1.2.0: version "1.2.0" resolved "https://registry.npm.taobao.org/react-github-btn/download/react-github-btn-1.2.0.tgz#464066f999a77c0eed27980260601b51cbe15614"