diff --git a/src/background/Wallet/WalletRecord.ts b/src/background/Wallet/WalletRecord.ts index 9f8ad531e..26b335f11 100644 --- a/src/background/Wallet/WalletRecord.ts +++ b/src/background/Wallet/WalletRecord.ts @@ -786,13 +786,14 @@ export class WalletRecordModel { record: WalletRecord, { preferences }: { preferences: Partial } ) { - return produce(record, (draft) => { - Object.assign(draft.publicPreferences, preferences); + if (preferences.enableHoldToSignButton != null) { emitter.emit( - 'preferencesChange', - draft.publicPreferences, - record.publicPreferences + 'holdToSignPreferenceChange', + preferences.enableHoldToSignButton ); + } + return produce(record, (draft) => { + Object.assign(draft.publicPreferences, preferences); }); } diff --git a/src/background/events.ts b/src/background/events.ts index efb25948e..b14c4d3a9 100644 --- a/src/background/events.ts +++ b/src/background/events.ts @@ -9,7 +9,7 @@ import type { import type { AddEthereumChainParameter } from 'src/modules/ethereum/types/AddEthereumChainParameter'; import type { State as GlobalPreferencesState } from './Wallet/GlobalPreferences'; import type { WalletOrigin } from './Wallet/model/WalletOrigin'; -import type { WalletContainer, WalletRecord } from './Wallet/model/types'; +import type { WalletContainer } from './Wallet/model/types'; type TransactionResponse = ethers.providers.TransactionResponse; @@ -59,9 +59,6 @@ export const emitter = createNanoEvents<{ state: GlobalPreferencesState, prevState: GlobalPreferencesState ) => void; - preferencesChange: ( - state: WalletRecord['publicPreferences'], - prevState: WalletRecord['publicPreferences'] - ) => void; + holdToSignPreferenceChange: (active: boolean) => void; eip6963SupportDetected: (data: { origin: string }) => void; }>(); diff --git a/src/shared/analytics/analytics.background.ts b/src/shared/analytics/analytics.background.ts index 0ceef49a4..b723bf68f 100644 --- a/src/shared/analytics/analytics.background.ts +++ b/src/shared/analytics/analytics.background.ts @@ -250,15 +250,13 @@ function trackAppEvents({ account }: { account: Account }) { }); }); - emitter.on('preferencesChange', (state, prevState) => { - if (state.enableHoldToSignButton !== prevState.enableHoldToSignButton) { - const params = createBaseParams({ - request_name: 'hold_to_sign_prerefence', - active: Boolean(state.enableHoldToSignButton), - }); - const mixpanelParams = omit(params, ['request_name']); - mixpanelTrack(account, 'Experiments: Hold Sign Button', mixpanelParams); - } + emitter.on('holdToSignPreferenceChange', (active) => { + const params = createBaseParams({ + request_name: 'hold_to_sign_prerefence', + active, + }); + const mixpanelParams = omit(params, ['request_name']); + mixpanelTrack(account, 'Experiments: Hold Sign Button', mixpanelParams); }); emitter.on('walletCreated', ({ walletContainer, origin }) => {