-
-
Notifications
You must be signed in to change notification settings - Fork 650
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from amacar/add-analytics-and-events
Add analytics and events
- Loading branch information
Showing
9 changed files
with
353 additions
and
251 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,60 @@ | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { languages } from 'config'; | ||
import { AppState } from 'features/reducers'; | ||
import { configMetaActions, configMetaSelectors } from 'features/config'; | ||
import './LanguageSelect.scss'; | ||
|
||
interface OwnProps { | ||
closePanel(): void; | ||
} | ||
|
||
interface StateProps { | ||
languageSelection: string; | ||
} | ||
|
||
interface DispatchProps { | ||
changeLanguage: configMetaActions.TChangeLanguage; | ||
} | ||
|
||
type Props = OwnProps & StateProps & DispatchProps; | ||
|
||
class LanguageSelect extends React.Component<Props> { | ||
public render() { | ||
const { languageSelection } = this.props; | ||
return ( | ||
<div className="LanguageSelect"> | ||
{Object.entries(languages).map(lang => ( | ||
<button | ||
key={lang[0]} | ||
className={classnames({ | ||
'LanguageSelect-language': true, | ||
'is-selected': languageSelection === lang[0] | ||
})} | ||
onClick={() => this.handleLanguageSelect(lang[0])} | ||
> | ||
{lang[1]} | ||
</button> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
private handleLanguageSelect = (lang: string) => { | ||
this.props.changeLanguage(lang); | ||
this.props.closePanel(); | ||
}; | ||
} | ||
|
||
export default connect( | ||
(state: AppState): StateProps => ({ | ||
languageSelection: configMetaSelectors.getLanguageSelection(state) | ||
}), | ||
{ | ||
changeLanguage: configMetaActions.changeLanguage | ||
} | ||
)(LanguageSelect); | ||
import React from 'react'; | ||
import classnames from 'classnames'; | ||
import { connect } from 'react-redux'; | ||
|
||
import { AnalyticsService, ANALYTICS_CATEGORIES } from 'v2/services'; | ||
import { languages } from 'config'; | ||
import { AppState } from 'features/reducers'; | ||
import { configMetaActions, configMetaSelectors } from 'features/config'; | ||
import './LanguageSelect.scss'; | ||
|
||
interface OwnProps { | ||
closePanel(): void; | ||
} | ||
|
||
interface StateProps { | ||
languageSelection: string; | ||
} | ||
|
||
interface DispatchProps { | ||
changeLanguage: configMetaActions.TChangeLanguage; | ||
} | ||
|
||
type Props = OwnProps & StateProps & DispatchProps; | ||
|
||
class LanguageSelect extends React.Component<Props> { | ||
public render() { | ||
const { languageSelection } = this.props; | ||
return ( | ||
<div className="LanguageSelect"> | ||
{Object.entries(languages).map(lang => ( | ||
<button | ||
key={lang[0]} | ||
className={classnames({ | ||
'LanguageSelect-language': true, | ||
'is-selected': languageSelection === lang[0] | ||
})} | ||
onClick={() => this.handleLanguageSelect(lang[0])} | ||
> | ||
{lang[1]} | ||
</button> | ||
))} | ||
</div> | ||
); | ||
} | ||
|
||
private handleLanguageSelect = (lang: string) => { | ||
this.props.changeLanguage(lang); | ||
this.props.closePanel(); | ||
AnalyticsService.instance.track(ANALYTICS_CATEGORIES.SIDEBAR, 'Language changed', { lang }); | ||
}; | ||
} | ||
|
||
export default connect( | ||
(state: AppState): StateProps => ({ | ||
languageSelection: configMetaSelectors.getLanguageSelection(state) | ||
}), | ||
{ | ||
changeLanguage: configMetaActions.changeLanguage | ||
} | ||
)(LanguageSelect); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.