-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Save logs data in downloads and show meaningful path #40777
Changes from 2 commits
8a27a7d
82788e4
fd8e965
d1bdd49
86b9836
afe7814
c7c14f4
dac895c
3c6c01d
b5e54f9
1a6ac07
f3b9bf4
a9d5766
14fddd0
5fc78ad
27d45bb
ace5f4e
a04a574
2cbb037
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,7 @@ function ClientSideLoggingToolMenu() { | |
onEnableLogging={() => setFile(undefined)} | ||
onDisableLogging={createAndSaveFile} | ||
onShareLogs={shareLogs} | ||
displayPath="/Downloads" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use constant for |
||
/> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,7 @@ function ClientSideLoggingToolMenu() { | |
onEnableLogging={() => setFile(undefined)} | ||
onDisableLogging={createFile} | ||
onShareLogs={shareLogs} | ||
displayPath="/New Expensify" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use constant |
||
/> | ||
); | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,16 @@ import CONST from '@src/CONST'; | |
import ONYXKEYS from '@src/ONYXKEYS'; | ||
import pkg from '../../../package.json'; | ||
|
||
type ProfilingToolMenuOnyxProps = { | ||
type BaseProfilingToolMenuOnyxProps = { | ||
isProfilingInProgress: OnyxEntry<boolean>; | ||
}; | ||
|
||
type ProfilingToolMenuProps = ProfilingToolMenuOnyxProps; | ||
type BaseProfilingToolMenuProps = { | ||
/** Path used to save the file */ | ||
pathToBeUsed: string; | ||
/** Path used to display location of saved file */ | ||
displayPath: string; | ||
} & BaseProfilingToolMenuOnyxProps; | ||
|
||
function formatBytes(bytes: number, decimals = 2) { | ||
if (!+bytes) { | ||
|
@@ -39,7 +44,7 @@ function formatBytes(bytes: number, decimals = 2) { | |
return `${parseFloat((bytes / k ** i).toFixed(dm))} ${sizes[i]}`; | ||
} | ||
|
||
function ProfilingToolMenu({isProfilingInProgress = false}: ProfilingToolMenuProps) { | ||
function BaseProfilingToolMenu({isProfilingInProgress = false, pathToBeUsed, displayPath}: BaseProfilingToolMenuProps) { | ||
const styles = useThemeStyles(); | ||
const [pathIOS, setPathIOS] = useState(''); | ||
const [sharePath, setSharePath] = useState(''); | ||
|
@@ -83,15 +88,16 @@ function ProfilingToolMenu({isProfilingInProgress = false}: ProfilingToolMenuPro | |
[totalMemory, usedMemory], | ||
); | ||
|
||
const newFileName = `Profile_trace_for_${pkg.version}.cpuprofile`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i think this can be moved outside the component |
||
|
||
useEffect(() => { | ||
if (!pathIOS) { | ||
return; | ||
} | ||
|
||
// eslint-disable-next-line @lwc/lwc/no-async-await | ||
const rename = async () => { | ||
const newFileName = `Profile_trace_for_${pkg.version}.cpuprofile`; | ||
const newFilePath = `${RNFS.DocumentDirectoryPath}/${newFileName}`; | ||
const newFilePath = `${pathToBeUsed}/${newFileName}`; | ||
|
||
try { | ||
const fileExists = await RNFS.exists(newFilePath); | ||
|
@@ -117,7 +123,7 @@ function ProfilingToolMenu({isProfilingInProgress = false}: ProfilingToolMenuPro | |
}; | ||
|
||
rename(); | ||
}, [pathIOS]); | ||
}, [pathIOS, newFileName, pathToBeUsed]); | ||
|
||
const onDownloadProfiling = useCallback(() => { | ||
// eslint-disable-next-line @lwc/lwc/no-async-await | ||
|
@@ -153,7 +159,7 @@ function ProfilingToolMenu({isProfilingInProgress = false}: ProfilingToolMenuPro | |
</TestToolRow> | ||
{!!pathIOS && ( | ||
<> | ||
<Text style={[styles.textLabelSupporting, styles.mb4]}>{`path: ${pathIOS}`}</Text> | ||
<Text style={[styles.textLabelSupporting, styles.mb4]}>{`path: ${displayPath}/${newFileName}`}</Text> | ||
<TestToolRow title={translate('initialSettingsPage.troubleshoot.profileTrace')}> | ||
<Button | ||
small | ||
|
@@ -167,10 +173,10 @@ function ProfilingToolMenu({isProfilingInProgress = false}: ProfilingToolMenuPro | |
); | ||
} | ||
|
||
ProfilingToolMenu.displayName = 'ProfilingToolMenu'; | ||
BaseProfilingToolMenu.displayName = 'BaseProfilingToolMenu'; | ||
|
||
export default withOnyx<ProfilingToolMenuProps, ProfilingToolMenuOnyxProps>({ | ||
export default withOnyx<BaseProfilingToolMenuProps, BaseProfilingToolMenuOnyxProps>({ | ||
isProfilingInProgress: { | ||
key: ONYXKEYS.APP_PROFILING_IN_PROGRESS, | ||
}, | ||
})(ProfilingToolMenu); | ||
})(BaseProfilingToolMenu); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import RNFS from 'react-native-fs'; | ||
import BaseProfilingToolMenu from './BaseProfilingToolMenu'; | ||
|
||
function ProfilingToolMenu() { | ||
return ( | ||
<BaseProfilingToolMenu | ||
pathToBeUsed={RNFS.DownloadDirectoryPath} | ||
displayPath="/Downloads" | ||
/> | ||
); | ||
} | ||
|
||
ProfilingToolMenu.displayName = 'ProfilingToolMenu'; | ||
|
||
export default ProfilingToolMenu; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import RNFS from 'react-native-fs'; | ||
import BaseProfilingToolMenu from './BaseProfilingToolMenu'; | ||
|
||
function ProfilingToolMenu() { | ||
return ( | ||
<BaseProfilingToolMenu | ||
pathToBeUsed={RNFS.DocumentDirectoryPath} | ||
displayPath="/New Expensify" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use costant whereever we use |
||
/> | ||
); | ||
} | ||
|
||
ProfilingToolMenu.displayName = 'ProfilingToolMenu'; | ||
|
||
export default ProfilingToolMenu; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we dont need file and displaypath both here, pass the display path (${displayPath}/${file.newFileName}`) only and build it in parent component