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

Add UI version to support log data #322

Merged
merged 5 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion packages/code-studio/src/log/LogExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function makeSafeToStringify(
return output;
}

function getReduxDataString() {
function getReduxDataString(): string {
const reduxData = store.getState();
return JSON.stringify(
makeSafeToStringify(reduxData),
Expand All @@ -72,9 +72,11 @@ function getReduxDataString() {

/**
* Export support logs with the given name.
* @param metadata Any extra metadata to be written to a metadata file
* @param fileNamePrefix The zip file name without the .zip extension. Ex: test will be saved as test.zip
*/
export async function exportLogs(
metadata = {},
mattrunyon marked this conversation as resolved.
Show resolved Hide resolved
fileNamePrefix = `${dh.i18n.DateTimeFormat.format(
FILENAME_DATE_FORMAT,
new Date()
Expand All @@ -84,6 +86,7 @@ export async function exportLogs(
const folder = zip.folder(fileNamePrefix) as JSZip;
folder.file('console.txt', logHistory.getFormattedHistory());
folder.file('redux.json', getReduxDataString());
folder.file('metadata', JSON.stringify(metadata));
mofojed marked this conversation as resolved.
Show resolved Hide resolved

const blob = await zip.generateAsync({ type: 'blob' });
const link = document.createElement('a');
Expand Down
11 changes: 9 additions & 2 deletions packages/code-studio/src/settings/SettingsMenu.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,15 @@ export class SettingsMenu extends Component {
}
}

static getVersion() {
return process.env.REACT_APP_VERSION;
}

static handleExportSupportLogs() {
exportLogs();
const metadata = {
uiVersion: SettingsMenu.getVersion(),
mattrunyon marked this conversation as resolved.
Show resolved Hide resolved
};
exportLogs(metadata);
}

constructor(props) {
Expand Down Expand Up @@ -68,7 +75,7 @@ export class SettingsMenu extends Component {
}

render() {
const version = process.env.REACT_APP_VERSION;
const version = SettingsMenu.getVersion();
const supportLink = process.env.REACT_APP_SUPPORT_LINK;
const docsLink = process.env.REACT_APP_DOCS_LINK;

Expand Down