Skip to content

Commit

Permalink
Add GA event to State selection (Fixes #782) (#808)
Browse files Browse the repository at this point in the history
* Switch back to CDN.

* Add GA event to State selection.

* Add explanatory comment to state selector.

* Improve event action text for state selection.
  • Loading branch information
philipdickinson authored May 14, 2018
1 parent a7bfc7d commit 8192d02
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions frontend/src/components/Selectors/StateSelector.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { DropDownMenu } from 'material-ui/DropDownMenu'
import MenuItem from 'material-ui/MenuItem'
import * as React from 'react'
import * as ReactGA from 'react-ga'
import { State, STATES } from '../../constants/states'
import { Store } from '../../services/store'

Expand All @@ -10,6 +11,10 @@ type StateSelectorProps = {
store: Store
}

/**
* This State Selector is used to select a state to view for US-wide datasets. These datasets
* include points for the entire US and allow the user to select which states to view.
*/
export let StateSelector: React.StatelessComponent<StateSelectorProps> = ({ className, store, value }) =>
<DropDownMenu
className={className ? className : undefined}
Expand All @@ -21,7 +26,15 @@ export let StateSelector: React.StatelessComponent<StateSelectorProps> = ({ clas
)}
</DropDownMenu >

/**
* As part of State selection, send an event to GA.
*/
function onStateChange(value: State, store: Store) {
ReactGA.event({
category: 'Filter',
action: 'Selected a state in a US-wide dataset',
label: value.toString()
})
store.set('selectedState')(value)
store.set('useCustomCountyUpload')(false)
store.set('selectedCounties')(null)
Expand Down

0 comments on commit 8192d02

Please sign in to comment.