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

Feedback overhaul #16638

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
55 changes: 31 additions & 24 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: ''
assignees: ''
# Bug/Crash Report: {{title}}

---
## System Information
- **Application Version**: {{appVersion}}
- **Platform**: {{platformVersion}}
- **Architecture**: {{architecture}}
- **Process**: renderer

## Error Message
{{errorMessage}}

## Context
- **Game/Mode**: {{gameMode}}
- **Extension Version**: {{extensionVersion}}

**Describe the bug**
A clear and concise description of what the bug is.
## External File (if applicable)
- **File**: [Archive Attachment]({{externalFileUrl}})

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error
## Steps to Reproduce
{{steps}}

**Expected behavior**
A clear and concise description of what you expected to happen.
## Expected Behavior
{{expectedBehavior}}

**Screenshots**
If applicable, add screenshots to help explain your problem.
## Actual Behavior
{{actualBehavior}}

## Reported By
- **User**: {{reportedBy}}

---

**Platform (please complete the following information):**
- OS: [e.g. Windows 10]
- Vortex Version [e.g. 0.16.12]
### Additional Information:
- **Date Reported**:
{{dateReported}}

**Additional context**
Add any other context about the problem here.
- **Additional Context**:
{{additionalContext}}
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"dependencies": {
"@electron/remote": "^2.0.12",
"@msgpack/msgpack": "^2.7.0",
"@nexusmods/nexus-api": "Nexus-Mods/node-nexus-api",
"@nexusmods/nexus-api": "Nexus-Mods/node-nexus-api#new-feedback-system",
"bbcode-to-react": "TanninOne/bbcode-to-react",
"big.js": "^5.2.2",
"bluebird": "^3.7.2",
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -197,15 +197,15 @@
"tslint-eslint-rules": "^5.4.0",
"tslint-react": "^4.1.0",
"typescript": "^4.4.3",
"vortex-api": "Nexus-Mods/vortex-api#fblo_api_update_1.8.11",
"vortex-api": "Nexus-Mods/vortex-api#api_update_1.8.12",
"webpack": "^5.76.0",
"webpack-cli": "^4.8.0",
"webpack-node-externals": "^3.0.0"
},
"dependencies": {
"@electron/remote": "^2.0.12",
"@msgpack/msgpack": "^2.7.0",
"@nexusmods/nexus-api": "Nexus-Mods/node-nexus-api",
"@nexusmods/nexus-api": "Nexus-Mods/node-nexus-api#new-feedback-system",
"bbcode-to-react": "TanninOne/bbcode-to-react",
"big.js": "^5.2.2",
"bluebird": "^3.7.2",
Expand Down
21 changes: 17 additions & 4 deletions src/extensions/nexus_integration/eventHandlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { activeGameId, currentGame, downloadPathForGame, gameById } from '../../
import { getSafe } from '../../util/storeHelper';
import { toPromise, truthy } from '../../util/util';

import { IFeedbackReport } from '../../types/IFeedbackReport';

import { resolveCategoryName } from '../category_management';
import { AlreadyDownloaded, DownloadIsHTML } from '../download_management/DownloadManager';
import { SITE_ID } from '../gamemode_management/constants';
Expand Down Expand Up @@ -646,12 +648,23 @@ export function onDownloadUpdate(api: IExtensionApi,
};
}

export function onSubmitFeedback(nexus: Nexus) {
export function onSubmitFeedback(api: IExtensionApi, nexus: Nexus) {
return (title: string, message: string, hash: string, feedbackFiles: string[],
anonymous: boolean, callback: (err: Error, response?: IFeedbackResponse) => void) => {
submitFeedback(nexus, title, message, feedbackFiles, anonymous, hash)
.then(response => callback(null, response))
.catch(err => callback(err));
const report: IFeedbackReport = {
title,
message,
files: feedbackFiles,
hash,
callback,
}

api.events.emit('report-feedback', report);
// Vortex used to send feedback reports to the Nexus Mods admin area
// for curation. Left this here for posterity.
// submitFeedback(nexus, title, message, feedbackFiles, anonymous, hash)
// .then(response => callback(null, response))
// .catch(err => callback(err));
};
}

Expand Down
4 changes: 2 additions & 2 deletions src/extensions/nexus_integration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -885,7 +885,7 @@ function extendAPI(api: IExtensionApi, nexus: NexusT): INexusAPIExtension
nexusGetLatestMods: eh.onGetLatestMods(api, nexus),
nexusGetTrendingMods: eh.onGetTrendingMods(api, nexus),
nexusEndorseMod: eh.onEndorseMod(api, nexus),
nexusSubmitFeedback: eh.onSubmitFeedback(nexus),
nexusSubmitFeedback: eh.onSubmitFeedback(api, nexus),
nexusSubmitCollection: eh.onSubmitCollection(nexus),
nexusModUpdate: eh.onModUpdate(api, nexus),
nexusOpenCollectionPage: eh.onOpenCollectionPage(api),
Expand Down Expand Up @@ -1038,7 +1038,7 @@ function once(api: IExtensionApi, callbacks: Array<(nexus: NexusT) => void>) {
api.onAsync('get-trending-mods', eh.onGetTrendingMods(api, nexus));
api.events.on('refresh-user-info', eh.onRefreshUserInfo(nexus, api));
api.events.on('endorse-mod', eh.onEndorseMod(api, nexus));
api.events.on('submit-feedback', eh.onSubmitFeedback(nexus));
api.events.on('submit-feedback', eh.onSubmitFeedback(api, nexus));
api.events.on('submit-collection', eh.onSubmitCollection(nexus));
api.events.on('mod-update', eh.onModUpdate(api, nexus));
api.events.on('open-collection-page', eh.onOpenCollectionPage(api));
Expand Down
3 changes: 3 additions & 0 deletions src/extensions/nexus_integration/selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import { truthy } from '../../util/util';
export const apiKey = (state: IState) =>
getSafe(state, ['confidential', 'account', 'nexus', 'APIKey'], undefined);

export const userName = (state: IState) =>
getSafe(state, ['confidential', 'account', 'nexus', 'userInfo', 'name'], undefined);

export const isLoggedIn = (state: IState) => {
const APIKEY = state.confidential.account['nexus']?.APIKey;
const OAuthCredentials = state.confidential.account['nexus']?.OAuthCredentials;
Expand Down
1 change: 1 addition & 0 deletions src/extensions/nexus_integration/util.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable */
import * as RemoteT from '@electron/remote';
import Nexus, {
EndorsedStatus, ICollectionQuery, IEndorsement, IFileInfo, IGameListEntry, IModInfo,
Expand Down
2 changes: 2 additions & 0 deletions src/extensions/nexus_integration/util/submitFeedback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import NexusT, { IFeedbackResponse } from '@nexusmods/nexus-api';
import Promise from 'bluebird';
import ZipT = require('node-7z');
import { tmpName } from 'tmp';
import { util } from '../../..';

function zipFiles(files: string[]): Promise<string> {
if (files.length === 0) {
Expand All @@ -26,6 +27,7 @@ function zipFiles(files: string[]): Promise<string> {

function submitFeedback(nexus: NexusT, title: string, message: string, feedbackFiles: string[],
anonymous: boolean, hash: string): Promise<IFeedbackResponse> {
return Promise.reject(new util.NotSupportedError());
let archive: string;
return zipFiles(feedbackFiles)
.then(tmpPath => {
Expand Down
3 changes: 3 additions & 0 deletions src/types/IErrorContext.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface IErrorContext {
[id: string]: string;
}
15 changes: 15 additions & 0 deletions src/types/IFeedbackReport.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// feedback-report event handler expects this structure.
import { IError } from './IError';
import { IErrorContext } from './IErrorContext';
export interface IFeedbackReport {
title: string;
message: string;
files: string[];
sourceProcess?: string;
reporterProcess?: string;
labels?: string[];
context?: IErrorContext;
error?: IError;
hash?: string;
callback?: (err: Error, response?: any) => void;
}
4 changes: 4 additions & 0 deletions src/types/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ export { IStarterInfo } from '../util/StarterInfo';

export { IRegisteredExtension } from '../util/ExtensionManager';

export { IErrorContext } from './IErrorContext';
export { IError } from './IError';
export { IFeedbackReport } from './IFeedbackReport';

export { IAvailableExtension, IExtension } from '../extensions/extension_manager/types';
export {
LoadOrder,
Expand Down
2 changes: 1 addition & 1 deletion src/util/ExtensionManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { Archive } from './archives';
import { COMPANY_ID } from './constants';
import { MissingDependency, NotSupportedError,
ProcessCanceled, ThirdPartyError, TimeoutError, UserCanceled } from './CustomErrors';
import { disableErrorReport, isOutdated } from './errorHandling';
import { disableErrorReport, isOutdated, setErrorContext } from './errorHandling';
import getVortexPath from './getVortexPath';
import { i18n, TString } from './i18n';
import lazyRequire from './lazyRequire';
Expand Down
6 changes: 6 additions & 0 deletions src/util/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ import walk from './walk';

import SevenZip = require('node-7z');
import { runElevated, runThreaded } from 'vortex-run';
import { genHash } from './genHash';
import { getErrorContext, setErrorContext, clearErrorContext } from './errorHandling';

export * from './network';

Expand All @@ -81,6 +83,7 @@ export {
calculateFolderSize,
Campaign,
checksum,
clearErrorContext,
convertGameIdReverse,
copyFileAtomic,
copyRecursive,
Expand All @@ -105,8 +108,10 @@ export {
getCurrentActivator,
getCurrentLanguage,
getDriveList,
getErrorContext,
getGame,
getGames,
genHash,
getManifest,
getModSource,
getModSources,
Expand Down Expand Up @@ -160,6 +165,7 @@ export {
Section,
semverCoerce,
setdefault,
setErrorContext,
SetupError,
SevenZip,
sortMods,
Expand Down
56 changes: 35 additions & 21 deletions src/util/errorHandling.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable */
import { NEXUS_BASE_URL, OAUTH_CLIENT_ID } from '../extensions/nexus_integration/constants';
import { IErrorOptions, IExtensionApi } from '../types/api';
import { IErrorOptions, IExtensionApi, IFeedbackReport } from '../types/api';
import { IError } from '../types/IError';

import { COMPANY_ID } from './constants';
Expand Down Expand Up @@ -33,12 +34,12 @@ import lazyRequire from './lazyRequire';

const remote = lazyRequire<typeof RemoteT>(() => require('@electron/remote'));

function createTitle(type: string, error: IError, hash: string) {
function createTitle(type: string, error: IError) {
return `${type}: ${error.message}`;
}

interface IErrorContext {
[id: string]: string;
[id: string]: any;
}

const globalContext: IErrorContext = {};
Expand Down Expand Up @@ -91,7 +92,7 @@ ${error.details}
if (Object.keys(context).length > 0) {
sections.push(`#### Context
\`\`\`
${Object.keys(context).map(key => `${key} = ${context[key]}`)}
${Object.keys(context).filter(key => context[key] !== 'extension-api').map(key => `${key} = ${context[key]}`)}
\`\`\``);
}

Expand Down Expand Up @@ -125,6 +126,26 @@ export function createErrorReport(type: string, error: IError, context: IErrorCo
spawnSelf(['--report', reportPath]);
}

function githubReport(api: IExtensionApi, type: string, error: IError, labels: string[],
context: IErrorContext, oauthToken: any, reporterProcess: string,
sourceProcess: string) {
const title = createTitle(type, error);
const body = createReport(type, error, context, getApplication().version, reporterProcess, sourceProcess);
const hash = genHash(body);
const feedbackReport: IFeedbackReport = {
title,
message: body,
files: [],
reporterProcess,
labels,
context,
error,
hash,
}
api.events.emit('report-feedback', feedbackReport);
return Promise.resolve(undefined);
}

function nexusReport(hash: string, type: string, error: IError, labels: string[],
context: IErrorContext, oauthToken: any,
reporterProcess: string, sourceProcess: string, attachment: string)
Expand All @@ -145,14 +166,12 @@ function nexusReport(hash: string, type: string, error: IError, labels: string[]
const anonymous = (oauthCredentials === undefined);
return Promise.resolve(Nexus.createWithOAuth(oauthCredentials, config, 'Vortex', getApplication().version, undefined))
.then(nexus => nexus.sendFeedback(
createTitle(type, error, hash),
createTitle(type, error),
createReport(type, error, context, getApplication().version, reporterProcess, sourceProcess),
attachment,
anonymous,
hash,
referenceId))
.tap(() =>
opn(`${NEXUS_BASE_URL}/crash-report/?key=${referenceId}`).catch(() => null))
.catch(err => {
log('error', 'failed to report error to nexus', err.message);
return undefined;
Expand Down Expand Up @@ -243,22 +262,17 @@ export function sendReportFile(fileName: string): Promise<IFeedbackResponse> {
export function sendReport(type: string, error: IError, context: IErrorContext,
labels: string[],
reporterToken: any, reporterProcess: string,
sourceProcess: string, attachment: string): Promise<IFeedbackResponse> {
sourceProcess: string, attachment: string): Promise<IFeedbackResponse | undefined> {
const dialog = process.type === 'renderer' ? remote.dialog : dialogIn;
const hash = genHash(error);
if (process.env.NODE_ENV === 'development') {
const fullMessage = error.title !== undefined
? error.message + `\n(${error.title})`
: error.message;
dialog.showErrorBox(fullMessage, JSON.stringify({
type, error, labels, context, reporterProcess, sourceProcess,
attachment,
}, undefined, 2));
// return nexusReport(hash, type, error, labels, context, reporterToken || fallbackOauthToken,
// reporterProcess, sourceProcess, attachment);
const api: IExtensionApi = context['extension-api'];
if (api === undefined) {
dialog.showErrorBox(error.title, error.message);
return Promise.resolve(undefined);
} else {
return nexusReport(hash, type, error, labels, context, reporterToken || fallbackOauthToken,
reporterProcess, sourceProcess, attachment);
}
return githubReport(api, type, error, labels, context, reporterToken || fallbackOauthToken,
reporterProcess, sourceProcess);
}

let defaultWindow: BrowserWindow = null;
Expand Down Expand Up @@ -532,7 +546,7 @@ export function toError(input: any, title?: string,
* @param id context id
* @param value context value
*/
export function setErrorContext(id: string, value: string) {
export function setErrorContext(id: string, value: any) {
globalContext[id] = value;
}

Expand Down
10 changes: 7 additions & 3 deletions src/util/genHash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,12 @@ export function extractToken(error: IError): string {
return hashStack.join('\n');
}

export function genHash(error: IError) {
export function genHash(input: IError | string): string {
const { createHash } = require('crypto');
const hash = createHash('md5');
return hash.update(extractToken(error)).digest('hex');
}
if (typeof input === 'string') {
return hash.update((input)).digest('hex');
} else {
return hash.update(extractToken(input)).digest('hex');
}
}
Loading