diff --git a/lib/socket/report-handler.react.js b/lib/socket/report-handler.react.js --- a/lib/socket/report-handler.react.js +++ b/lib/socket/report-handler.react.js @@ -4,6 +4,10 @@ import { sendReportsActionTypes } from '../actions/report-actions.js'; import { queuedReports as queuedReportsSelector } from '../selectors/socket-selectors.js'; +import { + IdentityClientContext, + type IdentityClientContextType, +} from '../shared/identity-client-context.js'; import { type ClientReportCreationRequest, type ClearDeliveredReportsPayload, @@ -22,6 +26,7 @@ ...BaseProps, +queuedReports: $ReadOnlyArray, +dispatchActionPromise: DispatchActionPromise, + +identityContext: ?IdentityClientContextType, }; class ReportHandler extends React.PureComponent { componentDidMount() { @@ -69,7 +74,9 @@ async sendReports( reports: $ReadOnlyArray, ): Promise { - await sendReports(reports); + const { identityContext } = this.props; + const authMetadata = await identityContext?.getAuthMetadata(); + await sendReports(reports, authMetadata); return { reports }; } } @@ -78,12 +85,14 @@ React.memo(function ConnectedReportHandler(props) { const queuedReports = useSelector(queuedReportsSelector); const dispatchActionPromise = useDispatchActionPromise(); + const identityContext = React.useContext(IdentityClientContext); return ( ); }); diff --git a/native/crash.react.js b/native/crash.react.js --- a/native/crash.react.js +++ b/native/crash.react.js @@ -19,6 +19,10 @@ sendReport, } from 'lib/actions/report-actions.js'; import { logOutActionTypes, useLogOut } from 'lib/actions/user-actions.js'; +import { + IdentityClientContext, + type IdentityClientContextType, +} from 'lib/shared/identity-client-context.js'; import type { KeyserverLogOutResult } from 'lib/types/account-types.js'; import { type ErrorData, reportTypes } from 'lib/types/report-types.js'; import { actionLogger } from 'lib/utils/action-logger.js'; @@ -54,6 +58,7 @@ // async functions that hit server APIs +logOut: () => Promise, +crashReportingEnabled: boolean, + +identityContext: ?IdentityClientContextType, }; type State = { +errorReportID: ?string, @@ -155,21 +160,25 @@ actions: actionLogger.actions, }: any); const sanitizedReduxReport = sanitizeReduxReport(rawReduxReport); - const result = await sendReport({ - type: reportTypes.ERROR, - platformDetails: { - platform: Platform.OS, - codeVersion, - stateVersion: persistConfig.version, + const authMetadata = await this.props.identityContext?.getAuthMetadata(); + const result = await sendReport( + { + type: reportTypes.ERROR, + platformDetails: { + platform: Platform.OS, + codeVersion, + stateVersion: persistConfig.version, + }, + errors: this.props.errorData.map(data => ({ + errorMessage: data.error.message, + stack: data.error.stack, + componentStack: data.info && data.info.componentStack, + })), + ...sanitizedReduxReport, + id: generateReportID(), }, - errors: this.props.errorData.map(data => ({ - errorMessage: data.error.message, - stack: data.error.stack, - componentStack: data.info && data.info.componentStack, - })), - ...sanitizedReduxReport, - id: generateReportID(), - }); + authMetadata, + ); this.setState({ errorReportID: result.id, doneWaiting: true, @@ -282,12 +291,14 @@ const dispatchActionPromise = useDispatchActionPromise(); const callLogOut = useLogOut(); const crashReportingEnabled = useIsReportEnabled('crashReports'); + const identityContext = React.useContext(IdentityClientContext); return ( ); },