Skip to content

Commit

Permalink
Fix analytics event
Browse files Browse the repository at this point in the history
  • Loading branch information
zerts committed Jun 21, 2024
1 parent fa04a75 commit 39f0521
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 19 deletions.
11 changes: 6 additions & 5 deletions src/background/Wallet/WalletRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -786,13 +786,14 @@ export class WalletRecordModel {
record: WalletRecord,
{ preferences }: { preferences: Partial<WalletRecord['publicPreferences']> }
) {
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);
});
}

Expand Down
7 changes: 2 additions & 5 deletions src/background/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}>();
16 changes: 7 additions & 9 deletions src/shared/analytics/analytics.background.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 }) => {
Expand Down

0 comments on commit 39f0521

Please sign in to comment.