Merge pull request #811 from strapi/ga-admin

Add ga in admin to improve Strapi
This commit is contained in:
Jim LAURIE 2018-03-19 18:20:57 +01:00 committed by GitHub
commit 4d5e02cd8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View File

@ -10,6 +10,7 @@
*/
import React from 'react';
import ReactGA from 'react-ga';
import PropTypes from 'prop-types';
import { connect } from 'react-redux';
import { createStructuredSelector } from 'reselect';
@ -71,11 +72,15 @@ export class AdminPage extends React.Component { // eslint-disable-line react/pr
componentDidMount() {
this.checkLogin(this.props);
ReactGA.initialize('UA-54313258-9');
}
componentWillReceiveProps(nextProps) {
if (nextProps.location.pathname !== this.props.location.pathname) {
this.checkLogin(nextProps);
ReactGA.pageview(nextProps.location.pathname);
}
if (get(nextProps.plugins.toJS(), ['users-permissions', 'hasAdminUser']) !== get(this.props.plugins.toJS(), ['users-permissions', 'hasAdminUser'])) {

View File

@ -23,6 +23,7 @@
"setup": "node ./scripts/setup.js"
},
"dependencies": {
"react-ga": "^2.4.1",
"shelljs": "^0.7.8"
},
"devDependencies": {
@ -47,4 +48,4 @@
"npm": ">= 3.0.0"
},
"license": "MIT"
}
}