diff --git a/packages/beacon-dapp/src/events.ts b/packages/beacon-dapp/src/events.ts index ff9e17fd7..507e40e7b 100644 --- a/packages/beacon-dapp/src/events.ts +++ b/packages/beacon-dapp/src/events.ts @@ -40,7 +40,7 @@ import { // EncryptionOperation } from '@airgap/beacon-core' import { shortenString } from './utils/shorten-string' -import { isMobile, isMobileOS } from '@airgap/beacon-ui' +import { isMobile, isMobileOS, openBugReport } from '@airgap/beacon-ui' const logger = new Logger('BeaconEvents') @@ -100,6 +100,8 @@ export enum BeaconEvent { PAIR_SUCCESS = 'PAIR_SUCCESS', CHANNEL_CLOSED = 'CHANNEL_CLOSED', + OPEN_BUG_REPORT = 'OPEN_BUG_REPORT', + INTERNAL_ERROR = 'INTERNAL_ERROR', UNKNOWN = 'UNKNOWN' } @@ -216,6 +218,7 @@ export interface BeaconEventType { | ExtendedWalletConnectPairingResponse [BeaconEvent.CHANNEL_CLOSED]: string [BeaconEvent.INTERNAL_ERROR]: { text: string; buttons?: AlertButton[] } + [BeaconEvent.OPEN_BUG_REPORT]: undefined [BeaconEvent.UNKNOWN]: undefined } @@ -331,10 +334,15 @@ const showInvalidActiveAccountState = async (): Promise => { */ const showGenericErrorAlert = async (errorMessage: string): Promise => { await openAlert({ - title: 'Error', - body: `${errorMessage}.
Please try again.
If this problem persists please reach out support@walletbeacon.io` + title: `${errorMessage}`, + body: 'Please try again. If this problem persists please send us a bug report here', + buttons: [ + { + label: 'Send Report', + type: 'primary', + onClick: () => openBugReport() + } + ] as any }) } @@ -436,6 +444,10 @@ const showExtensionConnectedAlert = async (): Promise => { await closeAlerts() } +const showBugReportForm = () => { + openBugReport() +} + /** * Show a "channel closed" alert for 1.5 seconds */ @@ -775,6 +787,7 @@ export const defaultEventCallbacks: { [BeaconEvent.HIDE_UI]: hideUI, [BeaconEvent.PAIR_INIT]: showPairAlert, [BeaconEvent.PAIR_SUCCESS]: showExtensionConnectedAlert, + [BeaconEvent.OPEN_BUG_REPORT]: showBugReportForm, [BeaconEvent.CHANNEL_CLOSED]: showChannelClosedAlert, [BeaconEvent.INTERNAL_ERROR]: showInternalErrorAlert, [BeaconEvent.UNKNOWN]: emptyHandler() @@ -836,6 +849,7 @@ export class BeaconEventHandler { [BeaconEvent.HIDE_UI]: [defaultEventCallbacks.HIDE_UI], [BeaconEvent.PAIR_INIT]: [defaultEventCallbacks.PAIR_INIT], [BeaconEvent.PAIR_SUCCESS]: [defaultEventCallbacks.PAIR_SUCCESS], + [BeaconEvent.OPEN_BUG_REPORT]: [defaultEventCallbacks.OPEN_BUG_REPORT], [BeaconEvent.CHANNEL_CLOSED]: [defaultEventCallbacks.CHANNEL_CLOSED], [BeaconEvent.INTERNAL_ERROR]: [defaultEventCallbacks.INTERNAL_ERROR], [BeaconEvent.UNKNOWN]: [defaultEventCallbacks.UNKNOWN] diff --git a/packages/beacon-ui/src/components/info/index.tsx b/packages/beacon-ui/src/components/info/index.tsx index 8270bfbae..8ce757534 100644 --- a/packages/beacon-ui/src/components/info/index.tsx +++ b/packages/beacon-ui/src/components/info/index.tsx @@ -27,7 +27,7 @@ const Info: Component = (props: InfoProps) => { )}

{props.title}

- {props.description &&
} + {props.description &&
{props.description}
} {props.data &&
{props.data}
}
diff --git a/packages/beacon-ui/src/index.ts b/packages/beacon-ui/src/index.ts index 0c0d230b5..a9aa4a5f7 100644 --- a/packages/beacon-ui/src/index.ts +++ b/packages/beacon-ui/src/index.ts @@ -1,4 +1,4 @@ -export { openAlert, closeAlerts } from './ui/alert' +export { openAlert, closeAlerts, openBugReport } from './ui/alert' export type { AlertButton, AlertConfig } from './ui/alert' export { diff --git a/packages/beacon-ui/src/ui/alert/index.tsx b/packages/beacon-ui/src/ui/alert/index.tsx index 345bb3355..ad765f773 100644 --- a/packages/beacon-ui/src/ui/alert/index.tsx +++ b/packages/beacon-ui/src/ui/alert/index.tsx @@ -122,7 +122,7 @@ const closeAlert = (_: string): Promise => { */ const closeAlerts = async (): Promise => { if (currentInfo() === 'help') { - console.log('setting status as pairing expired.') + logger.log('closeAlerts', 'setting status as pairing expired.') setPairingExpired(true) return } @@ -144,6 +144,11 @@ const closeAlerts = async (): Promise => { }) } +const openBugReport = () => { + setPreviousInfo(currentInfo()) + setCurrentInfo('help') +} + /** * Show an alert * @@ -155,9 +160,6 @@ const openAlert = async (config: AlertConfig): Promise => { const p2pPayload = config.pairingPayload?.p2pSyncCode() const wcPayload = config.pairingPayload?.walletConnectSyncCode() const isOnline = navigator.onLine - const areMetricsEnabled = localStorage - ? localStorage.getItem(StorageKey.ENABLE_METRICS) === 'true' - : false setAnalytics(config.analytics) @@ -1069,61 +1071,11 @@ const openAlert = async (config: AlertConfig): Promise => { } } > - {areMetricsEnabled && ( - { - handleCloseAlert() - }} - /> - )} - {!areMetricsEnabled && ( - <> - - - - - } - title="What is a wallet?" - description="Wallets let you send, receive, store and interact with digital assets. Your wallet can be used as an easy way to login, instead of having to remember a password." - /> - - - - - - } - title="Not sure where to start?" - description="If you are new to the Web3, we recommend that you start by creating a Kukai wallet. Kukai is a fast way of creating your first wallet using your preferred social account." - /> - - )} + { + handleCloseAlert() + }} + />
=> { - - - - - } - title={config.title || 'No title'} - description={config.body || 'No description'} - data={config.data} - buttons={[ - { - label: 'Close', - type: 'primary', - onClick: () => handleCloseAlert() - } - ]} - /> + <> + {currentInfo() === 'help' ? ( + { + handleCloseAlert() + }} + /> + ) : ( + + + + + + } + title={config.title || 'No title'} + description={config.body || 'No description'} + data={config.data} + buttons={ + (config.buttons as any) ?? [ + { + label: 'Close', + type: 'primary', + onClick: () => handleCloseAlert() + } + ] + } + /> + )} + } onCloseClick={() => handleCloseAlert()} /> @@ -1263,4 +1227,4 @@ const openAlert = async (config: AlertConfig): Promise => { return '' } -export { closeAlert, closeAlerts, openAlert } +export { closeAlert, closeAlerts, openAlert, openBugReport }