Skip to content

Commit

Permalink
Merge pull request #803 from alexstotsky/improve-analytics
Browse files Browse the repository at this point in the history
(improvements) Analytics: click tracking
  • Loading branch information
ezewer authored Apr 15, 2024
2 parents d34ea20 + 5873b1a commit fd4277f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/ui/DateInput/DateInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { DateInput as BptDateInput, TimePrecision } from '@blueprintjs/datetime'

import Icon from 'icons'
import { tracker } from 'utils/trackers'
import { getSourceFromPathName } from 'utils/browser'
import {
DEFAULT_DATETIME_FORMAT, momentFormatter, momentFormatterDays,
} from 'state/utils'
Expand All @@ -28,7 +29,7 @@ class DateInput extends PureComponent {
}

onToggle = (isOpen) => {
tracker.trackEvent('Date Input')
tracker.trackEvent('Date Input', getSourceFromPathName())
this.setState({ isOpen })
}

Expand Down
3 changes: 2 additions & 1 deletion src/ui/MultiSelect/MultiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MultiSelect as BlueprintMultiSelect } from '@blueprintjs/select'

import Icon from 'icons'
import { tracker } from 'utils/trackers'
import { getSourceFromPathName } from 'utils/browser'

import { propTypes, defaultProps } from './MultiSymbolSelector.props'

Expand All @@ -22,7 +23,7 @@ class MultiSelect extends PureComponent {

onToggle = (isOpen) => {
const { type } = this.props
tracker.trackEvent(type)
tracker.trackEvent(type, getSourceFromPathName())
this.setState({ isOpen })
}

Expand Down
3 changes: 2 additions & 1 deletion src/ui/Select/Select.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { Select as BlueprintSelect } from '@blueprintjs/select'
import Icons from 'icons'
import { tracker } from 'utils/trackers'
import { filterSelectorItem } from 'ui/utils'
import { getSourceFromPathName } from 'utils/browser'

class Select extends PureComponent {
static propTypes = {
Expand Down Expand Up @@ -101,7 +102,7 @@ class Select extends PureComponent {

onToggle = (nextOpenState) => {
const { type } = this.props
tracker.trackEvent(type)
tracker.trackEvent(type, getSourceFromPathName())
this.setState({ isOpen: nextOpenState })
}

Expand Down
3 changes: 2 additions & 1 deletion src/ui/TimeRange/TimeRange.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import classNames from 'classnames'
import Icon from 'icons'
import { tracker } from 'utils/trackers'
import { formatDate } from 'state/utils'
import { getSourceFromPathName } from 'utils/browser'

import { propTypes, defaultProps } from './TimeRange.props'

Expand All @@ -16,7 +17,7 @@ const TimeRange = ({
toggleTimeFrameDialog,
}) => {
const onClick = () => {
tracker.trackEvent('Date')
tracker.trackEvent('Date', getSourceFromPathName())
toggleTimeFrameDialog()
}

Expand Down
2 changes: 2 additions & 0 deletions src/utils/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ export const getCookieValue = (key) => cookie.get(key)
export const setCookie = (key, value, opts) => {
cookie.set(key, value, { ...defaultCookieOpts, ...opts })
}

export const getSourceFromPathName = () => window?.location?.pathname?.slice(1) ?? ''

0 comments on commit fd4277f

Please sign in to comment.