From 69db631e96c650fb20326f8d096740d1375aba5a Mon Sep 17 00:00:00 2001 From: zhangtao25 Date: Tue, 7 Jan 2025 18:50:46 +0800 Subject: [PATCH] chore: daily development --- .../src/helpers/utils/reportCoverage.ts | 21 +++++++++++++++++++ packages/canyon-platform/src/pages/index.tsx | 4 +++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 packages/canyon-platform/src/helpers/utils/reportCoverage.ts diff --git a/packages/canyon-platform/src/helpers/utils/reportCoverage.ts b/packages/canyon-platform/src/helpers/utils/reportCoverage.ts new file mode 100644 index 00000000..63814626 --- /dev/null +++ b/packages/canyon-platform/src/helpers/utils/reportCoverage.ts @@ -0,0 +1,21 @@ +export function reportCoverage() { + try { + // @ts-ignore + const canyon = window.__coverage__[0]; + return fetch(canyon.dsn,{ + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${localStorage.getItem("token")}`, + }, + method: "POST", + body: JSON.stringify({ + ...canyon, + // @ts-ignore + coverage: window.__coverage__, + reportID: localStorage.getItem("username")||undefined, + }), + }) + } catch (e) { + return Promise.resolve(); + } +} diff --git a/packages/canyon-platform/src/pages/index.tsx b/packages/canyon-platform/src/pages/index.tsx index 26115f99..ade0075f 100644 --- a/packages/canyon-platform/src/pages/index.tsx +++ b/packages/canyon-platform/src/pages/index.tsx @@ -17,8 +17,9 @@ import { import { MeDocument } from "../helpers/backend/gen/graphql.ts"; import { genBreadcrumbItems } from "../layouts/genBreadcrumbItems.tsx"; import { genTitle } from "../layouts/genTitle.ts"; +import {reportCoverage} from "@/helpers/utils/reportCoverage.ts"; const theme = localStorage.getItem("theme") || "light"; -// console.log(theme, 'theme'); + function Index() { const { t } = useTranslation(); const loc = useLocation(); @@ -34,6 +35,7 @@ function Index() { } else if (loc.pathname === "/"){ nav("/projects"); } + reportCoverage(); }, [loc.pathname]); const { data: meData } = useQuery(MeDocument);