Skip to content

Commit

Permalink
[FIX] Wallet Connected Events
Browse files Browse the repository at this point in the history
  • Loading branch information
flavioislima committed Sep 12, 2024
1 parent ed0da39 commit 1d5dfb5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/backend/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,9 @@ ipcMain.handle(
// sends messages to renderer process through preload.ts callbacks
backendEvents.on('walletConnected', function (accounts: string[]) {
getMainWindow()?.webContents.send('walletConnected', accounts)
trackEvent({
event: 'Wallet Connected'
})
})

backendEvents.on('walletDisconnected', function (code: number, reason: string) {
Expand All @@ -2006,12 +2009,24 @@ backendEvents.on('connectionRequestRejected', function () {

backendEvents.on('chainChanged', function (chainId: number) {
getMainWindow()?.webContents.send('chainChanged', chainId)
trackEvent({
event: 'Chain Changed',
properties: {
chainId
}
})
})

backendEvents.on(
'accountsChanged',
function (accounts: string[], provider: PROVIDERS) {
getMainWindow()?.webContents.send('accountChanged', accounts, provider)
trackEvent({
event: 'Accounts Changed',
properties: {
provider
}
})
}
)

Expand Down
18 changes: 18 additions & 0 deletions src/backend/metrics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,22 @@ export interface WalletConnected {
sensitiveProperties?: never
}

export interface ChainChanged {
event: 'Chain Changed'
properties: {
chainId: number
}
sensitiveProperties?: never
}

export interface AccountsChanged {
event: 'Accounts Changed'
properties: {
provider: PROVIDERS
}
sensitiveProperties?: never
}

export interface MetaMaskInitialized {
event: 'MetaMask Initialized'
properties?: {
Expand Down Expand Up @@ -374,5 +390,7 @@ export type PossibleMetricPayloads =
| RewardClaimStarted
| RewardClaimSuccess
| RewardClaimError
| ChainChanged
| AccountsChanged

export type PossibleMetricEventNames = PossibleMetricPayloads['event']

0 comments on commit 1d5dfb5

Please sign in to comment.