-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22d9d66
commit bb5b697
Showing
3 changed files
with
82 additions
and
3 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 |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { KeychainType } from '~/core/types/keychainTypes'; | ||
import { getStatus, getWallets } from '~/entries/popup/handlers/wallet'; | ||
|
||
import { analytics } from '..'; | ||
|
||
export const identifyWalletTypes = async () => { | ||
const { unlocked, ready } = await getStatus(); | ||
if (!unlocked || !ready) return; | ||
|
||
const wallets = await getWallets(); | ||
|
||
const ownedAccounts = wallets | ||
.filter( | ||
(a) => | ||
a.type === KeychainType.HdKeychain || | ||
a.type === KeychainType.KeyPairKeychain, | ||
) | ||
.reduce((count, wallet) => count + wallet.accounts.length, 0); | ||
|
||
const watchedAccounts = wallets | ||
.filter((a) => a.type === KeychainType.ReadOnlyKeychain) | ||
.reduce((count, wallet) => count + wallet.accounts.length, 0); | ||
|
||
const recoveryPhrases = wallets.filter( | ||
(a) => a.type === KeychainType.HdKeychain, | ||
).length; | ||
|
||
const importedRecoveryPhrases = wallets.filter( | ||
(a) => a.type === KeychainType.HdKeychain && !a.imported, | ||
).length; | ||
|
||
const privateKeys = wallets.filter( | ||
(a) => a.type === KeychainType.KeyPairKeychain, | ||
).length; | ||
|
||
const importedPrivateKeys = wallets.filter( | ||
(a) => a.type === KeychainType.KeyPairKeychain && !a.imported, | ||
).length; | ||
|
||
const hasImported = importedPrivateKeys > 0 || importedRecoveryPhrases > 0; | ||
|
||
const hardwareWallets = wallets.filter( | ||
(a) => a.type === KeychainType.HardwareWalletKeychain, | ||
); | ||
|
||
const hardwareAccounts = hardwareWallets.reduce( | ||
(count, wallet) => count + wallet.accounts.length, | ||
0, | ||
); | ||
|
||
const ledgerDevices = wallets.filter((a) => a.vendor === 'Ledger').length; | ||
|
||
const trezorDevices = wallets.filter((a) => a.vendor === 'Trezor').length; | ||
|
||
analytics.identify({ | ||
ownedAccounts, | ||
hardwareAccounts, | ||
watchedAccounts, | ||
recoveryPhrases, | ||
importedRecoveryPhrases, | ||
privateKeys, | ||
importedPrivateKeys, | ||
ledgerDevices, | ||
trezorDevices, | ||
hasImported, | ||
}); | ||
}; |
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,3 +1,13 @@ | ||
/* eslint-disable @typescript-eslint/no-empty-interface */ | ||
// these are all reported seperately so they must be optional | ||
export interface UserProperties {} | ||
// these can be reported separately so they must be optional | ||
export interface UserProperties { | ||
ownedAccounts?: number; | ||
hardwareAccounts?: number; | ||
watchedAccounts?: number; | ||
recoveryPhrases?: number; | ||
importedRecoveryPhrases?: number; | ||
privateKeys?: number; | ||
importedPrivateKeys?: number; | ||
trezorDevices?: number; | ||
ledgerDevices?: number; | ||
hasImported?: boolean; | ||
} |
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