Skip to content
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

feat: adds "data collection for marketing" toggles #24605

Merged
merged 54 commits into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
86cde15
Add metametrics toast when onboarded
jonybur May 16, 2024
288b56c
Add link
jonybur May 16, 2024
581a2ce
Add toggle
jonybur May 17, 2024
a91a256
Add popover
jonybur May 17, 2024
1413cb8
feat: add consent checkbox to onboarding metametrics page
mirceanis May 16, 2024
f726ff5
Merge branch 'develop' into feat/2526-update-consent-checkbox
mirceanis May 17, 2024
2322921
test: add cleanup to timer dependent test
mirceanis May 17, 2024
a0cef9f
Merge branch 'feat/2526-update-consent-checkbox' of github.com:MetaMa…
jonybur May 20, 2024
879d4d3
Merge branch 'jb-metametrics-id-toast' of github.com:MetaMask/metamas…
jonybur May 20, 2024
e971a28
Merge branch 'jb-metametrics-id-settings' of github.com:MetaMask/meta…
jonybur May 20, 2024
a5b9333
Tie all to state
jonybur May 20, 2024
3b8afb1
Add warning message to settings
jonybur May 20, 2024
f739f46
Dont trigger wallet message after onboarding
jonybur May 20, 2024
cfc0c66
Only show popover if participateInMetaMetrics is true
jonybur May 20, 2024
cf3f7c2
When toggling marketing on, also toggle participate in metametrics to on
jonybur May 20, 2024
a353506
Add segment events
jonybur May 20, 2024
5b7f1a8
Refactor tracking event
jonybur May 21, 2024
ddeb213
Fix lint
jonybur May 21, 2024
702bc6e
Merge branch 'develop' into jb-opt-in-metrics
jonybur May 21, 2024
a798922
Add const
jonybur May 21, 2024
479d491
Change Typography for Text
jonybur May 21, 2024
b2eb670
Add METAMETRICS_SETTINGS_LINK
jonybur May 22, 2024
23fcc8e
Merge branch 'develop' into jb-opt-in-metrics
jonybur May 22, 2024
94997fb
Remove unused import
jonybur May 22, 2024
94237ce
Merge branch 'jb-opt-in-metrics' of github.com:MetaMask/metamask-exte…
jonybur May 22, 2024
0e46f7c
Merge
jonybur May 23, 2024
58814db
Fix conflicts
jonybur May 23, 2024
4fba09b
Fix prop
jonybur May 23, 2024
eaeeec7
Fix test
jonybur May 23, 2024
ac58232
Merge branch 'develop' into jb-opt-in-metrics
jonybur May 23, 2024
b147ae4
Update traits
jonybur May 23, 2024
414061c
Merge branch 'jb-opt-in-metrics' of github.com:MetaMask/metamask-exte…
jonybur May 23, 2024
01c84d3
Fix test
jonybur May 23, 2024
f8d436c
Add dataCollectionForMarketing to FixtureBuilder
jonybur May 23, 2024
89fb6ff
prep build error fix for mmi
NidhiKJha May 24, 2024
73a48ce
updated error specs
NidhiKJha May 24, 2024
6699dd4
added state to sentry
NidhiKJha May 27, 2024
f3dcaaa
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jonybur May 28, 2024
000fa05
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jonybur May 29, 2024
6f868d5
Merge branch 'develop' into jb-opt-in-metrics
jonybur May 31, 2024
f74b23c
Merge
jonybur Jun 3, 2024
1c3cffa
Fix snapshot
jonybur Jun 4, 2024
53d7e47
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jonybur Jun 4, 2024
9d2e0d1
Merge branch 'develop' of github.com:MetaMask/metamask-extension into…
jonybur Jun 6, 2024
1e05075
Fixes
jonybur Jun 6, 2024
266127c
Rollback popover component
jonybur Jun 6, 2024
a4cc618
Refactor Popover for Modal
jonybur Jun 7, 2024
60759a8
Fix lint
darkwing Jun 7, 2024
8006556
Fix proptypes
jonybur Jun 7, 2024
6f7cf85
Unify consent function
jonybur Jun 7, 2024
085e482
Update ui store action method
jonybur Jun 10, 2024
6be0d81
Merge branch 'develop' into jb-opt-in-metrics
legobeat Jun 10, 2024
e27aef2
Merge branch 'develop' into jb-opt-in-metrics
NidhiKJha Jun 10, 2024
0dc9878
Embed link, add localization description
darkwing Jun 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions app/_locales/en/messages.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions app/scripts/controllers/metametrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,12 @@ export default class MetaMetricsController {
return metaMetricsId;
}

