feat: improved logging 9 12 (#7306)

* feat: add chain id and update name

* log metamask version

* fix: tests
This commit is contained in:
eddie 2023-09-14 12:03:14 -07:00 committed by GitHub
parent 7fc005024d
commit 172160deb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 10 deletions

@ -190,7 +190,7 @@
"@sentry/types": "^7.45.0",
"@types/react-window-infinite-loader": "^1.0.6",
"@uniswap/analytics": "^1.4.0",
"@uniswap/analytics-events": "^2.19.1",
"@uniswap/analytics-events": "^2.22.0",
"@uniswap/governance": "^1.0.2",
"@uniswap/liquidity-staker": "^1.0.2",
"@uniswap/merkle-distributor": "^1.0.1",

@ -70,6 +70,7 @@ describe('Web3Provider', () => {
const mockConnection = connections[0]
mockProvider = mockConnection.connector.provider as MockEIP1193Provider
mocked(getConnection).mockReturnValue(mockConnection)
jest.spyOn(console, 'warn').mockImplementation()
})
it('sends event when the active account changes', async () => {
@ -87,7 +88,7 @@ describe('Web3Provider', () => {
// Assert
expect(sendAnalyticsEvent).toHaveBeenCalledTimes(1)
expect(sendAnalyticsEvent).toHaveBeenCalledWith(InterfaceEventName.WALLET_CONNECT_TXN_COMPLETED, {
expect(sendAnalyticsEvent).toHaveBeenCalledWith(InterfaceEventName.WALLET_CONNECTED, {
result: WalletConnectionResult.SUCCEEDED,
wallet_address: '0x0000000000000000000000000000000000000000',
wallet_type: 'test',
@ -123,7 +124,7 @@ describe('Web3Provider', () => {
// Assert
expect(sendAnalyticsEvent).toHaveBeenCalledTimes(3)
expect(sendAnalyticsEvent).toHaveBeenCalledWith(InterfaceEventName.WALLET_CONNECT_TXN_COMPLETED, {
expect(sendAnalyticsEvent).toHaveBeenCalledWith(InterfaceEventName.WALLET_CONNECTED, {
result: WalletConnectionResult.SUCCEEDED,
wallet_address: '0x0000000000000000000000000000000000000000',
wallet_type: 'test',

@ -59,17 +59,28 @@ function Updater() {
(wallet) => wallet.account === account && wallet.walletType === walletType
)
provider
?.send('web3_clientVersion', [])
.then((clientVersion) => {
user.set(CustomUserProperties.WALLET_VERSION, clientVersion)
})
.catch((error) => {
console.warn('Failed to get client version', error)
})
// User properties *must* be set before sending corresponding event properties,
// so that the event contains the correct and up-to-date user properties.
user.set(CustomUserProperties.WALLET_ADDRESS, account)
user.postInsert(CustomUserProperties.ALL_WALLET_ADDRESSES_CONNECTED, account)
user.set(CustomUserProperties.WALLET_TYPE, walletType)
user.set(CustomUserProperties.PEER_WALLET_AGENT, peerWalletAgent ?? '')
if (chainId) {
user.set(CustomUserProperties.CHAIN_ID, chainId)
user.postInsert(CustomUserProperties.ALL_WALLET_CHAIN_IDS, chainId)
}
user.postInsert(CustomUserProperties.ALL_WALLET_ADDRESSES_CONNECTED, account)
sendAnalyticsEvent(InterfaceEventName.WALLET_CONNECT_TXN_COMPLETED, {
sendAnalyticsEvent(InterfaceEventName.WALLET_CONNECTED, {
result: WalletConnectionResult.SUCCEEDED,
wallet_address: account,
wallet_type: walletType,

@ -63,7 +63,7 @@ function useTryActivation() {
console.error(error)
// Failed Connection events are logged here, while successful ones are logged by Web3Provider
sendAnalyticsEvent(InterfaceEventName.WALLET_CONNECT_TXN_COMPLETED, {
sendAnalyticsEvent(InterfaceEventName.WALLET_CONNECTED, {
result: WalletConnectionResult.FAILED,
wallet_type: connection.getName(),
page: currentPage,

@ -6045,10 +6045,10 @@
"@typescript-eslint/types" "5.59.1"
eslint-visitor-keys "^3.3.0"
"@uniswap/analytics-events@^2.19.1":
version "2.19.1"
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.19.1.tgz#943a16b1ff1a43439af38c6e26f5f8583cd1afd7"
integrity sha512-22sdQ4dG+oYnRC9sJ62Cp3ZzwPqEPIkVlrndBGMpmCNXwCd6QeWdvsAP8rCZh+B8hlBieuPlxkiTlPDux6X7kw==
"@uniswap/analytics-events@^2.22.0":
version "2.22.0"
resolved "https://registry.yarnpkg.com/@uniswap/analytics-events/-/analytics-events-2.22.0.tgz#25600f5f6d9df4ea3aa7328dbc6ec44af4b652d1"
integrity sha512-Q/H4JaxQuEBFZvMWW40J3m51/zUXr2FYkfO2+IA0EJfoZiWE8Yl0xWtNrO5RDc4Q57Q9z0cEzzDLN2L1RQSpJA==
"@uniswap/analytics@^1.4.0":
version "1.4.0"