crashReport moved from client to shared

This commit is contained in:
Akmal Isomadinov 2024-02-08 19:13:57 +05:00
parent 8e51248969
commit f4d89afbf0
4 changed files with 22 additions and 6 deletions

View File

@ -16,7 +16,7 @@ import {
getCrashReport,
downloadJson,
getCurrentDate,
} from "SRC_DIR/helpers/crashReport";
} from "@docspace/shared/utils/crashReport";
import { DeviceType } from "@docspace/shared/enums";
const ModalDialogContainer = styled(ModalDialog)`

View File

@ -29,6 +29,7 @@
"csvjson-json_beautifier": "^5.0.4",
"email-addresses": "^3.1.0",
"fast-deep-equal": "^3.1.3",
"file-saver": "^2.0.5",
"framer-motion": "^4.1.17",
"global": "^4.4.0",
"html-to-react": "^1.5.0",
@ -113,6 +114,7 @@
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.1.2",
"@types/eslint": "^8.44.7",
"@types/file-saver": "^2.0.7",
"@types/jest": "^29.5.10",
"@types/lodash": "^4.14.202",
"@types/luxon": "^3.3.1",

View File

@ -1,27 +1,32 @@
import saveAs from "file-saver";
export const getCrashReport = (userId, version, language, error) => {
export const getCrashReport = (
userId: string,
version: string,
language?: string,
error?: Error,
) => {
const currentTime = new Date();
const reportTime = currentTime.toUTCString();
const lsObject = JSON.stringify(window.localStorage) || "";
const report = {
url: window.origin,
userId: userId,
version: version,
userId,
version,
platform: navigator?.platform,
userAgent: navigator?.userAgent,
language: language || "en",
errorMessage: error?.message,
errorStack: error?.stack,
localStorage: lsObject,
reportTime: reportTime,
reportTime,
};
return report;
};
export const downloadJson = (json, fileName) => {
export const downloadJson = (json: string, fileName: string) => {
const cleanJson = JSON.stringify(json);
const data = new Blob([cleanJson], { type: "application/json" });
const url = window.URL.createObjectURL(data);

View File

@ -3303,6 +3303,7 @@ __metadata:
"@testing-library/jest-dom": "npm:^6.1.4"
"@testing-library/react": "npm:^14.1.2"
"@types/eslint": "npm:^8.44.7"
"@types/file-saver": "npm:^2.0.7"
"@types/jest": "npm:^29.5.10"
"@types/lodash": "npm:^4.14.202"
"@types/luxon": "npm:^3.3.1"
@ -3349,6 +3350,7 @@ __metadata:
eslint-plugin-react-hooks: "npm:^4.6.0"
eslint-plugin-storybook: "npm:^0.6.15"
fast-deep-equal: "npm:^3.1.3"
file-saver: "npm:^2.0.5"
framer-motion: "npm:^4.1.17"
global: "npm:^4.4.0"
html-to-react: "npm:^1.5.0"
@ -8335,6 +8337,13 @@ __metadata:
languageName: node
linkType: hard
"@types/file-saver@npm:^2.0.7":
version: 2.0.7
resolution: "@types/file-saver@npm:2.0.7"
checksum: c3d1cd80eab1214767922cabac97681f3fb688e82b74890450d70deaca49537949bbc96d80d363d91e8f0a4752c7164909cc8902d9721c5c4809baafc42a3801
languageName: node
linkType: hard
"@types/find-cache-dir@npm:^3.2.1":
version: 3.2.1
resolution: "@types/find-cache-dir@npm:3.2.1"