Add debug log url when submitting it to Support
This commit is contained in:
parent
e09d148c1d
commit
ecdc583f2a
4 changed files with 104 additions and 49 deletions
46
app/main.ts
46
app/main.ts
|
@ -34,6 +34,7 @@ import * as GlobalErrors from './global_errors';
|
||||||
import { setup as setupCrashReports } from './crashReports';
|
import { setup as setupCrashReports } from './crashReports';
|
||||||
import { setup as setupSpellChecker } from './spell_check';
|
import { setup as setupSpellChecker } from './spell_check';
|
||||||
import { redactAll, addSensitivePath } from '../ts/util/privacy';
|
import { redactAll, addSensitivePath } from '../ts/util/privacy';
|
||||||
|
import { createSupportUrl } from '../ts/util/createSupportUrl';
|
||||||
import { missingCaseError } from '../ts/util/missingCaseError';
|
import { missingCaseError } from '../ts/util/missingCaseError';
|
||||||
import { strictAssert } from '../ts/util/assert';
|
import { strictAssert } from '../ts/util/assert';
|
||||||
import { consoleLogger } from '../ts/util/consoleLogger';
|
import { consoleLogger } from '../ts/util/consoleLogger';
|
||||||
|
@ -914,51 +915,8 @@ ipc.once('ready-for-updates', readyForUpdates);
|
||||||
const TEN_MINUTES = 10 * 60 * 1000;
|
const TEN_MINUTES = 10 * 60 * 1000;
|
||||||
setTimeout(readyForUpdates, TEN_MINUTES);
|
setTimeout(readyForUpdates, TEN_MINUTES);
|
||||||
|
|
||||||
// the support only provides a subset of languages available within the app
|
|
||||||
// so we have to list them out here and fallback to english if not included
|
|
||||||
|
|
||||||
const SUPPORT_LANGUAGES = [
|
|
||||||
'ar',
|
|
||||||
'bn',
|
|
||||||
'de',
|
|
||||||
'en-us',
|
|
||||||
'es',
|
|
||||||
'fr',
|
|
||||||
'hi',
|
|
||||||
'hi-in',
|
|
||||||
'hc',
|
|
||||||
'id',
|
|
||||||
'it',
|
|
||||||
'ja',
|
|
||||||
'ko',
|
|
||||||
'mr',
|
|
||||||
'ms',
|
|
||||||
'nl',
|
|
||||||
'pl',
|
|
||||||
'pt',
|
|
||||||
'ru',
|
|
||||||
'sv',
|
|
||||||
'ta',
|
|
||||||
'te',
|
|
||||||
'tr',
|
|
||||||
'uk',
|
|
||||||
'ur',
|
|
||||||
'vi',
|
|
||||||
'zh-cn',
|
|
||||||
'zh-tw',
|
|
||||||
];
|
|
||||||
|
|
||||||
function openContactUs() {
|
function openContactUs() {
|
||||||
const userLanguage = app.getLocale();
|
shell.openExternal(createSupportUrl({ locale: app.getLocale() }));
|
||||||
const language = SUPPORT_LANGUAGES.includes(userLanguage)
|
|
||||||
? userLanguage
|
|
||||||
: 'en-us';
|
|
||||||
|
|
||||||
// This URL needs a hardcoded language because the '?desktop' is dropped if the page
|
|
||||||
// auto-redirects to the proper URL
|
|
||||||
shell.openExternal(
|
|
||||||
`https://support.signal.org/hc/${language}/requests/new?desktop`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function openJoinTheBeta() {
|
function openJoinTheBeta() {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import { ToastDebugLogError } from './ToastDebugLogError';
|
||||||
import { ToastLinkCopied } from './ToastLinkCopied';
|
import { ToastLinkCopied } from './ToastLinkCopied';
|
||||||
import { ToastLoadingFullLogs } from './ToastLoadingFullLogs';
|
import { ToastLoadingFullLogs } from './ToastLoadingFullLogs';
|
||||||
import { openLinkInWebBrowser } from '../util/openLinkInWebBrowser';
|
import { openLinkInWebBrowser } from '../util/openLinkInWebBrowser';
|
||||||
|
import { createSupportUrl } from '../util/createSupportUrl';
|
||||||
import { useEscapeHandling } from '../hooks/useEscapeHandling';
|
import { useEscapeHandling } from '../hooks/useEscapeHandling';
|
||||||
|
|
||||||
enum LoadState {
|
enum LoadState {
|
||||||
|
@ -126,6 +127,13 @@ export const DebugLogWindow = ({
|
||||||
setToastType(ToastType.Copied);
|
setToastType(ToastType.Copied);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const supportURL = createSupportUrl({
|
||||||
|
locale: i18n.getLocale(),
|
||||||
|
query: {
|
||||||
|
debugLog: publicLogURL,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="DebugLogWindow">
|
<div className="DebugLogWindow">
|
||||||
<div>
|
<div>
|
||||||
|
@ -144,11 +152,7 @@ export const DebugLogWindow = ({
|
||||||
</div>
|
</div>
|
||||||
<div className="DebugLogWindow__footer">
|
<div className="DebugLogWindow__footer">
|
||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => openLinkInWebBrowser(supportURL)}
|
||||||
openLinkInWebBrowser(
|
|
||||||
'https://support.signal.org/hc/requests/new'
|
|
||||||
);
|
|
||||||
}}
|
|
||||||
variant={ButtonVariant.Secondary}
|
variant={ButtonVariant.Secondary}
|
||||||
>
|
>
|
||||||
{i18n('reportIssue')}
|
{i18n('reportIssue')}
|
||||||
|
|
30
ts/test-node/util/createSupportUrl_test.ts
Normal file
30
ts/test-node/util/createSupportUrl_test.ts
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
// Copyright 2022 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
import { assert } from 'chai';
|
||||||
|
|
||||||
|
import { createSupportUrl } from '../../util/createSupportUrl';
|
||||||
|
|
||||||
|
describe('createSupportUrl', () => {
|
||||||
|
it('returns support url for "en" locale', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
createSupportUrl({ locale: 'en' }),
|
||||||
|
'https://support.signal.org/hc/en-us/requests/new?desktop'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns support url for "fr" locale', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
createSupportUrl({ locale: 'fr' }),
|
||||||
|
'https://support.signal.org/hc/fr/requests/new?desktop'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returns support url with a query', () => {
|
||||||
|
assert.strictEqual(
|
||||||
|
createSupportUrl({ locale: 'en', query: { debugLog: 'https://' } }),
|
||||||
|
'https://support.signal.org/hc/en-us/requests/new?' +
|
||||||
|
'desktop&debugLog=https%3A%2F%2F'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
63
ts/util/createSupportUrl.ts
Normal file
63
ts/util/createSupportUrl.ts
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
// Copyright 2022 Signal Messenger, LLC
|
||||||
|
// SPDX-License-Identifier: AGPL-3.0-only
|
||||||
|
|
||||||
|
// the support only provides a subset of languages available within the app
|
||||||
|
// so we have to list them out here and fallback to english if not included
|
||||||
|
const SUPPORT_LANGUAGES = [
|
||||||
|
'ar',
|
||||||
|
'bn',
|
||||||
|
'de',
|
||||||
|
'en-us',
|
||||||
|
'es',
|
||||||
|
'fr',
|
||||||
|
'hi',
|
||||||
|
'hi-in',
|
||||||
|
'hc',
|
||||||
|
'id',
|
||||||
|
'it',
|
||||||
|
'ja',
|
||||||
|
'ko',
|
||||||
|
'mr',
|
||||||
|
'ms',
|
||||||
|
'nl',
|
||||||
|
'pl',
|
||||||
|
'pt',
|
||||||
|
'ru',
|
||||||
|
'sv',
|
||||||
|
'ta',
|
||||||
|
'te',
|
||||||
|
'tr',
|
||||||
|
'uk',
|
||||||
|
'ur',
|
||||||
|
'vi',
|
||||||
|
'zh-cn',
|
||||||
|
'zh-tw',
|
||||||
|
];
|
||||||
|
|
||||||
|
export type CreateSupportUrlOptionsType = Readonly<{
|
||||||
|
locale: string;
|
||||||
|
query?: Record<string, string>;
|
||||||
|
}>;
|
||||||
|
|
||||||
|
export function createSupportUrl({
|
||||||
|
locale,
|
||||||
|
query = {},
|
||||||
|
}: CreateSupportUrlOptionsType): string {
|
||||||
|
const language = SUPPORT_LANGUAGES.includes(locale) ? locale : 'en-us';
|
||||||
|
|
||||||
|
// This URL needs a hardcoded language because the '?desktop' is dropped if
|
||||||
|
// the page auto-redirects to the proper URL
|
||||||
|
const url = new URL(`https://support.signal.org/hc/${language}/requests/new`);
|
||||||
|
|
||||||
|
url.searchParams.set('desktop', '');
|
||||||
|
|
||||||
|
for (const key of Object.keys(query)) {
|
||||||
|
if (key === 'desktop') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
url.searchParams.set(key, query[key]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support page requires `?desktop&...` not `?desktop=&...`
|
||||||
|
return url.toString().replace('desktop=', 'desktop');
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue