Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement report problem feature, revert pn change #2322

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

job is now specified by the remote logger, if we also specify it here, every job will be the same whether they are incident reports or remote logging sessions. Having separate jobs should allow us to have different lifespans for each job type

system: `${getSystemName()} v${getSystemVersion()}`,
},
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
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)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm hoping this reverted line will fix the issue Shel mentioned that happens during SauceLabs app initialization

}

// 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
25 changes: 21 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 Down Expand Up @@ -380,6 +392,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={reported ? <Icon style={{ marginRight: 8 }} name={'check-circle'} size={18} color={ColorPallet.semantic.success} /> : undefined}
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
Loading