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

Varible name chanages: dsn -> sentryDsn; isValidDsn -> isValidSentryDsn

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen 2021-07-08 09:05:17 +03:00
parent 7ee40d5edd
commit 9c186ab65b
No known key found for this signature in database
GPG Key ID: 54B44603D251B788
6 changed files with 16 additions and 16 deletions

View File

@ -51,7 +51,7 @@ export * from "./toggle-set";
export * from "./toJS"; export * from "./toJS";
export * from "./type-narrowing"; export * from "./type-narrowing";
export * from "./isValidURL"; export * from "./isValidURL";
export * from "./isValidDsn"; export * from "./isValidSentryDsn";
import * as iter from "./iter"; import * as iter from "./iter";

View File

@ -25,12 +25,12 @@
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/; const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
/** /**
* check if string is valid Sentry dsn * check if string is a valid Sentry dsn
* *
* @param {(string | undefined | null)} url * @param {(string | undefined | null)} string
* @return {boolean} * @return {boolean}
*/ */
export const isValidDsn = (string: string | undefined | null) => { export const isValidSentryDsn = (string: string | undefined | null) => {
const valid = DSN_REGEX.exec(string); const valid = DSN_REGEX.exec(string);

View File

@ -25,7 +25,7 @@ import { SemVer } from "semver";
import packageInfo from "../../package.json"; import packageInfo from "../../package.json";
import { defineGlobal } from "./utils/defineGlobal"; import { defineGlobal } from "./utils/defineGlobal";
import { isValidURL } from "./utils/isValidURL"; import { isValidURL } from "./utils/isValidURL";
import { isValidDsn } from "./utils/isValidDsn"; import { isValidSentryDsn } from "./utils/isValidSentryDsn";
export const isMac = process.platform === "darwin"; export const isMac = process.platform === "darwin";
export const isWindows = process.platform === "win32"; export const isWindows = process.platform === "win32";
@ -73,6 +73,6 @@ export const supportUrl = "https://docs.k8slens.dev/latest/support/" as string;
export const appSemVer = new SemVer(packageInfo.version); export const appSemVer = new SemVer(packageInfo.version);
export const docsUrl = `https://docs.k8slens.dev/main/` as string; export const docsUrl = `https://docs.k8slens.dev/main/` as string;
export const dsn = packageInfo.config?.sentryDsn; export const sentryDsn = packageInfo.config?.sentryDsn;
export const dsnIsValid = isValidURL(dsn) && isValidDsn(dsn); export const sentryDsnIsValid = isValidURL(sentryDsn) && isValidSentryDsn(sentryDsn);

View File

@ -26,7 +26,7 @@ import * as Mobx from "mobx";
import * as LensExtensionsCommonApi from "../extensions/common-api"; import * as LensExtensionsCommonApi from "../extensions/common-api";
import * as LensExtensionsMainApi from "../extensions/main-api"; import * as LensExtensionsMainApi from "../extensions/main-api";
import { app, autoUpdater, dialog, powerMonitor } from "electron"; import { app, autoUpdater, dialog, powerMonitor } from "electron";
import { appName, isMac, productName, dsn, dsnIsValid, isProduction } from "../common/vars"; import { appName, isMac, productName, sentryDsn, sentryDsnIsValid, isProduction } from "../common/vars";
import path from "path"; import path from "path";
import { LensProxy } from "./proxy/lens-proxy"; import { LensProxy } from "./proxy/lens-proxy";
import { WindowManager } from "./window-manager"; import { WindowManager } from "./window-manager";
@ -62,7 +62,7 @@ import { FilesystemProvisionerStore } from "./extension-filesystem";
import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations"; import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations";
import * as Sentry from "@sentry/electron/dist/main"; import * as Sentry from "@sentry/electron/dist/main";
if (dsnIsValid) { if (sentryDsnIsValid) {
Sentry.init({ Sentry.init({
beforeSend(event) { beforeSend(event) {
const allow = UserStore.getInstance().allowErrorReporting; const allow = UserStore.getInstance().allowErrorReporting;
@ -71,7 +71,7 @@ if (dsnIsValid) {
return null; return null;
}, },
dsn, dsn: sentryDsn,
integrations: [ integrations: [
new CaptureConsole({ levels: ["error"] }), new CaptureConsole({ levels: ["error"] }),
new Dedupe(), new Dedupe(),

View File

@ -41,7 +41,7 @@ import { FormSwitch, Switcher } from "../switch";
import { KubeconfigSyncs } from "./kubeconfig-syncs"; import { KubeconfigSyncs } from "./kubeconfig-syncs";
import { SettingLayout } from "../layout/setting-layout"; import { SettingLayout } from "../layout/setting-layout";
import { Checkbox } from "../checkbox"; import { Checkbox } from "../checkbox";
import { dsnIsValid } from "../../../common/vars"; import { sentryDsnIsValid } from "../../../common/vars";
enum Pages { enum Pages {
Application = "application", Application = "application",
@ -259,7 +259,7 @@ export class Preferences extends React.Component {
<section id="telemetry"> <section id="telemetry">
<h2 data-testid="telemetry-header">Telemetry</h2> <h2 data-testid="telemetry-header">Telemetry</h2>
{telemetryExtensions.map(this.renderExtension)} {telemetryExtensions.map(this.renderExtension)}
{dsnIsValid ? ( {sentryDsnIsValid ? (
<React.Fragment key='sentry'> <React.Fragment key='sentry'>
<section id='sentry' className="small"> <section id='sentry' className="small">
<SubTitle title='Automatic Error Reporting' /> <SubTitle title='Automatic Error Reporting' />
@ -279,7 +279,7 @@ export class Preferences extends React.Component {
</section> </section>
<hr className="small" /> <hr className="small" />
</React.Fragment>) : </React.Fragment>) :
// we don't need to shows the checkbox at all if dsn is not a valid url // we don't need to shows the checkbox at all if Sentry dsn is not a valid url
null null
} }
</section> </section>

View File

@ -36,12 +36,12 @@ import { registerIpcHandlers } from "./ipc";
import { ipcRenderer } from "electron"; import { ipcRenderer } from "electron";
import { IpcRendererNavigationEvents } from "./navigation/events"; import { IpcRendererNavigationEvents } from "./navigation/events";
import { catalogEntityRegistry } from "./api/catalog-entity-registry"; import { catalogEntityRegistry } from "./api/catalog-entity-registry";
import { dsn, dsnIsValid, isProduction } from "../common/vars"; import { sentryDsn, sentryDsnIsValid, isProduction } from "../common/vars";
import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations"; import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations";
import * as Sentry from "@sentry/electron/dist/renderer"; import * as Sentry from "@sentry/electron/dist/renderer";
import { UserStore } from "../common/user-store"; import { UserStore } from "../common/user-store";
if (dsnIsValid) { if (sentryDsnIsValid) {
Sentry.init({ Sentry.init({
beforeSend(event) { beforeSend(event) {
const allow = UserStore.getInstance().allowErrorReporting; const allow = UserStore.getInstance().allowErrorReporting;
@ -50,7 +50,7 @@ if (dsnIsValid) {
return null; return null;
}, },
dsn, dsn: sentryDsn,
integrations: [ integrations: [
new CaptureConsole({ levels: ["error"] }), new CaptureConsole({ levels: ["error"] }),
new Dedupe(), new Dedupe(),