From b3186987415f240a19aec450da295f06d5f08ba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 4 Jul 2018 12:37:38 +0200 Subject: [PATCH 1/2] Use more properties instead of context --- src/analytics/segment.js | 44 ++++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 15 deletions(-) diff --git a/src/analytics/segment.js b/src/analytics/segment.js index 26e6a305..bf0d7938 100644 --- a/src/analytics/segment.js +++ b/src/analytics/segment.js @@ -16,12 +16,15 @@ if (!process.env.STORYBOOK_ENV) { const sessionId = uuid() -const getContext = store => { +const getContext = _store => ({ + ip: '0.0.0.0', +}) + +const extraProperties = store => { const state = store.getState() const { language, region } = langAndRegionSelector(state) const systemLocale = getSystemLocale() return { - ip: '0.0.0.0', appVersion: __APP_VERSION__, language, region, @@ -45,13 +48,9 @@ export const start = (store: *) => { return } load() - analytics.identify( - id, - {}, - { - context: getContext(store), - }, - ) + analytics.identify(id, extraProperties(store), { + context: getContext(store), + }) } export const stop = () => { @@ -75,9 +74,16 @@ export const track = (event: string, properties: ?Object) => { logger.error('analytics is not available') return } - analytics.track(event, properties, { - context: getContext(storeInstance), - }) + analytics.track( + event, + { + ...extraProperties(storeInstance), + ...properties, + }, + { + context: getContext(storeInstance), + }, + ) } export const page = (category: string, name: ?string, properties: ?Object) => { @@ -90,7 +96,15 @@ export const page = (category: string, name: ?string, properties: ?Object) => { logger.error('analytics is not available') return } - analytics.page(category, name, properties, { - context: getContext(storeInstance), - }) + analytics.page( + category, + name, + { + ...extraProperties(storeInstance), + ...properties, + }, + { + context: getContext(storeInstance), + }, + ) } From ff2faddc1ac0c5ee50c0a316f034fdbc51136cf4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20Renaudeau?= Date: Wed, 4 Jul 2018 14:42:50 +0200 Subject: [PATCH 2/2] Track more events --- src/components/DashboardPage/AccountsOrder.js | 2 + src/components/ExchangePage/ExchangeCard.js | 6 +-- src/components/IsUnlocked.js | 1 + src/components/Onboarding/steps/Finish.js | 8 ++-- .../Onboarding/steps/GenuineCheck/index.js | 4 +- src/components/Onboarding/steps/NoDevice.js | 8 ++-- src/components/OperationsList/index.js | 2 + src/components/PillsDaysCount.js | 24 +++++++----- src/components/RenderError.js | 6 ++- src/components/SelectExchange.js | 37 ++++++++++++------- src/components/SettingsPage/AboutRowItem.js | 4 +- src/components/SettingsPage/CleanButton.js | 1 + .../CounterValueExchangeSelect.js | 24 ++++++------ .../SettingsPage/CounterValueSelect.js | 3 +- src/components/SettingsPage/LanguageSelect.js | 6 +++ .../SettingsPage/MarketIndicatorRadio.js | 8 +++- src/components/SettingsPage/RegionSelect.js | 2 + .../SettingsPage/ReleaseNotesButton.js | 4 +- src/components/SettingsPage/ResetButton.js | 1 + .../SettingsPage/sections/Currencies.js | 2 +- .../SettingsPage/sections/CurrencyRows.js | 2 + src/components/StickyBackToTop.js | 2 + src/components/TopBar/ActivityIndicator.js | 2 + src/components/base/Modal/ConfirmModal.js | 4 ++ src/components/base/Modal/stories.js | 1 + .../modals/AccountSettingRenderBody.js | 12 +++++- src/components/modals/OperationDetails.js | 6 ++- src/components/modals/ReleaseNotes.js | 2 + .../modals/UpdateFirmware/Disclaimer.js | 2 + .../steps/01-step-install-full-firmware.js | 2 + .../UpdateFirmware/steps/02-step-flash-mcu.js | 2 + .../steps/03-step-confirmation.js | 2 + src/helpers/linking.js | 12 ++++++ 33 files changed, 141 insertions(+), 63 deletions(-) create mode 100644 src/helpers/linking.js diff --git a/src/components/DashboardPage/AccountsOrder.js b/src/components/DashboardPage/AccountsOrder.js index 0e2e20e0..5d1b33f4 100644 --- a/src/components/DashboardPage/AccountsOrder.js +++ b/src/components/DashboardPage/AccountsOrder.js @@ -21,6 +21,7 @@ import { reorderAccounts } from 'actions/accounts' import { accountsSelector } from 'reducers/accounts' import { saveSettings } from 'actions/settings' +import Track from 'analytics/Track' import BoldToggle from 'components/base/BoldToggle' import Box from 'components/base/Box' import DropDown, { DropDownItem } from 'components/base/DropDown' @@ -202,6 +203,7 @@ class AccountsOrder extends Component { onStateChange={this.onStateChange} value={sortItems.find(item => item.key === orderAccounts)} > + {t('app:common.sortBy')} diff --git a/src/components/ExchangePage/ExchangeCard.js b/src/components/ExchangePage/ExchangeCard.js index 0ae25b9d..699539c0 100644 --- a/src/components/ExchangePage/ExchangeCard.js +++ b/src/components/ExchangePage/ExchangeCard.js @@ -1,8 +1,7 @@ // @flow import React, { PureComponent } from 'react' -import { shell } from 'electron' -import { track } from 'analytics/segment' +import { openURL } from 'helpers/linking' import type { T } from 'types/common' @@ -19,8 +18,7 @@ type CardType = { export default class ExchangeCard extends PureComponent<{ t: T, card: CardType }> { onClick = () => { const { card } = this.props - shell.openExternal(card.url) - track('VisitExchange', { id: card.id, url: card.url }) + openURL(card.url, 'VisitExchange', { id: card.id }) } render() { const { diff --git a/src/components/IsUnlocked.js b/src/components/IsUnlocked.js index 9985f690..f5d8827f 100644 --- a/src/components/IsUnlocked.js +++ b/src/components/IsUnlocked.js @@ -186,6 +186,7 @@ class IsUnlocked extends Component { , - onClick: url => shell.openExternal(url), + onClick: url => openURL(url), }, { key: 'github', url: urls.github, icon: , - onClick: url => shell.openExternal(url), + onClick: url => openURL(url), }, { key: 'reddit', url: urls.reddit, icon: , - onClick: url => shell.openExternal(url), + onClick: url => openURL(url), }, ] diff --git a/src/components/Onboarding/steps/GenuineCheck/index.js b/src/components/Onboarding/steps/GenuineCheck/index.js index 42ee7376..0518d0ee 100644 --- a/src/components/Onboarding/steps/GenuineCheck/index.js +++ b/src/components/Onboarding/steps/GenuineCheck/index.js @@ -1,7 +1,7 @@ // @flow import React, { PureComponent } from 'react' -import { shell } from 'electron' +import { openURL } from 'helpers/linking' import { connect } from 'react-redux' import styled from 'styled-components' import { colors } from 'styles/theme' @@ -144,7 +144,7 @@ class GenuineCheck extends PureComponent { } contactSupport = () => { - shell.openExternal(urls.genuineCheckContactSupport) + openURL(urls.genuineCheckContactSupport) } handlePrevStep = () => { diff --git a/src/components/Onboarding/steps/NoDevice.js b/src/components/Onboarding/steps/NoDevice.js index 8a9af8a2..abe35227 100644 --- a/src/components/Onboarding/steps/NoDevice.js +++ b/src/components/Onboarding/steps/NoDevice.js @@ -1,7 +1,7 @@ // @flow import React, { PureComponent } from 'react' -import { shell } from 'electron' +import { openURL } from 'helpers/linking' import { i } from 'helpers/staticPath' import Box from 'components/base/Box' @@ -27,7 +27,7 @@ class NoDevice extends PureComponent { icon: , title: t('onboarding:noDevice.buyNew.title'), onClick: () => { - shell.openExternal(urls.noDeviceBuyNew) + openURL(urls.noDeviceBuyNew) }, }, { @@ -35,7 +35,7 @@ class NoDevice extends PureComponent { icon: , title: t('onboarding:noDevice.trackOrder.title'), onClick: () => { - shell.openExternal(urls.noDeviceTrackOrder) + openURL(urls.noDeviceTrackOrder) }, }, { @@ -43,7 +43,7 @@ class NoDevice extends PureComponent { icon: , title: t('onboarding:noDevice.learnMore.title'), onClick: () => { - shell.openExternal(urls.noDeviceLearnMore) + openURL(urls.noDeviceLearnMore) }, }, ] diff --git a/src/components/OperationsList/index.js b/src/components/OperationsList/index.js index 4e3678d3..31612830 100644 --- a/src/components/OperationsList/index.js +++ b/src/components/OperationsList/index.js @@ -25,6 +25,7 @@ import IconAngleDown from 'icons/AngleDown' import Box, { Card } from 'components/base/Box' import Text from 'components/base/Text' import Track from 'analytics/Track' +import { track } from 'analytics/segment' import SectionTitle from './SectionTitle' import OperationC from './Operation' @@ -81,6 +82,7 @@ export class OperationsList extends PureComponent { // TODO: convert of async/await if fetching with the api fetchMoreOperations = () => { + track('FetchMoreOperations') this.setState({ nbToShow: this.state.nbToShow + 20 }) } diff --git a/src/components/PillsDaysCount.js b/src/components/PillsDaysCount.js index 5d28d47a..b546987b 100644 --- a/src/components/PillsDaysCount.js +++ b/src/components/PillsDaysCount.js @@ -1,11 +1,12 @@ // @flow -import React, { PureComponent } from 'react' +import React, { Fragment, PureComponent } from 'react' import { translate } from 'react-i18next' import type { T } from 'types/common' import Pills from 'components/base/Pills' import { timeRangeDaysByKey } from 'reducers/settings' import type { TimeRange } from 'reducers/settings' +import Track from 'analytics/Track' type Props = { selected: string, @@ -17,15 +18,18 @@ class PillsDaysCount extends PureComponent { render() { const { selected, onChange, t } = this.props return ( - ({ - key, - value: timeRangeDaysByKey[key], - label: t(`app:time.${key}`), - }))} - activeKey={selected} - onChange={onChange} - /> + + + ({ + key, + value: timeRangeDaysByKey[key], + label: t(`app:time.${key}`), + }))} + activeKey={selected} + onChange={onChange} + /> + ) } } diff --git a/src/components/RenderError.js b/src/components/RenderError.js index a7ea33e0..0ed04df4 100644 --- a/src/components/RenderError.js +++ b/src/components/RenderError.js @@ -2,7 +2,8 @@ import React, { PureComponent } from 'react' import styled from 'styled-components' -import { shell, remote } from 'electron' +import { openURL } from 'helpers/linking' +import { remote } from 'electron' import qs from 'querystring' import { translate } from 'react-i18next' @@ -60,7 +61,7 @@ ${error.stack} \`\`\` `, }) - shell.openExternal(`https://github.com/LedgerHQ/ledger-live-desktop/issues/new?${q}`) + openURL(`https://github.com/LedgerHQ/ledger-live-desktop/issues/new?${q}`) } handleRestart = () => { @@ -112,6 +113,7 @@ ${error.stack} ({ value: e.id, label: e.name, ...e })) : [] + const value = options.find(e => e.id === exchangeId) return error ? ( {t('app:common.error.load')} ) : ( - + t('app:common.selectExchangeNoOption', { exchangeName: inputValue }) + } + {...props} + /> + ) } } diff --git a/src/components/SettingsPage/AboutRowItem.js b/src/components/SettingsPage/AboutRowItem.js index 096f2c3a..59abdb97 100644 --- a/src/components/SettingsPage/AboutRowItem.js +++ b/src/components/SettingsPage/AboutRowItem.js @@ -1,6 +1,6 @@ // @flow import React, { PureComponent } from 'react' -import { shell } from 'electron' +import { openURL } from 'helpers/linking' import IconExternalLink from 'icons/ExternalLink' import { Tabbable } from 'components/base/Box' import { SettingsSectionRow } from './SettingsSection' @@ -10,7 +10,7 @@ export default class AboutRowItem extends PureComponent<{ title: string, desc: string, }> { - onClick = () => shell.openExternal(this.props.url) + onClick = () => openURL(this.props.url) render() { const { title, desc } = this.props diff --git a/src/components/SettingsPage/CleanButton.js b/src/components/SettingsPage/CleanButton.js index 4d9aedd1..b262ea03 100644 --- a/src/components/SettingsPage/CleanButton.js +++ b/src/components/SettingsPage/CleanButton.js @@ -50,6 +50,7 @@ class CleanButton extends PureComponent { { render() { const { counterValueCurrency, counterValueExchange } = this.props - return ( + return counterValueCurrency ? ( - {counterValueCurrency ? ( - - ) : null} + + - ) + ) : null } } diff --git a/src/components/SettingsPage/CounterValueSelect.js b/src/components/SettingsPage/CounterValueSelect.js index abfd82a7..647cbeca 100644 --- a/src/components/SettingsPage/CounterValueSelect.js +++ b/src/components/SettingsPage/CounterValueSelect.js @@ -8,6 +8,7 @@ import type { Currency } from '@ledgerhq/live-common/lib/types' import { setCounterValue } from 'actions/settings' import { counterValueCurrencySelector } from 'reducers/settings' import Select from 'components/base/Select' +import Track from 'analytics/Track' const fiats = listFiatCurrencies() .map(f => f.units[0]) @@ -35,7 +36,7 @@ class CounterValueSelect extends PureComponent { return ( - {/* TODO Track */} + { render() { const { marketIndicator } = this.props return ( - + + + + ) } } diff --git a/src/components/SettingsPage/RegionSelect.js b/src/components/SettingsPage/RegionSelect.js index 2327b204..f4e77d78 100644 --- a/src/components/SettingsPage/RegionSelect.js +++ b/src/components/SettingsPage/RegionSelect.js @@ -8,6 +8,7 @@ import { langAndRegionSelector, counterValueCurrencySelector } from 'reducers/se import type { Currency } from '@ledgerhq/live-common/lib/types' import type { T } from 'types/common' +import Track from 'analytics/Track' import regionsByKey from 'helpers/regions.json' import Select from 'components/base/Select' @@ -39,6 +40,7 @@ class RegionSelect extends PureComponent { return ( +