Skip to content

Commit

Permalink
feat: implement report problem feature, revert pn change (#2322)
Browse files Browse the repository at this point in the history
Signed-off-by: Bryce McMath <[email protected]>
  • Loading branch information
bryce-mcmath authored Dec 17, 2024
1 parent 6f82780 commit 9de564c
Show file tree
Hide file tree
Showing 13 changed files with 95 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ const App = () => {
translucent={false}
/>
<NetInfo />
<ErrorModal />
<ErrorModal enableReport/>
<WebDisplay
destinationUrl={surveyMonkeyUrl}
exitUrl={surveyMonkeyExitUrl}
Expand Down
3 changes: 0 additions & 3 deletions app/__mocks__/react-native-device-info.ts

This file was deleted.

8 changes: 4 additions & 4 deletions app/container-imp.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Agent, BaseLogger } from '@credo-ts/core'
import { Agent } from '@credo-ts/core'
import {
Container,
TOKENS,
Expand All @@ -23,6 +23,7 @@ import {
PersistentState,
defaultConfig,
InlineErrorPosition,
BifoldLogger,
} from '@hyperledger/aries-bifold-core'
import { RemoteLogger, RemoteLoggerOptions } from '@hyperledger/aries-bifold-remote-logs'
import { getProofRequestTemplates } from '@hyperledger/aries-bifold-verifier'
Expand Down Expand Up @@ -78,7 +79,7 @@ export interface AppState {

export class AppContainer implements Container {
private _container: DependencyContainer
private log?: BaseLogger
private log?: BifoldLogger
private t: TFunction<'translation', undefined>
private navigate: (stack: never, params: never) => void
private setAppState: React.Dispatch<React.SetStateAction<AppState>>
Expand All @@ -90,7 +91,7 @@ export class AppContainer implements Container {
t: TFunction<'translation', undefined>,
navigate: (stack: never, params: never) => void,
useState: [AppState, React.Dispatch<React.SetStateAction<AppState>>],
log?: BaseLogger
log?: BifoldLogger
) {
this._container = bifoldContainer.container.createChildContainer()
this.log = log
Expand All @@ -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()}`,
},
Expand Down
4 changes: 2 additions & 2 deletions app/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions app/jestSetup.js
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 5 additions & 5 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion app/src/hooks/initialize-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions app/src/localization/en/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions app/src/localization/fr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 4 additions & 0 deletions app/src/localization/pt-br/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
33 changes: 29 additions & 4 deletions app/src/screens/Splash.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ 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'
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'
Expand Down Expand Up @@ -110,14 +112,23 @@ const Splash = () => {
const [initOnboardingCount, setInitOnboardingCount] = useState(0)
const [initAgentCount, setInitAgentCount] = useState(0)
const [initErrorType, setInitErrorType] = useState<InitErrorTypes>(InitErrorTypes.Onboarding)
const [initError, setInitError] = useState<Error | null>(null)
const [initError, setInitError] = useState<BifoldError | null>(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'),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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))
}
}

Expand All @@ -350,6 +361,7 @@ const Splash = () => {
store.onboarding.didConsiderBiometry,
navigation,
initAgentCount,
t,
])

const handleErrorCallToActionPressed = () => {
Expand All @@ -361,6 +373,14 @@ const Splash = () => {
}
}

const secondaryCallToActionIcon = useMemo(
() =>
reported ? (
<Icon style={{ marginRight: 8 }} name={'check-circle'} size={18} color={ColorPallet.semantic.success} />
) : undefined,
[reported, ColorPallet.semantic.success]
)

return (
<SafeAreaView style={styles.screenContainer}>
<ScrollView contentContainerStyle={styles.scrollContentContainer}>
Expand All @@ -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
/>
</View>
) : (
Expand Down
6 changes: 3 additions & 3 deletions app/src/services/attestation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -150,15 +150,15 @@ 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
// private _currentWorkflowState?: typeof AttestationEventTypes

// 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
Expand Down
58 changes: 33 additions & 25 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -3331,57 +3331,65 @@ __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
buffer: ^6.0.3
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

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 9de564c

Please sign in to comment.