Commit 47dda71b authored by Mattias J Duffy's avatar Mattias J Duffy

matomo events

adds events for search, card actions, and map dialog actions
parent 1d51fc46
Pipeline #2892 passed with stages
in 1 minute and 43 seconds
......@@ -35,19 +35,19 @@
<body>
<script type="text/javascript">
/*
The following code is generated by matomo to use for analytics.
*/
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function () {
var u = "//matomo.srct.gmu.edu/";
_paq.push(['setTrackerUrl', u + 'piwik.php']);
_paq.push(['setSiteId', '2']);
var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s);
})();
// /*
// The following code is generated by matomo to use for analytics.
// */
// var _paq = _paq || [];
// _paq.push(['trackPageView']);
// _paq.push(['enableLinkTracking']);
// (function () {
// var u = "//matomo.srct.gmu.edu/";
// _paq.push(['setTrackerUrl', u + 'piwik.php']);
// _paq.push(['setSiteId', '2']);
// var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0];
// g.type = 'text/javascript'; g.async = true; g.defer = true; g.src = u + 'piwik.js'; s.parentNode.insertBefore(g, s);
// })();
</script>
<noscript>
......
......@@ -3,6 +3,7 @@ import FavoriteBorderIcon from 'material-ui-icons/FavoriteBorder';
import FavoriteIcon from 'material-ui-icons/Favorite';
import PropTypes from 'prop-types';
import classNames from 'classnames';
import ReactPiwik from 'react-piwik';
class FavoriteButton extends React.Component {
......@@ -17,8 +18,10 @@ class FavoriteButton extends React.Component {
e.stopPropagation(); //Stops the card from being selected in the sidebar.
if (this.props.isFavorite) {
ReactPiwik.push(['trackEvent', 'card-action', 'un-favorite']);
this.props.removeFavoriteFacility(this.props.facility.slug);
} else {
ReactPiwik.push(['trackEvent', 'card-action', 'favorite']);
this.props.addFavoriteFacility(this.props.facility.slug);
}
};
......
......@@ -13,7 +13,7 @@ import CloseIcon from 'material-ui-icons/Close';
import IconButton from 'material-ui/IconButton';
import {removeBrackets} from '../utils/nameUtils';
import phoneFormatter from 'phone-formatter';
import ReactPiwik from 'react-piwik';
class Sidebar extends React.Component {
constructor(props) {
......@@ -30,11 +30,19 @@ class Sidebar extends React.Component {
};
handleMapDialogClose = () => {
ReactPiwik.push(['trackEvent', 'map-action', 'close']);
this.setState({
mapDialogOpen: false
});
};
handleMapDialogOpen = () => {
ReactPiwik.push(['trackEvent', 'map-action', 'open']);
this.setState({
mapDialogOpen: true
});
}
render() {
const {facility, isSidebarOpen, facilities} = this.props;
const {mapDialogOpen} = this.state;
......@@ -68,11 +76,7 @@ class Sidebar extends React.Component {
</div>
</div>
<div className={'sidebar-row2'}>
<div className={'sidebar-map-container'} onClick={() => {
this.setState({
mapDialogOpen: true
});
}}>
<div className={'sidebar-map-container'} onClick={this.handleMapDialogOpen}>
<FacilitiesMap
facilities={facilities}
facility={facility}
......
......@@ -12,6 +12,7 @@ import {removeBrackets} from '../utils/nameUtils';
import classNames from 'classnames';
import FacilityDialog from '../components/FacilityDialog';
import FacilityUtils from '../utils/facilityUtils';
import ReactPiwik from 'react-piwik';
class FacilityCard extends React.Component {
......@@ -23,6 +24,7 @@ class FacilityCard extends React.Component {
}
handleCardClick = () => {
ReactPiwik.push(['trackEvent', 'card-action', 'click']);
const isSelected = this.props.selectedFacility.slug === this.props.facility.slug;
this.props.setSelectedFacility(isSelected ? null : this.props.facility);
this.props.setSidebar(!isSelected);
......
......@@ -5,7 +5,7 @@ import Sidebar from '../components/Sidebar';
import {getAlerts, getFacilities, setAlerts, setFacilities, sortFacilityCards} from '../actions/api';
import {setSidebar, setSelectedFacility, setAllFavorites} from '../actions/ui';
import CardContainer from '../components/CardContainer';
import ReactPiwik from 'react-piwik';
class Layout extends React.Component {
constructor(props) {
super(props);
......
......@@ -12,6 +12,7 @@ import {MenuItem} from 'material-ui/Menu';
import Select from 'material-ui/Select';
import {FormControl} from 'material-ui/Form';
import classNames from 'classnames';
import ReactPiwik from 'react-piwik';
class SearchBar extends React.Component {
......@@ -35,6 +36,7 @@ class SearchBar extends React.Component {
};
handleRegionChange = (e) => {
ReactPiwik.push(['trackEvent', 'change-campus', e.target.value]);
this.setState({
campus: e.target.value
});
......@@ -43,6 +45,7 @@ class SearchBar extends React.Component {
};
handleFocus = () => {
ReactPiwik.push(['trackEvent', 'search-action', 'focused']);
this.setState({
isFocused: true
});
......
import React from 'react';
import ReactDOM from 'react-dom';
import ReactPiwik from 'react-piwik';
import {applyMiddleware, compose, createStore} from 'redux';
import './index.css';
import Layout from './containers/Layout';
......@@ -17,8 +18,17 @@ import '../public/manifest.json';
import '../public/favicon.png';
import '../public/apple-app-site-association';
const piwik = new ReactPiwik({
url: 'matomo.srct.gmu.edu/',
siteId: 2,
trackErrors: true,
enableLinkTracking: true,
trackDocumentTitle: true
});
// Create a history of your choosing (we're using a browser history in this case)
const history = createHistory();
const history = piwik.connectToHistory(createHistory());
// const history = createHistory();
const extension = window.__REDUX_DEVTOOLS_EXTENSION__ && window.__REDUX_DEVTOOLS_EXTENSION__();
const isProduction = process.env.NODE_ENV === 'production';
......
......@@ -3573,16 +3573,6 @@ from2@^2.1.0, from2@^2.1.1:
inherits "^2.0.1"
readable-stream "^2.0.0"
fs-extra@^0.30.0:
version "0.30.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-0.30.0.tgz#f233ffcc08d4da7d432daa449776989db1df93f0"
dependencies:
graceful-fs "^4.1.2"
jsonfile "^2.1.0"
klaw "^1.0.0"
path-is-absolute "^1.0.0"
rimraf "^2.2.8"
fs-minipass@^1.2.5:
version "1.2.5"
resolved "https://registry.yarnpkg.com/fs-minipass/-/fs-minipass-1.2.5.tgz#06c277218454ec288df77ada54a03b8702aacb9d"
......@@ -3914,7 +3904,7 @@ got@^8.3.1:
url-parse-lax "^3.0.0"
url-to-options "^1.0.1"
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4, graceful-fs@^4.1.6, graceful-fs@^4.1.9:
graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.4:
version "4.1.11"
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"
......@@ -4883,12 +4873,6 @@ json5@^0.5.0, json5@^0.5.1:
version "0.5.1"
resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821"
jsonfile@^2.1.0:
version "2.4.0"
resolved "https://registry.yarnpkg.com/jsonfile/-/jsonfile-2.4.0.tgz#3736a2b428b87bbda0cc83b53fa3d633a35c2ae8"
optionalDependencies:
graceful-fs "^4.1.6"
jsonify@~0.0.0:
version "0.0.0"
resolved "https://registry.yarnpkg.com/jsonify/-/jsonify-0.0.0.tgz#2c74b6ee41d93ca51b7b5aaee8f503631d252a73"
......@@ -5030,12 +5014,6 @@ kind-of@^6.0.0, kind-of@^6.0.2:
version "6.0.2"
resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.2.tgz#01146b36a6218e64e58f3a8d66de5d7fc6f6d051"
klaw@^1.0.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/klaw/-/klaw-1.3.1.tgz#4088433b46b3b1ba259d78785d8e96f73ba02439"
optionalDependencies:
graceful-fs "^4.1.9"
last-call-webpack-plugin@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/last-call-webpack-plugin/-/last-call-webpack-plugin-3.0.0.tgz#9742df0e10e3cf46e5c0381c2de90d3a7a2d7555"
......@@ -5267,7 +5245,7 @@ lodash.uniq@^4.5.0:
version "4.5.0"
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
"lodash@>=3.5 <5", lodash@^4.0.0, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@~4.17.4:
lodash@^4.0.0, lodash@^4.17.2, lodash@^4.17.3, lodash@^4.17.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@~4.17.4:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
......@@ -7086,6 +7064,10 @@ react-mapbox-gl@^2.5.2:
deep-equal "1.0.1"
supercluster "3.0.1"
react-piwik@^1.6.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/react-piwik/-/react-piwik-1.6.0.tgz#3b9eee55167d953824867791cd5288593d652d66"
react-popper@^0.7.4:
version "0.7.4"
resolved "https://registry.yarnpkg.com/react-popper/-/react-popper-0.7.4.tgz#8649d539837e7c6f47bc9b24c9cf57a404e199a1"
......@@ -8642,7 +8624,7 @@ uglify-js@3.3.x, uglify-js@^3.0.13:
commander "~2.12.1"
source-map "~0.6.1"
uglifyjs-webpack-plugin@^1.2.4, uglifyjs-webpack-plugin@^1.2.5:
uglifyjs-webpack-plugin@^1.2.4:
version "1.2.5"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.2.5.tgz#2ef8387c8f1a903ec5e44fa36f9f3cbdcea67641"
dependencies:
......@@ -8655,6 +8637,19 @@ uglifyjs-webpack-plugin@^1.2.4, uglifyjs-webpack-plugin@^1.2.5:
webpack-sources "^1.1.0"
worker-farm "^1.5.2"
uglifyjs-webpack-plugin@^1.2.6:
version "1.3.0"
resolved "https://registry.yarnpkg.com/uglifyjs-webpack-plugin/-/uglifyjs-webpack-plugin-1.3.0.tgz#75f548160858163a08643e086d5fefe18a5d67de"
dependencies:
cacache "^10.0.4"
find-cache-dir "^1.0.0"
schema-utils "^0.4.5"
serialize-javascript "^1.4.0"
source-map "^0.6.1"
uglify-es "^3.3.4"
webpack-sources "^1.1.0"
worker-farm "^1.5.2"
uid-number@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/uid-number/-/uid-number-0.0.6.tgz#0ea10e8035e8eb5b8e4449f06da1c730663baa81"
......@@ -9070,13 +9065,6 @@ webpack-log@^1.0.1, webpack-log@^1.1.2:
loglevelnext "^1.0.1"
uuid "^3.1.0"
webpack-manifest-plugin@1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/webpack-manifest-plugin/-/webpack-manifest-plugin-1.1.0.tgz#6b6c718aade8a2537995784b46bd2e9836057caa"
dependencies:
fs-extra "^0.30.0"
lodash ">=3.5 <5"
webpack-sources@^1.0.1, webpack-sources@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.1.0.tgz#a101ebae59d6507354d71d8013950a3a8b7a5a54"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment