mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 11:10:01 +08:00
📈 site: fix ga event
This commit is contained in:
parent
b9f8e1a058
commit
c1908e78e5
@ -113,7 +113,6 @@
|
||||
"cross-env": "^5.2.0",
|
||||
"css-split-webpack-plugin": "^0.2.6",
|
||||
"dekko": "^0.2.1",
|
||||
"delegate": "^3.2.0",
|
||||
"docsearch.js": "^2.5.2",
|
||||
"enquire-js": "^0.2.1",
|
||||
"enzyme": "^3.7.0",
|
||||
|
@ -80,7 +80,7 @@
|
||||
</div>
|
||||
<script src="{{ root }}common.js"></script>
|
||||
<script src="{{ root }}index.js"></script>
|
||||
<!-- Global site tag (gtag.js) - Google Analytics -->
|
||||
<!-- Global Site Tag (gtag.js) - Google Analytics -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-72788897-1"></script>
|
||||
<script>
|
||||
if (!location.port) {
|
||||
|
@ -4,7 +4,6 @@ import { FormattedMessage } from 'react-intl';
|
||||
import DocumentTitle from 'react-document-title';
|
||||
import { getChildren } from 'jsonml.js/lib/utils';
|
||||
import { Timeline, Alert, Affix } from 'antd';
|
||||
import delegate from 'delegate';
|
||||
import EditButton from './EditButton';
|
||||
import { ping } from '../utils';
|
||||
|
||||
@ -14,12 +13,6 @@ export default class Article extends React.Component {
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
// Add ga event click
|
||||
this.delegation = delegate(this.node, '.resource-card', 'click', (e) => {
|
||||
if (window.ga) {
|
||||
window.ga('send', 'event', 'Download', 'resource', e.delegateTarget.href);
|
||||
}
|
||||
}, false);
|
||||
this.componentDidUpdate();
|
||||
}
|
||||
|
||||
@ -39,9 +32,16 @@ export default class Article extends React.Component {
|
||||
|
||||
componentWillUnmount() {
|
||||
clearTimeout(this.pingTimer);
|
||||
if (this.delegation) {
|
||||
this.delegation.destroy();
|
||||
}
|
||||
|
||||
onResourceClick = (e) => {
|
||||
if (!window.gtag && e.target.className !== 'resource-card') {
|
||||
return;
|
||||
}
|
||||
window.gtag('event', 'resource', {
|
||||
event_category: 'Download',
|
||||
event_label: e.target.href,
|
||||
});
|
||||
}
|
||||
|
||||
getArticle(article) {
|
||||
@ -78,7 +78,8 @@ export default class Article extends React.Component {
|
||||
const isNotTranslated = locale === 'en-US' && typeof title === 'object';
|
||||
return (
|
||||
<DocumentTitle title={`${title[locale] || title} - Ant Design`}>
|
||||
<article className="markdown" ref={(node) => { this.node = node; }}>
|
||||
{ /* eslint-disable-next-line */ }
|
||||
<article className="markdown" onClick={this.onResourceClick}>
|
||||
{isNotTranslated && (
|
||||
<Alert
|
||||
type="warning"
|
||||
|
Loading…
Reference in New Issue
Block a user