Commit 1d2d1259 authored by Zach Pomerantz's avatar Zach Pomerantz Committed by GitHub

fix: set user properties before event properties (#6143)

parent 10eda002
......@@ -135,13 +135,8 @@ const sendAnalyticsEventAndUserInfo = (
isReconnect: boolean,
peerWalletAgent: string | undefined
) => {
sendAnalyticsEvent(InterfaceEventName.WALLET_CONNECT_TXN_COMPLETED, {
result: WalletConnectionResult.SUCCEEDED,
wallet_address: account,
wallet_type: walletType,
is_reconnect: isReconnect,
peer_wallet_agent: peerWalletAgent,
})
// 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.set(CustomUserProperties.WALLET_TYPE, walletType)
user.set(CustomUserProperties.PEER_WALLET_AGENT, peerWalletAgent ?? '')
......@@ -149,6 +144,14 @@ const sendAnalyticsEventAndUserInfo = (
user.postInsert(CustomUserProperties.ALL_WALLET_CHAIN_IDS, chainId)
}
user.postInsert(CustomUserProperties.ALL_WALLET_ADDRESSES_CONNECTED, account)
sendAnalyticsEvent(InterfaceEventName.WALLET_CONNECT_TXN_COMPLETED, {
result: WalletConnectionResult.SUCCEEDED,
wallet_address: account,
wallet_type: walletType,
is_reconnect: isReconnect,
peer_wallet_agent: peerWalletAgent,
})
}
export default function WalletModal({
......
......@@ -145,11 +145,14 @@ export default function App() {
}, [pathname])
useEffect(() => {
sendAnalyticsEvent(SharedEventName.APP_LOADED)
// 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.USER_AGENT, navigator.userAgent)
user.set(CustomUserProperties.BROWSER, getBrowser())
user.set(CustomUserProperties.SCREEN_RESOLUTION_HEIGHT, window.screen.height)
user.set(CustomUserProperties.SCREEN_RESOLUTION_WIDTH, window.screen.width)
sendAnalyticsEvent(SharedEventName.APP_LOADED)
getCLS(({ delta }: Metric) => sendAnalyticsEvent(SharedEventName.WEB_VITALS, { cumulative_layout_shift: delta }))
getFCP(({ delta }: Metric) => sendAnalyticsEvent(SharedEventName.WEB_VITALS, { first_contentful_paint_ms: delta }))
getFID(({ delta }: Metric) => sendAnalyticsEvent(SharedEventName.WEB_VITALS, { first_input_delay_ms: delta }))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment