Fix issue where file / link export accidentally included support request details

Summary: When doing a Flipper trace export through the app menu (not the support form), the export still contained a support request details section, with the default data of a bug report. That doesn't make any sense and is confusing, so this change makes sure the report is only included if it is supported through the supportRequestForm

Reviewed By: passy

Differential Revision: D19499408

fbshipit-source-id: ff7a5333f2045f2465966dffa0c5fb03aaeaceb8
This commit is contained in:
Michel Weststrate
2020-01-27 07:20:53 -08:00
committed by Facebook Github Bot
parent 82e65c68dc
commit 6218b00e15
3 changed files with 14 additions and 9 deletions

View File

@@ -110,6 +110,7 @@ export default class ShareSheetExportFile extends Component<Props, State> {
exportStoreToFile( exportStoreToFile(
this.props.file, this.props.file,
this.store, this.store,
false,
this.idler, this.idler,
(msg: string) => { (msg: string) => {
if (this.state.runInBackground) { if (this.state.runInBackground) {

View File

@@ -125,7 +125,7 @@ export default class ShareSheetExportUrl extends Component<Props, State> {
} }
}; };
const {serializedString, errorArray} = await reportPlatformFailures( const {serializedString, errorArray} = await reportPlatformFailures(
exportStore(this.store, this.idler, statusUpdate), exportStore(this.store, false, this.idler, statusUpdate),
`${EXPORT_FLIPPER_TRACE_EVENT}:UI_LINK`, `${EXPORT_FLIPPER_TRACE_EVENT}:UI_LINK`,
); );
const uploadMarker = `${EXPORT_FLIPPER_TRACE_EVENT}:upload`; const uploadMarker = `${EXPORT_FLIPPER_TRACE_EVENT}:upload`;

View File

@@ -580,6 +580,7 @@ export async function getStoreExport(
export async function exportStore( export async function exportStore(
store: MiddlewareAPI, store: MiddlewareAPI,
includeSupportDetails?: boolean,
idler?: Idler, idler?: Idler,
statusUpdate?: (msg: string) => void, statusUpdate?: (msg: string) => void,
): Promise<{serializedString: string; errorArray: Array<Error>}> { ): Promise<{serializedString: string; errorArray: Array<Error>}> {
@@ -593,13 +594,15 @@ export async function exportStore(
idler, idler,
); );
if (exportData != null) { if (exportData != null) {
exportData.supportRequestDetails = { if (includeSupportDetails) {
...state.supportForm?.supportFormV2, exportData.supportRequestDetails = {
appName: ...state.supportForm?.supportFormV2,
state.connections.selectedApp == null appName:
? '' state.connections.selectedApp == null
: deconstructClientId(state.connections.selectedApp).app, ? ''
}; : deconstructClientId(state.connections.selectedApp).app,
};
}
statusUpdate && statusUpdate('Serializing Flipper data...'); statusUpdate && statusUpdate('Serializing Flipper data...');
const serializedString = JSON.stringify(exportData); const serializedString = JSON.stringify(exportData);
@@ -622,10 +625,11 @@ export async function exportStore(
export const exportStoreToFile = ( export const exportStoreToFile = (
exportFilePath: string, exportFilePath: string,
store: MiddlewareAPI, store: MiddlewareAPI,
includeSupportDetails: boolean,
idler?: Idler, idler?: Idler,
statusUpdate?: (msg: string) => void, statusUpdate?: (msg: string) => void,
): Promise<{errorArray: Array<Error>}> => { ): Promise<{errorArray: Array<Error>}> => {
return exportStore(store, idler, statusUpdate).then( return exportStore(store, includeSupportDetails, idler, statusUpdate).then(
({serializedString, errorArray}) => { ({serializedString, errorArray}) => {
return promisify(fs.writeFile)(exportFilePath, serializedString).then( return promisify(fs.writeFile)(exportFilePath, serializedString).then(
() => { () => {