From 839f0e4a15a123f16997c1f5d30109d4c064b354 Mon Sep 17 00:00:00 2001 From: Gamaliel Padillo Date: Thu, 9 Jan 2025 14:21:17 -0800 Subject: [PATCH 1/5] devop: create event tracking --- packages/extension/src/libs/metrics/index.ts | 22 +++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/packages/extension/src/libs/metrics/index.ts b/packages/extension/src/libs/metrics/index.ts index 5aff53bc3..af8ba08a1 100644 --- a/packages/extension/src/libs/metrics/index.ts +++ b/packages/extension/src/libs/metrics/index.ts @@ -14,13 +14,33 @@ import { const metrics = new Metrics(); + +// tracks the new network ui +const trackNewNetworkUi = (event: string, options: { + networkName?: NetworkNames, + networkType?: 'regular' | 'testnet' | 'custom', + networkTab?: string, + isPinned?: boolean, + sortOption?: string, + customRpcUrl?: string, + customNetworkName?: string, + customChainId?: string, + customCurrencySymbol?: string, + customBlockExplorerUrl?: string +}) => { + metrics.track(event, options); +} + const trackGenericEvents = (event: GenericEvents) => { metrics.track('generic', { event }); }; const trackNetworkSelected = ( event: NetworkChangeEvents, - options: { provider: ProviderName; network: NetworkNames }, + options: { + provider: ProviderName; + network: NetworkNames + }, ) => { metrics.track('network', { event, ...options }); }; From eea40d1be0c476b30a4286fbd325f991108d5b73 Mon Sep 17 00:00:00 2001 From: Gamaliel Padillo Date: Fri, 10 Jan 2025 11:27:58 -0800 Subject: [PATCH 2/5] devop: add amplitude events for new network ui --- packages/extension/src/libs/metrics/index.ts | 33 ++++++++----------- packages/extension/src/libs/metrics/types.ts | 9 +++++ .../app-menu/components/app-menu-item.vue | 7 ++++ .../app-menu/components/app-menu-sort.vue | 5 +++ .../app-menu/components/app-menu-tab.vue | 5 +++ .../ui/action/components/app-menu/index.vue | 12 +++++++ .../components/add-network-item.vue | 6 ++++ .../src/ui/action/views/add-network/index.vue | 5 +++ .../add-network/views/add-custom-network.vue | 14 ++++++++ .../ui/action/views/network-assets/index.vue | 4 +-- 10 files changed, 79 insertions(+), 21 deletions(-) diff --git a/packages/extension/src/libs/metrics/index.ts b/packages/extension/src/libs/metrics/index.ts index af8ba08a1..110385647 100644 --- a/packages/extension/src/libs/metrics/index.ts +++ b/packages/extension/src/libs/metrics/index.ts @@ -14,23 +14,6 @@ import { const metrics = new Metrics(); - -// tracks the new network ui -const trackNewNetworkUi = (event: string, options: { - networkName?: NetworkNames, - networkType?: 'regular' | 'testnet' | 'custom', - networkTab?: string, - isPinned?: boolean, - sortOption?: string, - customRpcUrl?: string, - customNetworkName?: string, - customChainId?: string, - customCurrencySymbol?: string, - customBlockExplorerUrl?: string -}) => { - metrics.track(event, options); -} - const trackGenericEvents = (event: GenericEvents) => { metrics.track('generic', { event }); }; @@ -38,8 +21,20 @@ const trackGenericEvents = (event: GenericEvents) => { const trackNetworkSelected = ( event: NetworkChangeEvents, options: { - provider: ProviderName; - network: NetworkNames + provider?: ProviderName; + network?: NetworkNames, + networkTab?: string, + networkType?: 'regular' | 'custom' | 'testnet', + isPinned?: boolean, + sortOption?: string, + customRpcUrl?: string, + customNetworkName?: string, + customNetworkNameLong?: string, + customNetworkCurrency?: string, + customNetworkCurrencyLong?: string, + customChainId?: string, + customBlockExplorerUrlTx?: string + customBlockExplorerUrlAddr?: string }, ) => { metrics.track('network', { event, ...options }); diff --git a/packages/extension/src/libs/metrics/types.ts b/packages/extension/src/libs/metrics/types.ts index 955ee03e3..57036a3b3 100644 --- a/packages/extension/src/libs/metrics/types.ts +++ b/packages/extension/src/libs/metrics/types.ts @@ -1,3 +1,4 @@ +import { NetworkSortOption } from './../../ui/action/types/network-sort'; export enum SwapEventType { SwapOpen = 'swap_open', SwapRate = 'swap_rate', @@ -16,6 +17,14 @@ export enum GenericEvents { export enum NetworkChangeEvents { NetworkChangePopup = 'network_change_popup', NetworkChangeAPI = 'network_change_api', + NetworkTabsClicked = 'network_tabs_clicked', + NetworkPinnedStatusChanged = 'network_pinned_status_changed', + NetworkActiveChanged = 'network_active_changed', + NetworkSortOptionChanged = 'network_sort_option_changed', + NetworkAddCustomClicked = 'network_add_custom_clicked', + NetworkCustomNetworkAdded = 'network_custom_network_added', + NetworkDeleteCustomNetwork = 'network_delete_custom_network', + NetworkCustomBackButton = 'network_custom_back_button', } export enum BuyEventType { diff --git a/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue b/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue index 8e4d31d9c..dd8a08d32 100644 --- a/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue +++ b/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue @@ -58,6 +58,9 @@ import SwapAddedIcon from '@/ui/action/icons/asset/swap-added-icon.vue'; import PinIcon from '@action/icons/actions/pin.vue'; import DragIcon from '@action/icons/common/drag-icon.vue'; +import { trackNetworkSelected } from '@/libs/metrics'; +import { NetworkChangeEvents } from '@/libs/metrics/types'; + const props = defineProps({ network: { type: Object as PropType, @@ -177,6 +180,10 @@ watch( * ------------------------*/ const setPinned = async () => { + trackNetworkSelected(NetworkChangeEvents.NetworkPinnedStatusChanged, { + network: props.network.name, + isPinned: !props.isPinned, + }); emit('update:pinNetwork', props.network.name, !props.isPinned); }; diff --git a/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue b/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue index dd1bcaf34..4df0c9312 100644 --- a/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue +++ b/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue @@ -63,6 +63,8 @@ import { NetworkSortDirection, } from '@action/types/network-sort'; import SortDirectionIcon from '@/ui/action/icons/actions/sort/sort-direction-icon.vue'; +import { trackNetworkSelected } from '@/libs/metrics'; +import { NetworkChangeEvents } from '@/libs/metrics/types'; // Next Release Version: // import { onClickOutside } from '@vueuse/core'; @@ -90,6 +92,9 @@ const setActiveSort = (_sort: NetworkSortOption) => { // Next Release Version: update this function newSortBy.name = _sort; } + trackNetworkSelected(NetworkChangeEvents.NetworkSortOptionChanged, { + sortOption: newSortBy.name, + }); emit('update:sort', newSortBy); }; diff --git a/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue b/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue index dd64d55c3..5c673dcb9 100644 --- a/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue +++ b/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue @@ -40,6 +40,8 @@ diff --git a/packages/extension/src/ui/action/components/app-menu/index.vue b/packages/extension/src/ui/action/components/app-menu/index.vue index bfaedcff7..2509a6e52 100644 --- a/packages/extension/src/ui/action/components/app-menu/index.vue +++ b/packages/extension/src/ui/action/components/app-menu/index.vue @@ -66,6 +66,8 @@ import { } from '@action/types/network-sort'; import { useScroll } from '@vueuse/core'; import { newNetworks, newSwaps } from '@/providers/common/libs/new-features'; +import { trackNetworkSelected } from '@/libs/metrics'; +import { NetworkChangeEvents } from '@/libs/metrics/types'; const networksState = new NetworksState(); const props = defineProps({ @@ -114,6 +116,16 @@ const setNetwork = async (network: BaseNetwork) => { net => net !== network.name, ); } + + const networkType = network.isTestNetwork + ? 'testnet' + : network.isCustomNetwork + ? 'custom' + : 'regular'; + trackNetworkSelected(NetworkChangeEvents.NetworkActiveChanged, { + network: network.name, + networkType, + }); emit('update:network', network); }; diff --git a/packages/extension/src/ui/action/views/add-network/components/add-network-item.vue b/packages/extension/src/ui/action/views/add-network/components/add-network-item.vue index 98a2bfa69..a22bf2d18 100644 --- a/packages/extension/src/ui/action/views/add-network/components/add-network-item.vue +++ b/packages/extension/src/ui/action/views/add-network/components/add-network-item.vue @@ -46,6 +46,9 @@ import customNetworkIcon from '@/ui/action/icons/common/custom-network-icon.vue' import { NetworkNames } from '@enkryptcom/types'; import Tooltip from '@/ui/action/components/tooltip/index.vue'; +import { trackNetworkSelected } from '@/libs/metrics'; +import { NetworkChangeEvents } from '@/libs/metrics/types'; + const emit = defineEmits<{ (e: 'networkToggled', name: string, isActive: boolean): void; (e: 'networkDeleted', chainId: string): void; @@ -85,6 +88,9 @@ const setPinned = async () => { const deleteNetwork = async () => { const chainId = (props.network as unknown as CustomEvmNetwork).chainID; if (chainId !== undefined) { + trackNetworkSelected(NetworkChangeEvents.NetworkDeleteCustomNetwork, { + customChainId: chainId, + }); emit('networkDeleted', chainId); } }; diff --git a/packages/extension/src/ui/action/views/add-network/index.vue b/packages/extension/src/ui/action/views/add-network/index.vue index 1542b9be7..b466cf69b 100644 --- a/packages/extension/src/ui/action/views/add-network/index.vue +++ b/packages/extension/src/ui/action/views/add-network/index.vue @@ -19,6 +19,9 @@ import { ref } from 'vue'; import AddNetworkList from './views/add-network-list.vue'; import AddCustomNetwork from './views/add-custom-network.vue'; +import { trackNetworkSelected } from '@/libs/metrics'; +import { NetworkChangeEvents } from '@/libs/metrics/types'; + const isNetworkList = ref(true); const emit = defineEmits<{ @@ -38,9 +41,11 @@ const closePopup = () => { const toCustomNetwork = () => { isNetworkList.value = false; + trackNetworkSelected(NetworkChangeEvents.NetworkAddCustomClicked, {}); }; const toNetworkList = () => { + trackNetworkSelected(NetworkChangeEvents.NetworkCustomBackButton, {}); isNetworkList.value = true; }; diff --git a/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue b/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue index 210716608..abe3427e3 100644 --- a/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue +++ b/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue @@ -91,6 +91,9 @@ import { toHex } from 'web3-utils'; import CustomNetworksState from '@/libs/custom-networks-state'; import NetworksState from '@/libs/networks-state'; +import { trackNetworkSelected } from '@/libs/metrics'; +import { NetworkChangeEvents } from '@/libs/metrics/types'; + interface NetworkConfigItem { name: string; chain: string; @@ -260,6 +263,17 @@ const sendAction = async () => { await customNetworksState.addCustomNetwork(customNetworkOptions); await networksState.setNetworkStatus(customNetworkOptions.name, true); + trackNetworkSelected(NetworkChangeEvents.NetworkCustomNetworkAdded, { + customRpcUrl: customNetworkOptions.node, + customNetworkName: customNetworkOptions.name, + customNetworkNameLong: customNetworkOptions.name_long, + customChainId: customNetworkOptions.chainID, + customNetworkCurrency: customNetworkOptions.currencyName, + customNetworkCurrencyLong: customNetworkOptions.currencyNameLong, + customBlockExplorerUrlTx: customNetworkOptions.blockExplorerTX, + customBlockExplorerUrlAddr: customNetworkOptions.blockExplorerAddr, + }); + nameValue.value = ''; symbolValue.value = ''; chainIDValue.value = ''; diff --git a/packages/extension/src/ui/action/views/network-assets/index.vue b/packages/extension/src/ui/action/views/network-assets/index.vue index b95cf1c4c..a80fda217 100644 --- a/packages/extension/src/ui/action/views/network-assets/index.vue +++ b/packages/extension/src/ui/action/views/network-assets/index.vue @@ -21,7 +21,7 @@ :token="item" :network="network" @update:tokens="updateAssets" - > + />
- + Date: Fri, 10 Jan 2025 11:42:45 -0800 Subject: [PATCH 3/5] devop: use enum --- packages/extension/src/libs/metrics/types.ts | 6 ++++++ .../components/app-menu/components/app-menu-item.vue | 8 +++++++- .../extension/src/ui/action/components/app-menu/index.vue | 8 ++++---- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/extension/src/libs/metrics/types.ts b/packages/extension/src/libs/metrics/types.ts index 57036a3b3..7760a4694 100644 --- a/packages/extension/src/libs/metrics/types.ts +++ b/packages/extension/src/libs/metrics/types.ts @@ -14,6 +14,12 @@ export enum GenericEvents { login_error = 'login_error', } +export enum NetworkType { + Regular = 'regular', + Custom = 'custom', + Testnet = 'testnet', +} + export enum NetworkChangeEvents { NetworkChangePopup = 'network_change_popup', NetworkChangeAPI = 'network_change_api', diff --git a/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue b/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue index dd8a08d32..af24075d0 100644 --- a/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue +++ b/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue @@ -59,7 +59,7 @@ import PinIcon from '@action/icons/actions/pin.vue'; import DragIcon from '@action/icons/common/drag-icon.vue'; import { trackNetworkSelected } from '@/libs/metrics'; -import { NetworkChangeEvents } from '@/libs/metrics/types'; +import { NetworkChangeEvents, NetworkType } from '@/libs/metrics/types'; const props = defineProps({ network: { @@ -180,8 +180,14 @@ watch( * ------------------------*/ const setPinned = async () => { + const networkType = props.network.isTestNetwork + ? NetworkType.Testnet + : props.network.isCustomNetwork + ? NetworkType.Custom + : NetworkType.Regular; trackNetworkSelected(NetworkChangeEvents.NetworkPinnedStatusChanged, { network: props.network.name, + networkType: networkType, isPinned: !props.isPinned, }); emit('update:pinNetwork', props.network.name, !props.isPinned); diff --git a/packages/extension/src/ui/action/components/app-menu/index.vue b/packages/extension/src/ui/action/components/app-menu/index.vue index 2509a6e52..226a8e09d 100644 --- a/packages/extension/src/ui/action/components/app-menu/index.vue +++ b/packages/extension/src/ui/action/components/app-menu/index.vue @@ -67,7 +67,7 @@ import { import { useScroll } from '@vueuse/core'; import { newNetworks, newSwaps } from '@/providers/common/libs/new-features'; import { trackNetworkSelected } from '@/libs/metrics'; -import { NetworkChangeEvents } from '@/libs/metrics/types'; +import { NetworkChangeEvents, NetworkType } from '@/libs/metrics/types'; const networksState = new NetworksState(); const props = defineProps({ @@ -118,10 +118,10 @@ const setNetwork = async (network: BaseNetwork) => { } const networkType = network.isTestNetwork - ? 'testnet' + ? NetworkType.Testnet : network.isCustomNetwork - ? 'custom' - : 'regular'; + ? NetworkType.Custom + : NetworkType.Regular; trackNetworkSelected(NetworkChangeEvents.NetworkActiveChanged, { network: network.name, networkType, From f12fab70d6f40592460a9b86ba55b3f5cb810507 Mon Sep 17 00:00:00 2001 From: Gamaliel Padillo Date: Fri, 10 Jan 2025 11:50:25 -0800 Subject: [PATCH 4/5] chore: remove unused import --- packages/extension/src/libs/metrics/types.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/extension/src/libs/metrics/types.ts b/packages/extension/src/libs/metrics/types.ts index 7760a4694..8c5c5bc7c 100644 --- a/packages/extension/src/libs/metrics/types.ts +++ b/packages/extension/src/libs/metrics/types.ts @@ -1,4 +1,3 @@ -import { NetworkSortOption } from './../../ui/action/types/network-sort'; export enum SwapEventType { SwapOpen = 'swap_open', SwapRate = 'swap_rate', From f5654c3c8a593a65052ccd10a4110371f845c2da Mon Sep 17 00:00:00 2001 From: Gamaliel Padillo Date: Fri, 10 Jan 2025 11:55:40 -0800 Subject: [PATCH 5/5] chore: rename trackNetworkChange function --- packages/extension/src/libs/metrics/index.ts | 7 ++++--- .../src/providers/bitcoin/methods/btc_switchNetwork.ts | 7 +++---- .../providers/ethereum/methods/wallet_addEthereumChain.ts | 4 ++-- .../ethereum/methods/wallet_switchEthereumChain.ts | 7 +++---- .../src/providers/polkadot/ui/dot-verify-transaction.vue | 4 ++-- packages/extension/src/ui/action/App.vue | 4 ++-- .../components/app-menu/components/app-menu-item.vue | 4 ++-- .../components/app-menu/components/app-menu-sort.vue | 4 ++-- .../action/components/app-menu/components/app-menu-tab.vue | 4 ++-- .../extension/src/ui/action/components/app-menu/index.vue | 4 ++-- .../views/add-network/components/add-network-item.vue | 4 ++-- .../extension/src/ui/action/views/add-network/index.vue | 6 +++--- .../action/views/add-network/views/add-custom-network.vue | 4 ++-- 13 files changed, 31 insertions(+), 32 deletions(-) diff --git a/packages/extension/src/libs/metrics/index.ts b/packages/extension/src/libs/metrics/index.ts index 110385647..1163b7af0 100644 --- a/packages/extension/src/libs/metrics/index.ts +++ b/packages/extension/src/libs/metrics/index.ts @@ -7,6 +7,7 @@ import { GenericEvents, NFTEventType, NetworkChangeEvents, + NetworkType, SendEventType, SettingEventType, SwapEventType, @@ -18,13 +19,13 @@ const trackGenericEvents = (event: GenericEvents) => { metrics.track('generic', { event }); }; -const trackNetworkSelected = ( +const trackNetwork = ( event: NetworkChangeEvents, options: { provider?: ProviderName; network?: NetworkNames, networkTab?: string, - networkType?: 'regular' | 'custom' | 'testnet', + networkType?: NetworkType, isPinned?: boolean, sortOption?: string, customRpcUrl?: string, @@ -102,7 +103,7 @@ const optOutofMetrics = (optOut: boolean) => { }; export { - trackNetworkSelected, + trackNetwork, trackSwapEvents, trackBuyEvents, trackSendEvents, diff --git a/packages/extension/src/providers/bitcoin/methods/btc_switchNetwork.ts b/packages/extension/src/providers/bitcoin/methods/btc_switchNetwork.ts index 307736a10..1e1e5a7fa 100644 --- a/packages/extension/src/providers/bitcoin/methods/btc_switchNetwork.ts +++ b/packages/extension/src/providers/bitcoin/methods/btc_switchNetwork.ts @@ -7,7 +7,7 @@ import BTCNetworks from '../networks'; import DomainState from '@/libs/domain-state'; import BitcoinProvider from '..'; import { BitcoinNetworks } from '../types'; -import { trackNetworkSelected } from '@/libs/metrics'; +import { trackNetwork } from '@/libs/metrics'; import { NetworkChangeEvents } from '@/libs/metrics/types'; const method: MiddlewareFunction = function ( this: BitcoinProvider, @@ -29,7 +29,7 @@ const method: MiddlewareFunction = function ( const allNetworks = Object.values(BTCNetworks); const validNetwork = allNetworks.find(net => net.name === internalName); if (validNetwork) { - trackNetworkSelected(NetworkChangeEvents.NetworkChangeAPI, { + trackNetwork(NetworkChangeEvents.NetworkChangeAPI, { provider: validNetwork.provider, network: validNetwork.name, }); @@ -49,8 +49,7 @@ const method: MiddlewareFunction = function ( } else { return res( getCustomError( - `btc_switchNetwork: porvided network ${ - payload.params![0] + `btc_switchNetwork: porvided network ${payload.params![0] } not supported`, ), ); diff --git a/packages/extension/src/providers/ethereum/methods/wallet_addEthereumChain.ts b/packages/extension/src/providers/ethereum/methods/wallet_addEthereumChain.ts index 945471d46..2ce8f8d88 100644 --- a/packages/extension/src/providers/ethereum/methods/wallet_addEthereumChain.ts +++ b/packages/extension/src/providers/ethereum/methods/wallet_addEthereumChain.ts @@ -18,7 +18,7 @@ import { getAllNetworks } from '@/libs/utils/networks'; import CustomNetworksState from '@/libs/custom-networks-state'; import NetworksState from '@/libs/networks-state'; import { EvmNetwork } from '../types/evm-network'; -import { trackNetworkSelected } from '@/libs/metrics'; +import { trackNetwork } from '@/libs/metrics'; import { NetworkChangeEvents } from '@/libs/metrics/types'; interface AddEthereumChainPayload { @@ -128,7 +128,7 @@ const setExistingCustomNetwork = async ( ) as EvmNetwork | undefined; } if (existingNetwork) { - trackNetworkSelected(NetworkChangeEvents.NetworkChangeAPI, { + trackNetwork(NetworkChangeEvents.NetworkChangeAPI, { provider: ProviderName.ethereum, network: existingNetwork.name as NetworkNames, }); diff --git a/packages/extension/src/providers/ethereum/methods/wallet_switchEthereumChain.ts b/packages/extension/src/providers/ethereum/methods/wallet_switchEthereumChain.ts index 058e64394..71f04c4a5 100644 --- a/packages/extension/src/providers/ethereum/methods/wallet_switchEthereumChain.ts +++ b/packages/extension/src/providers/ethereum/methods/wallet_switchEthereumChain.ts @@ -9,7 +9,7 @@ import DomainState from '@/libs/domain-state'; import { getAllNetworks } from '@/libs/utils/networks'; import { EvmNetwork } from '../types/evm-network'; import NetworksState from '@/libs/networks-state'; -import { trackNetworkSelected } from '@/libs/metrics'; +import { trackNetwork } from '@/libs/metrics'; import { NetworkChangeEvents } from '@/libs/metrics/types'; const method: MiddlewareFunction = function ( @@ -33,7 +33,7 @@ const method: MiddlewareFunction = function ( net => (net as EvmNetwork).chainID === payload.params![0].chainId, ) as EvmNetwork | undefined; if (validNetwork) { - trackNetworkSelected(NetworkChangeEvents.NetworkChangeAPI, { + trackNetwork(NetworkChangeEvents.NetworkChangeAPI, { provider: validNetwork.provider, network: validNetwork.name, }); @@ -68,8 +68,7 @@ const method: MiddlewareFunction = function ( } else { return res( getCustomError( - `wallet_switchEthereumChain: provided network ${ - payload.params![0].chainId + `wallet_switchEthereumChain: provided network ${payload.params![0].chainId } not supported`, ), ); diff --git a/packages/extension/src/providers/polkadot/ui/dot-verify-transaction.vue b/packages/extension/src/providers/polkadot/ui/dot-verify-transaction.vue index 4690bfbb5..c3a9d5fcc 100644 --- a/packages/extension/src/providers/polkadot/ui/dot-verify-transaction.vue +++ b/packages/extension/src/providers/polkadot/ui/dot-verify-transaction.vue @@ -151,7 +151,7 @@ import { u8aToHex } from '@polkadot/util'; import ActivityState from '@/libs/activity-state'; import Polkadot from '@/providers/polkadot/networks/polkadot'; import { getAllNetworks } from '@/libs/utils/networks'; -import { trackNetworkSelected, trackSendEvents } from '@/libs/metrics'; +import { trackNetwork, trackSendEvents } from '@/libs/metrics'; import { NetworkChangeEvents, SendEventType } from '@/libs/metrics/types'; const windowPromise = WindowPromiseHandler(2); @@ -194,7 +194,7 @@ onBeforeMount(async () => { if (targetNetwork) { network.value = targetNetwork; - trackNetworkSelected(NetworkChangeEvents.NetworkChangeAPI, { + trackNetwork(NetworkChangeEvents.NetworkChangeAPI, { provider: targetNetwork.provider, network: targetNetwork.name, }); diff --git a/packages/extension/src/ui/action/App.vue b/packages/extension/src/ui/action/App.vue index a723bd0b0..4078fb490 100644 --- a/packages/extension/src/ui/action/App.vue +++ b/packages/extension/src/ui/action/App.vue @@ -148,7 +148,7 @@ import { EnkryptProviderEventMethods, ProviderName } from '@/types/provider'; import { onClickOutside } from '@vueuse/core'; import RateState from '@/libs/rate-state'; import SwapLookingAnimation from '@action/icons/swap/swap-looking-animation.vue'; -import { trackBuyEvents, trackNetworkSelected } from '@/libs/metrics'; +import { trackBuyEvents, trackNetwork } from '@/libs/metrics'; import { getLatestEnkryptVersion } from '@action/utils/browser'; import { gt as semverGT } from 'semver'; import { BuyEventType, NetworkChangeEvents } from '@/libs/metrics/types'; @@ -301,7 +301,7 @@ const updateGradient = (newGradient: string) => { `radial-gradient(137.35% 97% at 100% 50%, rgba(250, 250, 250, 0.94) 0%, rgba(250, 250, 250, 0.96) 28.91%, rgba(250, 250, 250, 0.98) 100%), linear-gradient(180deg, ${newGradient} 80%, #684CFF 100%)`; }; const setNetwork = async (network: BaseNetwork) => { - trackNetworkSelected(NetworkChangeEvents.NetworkChangePopup, { + trackNetwork(NetworkChangeEvents.NetworkChangePopup, { provider: network.provider, network: network.name, }); diff --git a/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue b/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue index af24075d0..5fca329e3 100644 --- a/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue +++ b/packages/extension/src/ui/action/components/app-menu/components/app-menu-item.vue @@ -58,7 +58,7 @@ import SwapAddedIcon from '@/ui/action/icons/asset/swap-added-icon.vue'; import PinIcon from '@action/icons/actions/pin.vue'; import DragIcon from '@action/icons/common/drag-icon.vue'; -import { trackNetworkSelected } from '@/libs/metrics'; +import { trackNetwork } from '@/libs/metrics'; import { NetworkChangeEvents, NetworkType } from '@/libs/metrics/types'; const props = defineProps({ @@ -185,7 +185,7 @@ const setPinned = async () => { : props.network.isCustomNetwork ? NetworkType.Custom : NetworkType.Regular; - trackNetworkSelected(NetworkChangeEvents.NetworkPinnedStatusChanged, { + trackNetwork(NetworkChangeEvents.NetworkPinnedStatusChanged, { network: props.network.name, networkType: networkType, isPinned: !props.isPinned, diff --git a/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue b/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue index 4df0c9312..a50f1a558 100644 --- a/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue +++ b/packages/extension/src/ui/action/components/app-menu/components/app-menu-sort.vue @@ -63,7 +63,7 @@ import { NetworkSortDirection, } from '@action/types/network-sort'; import SortDirectionIcon from '@/ui/action/icons/actions/sort/sort-direction-icon.vue'; -import { trackNetworkSelected } from '@/libs/metrics'; +import { trackNetwork } from '@/libs/metrics'; import { NetworkChangeEvents } from '@/libs/metrics/types'; // Next Release Version: @@ -92,7 +92,7 @@ const setActiveSort = (_sort: NetworkSortOption) => { // Next Release Version: update this function newSortBy.name = _sort; } - trackNetworkSelected(NetworkChangeEvents.NetworkSortOptionChanged, { + trackNetwork(NetworkChangeEvents.NetworkSortOptionChanged, { sortOption: newSortBy.name, }); emit('update:sort', newSortBy); diff --git a/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue b/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue index 5c673dcb9..7de225392 100644 --- a/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue +++ b/packages/extension/src/ui/action/components/app-menu/components/app-menu-tab.vue @@ -40,7 +40,7 @@ diff --git a/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue b/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue index eb0512758..dcbe100c9 100644 --- a/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue +++ b/packages/extension/src/ui/action/views/add-network/views/add-custom-network.vue @@ -91,7 +91,7 @@ import { toHex } from 'web3-utils'; import CustomNetworksState from '@/libs/custom-networks-state'; import NetworksState from '@/libs/networks-state'; -import { trackNetworkSelected } from '@/libs/metrics'; +import { trackNetwork } from '@/libs/metrics'; import { NetworkChangeEvents } from '@/libs/metrics/types'; interface NetworkConfigItem { @@ -267,7 +267,7 @@ const sendAction = async () => { await customNetworksState.addCustomNetwork(customNetworkOptions); await networksState.setNetworkStatus(customNetworkOptions.name, true); - trackNetworkSelected(NetworkChangeEvents.NetworkCustomNetworkAdded, { + trackNetwork(NetworkChangeEvents.NetworkCustomNetworkAdded, { customRpcUrl: customNetworkOptions.node, customNetworkName: customNetworkOptions.name, customNetworkNameLong: customNetworkOptions.name_long,