From 9de564c6fd79d04a8c986f88b217546939ad1060 Mon Sep 17 00:00:00 2001 From: Bryce McMath <32586431+bryce-mcmath@users.noreply.github.com> Date: Mon, 16 Dec 2024 16:41:09 -0800 Subject: [PATCH] feat: implement report problem feature, revert pn change (#2322) Signed-off-by: Bryce McMath --- app/App.tsx | 2 +- app/__mocks__/react-native-device-info.ts | 3 -- app/container-imp.ts | 8 ++-- app/ios/Podfile.lock | 4 +- app/jestSetup.js | 5 ++ app/package.json | 10 ++-- app/src/hooks/initialize-agent.ts | 2 +- app/src/localization/en/index.ts | 4 ++ app/src/localization/fr/index.ts | 4 ++ app/src/localization/pt-br/index.ts | 4 ++ app/src/screens/Splash.tsx | 33 +++++++++++-- app/src/services/attestation.ts | 6 +-- yarn.lock | 58 +++++++++++++---------- 13 files changed, 95 insertions(+), 48 deletions(-) delete mode 100644 app/__mocks__/react-native-device-info.ts diff --git a/app/App.tsx b/app/App.tsx index 708981b4..ff4b6c78 100644 --- a/app/App.tsx +++ b/app/App.tsx @@ -79,7 +79,7 @@ const App = () => { translucent={false} /> - + private navigate: (stack: never, params: never) => void private setAppState: React.Dispatch> @@ -90,7 +91,7 @@ export class AppContainer implements Container { t: TFunction<'translation', undefined>, navigate: (stack: never, params: never) => void, useState: [AppState, React.Dispatch>], - log?: BaseLogger + log?: BifoldLogger ) { this._container = bifoldContainer.container.createChildContainer() this.log = log @@ -113,7 +114,6 @@ export class AppContainer implements Container { lokiUrl: Config.REMOTE_LOGGING_URL, lokiLabels: { application: getApplicationName().toLowerCase(), - job: 'react-native-logs', version: `${getVersion()}-${getBuildNumber()}`, system: `${getSystemName()} v${getSystemVersion()}`, }, diff --git a/app/ios/Podfile.lock b/app/ios/Podfile.lock index 7f4c2fb8..b564e6ac 100644 --- a/app/ios/Podfile.lock +++ b/app/ios/Podfile.lock @@ -445,7 +445,7 @@ PODS: - React-jsinspector (0.72.5) - React-logger (0.72.5): - glog - - "react-native-attestation (1.0.0-alpha.391+6f8357ae)": + - "react-native-attestation (1.0.0-alpha.395+99c753a2)": - RCT-Folly (= 2021.07.22.00) - React-Core - react-native-config (1.5.0): @@ -936,7 +936,7 @@ SPEC CHECKSUMS: React-jsiexecutor: ff70a72027dea5cc7d71cfcc6fad7f599f63987a React-jsinspector: aef73cbd43b70675f572214d10fa438c89bf11ba React-logger: 2e4aee3e11b3ec4fa6cfd8004610bbb3b8d6cca4 - react-native-attestation: a4fd5220ba42bc4a817e86cfab53d0303f0f9242 + react-native-attestation: 99f1d3d799ff7001d1f0c3881e267f7ca96ceda9 react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727 react-native-date-picker: 06a4d96ab525a163c7a90bccd68833d136b0bb13 react-native-encrypted-storage: db300a3f2f0aba1e818417c1c0a6be549038deb7 diff --git a/app/jestSetup.js b/app/jestSetup.js index 70ccd16c..a3d871b0 100644 --- a/app/jestSetup.js +++ b/app/jestSetup.js @@ -1,7 +1,12 @@ /* eslint-disable no-undef */ import 'react-native-gesture-handler/jestSetup' import mockRNLocalize from 'react-native-localize/mock' +import mockRNDeviceInfo from 'react-native-device-info/jest/react-native-device-info-mock' +mockRNDeviceInfo.getVersion = jest.fn(() => '1') +mockRNDeviceInfo.getBuildNumber = jest.fn(() => '1') + +jest.mock('react-native-device-info', () => mockRNDeviceInfo) jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper') jest.mock('react-native/Libraries/EventEmitter/NativeEventEmitter') jest.mock('react-native-localize', () => mockRNLocalize) diff --git a/app/package.json b/app/package.json index dd7e5571..06513a96 100644 --- a/app/package.json +++ b/app/package.json @@ -62,11 +62,11 @@ "@formatjs/intl-relativetimeformat": "9.3.1", "@hyperledger/anoncreds-react-native": "0.2.4", "@hyperledger/aries-askar-react-native": "0.2.3", - "@hyperledger/aries-bifold-core": "1.0.0-alpha.391", - "@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.391", - "@hyperledger/aries-bifold-verifier": "1.0.0-alpha.391", - "@hyperledger/aries-oca": "1.0.0-alpha.391", - "@hyperledger/aries-react-native-attestation": "1.0.0-alpha.391", + "@hyperledger/aries-bifold-core": "1.0.0-alpha.395", + "@hyperledger/aries-bifold-remote-logs": "1.0.0-alpha.395", + "@hyperledger/aries-bifold-verifier": "1.0.0-alpha.395", + "@hyperledger/aries-oca": "1.0.0-alpha.395", + "@hyperledger/aries-react-native-attestation": "1.0.0-alpha.395", "@hyperledger/indy-vdr-react-native": "0.2.2", "@hyperledger/indy-vdr-shared": "0.2.2", "@react-native-async-storage/async-storage": "1.15.11", diff --git a/app/src/hooks/initialize-agent.ts b/app/src/hooks/initialize-agent.ts index 8e66824e..1b8e16a1 100644 --- a/app/src/hooks/initialize-agent.ts +++ b/app/src/hooks/initialize-agent.ts @@ -190,7 +190,7 @@ const useInitializeBCAgent = () => { if (store.preferences.usePushNotifications) { logger.info('Activating push notifications...') - await activate(newAgent) + activate(newAgent) } // In case the old attestationMonitor is still active, stop it and start a new one diff --git a/app/src/localization/en/index.ts b/app/src/localization/en/index.ts index 95bf785f..8aa24e4f 100644 --- a/app/src/localization/en/index.ts +++ b/app/src/localization/en/index.ts @@ -21,6 +21,10 @@ const translation = { "Message2028": "There was a problem receiving the attestation invitation to connect.", "Title2029": "Unable to handle attestation proof", "Message2029": "There was a problem while handling an attestation proof request.", + "Title2030": "Unable to complete app initialization", + "Message2030": "There was a problem while initializing the app.", + "Title2031": "Unable to complete agent initialization", + "Message2031": "There was a problem while initializing the agent.", "NoMessage": "No Message", }, "CameraDisclosure": { diff --git a/app/src/localization/fr/index.ts b/app/src/localization/fr/index.ts index e5195faa..2c3eabec 100644 --- a/app/src/localization/fr/index.ts +++ b/app/src/localization/fr/index.ts @@ -21,6 +21,10 @@ const translation = { "Message2028": "Un problème est survenu pendant la réception de l'attestation de l'invitation de connection.", "Title2029": "Incapable de gérer la preuve d'attestation.", "Message2029": "Un problème est survenu de la gestion lors de la requête de preuve d'attestation.", + "Title2030": "Unable to complete app initialization (FR)", + "Message2030": "There was a problem while initializing the app. (FR)", + "Title2031": "Unable to complete agent initialization (FR)", + "Message2031": "There was a problem while initializing the agent. (FR)", "NoMessage": "Aucun message", }, "CameraDisclosure": { diff --git a/app/src/localization/pt-br/index.ts b/app/src/localization/pt-br/index.ts index ddcb85d0..897e8048 100644 --- a/app/src/localization/pt-br/index.ts +++ b/app/src/localization/pt-br/index.ts @@ -21,6 +21,10 @@ const translation = { "Message2028": "There was a problem receiving the attestation invitation to connect. (PT-BR)", "Title2029": "Unable to handle attestation proof (PT-BR)", "Message2029": "There was a problem while handling an attestation proof request. (PT-BR)", + "Title2030": "Unable to complete app initialization (PT-BR)", + "Message2030": "There was a problem while initializing the app. (PT-BR)", + "Title2031": "Unable to complete agent initialization (PT-BR)", + "Message2031": "There was a problem while initializing the agent. (PT-BR)", "NoMessage": "No Message (PT-BR)", }, "CameraDisclosure": { diff --git a/app/src/screens/Splash.tsx b/app/src/screens/Splash.tsx index 9ce198c7..e6308e2f 100644 --- a/app/src/screens/Splash.tsx +++ b/app/src/screens/Splash.tsx @@ -9,6 +9,7 @@ import { testIdWithKey, TOKENS, useServices, + BifoldError, } from '@hyperledger/aries-bifold-core' import { RemoteOCABundleResolver } from '@hyperledger/aries-oca/build/legacy' import { CommonActions, useNavigation } from '@react-navigation/native' @@ -16,6 +17,7 @@ import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react' import { useTranslation } from 'react-i18next' import { StyleSheet, View, Text, Image, useWindowDimensions, ScrollView } from 'react-native' import { SafeAreaView } from 'react-native-safe-area-context' +import Icon from 'react-native-vector-icons/MaterialCommunityIcons' import ProgressBar from '../components/ProgressBar' import TipCarousel from '../components/TipCarousel' @@ -110,14 +112,23 @@ const Splash = () => { const [initOnboardingCount, setInitOnboardingCount] = useState(0) const [initAgentCount, setInitAgentCount] = useState(0) const [initErrorType, setInitErrorType] = useState(InitErrorTypes.Onboarding) - const [initError, setInitError] = useState(null) + const [initError, setInitError] = useState(null) + const [reported, setReported] = useState(false) const initializing = useRef(false) const { initializeAgent } = useInitializeBCAgent() - const [ocaBundleResolver, { showPreface, enablePushNotifications }] = useServices([ + const [logger, ocaBundleResolver, { showPreface, enablePushNotifications }] = useServices([ + TOKENS.UTIL_LOGGER, TOKENS.UTIL_OCA_RESOLVER, TOKENS.CONFIG, ]) + const report = useCallback(() => { + if (initError) { + logger.report(initError) + } + setReported(true) + }, [logger, initError]) + const steps: string[] = useMemo( () => [ t('Init.Starting'), @@ -274,7 +285,7 @@ const Splash = () => { } } catch (e: unknown) { setInitErrorType(InitErrorTypes.Onboarding) - setInitError(e as Error) + setInitError(new BifoldError(t('Error.Title2030'), t('Error.Message2030'), (e as Error)?.message, 2030)) } }, [ mounted, @@ -335,7 +346,7 @@ const Splash = () => { } catch (e: unknown) { initializing.current = false setInitErrorType(InitErrorTypes.Agent) - setInitError(e as Error) + setInitError(new BifoldError(t('Error.Title2031'), t('Error.Message2031'), (e as Error)?.message, 2031)) } } @@ -350,6 +361,7 @@ const Splash = () => { store.onboarding.didConsiderBiometry, navigation, initAgentCount, + t, ]) const handleErrorCallToActionPressed = () => { @@ -361,6 +373,14 @@ const Splash = () => { } } + const secondaryCallToActionIcon = useMemo( + () => + reported ? ( + + ) : undefined, + [reported, ColorPallet.semantic.success] + ) + return ( @@ -380,6 +400,11 @@ const Splash = () => { message={initError?.message || t('Error.Unknown')} onCallToActionLabel={t('Init.Retry')} onCallToActionPressed={handleErrorCallToActionPressed} + secondaryCallToActionTitle={reported ? t('Error.Reported') : t('Error.ReportThisProblem')} + secondaryCallToActionDisabled={reported} + secondaryCallToActionIcon={secondaryCallToActionIcon} + secondaryCallToActionPressed={initError ? report : undefined} + showVersionFooter /> ) : ( diff --git a/app/src/services/attestation.ts b/app/src/services/attestation.ts index 34e0d500..f88ef0c1 100644 --- a/app/src/services/attestation.ts +++ b/app/src/services/attestation.ts @@ -8,12 +8,12 @@ import { ProofState, ProofEventTypes, ProofExchangeRecord, - BaseLogger, ConnectionRecord, } from '@credo-ts/core' import { BifoldError, BifoldAgent, + BifoldLogger, AttestationEventTypes, AttestationMonitor as AttestationMonitorI, } from '@hyperledger/aries-bifold-core' @@ -150,7 +150,7 @@ export class AttestationMonitor implements AttestationMonitorI { private offerSubscription?: Subscription private agent?: Agent private options: AttestationMonitorOptions - private log?: BaseLogger + private log?: BifoldLogger private _attestationWorkflowInProgress = false private _shouldHandleProofRequestAutomatically = false private _proofRequest?: ProofExchangeRecord @@ -158,7 +158,7 @@ export class AttestationMonitor implements AttestationMonitorI { // take in options, agent, and logger. Options should include the attestation service URL // and the proof to watch for along with the cred_ef_id of the attestation credentials. - public constructor(logger: BaseLogger, options: AttestationMonitorOptions) { + public constructor(logger: BifoldLogger, options: AttestationMonitorOptions) { this.log = logger this.options = options const { shouldHandleProofRequestAutomatically } = options diff --git a/yarn.lock b/yarn.lock index de8767a7..fa6ff669 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3253,9 +3253,9 @@ __metadata: languageName: node linkType: hard -"@hyperledger/aries-bifold-core@npm:1.0.0-alpha.391": - version: 1.0.0-alpha.391 - resolution: "@hyperledger/aries-bifold-core@npm:1.0.0-alpha.391" +"@hyperledger/aries-bifold-core@npm:1.0.0-alpha.395, @hyperledger/aries-bifold-core@npm:^1.0.0-alpha.395+99c753a2": + version: 1.0.0-alpha.395 + resolution: "@hyperledger/aries-bifold-core@npm:1.0.0-alpha.395" peerDependencies: "@credo-ts/anoncreds": 0.5.11 "@credo-ts/askar": 0.5.11 @@ -3331,13 +3331,21 @@ __metadata: uuid: ^9.0.0 bin: bifold: bin/bifold - checksum: 8d74a2baab46cd9d3f73bee6c6d89b6591ccc9d0d71af5cc3ef5e7241604c7490255225dfb172a461ec9522071fc8c9a6e244644834268697b4e32f743ad94fc + checksum: 8a77e4507938d4d794c141a402aae7957ab316bdd41404f78dda2dc031fd8d248578f565017360a7ef28552afae32f624955429d519ea4ee194e757d82c837a3 languageName: node linkType: hard -"@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.391": - version: 1.0.0-alpha.391 - resolution: "@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.391" +"@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.395": + version: 1.0.0-alpha.395 + resolution: "@hyperledger/aries-bifold-remote-logs@npm:1.0.0-alpha.395" + dependencies: + "@credo-ts/core": "npm:0.5.11" + "@hyperledger/aries-bifold-core": "npm:^1.0.0-alpha.395+99c753a2" + axios: "npm:^1.4.0" + buffer: "npm:^6.0.3" + react: "npm:18.2.0" + react-native: "npm:0.72.5" + react-native-logs: "npm:^5.1.0" peerDependencies: "@credo-ts/core": 0.5.11 axios: ^1.4.0 @@ -3345,43 +3353,43 @@ __metadata: react: ^18.2.0 react-native: ^0.72.5 react-native-logs: ^5.1.0 - checksum: aa77574c46cf44b6cb097f77b666241e298189fd39deacbbbe538084ac2860400454939effb5f88be9466c21eca2aaf3030c4eac134be518bbb573bb64556cf9 + checksum: f44185576214c3ec3eb8596517e11db0b470433cbd665249e6a17610f9acfcb2e2c22e60bd69f471be0ad6aeccf962ddacbaaa68b7a5a05c3be12361a45335b7 languageName: node linkType: hard -"@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.391": - version: 1.0.0-alpha.391 - resolution: "@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.391" +"@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.395": + version: 1.0.0-alpha.395 + resolution: "@hyperledger/aries-bifold-verifier@npm:1.0.0-alpha.395" peerDependencies: "@credo-ts/anoncreds": 0.5.11 "@credo-ts/core": 0.5.11 "@credo-ts/react-hooks": ^0.6.0 "@hyperledger/anoncreds-shared": 0.2.4 react: ^18.2.0 - checksum: d23703c83d4bfb1eaf8257c1a06b7f24f622de0de845783bb85f4fddad8f4d8795f8ba0abd4acdfd11700806460c081d1218dba8c257dc2afee8d9f478859f97 + checksum: 1f7c651cc3a5ddf3c90ee79581b70bcb335f018498573a5babfaac3cf3ec80447848e1d4c4d3be815c11034894c38eda92421166a9331913b1d8f6defa941a9b languageName: node linkType: hard -"@hyperledger/aries-oca@npm:1.0.0-alpha.391": - version: 1.0.0-alpha.391 - resolution: "@hyperledger/aries-oca@npm:1.0.0-alpha.391" +"@hyperledger/aries-oca@npm:1.0.0-alpha.395": + version: 1.0.0-alpha.395 + resolution: "@hyperledger/aries-oca@npm:1.0.0-alpha.395" dependencies: "@credo-ts/anoncreds": "npm:0.5.11" "@credo-ts/core": "npm:0.5.11" axios: "npm:^1.4.0" lodash.startcase: "npm:^4.4.0" react-native-fs: "npm:^2.16.6" - checksum: 48a4ebea014d127eef9c92c7a419c9bfaa4730eb115ea3660ad727e374ef8ddf94cba1c5151a4616885db990504fc4d88397b092676bc5d1b0baf62d0dfc99fb + checksum: 19760e1a422251192a4cd898e31b1dad18c5423b7e269fbe73fd1ba624daa71854d68e7dcff8819239f69f811103a07c60736a7f9d16b5d8c1ff093d0043f4dd languageName: node linkType: hard -"@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.391": - version: 1.0.0-alpha.391 - resolution: "@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.391" +"@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.395": + version: 1.0.0-alpha.395 + resolution: "@hyperledger/aries-react-native-attestation@npm:1.0.0-alpha.395" peerDependencies: react: "*" react-native: "*" - checksum: 3d8775696ee976a8b7849ae4dc6661149fcd6c682beed5da59af7cd933078f5d250ba8116e6b14a3c94acc6fa22469b32c945f555aa10b8b3028c7588c768aa1 + checksum: de91df1f4ba93a602adc9869fe12ae92cbafa2946644006768fd76008c5e00efc25302f82b82ae43a625fc0c769f8bdaff7a27809d96bc5e1183bd2d7d53ad6b languageName: node linkType: hard @@ -8292,11 +8300,11 @@ __metadata: "@formatjs/intl-relativetimeformat": "npm:9.3.1" "@hyperledger/anoncreds-react-native": "npm:0.2.4" "@hyperledger/aries-askar-react-native": "npm:0.2.3" - "@hyperledger/aries-bifold-core": "npm:1.0.0-alpha.391" - "@hyperledger/aries-bifold-remote-logs": "npm:1.0.0-alpha.391" - "@hyperledger/aries-bifold-verifier": "npm:1.0.0-alpha.391" - "@hyperledger/aries-oca": "npm:1.0.0-alpha.391" - "@hyperledger/aries-react-native-attestation": "npm:1.0.0-alpha.391" + "@hyperledger/aries-bifold-core": "npm:1.0.0-alpha.395" + "@hyperledger/aries-bifold-remote-logs": "npm:1.0.0-alpha.395" + "@hyperledger/aries-bifold-verifier": "npm:1.0.0-alpha.395" + "@hyperledger/aries-oca": "npm:1.0.0-alpha.395" + "@hyperledger/aries-react-native-attestation": "npm:1.0.0-alpha.395" "@hyperledger/indy-vdr-react-native": "npm:0.2.2" "@hyperledger/indy-vdr-shared": "npm:0.2.2" "@react-native-async-storage/async-storage": "npm:1.15.11"