1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add type for Sentry event

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen 2021-07-08 10:24:28 +03:00
parent 3e43757b01
commit 78ab3a2f90
No known key found for this signature in database
GPG Key ID: 54B44603D251B788
3 changed files with 6 additions and 2 deletions

View File

@ -255,6 +255,7 @@
"@material-ui/lab": "^4.0.0-alpha.57", "@material-ui/lab": "^4.0.0-alpha.57",
"@pmmmwh/react-refresh-webpack-plugin": "^0.4.3", "@pmmmwh/react-refresh-webpack-plugin": "^0.4.3",
"@sentry/react": "^6.8.0", "@sentry/react": "^6.8.0",
"@sentry/types": "^6.8.0",
"@testing-library/jest-dom": "^5.13.0", "@testing-library/jest-dom": "^5.13.0",
"@testing-library/react": "^11.2.6", "@testing-library/react": "^11.2.6",
"@types/byline": "^4.2.32", "@types/byline": "^4.2.32",

View File

@ -20,6 +20,7 @@
*/ */
import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations"; import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations";
import type { Event as SentryEvent } from "@sentry/types";
import { sentryDsn, sentryDsnIsValid, isProduction } from "./vars"; import { sentryDsn, sentryDsnIsValid, isProduction } from "./vars";
import { UserStore } from "./user-store"; import { UserStore } from "./user-store";
import logger from "../main/logger"; import logger from "../main/logger";
@ -82,7 +83,7 @@ export const SentryInit = () => {
try { try {
Sentry.init({ Sentry.init({
beforeSend(event: unknown) { beforeSend(event: SentryEvent) {
const allowErrorReporting = UserStore.getInstance().allowErrorReporting; const allowErrorReporting = UserStore.getInstance().allowErrorReporting;
if (allowErrorReporting) return event; if (allowErrorReporting) return event;
@ -90,6 +91,8 @@ export const SentryInit = () => {
logger.info(`🔒 [SENTRY-BEFORE-SEND-HOOK]: allowErrorReporting: ${allowErrorReporting}. Sentry event is caught but not sent to server.`); logger.info(`🔒 [SENTRY-BEFORE-SEND-HOOK]: allowErrorReporting: ${allowErrorReporting}. Sentry event is caught but not sent to server.`);
logger.info(event); logger.info(event);
// if return null, the event won't be sent
// ref https://github.com/getsentry/sentry-javascript/issues/2039
return null; return null;
}, },
dsn: sentryDsn, dsn: sentryDsn,

View File

@ -1088,7 +1088,7 @@
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.7.1.tgz#c8263e1886df5e815570c4668eb40a1cfaa1c88b" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.7.1.tgz#c8263e1886df5e815570c4668eb40a1cfaa1c88b"
integrity sha512-9AO7HKoip2MBMNQJEd6+AKtjj2+q9Ze4ooWUdEvdOVSt5drg7BGpK221/p9JEOyJAZwEPEXdcMd3VAIMiOb4MA== integrity sha512-9AO7HKoip2MBMNQJEd6+AKtjj2+q9Ze4ooWUdEvdOVSt5drg7BGpK221/p9JEOyJAZwEPEXdcMd3VAIMiOb4MA==
"@sentry/types@6.8.0": "@sentry/types@6.8.0", "@sentry/types@^6.8.0":
version "6.8.0" version "6.8.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.8.0.tgz#97fd531a0ed1e75e65b4a24b26509fb7c15eb7b8" resolved "https://registry.yarnpkg.com/@sentry/types/-/types-6.8.0.tgz#97fd531a0ed1e75e65b4a24b26509fb7c15eb7b8"
integrity sha512-PbSxqlh6Fd5thNU5f8EVYBVvX+G7XdPA+ThNb2QvSK8yv3rIf0McHTyF6sIebgJ38OYN7ZFK7vvhC/RgSAfYTA== integrity sha512-PbSxqlh6Fd5thNU5f8EVYBVvX+G7XdPA+ThNb2QvSK8yv3rIf0McHTyF6sIebgJ38OYN7ZFK7vvhC/RgSAfYTA==