|
1 | 1 | import {prepareErrorMessage} from '../../utils/prepareErrorMessage';
|
2 | 2 |
|
3 | 3 | export async function collectDiagnosticsData(error: Error) {
|
4 |
| - return await getBackendVersion().then((backendVersion) => { |
5 |
| - return { |
6 |
| - location: window.location.href, |
7 |
| - userAgent: navigator.userAgent, |
8 |
| - error: { |
9 |
| - message: prepareErrorMessage(error), |
10 |
| - stack: prepareErrorStack(error.stack, {trim: true, maxLines: 10}), |
11 |
| - }, |
12 |
| - uiVersion: process.env.UI_VERSION, |
13 |
| - backendVersion, |
14 |
| - }; |
15 |
| - }); |
| 4 | + return await Promise.all([getUiVersion(), getBackendVersion()]).then( |
| 5 | + ([uiVersion, backendVersion]) => { |
| 6 | + return { |
| 7 | + location: window.location.href, |
| 8 | + userAgent: navigator.userAgent, |
| 9 | + error: { |
| 10 | + message: prepareErrorMessage(error), |
| 11 | + stack: prepareErrorStack(error.stack, {trim: true, maxLines: 10}), |
| 12 | + }, |
| 13 | + uiVersion, |
| 14 | + backendVersion, |
| 15 | + }; |
| 16 | + }, |
| 17 | + ); |
16 | 18 | }
|
17 | 19 |
|
18 | 20 | export type DiagnosticsData = Awaited<ReturnType<typeof collectDiagnosticsData>>;
|
19 | 21 |
|
| 22 | +async function getUiVersion() { |
| 23 | + try { |
| 24 | + const packageJson = await import('../../../package.json'); |
| 25 | + return packageJson.version; |
| 26 | + } catch (error) { |
| 27 | + return {error: prepareErrorMessage(error)}; |
| 28 | + } |
| 29 | +} |
| 30 | + |
20 | 31 | async function getBackendVersion() {
|
21 | 32 | try {
|
22 | 33 | // node_id=. returns data about node that fullfills request
|
|
0 commit comments