-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: add missing onboarding and multiwallet posthog events, improve t…
…ype-safety
- Loading branch information
1 parent
5e0a649
commit 23b3f3f
Showing
20 changed files
with
1,101 additions
and
188 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 0 additions & 81 deletions
81
apps/browser-extension-wallet/src/providers/AnalyticsProvider/analyticsTracker/events.ts
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...browser-extension-wallet/src/providers/AnalyticsProvider/analyticsTracker/events/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export { postHogMultiWalletActions } from './multi-wallet'; | ||
export type { PostHogMultiWalletAction, PostHogMultiWalletActions } from './multi-wallet'; | ||
export { postHogOnboardingActions } from './onboarding'; | ||
export type { PostHogOnboardingAction, PostHogOnboardingActions } from './onboarding'; |
63 changes: 63 additions & 0 deletions
63
...-extension-wallet/src/providers/AnalyticsProvider/analyticsTracker/events/multi-wallet.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { ExtractActionsAsUnion, ValidateMultiWalletActionsStructure } from './types'; | ||
|
||
export type PostHogMultiWalletActions = typeof multiWalletActions; | ||
export type PostHogMultiWalletAction = ExtractActionsAsUnion<PostHogMultiWalletActions>; | ||
|
||
const makeMultiWalletCreateEvent = <E extends string>(eventSuffix: E) => | ||
`multiwallet | new wallet revamp | ${eventSuffix}` as const; | ||
const makeMultiWalletRestoreEvent = <E extends string>(eventSuffix: E) => | ||
`multiwallet | restore wallet revamp | ${eventSuffix}` as const; | ||
const makeMultiWalletHardwareEvent = <E extends string>(eventSuffix: E) => | ||
`multiwallet | hardware wallet revamp | ${eventSuffix}` as const; | ||
|
||
const multiWalletActions = { | ||
create: { | ||
SETUP_OPTION_CLICK: makeMultiWalletCreateEvent('create | click'), | ||
SAVE_RECOVERY_PHRASE_NEXT_CLICK: makeMultiWalletCreateEvent('save your recovery phrase | next | click'), | ||
ENTER_RECOVERY_PHRASE_NEXT_CLICK: makeMultiWalletCreateEvent('enter your recovery phrase | next | click'), | ||
ENTER_WALLET: makeMultiWalletCreateEvent("let's set up your new wallet | enter wallet | click"), | ||
RECOVERY_PHRASE_INTRO_WATCH_VIDEO_CLICK: makeMultiWalletCreateEvent( | ||
'save your recovery phrase | watch video | click' | ||
), | ||
RECOVERY_PHRASE_INTRO_VIDEO_GOTIT_CLICK: makeMultiWalletCreateEvent('keeping your wallet secure | got it | click'), | ||
RECOVERY_PHRASE_COPY_TO_CLIPBOARD_CLICK: makeMultiWalletCreateEvent( | ||
'save your recovery phrase | copy to clipboard | click' | ||
), | ||
RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK: makeMultiWalletCreateEvent( | ||
'enter your recovery phrase | paste from clipboard | click' | ||
), | ||
RECOVERY_PHRASE_COPY_READ_MORE_CLICK: makeMultiWalletCreateEvent( | ||
'save your recovery phrase | best practices faq | click' | ||
), | ||
RECOVERY_PHRASE_PASTE_READ_MORE_CLICK: makeMultiWalletCreateEvent( | ||
'enter your recovery phrase | best practices faq | click' | ||
), | ||
WALLET_ADDED: makeMultiWalletCreateEvent('added') | ||
}, | ||
restore: { | ||
SETUP_OPTION_CLICK: makeMultiWalletRestoreEvent('restore | click'), | ||
ENTER_WALLET: makeMultiWalletRestoreEvent("let's set up your new wallet | enter wallet | click"), | ||
ENTER_RECOVERY_PHRASE_NEXT_CLICK: makeMultiWalletRestoreEvent(' enter your recovery phrase | next | click'), | ||
RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK: makeMultiWalletRestoreEvent( | ||
'enter your recovery phrase | paste from clipboard | click' | ||
), | ||
RECOVERY_PHRASE_PASTE_READ_MORE_CLICK: makeMultiWalletRestoreEvent( | ||
'enter your recovery phrase | best practices faq | click' | ||
), | ||
WALLET_ADDED: makeMultiWalletRestoreEvent('added'), | ||
HD_WALLET: makeMultiWalletRestoreEvent('hd wallet') | ||
}, | ||
hardware: { | ||
SETUP_OPTION_CLICK: makeMultiWalletHardwareEvent('connect | click'), | ||
CONNECT_HW_VIEW: makeMultiWalletHardwareEvent('connect your device | view'), | ||
HW_POPUP_CONNECT_CLICK: makeMultiWalletHardwareEvent('native browser pop-up with HWs | connect | click'), | ||
CONNECT_HW_TRY_AGAIN_CLICK: makeMultiWalletHardwareEvent('connect your device | try again | click'), | ||
SETUP_HW_ACCOUNT_NO_CLICK: makeMultiWalletHardwareEvent("let's set up your wallet | Account No | click"), | ||
ENTER_WALLET: makeMultiWalletHardwareEvent("let's set up your wallet | enter wallet | click"), | ||
WALLET_ADDED: makeMultiWalletHardwareEvent('added'), | ||
HD_WALLET: makeMultiWalletHardwareEvent('hd wallet') | ||
} | ||
}; | ||
|
||
export const postHogMultiWalletActions: ValidateMultiWalletActionsStructure<PostHogMultiWalletActions> = | ||
multiWalletActions; |
81 changes: 81 additions & 0 deletions
81
...er-extension-wallet/src/providers/AnalyticsProvider/analyticsTracker/events/onboarding.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
/* eslint-disable sonarjs/no-duplicate-string */ | ||
import { ExtractActionsAsUnion, ValidateOnboardingActionsStructure } from './types'; | ||
|
||
export type PostHogOnboardingActions = typeof onboardingActions; | ||
export type PostHogOnboardingAction = ExtractActionsAsUnion<PostHogOnboardingActions>; | ||
|
||
const makeOnboardingEvent = <E extends string>(eventSuffix: E) => `onboarding | ${eventSuffix}` as const; | ||
const makeOnboardingCreateEvent = <E extends string>(eventSuffix: E) => | ||
`onboarding | new wallet revamp | ${eventSuffix}` as const; | ||
const makeOnboardingRestoreEvent = <E extends string>(eventSuffix: E) => | ||
`onboarding | restore wallet revamp | ${eventSuffix}` as const; | ||
const makeOnboardingHardwareEvent = <E extends string>(eventSuffix: E) => | ||
`onboarding | hardware wallet revamp | ${eventSuffix}` as const; | ||
const makeForgotPasswordEvent = <E extends string>(eventSuffix: E) => | ||
`unlock wallet | forgot password? | ${eventSuffix}` as const; | ||
|
||
const onboardingActions = { | ||
onboarding: { | ||
ANALYTICS_AGREE_CLICK: makeOnboardingEvent('analytics banner | agree | click'), | ||
ANALYTICS_REJECT_CLICK: makeOnboardingEvent('analytics banner | reject | click'), | ||
LEARN_MORE_CLICK: makeOnboardingEvent('analytics banner | learn more | click'), | ||
GOT_IT_CLICK: makeOnboardingEvent('help us improve your experience | got it | click'), | ||
PIN_EXTENSION_CLICK: makeOnboardingEvent('lace main view | pin the wallet extension | click') | ||
}, | ||
create: { | ||
SETUP_OPTION_CLICK: makeOnboardingCreateEvent('create | click'), | ||
SAVE_RECOVERY_PHRASE_NEXT_CLICK: makeOnboardingCreateEvent('save your recovery phrase | next | click'), | ||
ENTER_RECOVERY_PHRASE_NEXT_CLICK: makeOnboardingCreateEvent('enter your recovery phrase | next | click'), | ||
ENTER_WALLET: makeOnboardingCreateEvent("let's set up your new wallet | enter wallet | click"), | ||
RECOVERY_PHRASE_INTRO_WATCH_VIDEO_CLICK: makeOnboardingCreateEvent( | ||
'save your recovery phrase | watch video | click' | ||
), | ||
RECOVERY_PHRASE_INTRO_VIDEO_GOTIT_CLICK: makeOnboardingCreateEvent('keeping your wallet secure | got it | click'), | ||
RECOVERY_PHRASE_COPY_TO_CLIPBOARD_CLICK: makeOnboardingCreateEvent( | ||
'save your recovery phrase | copy to clipboard | click' | ||
), | ||
RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK: makeOnboardingCreateEvent( | ||
'enter your recovery phrase | paste from clipboard | click' | ||
), | ||
RECOVERY_PHRASE_COPY_READ_MORE_CLICK: makeOnboardingCreateEvent( | ||
'save your recovery phrase | best practices faq | click' | ||
), | ||
RECOVERY_PHRASE_PASTE_READ_MORE_CLICK: makeOnboardingCreateEvent( | ||
'enter your recovery phrase | best practices faq | click' | ||
), | ||
WALLET_ADDED: makeOnboardingCreateEvent('added') | ||
}, | ||
restore: { | ||
SETUP_OPTION_CLICK: makeOnboardingRestoreEvent('restore | click'), | ||
ENTER_WALLET: makeOnboardingRestoreEvent("let's set up your new wallet | enter wallet | click"), | ||
ENTER_RECOVERY_PHRASE_NEXT_CLICK: makeOnboardingRestoreEvent(' enter your recovery phrase | next | click'), | ||
RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK: makeOnboardingRestoreEvent( | ||
'enter your recovery phrase | paste from clipboard | click' | ||
), | ||
RECOVERY_PHRASE_PASTE_READ_MORE_CLICK: makeOnboardingRestoreEvent( | ||
'enter your recovery phrase | best practices faq | click' | ||
), | ||
WALLET_ADDED: makeOnboardingRestoreEvent('added'), | ||
HD_WALLET: makeOnboardingRestoreEvent('hd wallet') | ||
}, | ||
hw: { | ||
SETUP_OPTION_CLICK: makeOnboardingHardwareEvent('connect | click'), | ||
CONNECT_HW_VIEW: makeOnboardingHardwareEvent('connect your device | view'), | ||
HW_POPUP_CONNECT_CLICK: makeOnboardingHardwareEvent('native browser pop-up with HWs | connect | click'), | ||
CONNECT_HW_TRY_AGAIN_CLICK: makeOnboardingHardwareEvent('connect your device | try again | click'), | ||
SETUP_HW_ACCOUNT_NO_CLICK: makeOnboardingHardwareEvent("let's set up your wallet | Account No | click"), | ||
ENTER_WALLET: makeOnboardingHardwareEvent("let's set up your wallet | enter wallet | click"), | ||
WALLET_ADDED: makeOnboardingHardwareEvent('added'), | ||
HD_WALLET: makeOnboardingHardwareEvent('hd wallet') | ||
}, | ||
// eslint-disable-next-line camelcase | ||
forgot_password: { | ||
ENTER_RECOVERY_PHRASE_NEXT_CLICK: makeForgotPasswordEvent('enter your recovery phrase | next | click'), | ||
ENTER_WALLET: makeForgotPasswordEvent('set up your password | enter wallet | click'), | ||
RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK: makeForgotPasswordEvent( | ||
'enter your recovery phrase | paste from clipboard | click' | ||
) | ||
} | ||
}; | ||
|
||
export const postHogOnboardingActions: ValidateOnboardingActionsStructure<PostHogOnboardingActions> = onboardingActions; |
67 changes: 67 additions & 0 deletions
67
...browser-extension-wallet/src/providers/AnalyticsProvider/analyticsTracker/events/types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
export type CreateFlowActions = Record< | ||
| 'SETUP_OPTION_CLICK' | ||
| 'SAVE_RECOVERY_PHRASE_NEXT_CLICK' | ||
| 'ENTER_RECOVERY_PHRASE_NEXT_CLICK' | ||
| 'ENTER_WALLET' | ||
| 'RECOVERY_PHRASE_INTRO_WATCH_VIDEO_CLICK' | ||
| 'RECOVERY_PHRASE_INTRO_VIDEO_GOTIT_CLICK' | ||
| 'RECOVERY_PHRASE_COPY_TO_CLIPBOARD_CLICK' | ||
| 'RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK' | ||
| 'RECOVERY_PHRASE_COPY_READ_MORE_CLICK' | ||
| 'RECOVERY_PHRASE_PASTE_READ_MORE_CLICK' | ||
| 'WALLET_ADDED', | ||
string | ||
>; | ||
export type RestoreFlowActions = Record< | ||
| 'SETUP_OPTION_CLICK' | ||
| 'ENTER_RECOVERY_PHRASE_NEXT_CLICK' | ||
| 'ENTER_WALLET' | ||
| 'RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK' | ||
| 'RECOVERY_PHRASE_PASTE_READ_MORE_CLICK' | ||
| 'WALLET_ADDED' | ||
| 'HD_WALLET', | ||
string | ||
>; | ||
export type HardwareFlowActions = Record< | ||
| 'SETUP_OPTION_CLICK' | ||
| 'CONNECT_HW_VIEW' | ||
| 'HW_POPUP_CONNECT_CLICK' | ||
| 'CONNECT_HW_TRY_AGAIN_CLICK' | ||
| 'SETUP_HW_ACCOUNT_NO_CLICK' | ||
| 'ENTER_WALLET' | ||
| 'WALLET_ADDED' | ||
| 'HD_WALLET', | ||
string | ||
>; | ||
|
||
export type ValidateOnboardingActionsStructure< | ||
T extends { | ||
create: CreateFlowActions; | ||
restore: RestoreFlowActions; | ||
hw: HardwareFlowActions; | ||
// eslint-disable-next-line camelcase | ||
forgot_password: Record< | ||
'ENTER_RECOVERY_PHRASE_NEXT_CLICK' | 'ENTER_WALLET' | 'RECOVERY_PHRASE_PASTE_FROM_CLIPBOARD_CLICK', | ||
string | ||
>; | ||
onboarding: Record< | ||
'ANALYTICS_AGREE_CLICK' | 'ANALYTICS_REJECT_CLICK' | 'LEARN_MORE_CLICK' | 'GOT_IT_CLICK' | 'PIN_EXTENSION_CLICK', | ||
string | ||
>; | ||
} | ||
> = T; | ||
|
||
export type ValidateMultiWalletActionsStructure< | ||
T extends { | ||
create: CreateFlowActions; | ||
restore: RestoreFlowActions; | ||
hardware: HardwareFlowActions; | ||
} | ||
> = T; | ||
|
||
type ActionsObject = Record<string, Record<string, unknown>>; | ||
type Values<T> = T[keyof T]; | ||
type ActionsMap<T extends ActionsObject> = { | ||
[Prop in keyof T]: T[Prop][keyof T[Prop]]; | ||
}; | ||
export type ExtractActionsAsUnion<A extends ActionsObject> = Values<ActionsMap<A>>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.