From 9c186ab65b6e55dd83ce36a1d0ca73e8b94b1c80 Mon Sep 17 00:00:00 2001 From: "Hung-Han (Henry) Chen" Date: Thu, 8 Jul 2021 09:05:17 +0300 Subject: [PATCH] Varible name chanages: dsn -> sentryDsn; isValidDsn -> isValidSentryDsn Signed-off-by: Hung-Han (Henry) Chen --- src/common/utils/index.ts | 2 +- src/common/utils/{isValidDsn.ts => isValidSentryDsn.ts} | 6 +++--- src/common/vars.ts | 6 +++--- src/main/index.ts | 6 +++--- src/renderer/components/+preferences/preferences.tsx | 6 +++--- src/renderer/lens-app.tsx | 6 +++--- 6 files changed, 16 insertions(+), 16 deletions(-) rename src/common/utils/{isValidDsn.ts => isValidSentryDsn.ts} (90%) diff --git a/src/common/utils/index.ts b/src/common/utils/index.ts index 866c6bfded..b9c9d7561d 100644 --- a/src/common/utils/index.ts +++ b/src/common/utils/index.ts @@ -51,7 +51,7 @@ export * from "./toggle-set"; export * from "./toJS"; export * from "./type-narrowing"; export * from "./isValidURL"; -export * from "./isValidDsn"; +export * from "./isValidSentryDsn"; import * as iter from "./iter"; diff --git a/src/common/utils/isValidDsn.ts b/src/common/utils/isValidSentryDsn.ts similarity index 90% rename from src/common/utils/isValidDsn.ts rename to src/common/utils/isValidSentryDsn.ts index c9c6aacd0d..9b91ae1cac 100644 --- a/src/common/utils/isValidDsn.ts +++ b/src/common/utils/isValidSentryDsn.ts @@ -25,12 +25,12 @@ 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} */ -export const isValidDsn = (string: string | undefined | null) => { +export const isValidSentryDsn = (string: string | undefined | null) => { const valid = DSN_REGEX.exec(string); diff --git a/src/common/vars.ts b/src/common/vars.ts index 61a2d9559d..f049d8b656 100644 --- a/src/common/vars.ts +++ b/src/common/vars.ts @@ -25,7 +25,7 @@ import { SemVer } from "semver"; import packageInfo from "../../package.json"; import { defineGlobal } from "./utils/defineGlobal"; import { isValidURL } from "./utils/isValidURL"; -import { isValidDsn } from "./utils/isValidDsn"; +import { isValidSentryDsn } from "./utils/isValidSentryDsn"; export const isMac = process.platform === "darwin"; 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 docsUrl = `https://docs.k8slens.dev/main/` as string; -export const dsn = packageInfo.config?.sentryDsn; -export const dsnIsValid = isValidURL(dsn) && isValidDsn(dsn); +export const sentryDsn = packageInfo.config?.sentryDsn; +export const sentryDsnIsValid = isValidURL(sentryDsn) && isValidSentryDsn(sentryDsn); diff --git a/src/main/index.ts b/src/main/index.ts index 5260b25809..321cf37fb2 100644 --- a/src/main/index.ts +++ b/src/main/index.ts @@ -26,7 +26,7 @@ import * as Mobx from "mobx"; import * as LensExtensionsCommonApi from "../extensions/common-api"; import * as LensExtensionsMainApi from "../extensions/main-api"; 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 { LensProxy } from "./proxy/lens-proxy"; import { WindowManager } from "./window-manager"; @@ -62,7 +62,7 @@ import { FilesystemProvisionerStore } from "./extension-filesystem"; import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations"; import * as Sentry from "@sentry/electron/dist/main"; -if (dsnIsValid) { +if (sentryDsnIsValid) { Sentry.init({ beforeSend(event) { const allow = UserStore.getInstance().allowErrorReporting; @@ -71,7 +71,7 @@ if (dsnIsValid) { return null; }, - dsn, + dsn: sentryDsn, integrations: [ new CaptureConsole({ levels: ["error"] }), new Dedupe(), diff --git a/src/renderer/components/+preferences/preferences.tsx b/src/renderer/components/+preferences/preferences.tsx index ddc270ca64..3ec4693fe8 100644 --- a/src/renderer/components/+preferences/preferences.tsx +++ b/src/renderer/components/+preferences/preferences.tsx @@ -41,7 +41,7 @@ import { FormSwitch, Switcher } from "../switch"; import { KubeconfigSyncs } from "./kubeconfig-syncs"; import { SettingLayout } from "../layout/setting-layout"; import { Checkbox } from "../checkbox"; -import { dsnIsValid } from "../../../common/vars"; +import { sentryDsnIsValid } from "../../../common/vars"; enum Pages { Application = "application", @@ -259,7 +259,7 @@ export class Preferences extends React.Component {

Telemetry

{telemetryExtensions.map(this.renderExtension)} - {dsnIsValid ? ( + {sentryDsnIsValid ? (
@@ -279,7 +279,7 @@ export class Preferences extends React.Component {

) : - // 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 }
diff --git a/src/renderer/lens-app.tsx b/src/renderer/lens-app.tsx index 21109c9355..a34f4c6bd0 100644 --- a/src/renderer/lens-app.tsx +++ b/src/renderer/lens-app.tsx @@ -36,12 +36,12 @@ import { registerIpcHandlers } from "./ipc"; import { ipcRenderer } from "electron"; import { IpcRendererNavigationEvents } from "./navigation/events"; 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 * as Sentry from "@sentry/electron/dist/renderer"; import { UserStore } from "../common/user-store"; -if (dsnIsValid) { +if (sentryDsnIsValid) { Sentry.init({ beforeSend(event) { const allow = UserStore.getInstance().allowErrorReporting; @@ -50,7 +50,7 @@ if (dsnIsValid) { return null; }, - dsn, + dsn: sentryDsn, integrations: [ new CaptureConsole({ levels: ["error"] }), new Dedupe(),