From e91d067f0a06b0e3442bf0b1d8fe3c6aaf186dc7 Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 20 Feb 2018 12:13:26 -0500 Subject: [PATCH 1/3] Add GA events to bgroup --- src/containers/BGroup/BGroup.js | 32 ++++++++++++++++++++++++++++---- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index 5a0df2ea..4dc668d8 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -7,6 +7,7 @@ import { Button, Nav, NavItem, NavLink } from 'reactstrap'; import ReactTable from 'react-table'; import 'react-table/react-table.css'; import { Icon } from 'react-fa'; +import ReactGA from 'react-ga'; import ReactTooltip from 'react-tooltip'; import Loading from '../../components/Loading'; import NavBar from '../../components/NavBar'; @@ -615,16 +616,25 @@ export class BGroup extends Component { columns={columns} defaultPageSize={50} ref={(reactTable) => { this.reactTable = reactTable; }} - onFilteredChange={() => { + onFilteredChange={(filter) => { // Create a bounce function so as to not decrease the speed of the filter. clearTimeout(this.updateNumRows); this.updateNumRows = setTimeout( () => { + ReactGA.event({ + category: 'Building Group', + action: 'Filter', + label: filter.reduce((acc, val) => { + return ( + `${acc}, ${val.id}: ${val.value}` + ); + }, `# Results: ${this.reactTable.state.sortedData.length}`), + }); this.setState({ numRows: this.reactTable.state.sortedData.length, }); }, - 100, + 250, ); }} noDataText={this.props.bGroup.bGroupDetailLoading ? 'Loading...' : 'No data'} @@ -732,7 +742,14 @@ export class BGroup extends Component { this.setState({ overviewTab: 'projects' })} + onClick={() => { + this.setState({ overviewTab: 'projects' }); + ReactGA.event({ + category: 'Building Group', + action: 'Click Projects Overview Tab', + label: this.props.bGroup.bGroupDetail.name, + }); + }} > Projects Overview @@ -740,7 +757,14 @@ export class BGroup extends Component { this.setState({ overviewTab: 'buildings' })} + onClick={() => { + this.setState({ overviewTab: 'buildings' }); + ReactGA.event({ + category: 'Building Group', + action: 'Click Buildings Overview Tab', + label: this.props.bGroup.bGroupDetail.name, + }); + }} > Buildings Overview -- GitLab From de175e0fafba0fa06ea4e4b26d9b4dbac430c7ae Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 20 Feb 2018 12:18:46 -0500 Subject: [PATCH 2/3] Add bgroup name to filter GAEvent --- src/containers/BGroup/BGroup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index 4dc668d8..4375160d 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -628,7 +628,7 @@ export class BGroup extends Component { return ( `${acc}, ${val.id}: ${val.value}` ); - }, `# Results: ${this.reactTable.state.sortedData.length}`), + }, `Building Group: ${this.prop.bGroup.bGroupDetail.name}, # Results: ${this.reactTable.state.sortedData.length}`), }); this.setState({ numRows: this.reactTable.state.sortedData.length, -- GitLab From 6557f399f2d4ae769164ffa0cd33812ed51f4d8e Mon Sep 17 00:00:00 2001 From: Conrad Date: Tue, 20 Feb 2018 12:20:11 -0500 Subject: [PATCH 3/3] Fix typo --- src/containers/BGroup/BGroup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/containers/BGroup/BGroup.js b/src/containers/BGroup/BGroup.js index 4375160d..211dbeee 100644 --- a/src/containers/BGroup/BGroup.js +++ b/src/containers/BGroup/BGroup.js @@ -628,7 +628,7 @@ export class BGroup extends Component { return ( `${acc}, ${val.id}: ${val.value}` ); - }, `Building Group: ${this.prop.bGroup.bGroupDetail.name}, # Results: ${this.reactTable.state.sortedData.length}`), + }, `Building Group: ${this.props.bGroup.bGroupDetail.name}, # Results: ${this.reactTable.state.sortedData.length}`), }); this.setState({ numRows: this.reactTable.state.sortedData.length, -- GitLab