Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3379474
D10931.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D10931.diff
View Options
diff --git a/lib/actions/report-actions.js b/lib/actions/report-actions.js
--- a/lib/actions/report-actions.js
+++ b/lib/actions/report-actions.js
@@ -1,8 +1,14 @@
// @flow
-import type { AuthMetadata } from '../shared/identity-client-context';
+import * as React from 'react';
+
+import {
+ IdentityClientContext,
+ type AuthMetadata,
+} from '../shared/identity-client-context.js';
import type {
ClientReportCreationRequest,
+ ReportsServiceSendReportsAction,
ReportCreationResponse,
} from '../types/report-types.js';
import { sendReports as callSendReports } from '../utils/reports-service.js';
@@ -27,6 +33,22 @@
return { id };
};
+function useSendReports(): ReportsServiceSendReportsAction {
+ const identityContext = React.useContext(IdentityClientContext);
+ const getAuthMetadata = identityContext?.getAuthMetadata;
+
+ return React.useCallback(
+ async request => {
+ let authMetadata;
+ if (getAuthMetadata) {
+ authMetadata = await getAuthMetadata();
+ }
+ return callSendReports(request, authMetadata);
+ },
+ [getAuthMetadata],
+ );
+}
+
const sendReportsActionTypes = Object.freeze({
started: 'SEND_REPORTS_STARTED',
success: 'SEND_REPORTS_SUCCESS',
@@ -40,4 +62,5 @@
sendReport,
sendReportsActionTypes,
queueReportsActionType,
+ useSendReports,
};
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
@@ -2,18 +2,21 @@
import * as React from 'react';
-import { sendReportsActionTypes } from '../actions/report-actions.js';
+import {
+ sendReportsActionTypes,
+ useSendReports,
+} from '../actions/report-actions.js';
import { queuedReports as queuedReportsSelector } from '../selectors/socket-selectors.js';
import {
type ClientReportCreationRequest,
type ClearDeliveredReportsPayload,
+ type ReportsServiceSendReportsAction,
} from '../types/report-types.js';
import {
type DispatchActionPromise,
useDispatchActionPromise,
} from '../utils/redux-promise-utils.js';
import { useSelector } from '../utils/redux-utils.js';
-import { sendReports } from '../utils/reports-service.js';
type BaseProps = {
+canSendReports: boolean,
@@ -22,6 +25,7 @@
...BaseProps,
+queuedReports: $ReadOnlyArray<ClientReportCreationRequest>,
+dispatchActionPromise: DispatchActionPromise,
+ +sendReports: ReportsServiceSendReportsAction,
};
class ReportHandler extends React.PureComponent<Props> {
componentDidMount() {
@@ -69,7 +73,7 @@
async sendReports(
reports: $ReadOnlyArray<ClientReportCreationRequest>,
): Promise<ClearDeliveredReportsPayload> {
- await sendReports(reports);
+ await this.props.sendReports(reports);
return { reports };
}
}
@@ -78,12 +82,14 @@
React.memo<BaseProps>(function ConnectedReportHandler(props) {
const queuedReports = useSelector(queuedReportsSelector);
const dispatchActionPromise = useDispatchActionPromise();
+ const callSendReports = useSendReports();
return (
<ReportHandler
{...props}
queuedReports={queuedReports}
dispatchActionPromise={dispatchActionPromise}
+ sendReports={callSendReports}
/>
);
});
diff --git a/lib/types/report-types.js b/lib/types/report-types.js
--- a/lib/types/report-types.js
+++ b/lib/types/report-types.js
@@ -204,6 +204,9 @@
export type ReportsServiceSendReportsResponse = {
+reportIDs: $ReadOnlyArray<string>,
};
+export type ReportsServiceSendReportsAction = (
+ request: ReportsServiceSendReportsRequest,
+) => Promise<ReportsServiceSendReportsResponse>;
// Keyserver specific types
type ReportInfo = {
diff --git a/native/crash.react.js b/native/crash.react.js
--- a/native/crash.react.js
+++ b/native/crash.react.js
@@ -155,21 +155,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 commCoreModule.getCommServicesAuthMetadata();
+ 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,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Nov 28, 4:27 PM (21 h, 41 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2594418
Default Alt Text
D10931.diff (5 KB)
Attached To
Mode
D10931: [lib][native] Pass CSAT to Reports endpoint
Attached
Detach File
Event Timeline
Log In to Comment