-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Analytics notice and settings component #2568
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5e66c92
Adds bare bones analytics notice
jorbuedo a458eb9
Use svg image
jorbuedo 0d546d5
Adds styles
jorbuedo 291713a
Fix lint
jorbuedo 376c3c7
Refactor line
jorbuedo c5665a5
json changes
jorbuedo 9d02556
Adds en-US strings
jorbuedo 23ec2b5
Update apps/wallet-mobile/src/components/Analytics/Analytics.tsx
stackchain 21791b0
Update apps/wallet-mobile/src/i18n/locales/en-US.json
stackchain 1f9d96f
Remove margins
jorbuedo ccf716c
feature(settings): Analytics section (#2572)
banklesss 7c6c8d1
feature(notice): analytics consent notice (#2573)
jorbuedo a8e8b79
Merge branch 'develop' into yomo-657-analytics-warning
stackchain File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 8 additions & 0 deletions
8
apps/wallet-mobile/src/components/Analytics/Analytics.stories.tsx
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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import {storiesOf} from '@storybook/react-native' | ||
import React from 'react' | ||
|
||
import {Analytics} from './Analytics' | ||
|
||
storiesOf('Analytics', module) | ||
.add('Notice', () => <Analytics type="notice" />) | ||
.add('Settings', () => <Analytics type="settings" />) |
237 changes: 237 additions & 0 deletions
237
apps/wallet-mobile/src/components/Analytics/Analytics.tsx
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 |
---|---|---|
@@ -0,0 +1,237 @@ | ||
import React from 'react' | ||
import {defineMessages, useIntl} from 'react-intl' | ||
import {Linking, ScrollView, StyleSheet, Switch, TouchableOpacity, View} from 'react-native' | ||
|
||
import {Button, Spacer, Text} from '../../components' | ||
import {useMetrics} from '../../metrics/metricsManager' | ||
import {COLORS} from '../../theme' | ||
import {AnalyticsImage} from './AnalyticsImage' | ||
|
||
type Props = { | ||
type: 'notice' | 'settings' | ||
onClose?: () => null | ||
} | ||
|
||
export const Analytics = ({type, onClose}: Props) => { | ||
const strings = useStrings() | ||
const metrics = useMetrics() | ||
|
||
return ( | ||
<ScrollView style={styles.scrollView}> | ||
<View style={styles.centered}> | ||
{type === 'notice' && ( | ||
<> | ||
<Text style={styles.title}>{strings.header}</Text> | ||
|
||
<Spacer height={12} /> | ||
</> | ||
)} | ||
|
||
<AnalyticsImage /> | ||
</View> | ||
|
||
<Spacer height={12} /> | ||
|
||
<View style={styles.centered}> | ||
{type === 'settings' && ( | ||
<> | ||
<Text style={styles.paragraph} bold> | ||
{strings.header} | ||
</Text> | ||
|
||
<Spacer height={12} /> | ||
</> | ||
)} | ||
|
||
<Text style={styles.paragraph} bold={type === 'notice'}> | ||
{strings.description} | ||
</Text> | ||
|
||
<Spacer height={12} /> | ||
</View> | ||
|
||
<Spacer height={12} /> | ||
|
||
<View> | ||
{list.map(({style, icon, key}) => ( | ||
<View key={key} style={styles.item}> | ||
<Text style={style}>{icon}</Text> | ||
|
||
<Text style={styles.text}>{strings[key]}</Text> | ||
</View> | ||
))} | ||
</View> | ||
|
||
<Spacer height={12} /> | ||
|
||
<TouchableOpacity onPress={() => Linking.openURL('')}> | ||
<Text style={styles.link}>{strings.more}</Text> | ||
</TouchableOpacity> | ||
|
||
<Spacer height={12} /> | ||
|
||
{type === 'notice' && ( | ||
<> | ||
<Spacer height={12} /> | ||
|
||
<View style={styles.buttons}> | ||
<Button | ||
block | ||
outlineShelley | ||
onPress={() => { | ||
metrics.disable() | ||
onClose?.() | ||
}} | ||
title={strings.skip} | ||
style={styles.skip} | ||
/> | ||
|
||
<Button | ||
block | ||
shelleyTheme | ||
onPress={() => { | ||
metrics.enable() | ||
onClose?.() | ||
}} | ||
title={strings.accept} | ||
/> | ||
</View> | ||
</> | ||
)} | ||
|
||
{type === 'settings' && ( | ||
<View style={styles.toggle}> | ||
<Text bold>{strings.toggle}</Text> | ||
|
||
<Switch | ||
value={metrics.isEnabled} | ||
onValueChange={() => (metrics.isEnabled ? metrics.disable() : metrics.enable())} | ||
/> | ||
</View> | ||
)} | ||
</ScrollView> | ||
) | ||
} | ||
|
||
const styles = StyleSheet.create({ | ||
scrollView: { | ||
paddingHorizontal: 10, | ||
}, | ||
text: { | ||
fontSize: 14, | ||
lineHeight: 22, | ||
}, | ||
item: { | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'baseline', | ||
}, | ||
paragraph: { | ||
fontSize: 14, | ||
lineHeight: 22, | ||
textAlign: 'center', | ||
}, | ||
link: { | ||
color: COLORS.BLUE_LIGHTER, | ||
textAlign: 'center', | ||
}, | ||
centered: { | ||
alignItems: 'center', | ||
justifyContent: 'center', | ||
}, | ||
title: { | ||
fontSize: 20, | ||
lineHeight: 22, | ||
fontWeight: 'bold', | ||
}, | ||
buttons: { | ||
flexDirection: 'column', | ||
gap: 8, | ||
}, | ||
skip: { | ||
borderWidth: 0, | ||
}, | ||
tick: { | ||
color: COLORS.DARK_BLUE, | ||
paddingRight: 8, | ||
}, | ||
cross: { | ||
color: COLORS.RED, | ||
paddingRight: 8, | ||
}, | ||
toggle: {display: 'flex', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center'}, | ||
}) | ||
|
||
const list = [ | ||
{style: styles.tick, icon: '✓', key: 'anonymous'}, | ||
{style: styles.tick, icon: '✓', key: 'optout'}, | ||
{style: styles.cross, icon: '✕', key: 'private'}, | ||
{style: styles.cross, icon: '✕', key: 'noip'}, | ||
{style: styles.cross, icon: '✕', key: 'nosell'}, | ||
] as const | ||
|
||
const bold = {b: (text) => <Text bold>{text}</Text>} | ||
|
||
const useStrings = () => { | ||
const intl = useIntl() | ||
return { | ||
header: intl.formatMessage(messages.header), | ||
description: intl.formatMessage(messages.description), | ||
anonymous: intl.formatMessage(messages.anonymous), | ||
optout: intl.formatMessage(messages.optout), | ||
private: intl.formatMessage(messages.private, bold), | ||
noip: intl.formatMessage(messages.noip, bold), | ||
nosell: intl.formatMessage(messages.nosell, bold), | ||
more: intl.formatMessage(messages.more), | ||
skip: intl.formatMessage(messages.skip), | ||
accept: intl.formatMessage(messages.accept), | ||
toggle: intl.formatMessage(messages.toggle), | ||
} | ||
} | ||
|
||
const messages = defineMessages({ | ||
header: { | ||
id: 'analytics.header', | ||
defaultMessage: '!!!Join the journey to improve Yoroi', | ||
}, | ||
description: { | ||
id: 'analytics.description', | ||
defaultMessage: '!!!Share user insights to help us fine tune Yoroi to better serve your needs.', | ||
}, | ||
anonymous: { | ||
id: 'analytics.anonymous', | ||
defaultMessage: '!!!Anonymous analytics data', | ||
}, | ||
optout: { | ||
id: 'analytics.optout', | ||
defaultMessage: '!!!You can always opt-out via Settings', | ||
}, | ||
private: { | ||
id: 'analytics.private', | ||
defaultMessage: '!!!We <b>cannot</b> access private keys', | ||
}, | ||
noip: { | ||
id: 'analytics.noip', | ||
defaultMessage: '!!!We <b>are not</b> recording IP addresses', | ||
}, | ||
nosell: { | ||
id: 'analytics.nosell', | ||
defaultMessage: '!!!We <b>do not</b> sell data', | ||
}, | ||
more: { | ||
id: 'analytics.more', | ||
defaultMessage: '!!!Learn more about user insights', | ||
}, | ||
skip: { | ||
id: 'analytics.skip', | ||
defaultMessage: '!!!Skip', | ||
}, | ||
accept: { | ||
id: 'analytics.accept', | ||
defaultMessage: '!!!Accept', | ||
}, | ||
toggle: { | ||
id: 'analytics.toggle', | ||
defaultMessage: '!!!Allow Yoroi analytics', | ||
}, | ||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we have the both stories?
notice
andsettings
, then I think we are g2gThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The component has the stories for both. Not their containers though.