async setDataCollectionForMarketing(dataCollectionForMarketing) {
jonybur marked this conversation as resolved.
Show resolved Hide resolved
const { metaMetricsId } = this.state;
this.store.updateState({ dataCollectionForMarketing });
return metaMetricsId;
}

get state() {
return this.store.getState();
}
Expand Down
4 changes: 4 additions & 0 deletions app/scripts/metamask-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -2948,6 +2948,10 @@ export default class MetamaskController extends EventEmitter {
metaMetricsController.setParticipateInMetaMetrics.bind(
metaMetricsController,
),
setDataCollectionForMarketing:
metaMetricsController.setDataCollectionForMarketing.bind(
metaMetricsController,
),
setCurrentLocale: preferencesController.setCurrentLocale.bind(
preferencesController,
),
Expand Down
1 change: 1 addition & 0 deletions shared/constants/metametrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ export enum MetaMetricsEventName {
AccountRenamed = 'Account Renamed',
ActivityDetailsOpened = 'Activity Details Opened',
ActivityDetailsClosed = 'Activity Details Closed',
AnalyticsPreferenceSelected = 'Analytics Preference Selected',
AppInstalled = 'App Installed',
AppUnlocked = 'App Unlocked',
AppUnlockedFailed = 'App Unlocked Failed',
Expand Down
4 changes: 4 additions & 0 deletions ui/components/ui/popover/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
&__title--center {
flex: 1;
}

&__title-wrap {
white-space: normal;
}
}

&-bg {
Expand Down
6 changes: 6 additions & 0 deletions ui/components/ui/popover/popover.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const Popover = ({
showScrollDown,
onScrollDownButtonClick,
centerTitle,
wrapTitle,
headerProps = defaultHeaderProps,
contentProps = defaultContentProps,
footerProps = defaultFooterProps,
Expand Down Expand Up @@ -106,6 +107,7 @@ const Popover = ({
) : null}
<Text
textAlign={centerTitle ? TextAlign.Center : TextAlign.Start}
className={wrapTitle ? 'popover-header__title-wrap' : null}
ellipsis
variant={TextVariant.headingSm}
as="h2"
Expand Down Expand Up @@ -184,6 +186,10 @@ const Popover = ({
};

Popover.propTypes = {
/**
* Avoid wrapping title
*/
wrapTitle: PropTypes.bool,
/**
* Show title of the popover
*/
Expand Down
7 changes: 7 additions & 0 deletions ui/ducks/metamask/metamask.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const initialState = {
knownMethodData: {},
use4ByteResolution: true,
participateInMetaMetrics: null,
dataCollectionForMarketing: null,
nextNonce: null,
currencyRates: {
ETH: {
Expand Down Expand Up @@ -162,6 +163,12 @@ export default function reduceMetamask(state = initialState, action) {
participateInMetaMetrics: action.value,
};

case actionConstants.SET_DATA_COLLECTION_FOR_MARKETING:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is this for? Generally we shouldn't adding anything to this Redux slice, it's meant as a mirror of the background state. The actions here other than the background state update action are all examples of technical debt that we have not cleaned up yet.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is to mirror the implementation of SET_PARTICIPATE_IN_METAMETRICS. We are adding the marketing toggle flag to the state as well (dataCollectionForMarketing)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a misunderstanding. SET_PARTICIPATE_IN_METAMETRICS shouldn't be here either

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are good points, and these changes will be postponed for a later date given our time constraints. Both SET_PARTICIPATE_IN_METAMETRICS and SET_DATA_COLLECTION_FOR_MARKETING should be deleted from the redux state.

return {
...metamaskState,
dataCollectionForMarketing: action.value,
};

case actionConstants.CLOSE_WELCOME_SCREEN:
return {
...metamaskState,
Expand Down
106 changes: 105 additions & 1 deletion ui/pages/home/home.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import SmartTransactionsOptInModal from '../../components/app/smart-transactions
///: END:ONLY_INCLUDE_IF
import HomeNotification from '../../components/app/home-notification';
import MultipleNotifications from '../../components/app/multiple-notifications';
import Typography from '../../components/ui/typography/typography';
import TransactionList from '../../components/app/transaction-list';
import Popover from '../../components/ui/popover';
import Button from '../../components/ui/button';
import Popover from '../../components/ui/popover';
import ConnectedSites from '../connected-sites';
import ConnectedAccounts from '../connected-accounts';
import { Tabs, Tab } from '../../components/ui/tabs';
Expand All @@ -40,6 +41,8 @@ import {
JustifyContent,
///: END:ONLY_INCLUDE_IF
Severity,
FlexDirection,
BlockSize,
} from '../../helpers/constants/design-system';
import { SECOND } from '../../../shared/constants/time';
import {
Expand Down Expand Up @@ -162,9 +165,12 @@ export default class Home extends PureComponent {
// eslint-disable-next-line react/no-unused-prop-types
totalUnapprovedCount: PropTypes.number.isRequired,
defaultHomeActiveTabName: PropTypes.string,
participateInMetaMetrics: PropTypes.bool.isRequired,
onTabClick: PropTypes.func.isRequired,
haveSwapsQuotes: PropTypes.bool.isRequired,
showAwaitingSwapScreen: PropTypes.bool.isRequired,
setDataCollectionForMarketing: PropTypes.func.isRequired,
dataCollectionForMarketing: PropTypes.bool.isRequired,
swapsFetchParams: PropTypes.object,
location: PropTypes.object,
shouldShowWeb3ShimUsageNotification: PropTypes.bool.isRequired,
Expand Down Expand Up @@ -756,6 +762,98 @@ export default class Home extends PureComponent {
);
}

renderOnboardingPopover = () => {
darkwing marked this conversation as resolved.
Show resolved Hide resolved
const { t } = this.context;
const { setDataCollectionForMarketing } = this.props;

return (
<Popover
jonybur marked this conversation as resolved.
Show resolved Hide resolved
wrapTitle
centerTitle
onClose={() => {
setDataCollectionForMarketing(false);
this.context.trackEvent({
category: MetaMetricsEventCategory.Home,
event: MetaMetricsEventName.AnalyticsPreferenceSelected,
properties: {
has_marketing_consent: false,
location: 'marketing_consent_modal',
},
});
}}
title={t('onboardedMetametricsTitle')}
footer={
<Box
gap={2}
display={Display.Flex}
width={BlockSize.Full}
flexDirection={FlexDirection.Row}
>
<Button
type="secondary"
onClick={() => {
setDataCollectionForMarketing(false);
this.context.trackEvent({
category: MetaMetricsEventCategory.Home,
event: MetaMetricsEventName.AnalyticsPreferenceSelected,
properties: {
has_marketing_consent: false,
location: 'marketing_consent_modal',
},
});
}}
>
{t('onboardedMetametricsDisagree')}
</Button>
<Button
type="primary"
onClick={() => {
setDataCollectionForMarketing(true);
this.context.trackEvent({
category: MetaMetricsEventCategory.Home,
event: MetaMetricsEventName.AnalyticsPreferenceSelected,
properties: {
has_marketing_consent: true,
location: 'marketing_consent_modal',
},
});
}}
>
{t('onboardedMetametricsAccept')}
</Button>
</Box>
}
>
<Box
display={Display.Flex}
flexDirection={FlexDirection.Column}
gap={2}
margin={4}
>
<Typography>
{t('onboardedMetametricsParagraph1', [
<a
href="https://support.metamask.io/privacy-and-security/how-to-manage-your-metametrics-settings/"
jonybur marked this conversation as resolved.
Show resolved Hide resolved
target="_blank"
rel="noopener noreferrer"
key="retention-link"
>
{t('onboardedMetametricsLink')}
</a>,
])}
</Typography>
<Typography>{t('onboardedMetametricsParagraph2')}</Typography>
<ul className="home__onboarding_list">
<li>{t('onboardedMetametricsKey1')}</li>
<li>{t('onboardedMetametricsKey2')}</li>
<li>{t('onboardedMetametricsKey3')}</li>
</ul>
<Typography>{t('onboardedMetametricsParagraph3')}</Typography>
</Box>
</Popover>
);
};

renderPopover = () => {
const { setConnectedStatusPopoverHasBeenShown } = this.props;
const { t } = this.context;
Expand Down Expand Up @@ -820,8 +918,10 @@ export default class Home extends PureComponent {
showWhatsNewPopup,
hideWhatsNewPopup,
completedOnboarding,
participateInMetaMetrics,
onboardedInThisUISession,
announcementsToShow,
dataCollectionForMarketing,
firstTimeFlowType,
newNetworkAddedConfigurationId,
isSmartTransactionsOptInModalAvailable,
Expand Down Expand Up @@ -905,6 +1005,10 @@ export default class Home extends PureComponent {
{isPopup && !connectedStatusPopoverHasBeenShown
? this.renderPopover()
: null}
{dataCollectionForMarketing === null &&
participateInMetaMetrics === true
? this.renderOnboardingPopover()
: null}
{
///: END:ONLY_INCLUDE_IF
}
Expand Down
7 changes: 7 additions & 0 deletions ui/pages/home/home.container.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import {
setNewTokensImported,
setActiveNetwork,
setNewTokensImportedError,
setDataCollectionForMarketing,
} from '../../store/actions';
import {
hideWhatsNewPopup,
Expand Down Expand Up @@ -98,6 +99,8 @@ const mapStateToProps = (state) => {
connectedStatusPopoverHasBeenShown,
defaultHomeActiveTabName,
swapsState,
dataCollectionForMarketing,
participateInMetaMetrics,
firstTimeFlowType,
completedOnboarding,
} = metamask;
Expand Down Expand Up @@ -156,9 +159,11 @@ const mapStateToProps = (state) => {
shouldShowSeedPhraseReminder: getShouldShowSeedPhraseReminder(state),
isPopup,
isNotification,
dataCollectionForMarketing,
selectedAddress,
firstPermissionsRequestId,
totalUnapprovedCount,
participateInMetaMetrics,
hasApprovalFlows: getApprovalFlows(state)?.length > 0,
connectedStatusPopoverHasBeenShown,
defaultHomeActiveTabName,
Expand Down Expand Up @@ -209,6 +214,8 @@ const mapDispatchToProps = (dispatch) => {
///: END:ONLY_INCLUDE_IF

return {
setDataCollectionForMarketing: (val) =>
dispatch(setDataCollectionForMarketing(val)),
closeNotificationPopup: () => closeNotificationPopup(),
setConnectedStatusPopoverHasBeenShown: () =>
dispatch(setConnectedStatusPopoverHasBeenShown()),
Expand Down
8 changes: 8 additions & 0 deletions ui/pages/home/index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
@use "design-system";

.home {
&__onboarding_list {
list-style: initial;
margin-left: 20px;
jonybur marked this conversation as resolved.
Show resolved Hide resolved
display: flex;
flex-direction: column;
gap: 10px;
}

&__container {
display: flex;
min-height: 100%;
Expand Down
Loading