Skip to content

Commit d400ac5

Browse files
authored
Revert "Downloadable logs (#152)"
This reverts commit ea4ab36.
1 parent c0de461 commit d400ac5

File tree

5 files changed

+31
-97
lines changed

5 files changed

+31
-97
lines changed

src/components/crash-message/crash-message.jsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import {FormattedMessage} from 'react-intl';
55

66
import styles from './crash-message.css';
77
import reloadIcon from './reload.svg';
8-
import { downloadLogs } from '../../lib/pm-log-capture.js';
98

109
const CrashMessage = props => (
1110
<div className={styles.crashWrapper}>
@@ -26,7 +25,7 @@ const CrashMessage = props => (
2625
defaultMessage={'We are so sorry, but it looks like the page has crashed.' +
2726
' Please refresh your page to try' +
2827
' again.' +
29-
' If the problem persists, please report the downloadable error below to our Discord.'}
28+
' If the problem persists, please report this error to our Discord.'}
3029
description="Message to inform the user that page has crashed."
3130
id="tw.gui.crashMessage.description"
3231
/>
@@ -58,12 +57,6 @@ const CrashMessage = props => (
5857
id="gui.crashMessage.reload"
5958
/>
6059
</button>
61-
<button
62-
className={styles.reloadButton}
63-
onClick={downloadLogs}
64-
>
65-
{'Download Error'}
66-
</button>
6760
</Box>
6861
</div>
6962
);

src/components/menu-bar/menu-bar.jsx

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ import sharedMessages from '../../lib/shared-messages';
8585
import SeeInsideButton from './tw-see-inside.jsx';
8686
import { notScratchDesktop } from '../../lib/isScratchDesktop.js';
8787

88-
import { downloadLogs } from '../../lib/pm-log-capture.js';
88+
//import { consoleLogs } from '../../lib/pm-log-capture.js';
8989

9090
const ariaMessages = defineMessages({
9191
language: {
@@ -207,7 +207,6 @@ class MenuBar extends React.Component {
207207
'handleClickPackager',
208208
'handleClickRestorePoints',
209209
'handleClickSeeCommunity',
210-
'handleClickDownloadLogs',
211210
'handleClickShare',
212211
'handleKeyPress',
213212
'handleLanguageMouseUp',
@@ -423,7 +422,21 @@ class MenuBar extends React.Component {
423422
this.props.onRequestCloseAbout();
424423
};
425424
}
426-
handleClickDownloadLogs() { downloadLogs(); }
425+
/*
426+
- hidden until this is actually helpful for developers
427+
- unhide when a solution is found for not blocking error tracking/using 3rd parties
428+
handleClickDownloadLogs() {
429+
const str = JSON.stringify(consoleLogs);
430+
const a = document.createElement('a');
431+
a.style.display = 'none';
432+
document.body.append(a);
433+
const url = window.URL.createObjectURL(new Blob([str]));
434+
a.href = url;
435+
a.download = 'pm-log-trace.json';
436+
a.click();
437+
window.URL.revokeObjectURL(url);
438+
a.remove();
439+
}*/
427440
render() {
428441
const saveNowMessage = (
429442
<FormattedMessage
@@ -847,9 +860,6 @@ class MenuBar extends React.Component {
847860
id="pm.menuBar.moreSettings"
848861
/>
849862
</MenuItem>
850-
<MenuItem onClick={this.handleClickDownloadLogs}>
851-
Download Logs
852-
</MenuItem>
853863
</MenuSection>
854864
</MenuBarMenu>
855865
</div>

src/lib/analytics.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,3 @@ const GoogleAnalytics = {
44
};
55

66
export default GoogleAnalytics;
7-

src/lib/pm-log-capture.js

Lines changed: 12 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
import JSZip from 'jszip';
2-
import uid from './uid';
3-
41
/**
52
* String.prototype.indexOf, but it returns NaN not -1 on failure
63
* @param {string} str The string to check in
@@ -59,7 +56,7 @@ const push = (type, message, trace) => {
5956
trace
6057
});
6158
};
62-
const _parseFirefoxStack = stack => stack.split('\n').slice(1)
59+
const _parseFirefoxStack = stack => stack.split('\n')
6360
.map(line => {
6461
const at = line.indexOf('@');
6562
const secondCol = line.lastIndexOf(':');
@@ -90,7 +87,7 @@ const _parseFirefoxStack = stack => stack.split('\n').slice(1)
9087
origin
9188
};
9289
});
93-
const _parseChromeStack = stack => stack.split('\n').slice(2)
90+
const _parseChromeStack = stack => stack.split('\n').slice(1)
9491
.map(line => {
9592
// we have no use for the human readable fluff
9693
line = line.slice(7);
@@ -145,83 +142,18 @@ const parseStack = (stack, url, line, column) => {
145142
if (stack.split('\n', 2)[0].includes('@')) return _parseFirefoxStack(stack);
146143
return _parseChromeStack(stack);
147144
};
148-
const downloadLogs = async () => {
149-
const files = new JSZip();
150-
files.file('logs.json', JSON.stringify(consoleLogs));
151-
const index = {};
152-
// get files
153-
// sadly, this may just dead ass fail to get files due to blob lifecycle
154-
// and i dont want to make these files get stored at runtime, cause poopy doo doo ram
155-
for (const log of consoleLogs) {
156-
for (const trace of log.trace) {
157-
if (index[trace.url]) continue;
158-
const id = uid();
159-
const content = await fetch(trace.url)
160-
.then(res => res.ok ? res.text() : null)
161-
.catch(() => {});
162-
if (!content) continue;
163-
files.file(id, content);
164-
index[trace.url] = id;
165-
}
166-
}
167-
files.file('index.json', JSON.stringify(index));
168-
let blob = await files.generateAsync({ type: 'blob', compression: 'DEFLATE' });
169-
let filename = 'pm-error-download.pml';
170-
/* actually, this is a bad idea
171-
// if we can, include the project
172-
if (vm) {
173-
filename = 'pm-error-download.pmp';
174-
const archive = vm._saveProjectZip();
175-
archive.file('logs.json', blob);
176-
blob = await archive.generateAsync({
177-
type: 'blob',
178-
mimeType: 'application/x.scratch.sb3',
179-
compression: 'DEFLATE'
180-
});
181-
}
182-
*/
183-
const a = document.createElement('a');
184-
a.style.display = 'none';
185-
document.body.append(a);
186-
const url = window.URL.createObjectURL(blob);
187-
a.href = url;
188-
a.download = filename;
189-
a.click();
190-
window.URL.revokeObjectURL(url);
191-
a.remove();
192-
};
193-
window.downloadLogs = downloadLogs;
194145

195146
window.addEventListener('error', e =>
196147
push('error', e.message, parseStack(`\n${e.error.stack}`, e.filename, e.lineno, e.colno)));
197148
window.addEventListener('unhandledrejection', e => push('promiseError', e.reason, []));
198-
class StackTrace extends Error {
199-
constructor() {
200-
super('');
201-
if (this.stack.split('\n', 2)[0].includes('@'))
202-
this.stack = this.stack
203-
.split('\n')
204-
.slice(2, 3)
205-
.join('\n');
206-
else {
207-
// chrome is weird ngl
208-
const lines = this.stack
209-
.split('\n')
210-
.slice(0, 3);
211-
lines.splice(1, 2);
212-
this.stack = lines.join('\n');
213-
}
214-
}
149+
for (const name of ['log', 'warn', 'error', 'debug', 'info']) {
150+
const item = window.console[name];
151+
window.console[name] = (...args) => {
152+
let stack = [];
153+
if (browserHasStack) stack = parseStack(new Error().stack);
154+
push(name, args, stack);
155+
item(...args);
156+
};
215157
}
216-
if (!String(window.location.href).startsWith(`http://localhost:`)) {
217-
for (const name of ['log', 'warn', 'error', 'debug', 'info']) {
218-
const item = window.console[name];
219-
window.console[name] = (...args) => {
220-
let stack = [];
221-
if (browserHasStack) stack = parseStack(new Error().stack);
222-
push(name, args, stack);
223-
item.call(console, ...args, new StackTrace());
224-
};
225-
}
226-
}
227-
export { consoleLogs, parseStack, push, downloadLogs };
158+
159+
export { consoleLogs, parseStack, push };

src/lib/uid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
* Legal characters for the unique ID.
77
* Should be all on a US keyboard. No XML special characters or control codes.
88
* Removed $ due to issue 251.
9-
* Removed all symbols due to use in files
109
* @private
1110
*/
12-
const soup_ = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
11+
const soup_ = '!#%()*+,-./:;=?@[]^_`{|}~' +
12+
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
1313

1414
/**
1515
* Generate a unique ID, from Blockly. This should be globally unique.

0 commit comments

Comments
 (0)