From 74d2e303e4fdd8baf4c33de4a201c47d88f46892 Mon Sep 17 00:00:00 2001 From: hana Date: Tue, 9 Apr 2024 02:27:20 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20sendClientError=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 18 ++++++------------ package.json | 6 +++--- src/index.ts | 3 ++- src/{koin-error => koinError}/index.ts | 0 src/sendClientError/index.ts | 20 ++++++++++++++++++++ 5 files changed, 31 insertions(+), 16 deletions(-) rename src/{koin-error => koinError}/index.ts (100%) create mode 100644 src/sendClientError/index.ts diff --git a/package-lock.json b/package-lock.json index 9e499c5..480ef8c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,7 +9,7 @@ "version": "0.0.10", "license": "MIT", "dependencies": { - "axios": "^1.6.8" + "axios": "^0.27.2" }, "devDependencies": { "typescript": "^5.4.4" @@ -21,13 +21,12 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" }, "node_modules/axios": { - "version": "1.6.8", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", - "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "version": "0.27.2", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", "dependencies": { - "follow-redirects": "^1.15.6", - "form-data": "^4.0.0", - "proxy-from-env": "^1.1.0" + "follow-redirects": "^1.14.9", + "form-data": "^4.0.0" } }, "node_modules/combined-stream": { @@ -100,11 +99,6 @@ "node": ">= 0.6" } }, - "node_modules/proxy-from-env": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" - }, "node_modules/typescript": { "version": "5.4.4", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.4.4.tgz", diff --git a/package.json b/package.json index 2b4ba6f..c38dc91 100644 --- a/package.json +++ b/package.json @@ -28,10 +28,10 @@ "types": "./dist/index.d.ts" } }, - "dependencies": { - "axios": "^1.6.8" - }, "devDependencies": { "typescript": "^5.4.4" + }, + "peerDependencies": { + "axios": "^0.27.2" } } diff --git a/src/index.ts b/src/index.ts index 59ffd95..4862e7c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,2 @@ -export * from "./koin-error"; +export * from "./koinError"; +export * from "./sendClientError"; \ No newline at end of file diff --git a/src/koin-error/index.ts b/src/koinError/index.ts similarity index 100% rename from src/koin-error/index.ts rename to src/koinError/index.ts diff --git a/src/sendClientError/index.ts b/src/sendClientError/index.ts new file mode 100644 index 0000000..0485485 --- /dev/null +++ b/src/sendClientError/index.ts @@ -0,0 +1,20 @@ +import axios from 'axios'; + +export const sendClientError = (error: unknown) => { + const url = window.location.href; + + const serializedError = JSON.stringify( + error, + Object.getOwnPropertyNames(error), + ); + + const deserializedError = Object.assign( + new Error(), + JSON.parse(serializedError), + ); + + axios.post('https://api-slack.internal.bcsdlab.com/api/error-notice/frontend', { + url, + error: deserializedError, + }); +};