mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Adding back isValidSentryDsn and sentryDsnIsValid, and use sentryDsnIsValid to determine the UI should be shown, regression introduced in https://github.com/lensapp/lens/pull/3315
Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
parent
77f8ea67bd
commit
b68288e8e4
@ -51,6 +51,7 @@ export * from "./tar";
|
||||
export * from "./toggle-set";
|
||||
export * from "./toJS";
|
||||
export * from "./type-narrowing";
|
||||
export * from "./isValidSentryDsn";
|
||||
|
||||
import * as iter from "./iter";
|
||||
|
||||
|
||||
38
src/common/utils/isValidSentryDsn.ts
Normal file
38
src/common/utils/isValidSentryDsn.ts
Normal file
@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) 2021 OpenLens Authors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
|
||||
// Regular expression used to parse a Sentry Dsn.
|
||||
// from https://github.com/getsentry/sentry-javascript/blob/f624f442fd76bf655de6def9fa4d7631735ebba0/packages/utils/src/dsn.ts#L6
|
||||
const DSN_REGEX = /^(?:(\w+):)\/\/(?:(\w+)(?::(\w+))?@)([\w.-]+)(?::(\d+))?\/(.+)/;
|
||||
|
||||
/**
|
||||
* check if string is a valid Sentry dsn
|
||||
*
|
||||
* @param {(string | undefined | null)} string
|
||||
* @return {boolean}
|
||||
*/
|
||||
export const isValidSentryDsn = (string: string | undefined | null) => {
|
||||
|
||||
const valid = DSN_REGEX.exec(string);
|
||||
|
||||
return valid;
|
||||
};
|
||||
@ -24,6 +24,7 @@ import path from "path";
|
||||
import { SemVer } from "semver";
|
||||
import packageInfo from "../../package.json";
|
||||
import { defineGlobal } from "./utils/defineGlobal";
|
||||
import { isValidSentryDsn } from "./utils/isValidSentryDsn";
|
||||
|
||||
export const isMac = process.platform === "darwin";
|
||||
export const isWindows = process.platform === "win32";
|
||||
@ -71,4 +72,5 @@ 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 sentryDsn = packageInfo.config?.sentryDsn;
|
||||
export const sentryDsn = packageInfo.config?.sentryDsn ?? "";
|
||||
export const sentryDsnIsValid = isValidSentryDsn(sentryDsn);
|
||||
|
||||
@ -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 { sentryIsInitialized } from "../../../common/sentry";
|
||||
import { sentryDsnIsValid } from "../../../common/vars";
|
||||
|
||||
enum Pages {
|
||||
Application = "application",
|
||||
@ -259,7 +259,7 @@ export class Preferences extends React.Component {
|
||||
<section id="telemetry">
|
||||
<h2 data-testid="telemetry-header">Telemetry</h2>
|
||||
{telemetryExtensions.map(this.renderExtension)}
|
||||
{sentryIsInitialized ? (
|
||||
{sentryDsnIsValid ? (
|
||||
<React.Fragment key='sentry'>
|
||||
<section id='sentry' className="small">
|
||||
<SubTitle title='Automatic Error Reporting' />
|
||||
|
||||
Loading…
Reference in New Issue
Block a user