Browse Source

Allow users to generate some useful debug information in a zip file

pull/1473/head
Samuel Attard 6 years ago
parent
commit
938fb2293e
  1. 4
      ISSUE_TEMPLATE.md
  2. 1
      package.json
  3. 2
      src/index.js
  4. 3
      src/inject/generic/core/goToURL.js
  5. 62
      src/main/features/core/debug.js
  6. 1
      src/main/features/core/index.js

4
ISSUE_TEMPLATE.md

@ -9,6 +9,10 @@ Before you click that big tempting "Submit New Issue" button though, can you qui
If you have done those 3 things go ahead and fill out the information below.
Once again, thanks for taking the time to submit an issue
If appropriate please attach the DEBUG information zip file that you can generate by following the instructions in the FAQ
(https://github.com/MarshallOfSound/Google-Play-Music-Desktop-Player-UNOFFICIAL-/wiki/FAQ)
-->
**OS:**

1
package.json

@ -45,6 +45,7 @@
"homepage": "http://www.googleplaymusicdesktopplayer.com",
"license": "MIT",
"dependencies": {
"archiver": "^1.0.1",
"auto-launch": "^3.0.0",
"electron": "1.3.2",
"electron-chromecast": "^1.0.14",

2
src/index.js

@ -67,7 +67,7 @@ updateShortcuts();
global.Logger = new (winston.Logger)({
transports: [
new (winston.transports.File)({
filename: path.resolve(app.getPath('userData'), 'gpmdc.log'),
filename: path.resolve(app.getPath('userData'), 'gpmdp.log'),
level: defaultFileLogLevel,
maxsize: 5000000,
maxfiles: 2,

3
src/inject/generic/core/goToURL.js

@ -14,6 +14,8 @@ const parseURL = (url) => {
setTimeout(() => {
remote.app.quit();
}, 500);
} else if (url === 'DEBUG_INFO') {
Emitter.fire('generateDebugInfo');
}
if (!/https:\/\/play\.google\.com\/music\/listen/g.test(url)) return;
document.querySelector('webview').executeJavaScript(`window.location = "${url}"`);
@ -30,6 +32,7 @@ window.addEventListener('load', () => {
modal.openModal({
dismissible: true,
});
URLInput.focus();
});
URLButton.click(() => {

62
src/main/features/core/debug.js

@ -0,0 +1,62 @@
import { app, shell } from 'electron';
import archiver from 'archiver';
import fs from 'fs';
import os from 'os';
import path from 'path';
const packageJSON = require(path.resolve(__dirname, '../../../..', 'package.json'));
Emitter.on('generateDebugInfo', () => {
const debugInfo =
`Dump Details:
Timestamp: ${new Date()}
App Details:
Version: ${packageJSON.version}
Electron Version: ${packageJSON.dependencies.electron}
Development Build: ${fs.existsSync(path.resolve(__dirname, '../../../..', 'circle.yml')) ? 'true' : 'false'}
Operating System Details:
OS: ${os.platform()}
OS Version: ${os.release()}
OS Arch: ${os.arch()}
System Memory: ${os.totalmem()}
`;
const debugFolder = path.resolve(os.tmpdir(), 'gpmdp_debug_info');
if (!fs.existsSync(debugFolder)) fs.mkdirSync(debugFolder);
const zip = archiver('zip');
const output = fs.createWriteStream(path.resolve(debugFolder, 'debug_info.zip'));
const toRemove = [];
const addStringToZip = (name, data) => {
fs.writeFileSync(path.resolve(debugFolder, name), data);
zip.file(path.resolve(debugFolder, name), {
name,
});
toRemove.push(path.resolve(debugFolder, name));
};
const addFileToZip = (filePath) => {
zip.file(filePath, {
name: path.basename(filePath),
});
};
output.on('close', () => {
toRemove.forEach((removePath) => {
fs.unlinkSync(removePath);
});
shell.showItemInFolder(path.resolve(debugFolder, 'debug_info.zip'));
});
zip.on('error', (err) => {
Logger.error(err);
});
zip.pipe(output);
addStringToZip('install.txt', debugInfo.replace(/\n/g, os.EOL));
addStringToZip('settings.json', JSON.stringify(Object.assign({}, Settings.data, { lastFMKey: 'HIDDEN' }), null, 4));
addFileToZip(path.resolve(app.getPath('userData'), 'gpmdp.log'));
if (process.platform === 'win32') {
addFileToZip(path.resolve(process.env['LOCALAPPDATA'], 'GPMDP_3', 'SquirrelSetup.log')); // eslint-disable-line
}
zip.finalize();
});

1
src/main/features/core/index.js

@ -2,6 +2,7 @@ import './keyboardShortcuts';
import './persistAppState';
import './controlBar';
import './customTheme';
import './debug';
import './desktopSettings';
import './errorHandler';
import './tray';

Loading…
Cancel
Save