Skip to content

Commit

Permalink
Change setup to use the master pubkey hash as the identifier (#359)
Browse files Browse the repository at this point in the history
  • Loading branch information
victorkirov authored Jun 24, 2024
1 parent f282321 commit 28c1d25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
18 changes: 17 additions & 1 deletion src/app/hooks/useWalletReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ import {
} from '@stores/wallet/actions/actionCreators';
import { useQueryClient } from '@tanstack/react-query';
import { generatePasswordHash } from '@utils/encryptionUtils';
import { resetMixPanel, trackMixPanel } from '@utils/mixpanel';
import {
hasOptedInMixPanelTracking,
optInMixPanel,
resetMixPanel,
trackMixPanel,
} from '@utils/mixpanel';
import { useCallback } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import useSeedVault from './useSeedVault';
Expand Down Expand Up @@ -275,6 +280,17 @@ const useWalletReducer = () => {
if (showDataCollectionAlert !== null && showDataCollectionAlert !== undefined) {
changeShowDataCollectionAlert(!showDataCollectionAlert);
changeShowDataCollectionAlert(showDataCollectionAlert);

// reinitialise with masterpubkey hash now that we have it
if (hasOptedInMixPanelTracking()) {
const seed = await seedVault.getSeed();
const wallet = await walletFromSeedPhrase({
mnemonic: seed,
index: 0n,
network: 'Mainnet',
});
optInMixPanel(wallet.masterPubKey);
}
}
localStorage.setItem('migrated', 'true');
setSessionStartTime();
Expand Down
20 changes: 3 additions & 17 deletions src/app/screens/legal/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import LinkIcon from '@assets/img/linkIcon.svg';
import Separator from '@components/separator';
import useSeedVault from '@hooks/useSeedVault';
import useWalletReducer from '@hooks/useWalletReducer';
import { CustomSwitch } from '@screens/ledger/importLedgerAccount/steps/index.styled';
import { walletFromSeedPhrase } from '@secretkeylabs/xverse-core';
import Button from '@ui-library/button';
import { PRIVACY_POLICY_LINK, TERMS_LINK } from '@utils/constants';
import { saveIsTermsAccepted } from '@utils/localStorage';
Expand Down Expand Up @@ -76,7 +74,6 @@ function Legal() {
const { t } = useTranslation('translation', { keyPrefix: 'LEGAL_SCREEN' });
const navigate = useNavigate();
const { changeShowDataCollectionAlert } = useWalletReducer();
const seedVault = useSeedVault();
const [searchParams] = useSearchParams();
const theme = useTheme();
const [isToggleEnabled, setIsToggleEnabled] = useState(true);
Expand All @@ -85,23 +82,12 @@ function Legal() {

const handleLegalAccept = async () => {
if (isToggleEnabled) {
try {
const seed = await seedVault.getSeed();
const wallet = await walletFromSeedPhrase({
mnemonic: seed,
index: 0n,
network: 'Mainnet',
});
optInMixPanel(wallet.masterPubKey);
changeShowDataCollectionAlert();
} catch (e) {
console.error(e);
// if this fails, user will be shown the data collection alert again on first start
}
optInMixPanel();
} else {
optOutMixPanel();
changeShowDataCollectionAlert();
}

changeShowDataCollectionAlert();
saveIsTermsAccepted(true);
const isRestore = !!searchParams.get('restore');
if (isRestore) {
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/settings/privacyPreferences/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function PrivacyPreferencesScreen() {
setIsEnabled(checked);

if (checked) {
optInMixPanel(selectedAccount?.masterPubKey);
optInMixPanel(selectedAccount.masterPubKey);
} else {
optOutMixPanel();
}
Expand Down

0 comments on commit 28c1d25

Please sign in to comment.