diff --git a/src/analytics/Track.js b/src/analytics/Track.js index 9c5d82e2..997fa783 100644 --- a/src/analytics/Track.js +++ b/src/analytics/Track.js @@ -1,3 +1,4 @@ +import logger from 'logger' import { PureComponent } from 'react' import { track } from './segment' @@ -6,9 +7,11 @@ class Track extends PureComponent<{ onUnmount?: boolean, onUpdate?: boolean, event: string, - properties?: Object, }> { componentDidMount() { + if (typeof this.props.event !== 'string') { + logger.warn('analytics Track: invalid event=', this.props.event) + } if (this.props.onMount) this.track() } componentDidUpdate() { @@ -18,7 +21,7 @@ class Track extends PureComponent<{ if (this.props.onUnmount) this.track() } track = () => { - const { event, properties } = this.props + const { event, onMount, onUnmount, onUpdate, ...properties } = this.props track(event, properties) } render() { diff --git a/src/analytics/TrackPage.js b/src/analytics/TrackPage.js index 2e18e868..f1b5537a 100644 --- a/src/analytics/TrackPage.js +++ b/src/analytics/TrackPage.js @@ -1,9 +1,9 @@ import { PureComponent } from 'react' import { page } from './segment' -class TrackPage extends PureComponent<{ category: string, name?: string, properties?: Object }> { +class TrackPage extends PureComponent<{ category: string, name?: string }> { componentDidMount() { - const { category, name, properties } = this.props + const { category, name, ...properties } = this.props page(category, name, properties) } render() { diff --git a/src/components/AccountPage/index.js b/src/components/AccountPage/index.js index 2da8032f..730ba135 100644 --- a/src/components/AccountPage/index.js +++ b/src/components/AccountPage/index.js @@ -109,10 +109,8 @@ class AccountPage extends PureComponent { diff --git a/src/components/DashboardPage/index.js b/src/components/DashboardPage/index.js index 2582a017..f9c0f3da 100644 --- a/src/components/DashboardPage/index.js +++ b/src/components/DashboardPage/index.js @@ -104,7 +104,9 @@ class DashboardPage extends PureComponent { {totalAccounts > 0 ? ( diff --git a/src/components/ExportLogsBtn.js b/src/components/ExportLogsBtn.js index 07c1ca66..22291d90 100644 --- a/src/components/ExportLogsBtn.js +++ b/src/components/ExportLogsBtn.js @@ -71,7 +71,7 @@ class ExportLogsBtn extends Component<{ return hookToShortcut ? ( ) : ( - ) diff --git a/src/components/OperationsList/index.js b/src/components/OperationsList/index.js index 6a9d5bc4..5f177c89 100644 --- a/src/components/OperationsList/index.js +++ b/src/components/OperationsList/index.js @@ -134,13 +134,11 @@ export class OperationsList extends PureComponent { sum + s.data.length, - 0, - ), - }} + totalSections={groupedOperations.sections.length} + totalOperations={groupedOperations.sections.reduce( + (sum, s) => sum + s.data.length, + 0, + )} /> ) : null} {!groupedOperations.completed ? ( diff --git a/src/components/SettingsPage/sections/Profile.js b/src/components/SettingsPage/sections/Profile.js index b0ccfb8d..044ea9d7 100644 --- a/src/components/SettingsPage/sections/Profile.js +++ b/src/components/SettingsPage/sections/Profile.js @@ -15,6 +15,7 @@ import hardReset from 'helpers/hardReset' import type { SettingsState } from 'reducers/settings' import type { T } from 'types/common' +import Track from 'analytics/Track' import TrackPage from 'analytics/TrackPage' import ExportLogsBtn from 'components/ExportLogsBtn' import CheckBox from 'components/base/CheckBox' @@ -157,6 +158,7 @@ class TabProfile extends PureComponent { title={t('app:settings.profile.password')} desc={t('app:settings.profile.passwordDesc')} > + {isPasswordEnabled && ( @@ -205,7 +210,7 @@ class TabProfile extends PureComponent { title={t('app:settings.profile.hardResetTitle')} desc={t('app:settings.profile.hardResetDesc')} > - diff --git a/src/components/base/Button/index.js b/src/components/base/Button/index.js index 8953eb31..ed745d14 100644 --- a/src/components/base/Button/index.js +++ b/src/components/base/Button/index.js @@ -4,6 +4,7 @@ import React from 'react' import styled from 'styled-components' import { space, fontSize, fontWeight, color } from 'styled-system' import noop from 'lodash/noop' +import { track } from 'analytics/segment' import { darken, lighten, rgba } from 'styles/helpers' import fontFamily from 'styles/styled/fontFamily' @@ -171,13 +172,24 @@ type Props = { small?: boolean, padded?: boolean, isLoading?: boolean, + event?: string, + eventProperties?: Object, } const Button = (props: Props) => { - const { onClick, children, disabled, isLoading } = props + const { disabled } = props + const { onClick, children, isLoading, event, eventProperties, ...rest } = props const isClickDisabled = disabled || isLoading + const onClickHandler = e => { + if (onClick) { + if (event) { + track(event, eventProperties) + } + onClick(e) + } + } return ( - + {isLoading ? : children} )