فهرست منبع

Merge pull request #2683 from porter-dev/feat/remove-highlight-cohere

feat: remove highlight cohere
jusrhee 3 سال پیش
والد
کامیت
fda5666fc4

+ 0 - 15
dashboard/package-lock.json

@@ -3737,16 +3737,6 @@
       "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
       "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.1.1.tgz",
       "integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA=="
       "integrity": "sha512-6/bPho624p3S2pMyvP5kKBPXnI3ufHLObBFCfgx+LkeR5lg2XYy2hqZqUf45ypD8COn2bhgGJSUE+l5dhNBieA=="
     },
     },
-    "cohere-js": {
-      "version": "1.0.19",
-      "resolved": "https://registry.npmjs.org/cohere-js/-/cohere-js-1.0.19.tgz",
-      "integrity": "sha512-2XVX2LUKHjbJ4GCsnizXnAVHZfq9RM1RmHl8zE4G2ORdXmDpzSx5i0UIj/0GZ3AwjKIlYsrGA4kdCGT+WapjPQ=="
-    },
-    "cohere-sentry": {
-      "version": "1.0.1",
-      "resolved": "https://registry.npmjs.org/cohere-sentry/-/cohere-sentry-1.0.1.tgz",
-      "integrity": "sha512-OHdKcc8LED8X/JQKlMD0Zapb4rcOkPu0m11+okHouMDep1/MvyOG4JXcK4Mo3sabJT65yozc9Uo+nJfSWzaFcg=="
-    },
     "collection-visit": {
     "collection-visit": {
       "version": "1.0.0",
       "version": "1.0.0",
       "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
       "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz",
@@ -5789,11 +5779,6 @@
       "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
       "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
       "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
       "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw=="
     },
     },
-    "highlight.run": {
-      "version": "1.7.5",
-      "resolved": "https://registry.npmjs.org/highlight.run/-/highlight.run-1.7.5.tgz",
-      "integrity": "sha512-Kens7xbGJE/vZ21z+wVcdbdzn6bsFJD+gMh942cG/1ewgdWp5JmGqIiO33aJWyzEcXj0dBE8gQUi6Ql+9jSNUQ=="
-    },
     "history": {
     "history": {
       "version": "4.10.1",
       "version": "4.10.1",
       "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz",
       "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz",

+ 0 - 3
dashboard/package.json

@@ -27,8 +27,6 @@
     "brace": "^0.11.1",
     "brace": "^0.11.1",
     "chroma-js": "^2.4.2",
     "chroma-js": "^2.4.2",
     "clipboard": "^2.0.8",
     "clipboard": "^2.0.8",
-    "cohere-js": "^1.0.19",
-    "cohere-sentry": "^1.0.1",
     "color": "^4.2.3",
     "color": "^4.2.3",
     "core-js": "^3.16.1",
     "core-js": "^3.16.1",
     "cron-parser": "^4.3.0",
     "cron-parser": "^4.3.0",
@@ -39,7 +37,6 @@
     "dayjs": "^1.11.5",
     "dayjs": "^1.11.5",
     "dotenv": "^8.2.0",
     "dotenv": "^8.2.0",
     "fuse.js": "^6.6.2",
     "fuse.js": "^6.6.2",
-    "highlight.run": "^1.4.5",
     "ini": ">=1.3.6",
     "ini": ">=1.3.6",
     "js-base64": "^3.6.0",
     "js-base64": "^3.6.0",
     "js-yaml": "^4.1.0",
     "js-yaml": "^4.1.0",

+ 0 - 5
dashboard/src/index.tsx

@@ -3,7 +3,6 @@ import "regenerator-runtime/runtime";
 
 
 import * as React from "react";
 import * as React from "react";
 import * as ReactDOM from "react-dom";
 import * as ReactDOM from "react-dom";
-import Cohere from "cohere-js";
 import App from "./App";
 import App from "./App";
 import { SetupSentry } from "shared/error_handling/sentry/setup";
 import { SetupSentry } from "shared/error_handling/sentry/setup";
 import { EnableErrorHandling } from "shared/error_handling/window_error_handling";
 import { EnableErrorHandling } from "shared/error_handling/window_error_handling";
@@ -14,10 +13,6 @@ declare global {
   }
   }
 }
 }
 
 
-if (process.env.ENABLE_COHERE && process.env.COHERE_API_KEY) {
-  Cohere.init(process.env.COHERE_API_KEY);
-}
-
 if (process.env.ENABLE_SENTRY) {
 if (process.env.ENABLE_SENTRY) {
   SetupSentry();
   SetupSentry();
 }
 }

+ 0 - 8
dashboard/src/main/Main.tsx

@@ -3,7 +3,6 @@ import { Route, Redirect, Switch } from "react-router-dom";
 
 
 import api from "shared/api";
 import api from "shared/api";
 import { Context } from "shared/Context";
 import { Context } from "shared/Context";
-import Cohere from "cohere-js";
 import ResetPasswordInit from "./auth/ResetPasswordInit";
 import ResetPasswordInit from "./auth/ResetPasswordInit";
 import ResetPasswordFinalize from "./auth/ResetPasswordFinalize";
 import ResetPasswordFinalize from "./auth/ResetPasswordFinalize";
 import Login from "./auth/Login";
 import Login from "./auth/Login";
@@ -42,13 +41,6 @@ export default class Main extends Component<PropsType, StateType> {
       .checkAuth("", {}, {})
       .checkAuth("", {}, {})
       .then((res) => {
       .then((res) => {
         if (res && res?.data) {
         if (res && res?.data) {
-          if (process.env.ENABLE_COHERE) {
-            Cohere.identify(res?.data?.id, {
-              displayName: res?.data?.email,
-              email: res?.data?.email,
-            });
-          }
-
           setUser(res?.data?.id, res?.data?.email);
           setUser(res?.data?.id, res?.data?.email);
           this.setState({
           this.setState({
             isLoggedIn: true,
             isLoggedIn: true,

+ 0 - 10
dashboard/src/main/home/Home.tsx

@@ -3,7 +3,6 @@ import { Route, RouteComponentProps, Switch, withRouter } from "react-router";
 import styled from "styled-components";
 import styled from "styled-components";
 
 
 import api from "shared/api";
 import api from "shared/api";
-import { H } from "highlight.run";
 import { Context } from "shared/Context";
 import { Context } from "shared/Context";
 import { PorterUrl, pushFiltered, pushQueryParams } from "shared/routing";
 import { PorterUrl, pushFiltered, pushQueryParams } from "shared/routing";
 import { ClusterType, ProjectType } from "shared/types";
 import { ClusterType, ProjectType } from "shared/types";
@@ -159,15 +158,6 @@ class Home extends Component<PropsType, StateType> {
 
 
     let { user } = this.context;
     let { user } = this.context;
 
 
-    // Initialize Highlight
-    if (
-      window.location.href.includes("dashboard.getporter.dev") &&
-      !user.email.includes("@getporter.dev")
-    ) {
-      H.init("y2d13lgr");
-      H.identify(user.email, { id: user.id });
-    }
-
     // Handle redirect from DO
     // Handle redirect from DO
     let queryString = window.location.search;
     let queryString = window.location.search;
     let urlParams = new URLSearchParams(queryString);
     let urlParams = new URLSearchParams(queryString);

+ 0 - 12
dashboard/src/main/home/onboarding/steps/ProvisionResources/ProvisionResources.tsx

@@ -2,7 +2,6 @@ import Helper from "components/form-components/Helper";
 import SaveButton from "components/SaveButton";
 import SaveButton from "components/SaveButton";
 import TitleSection from "components/TitleSection";
 import TitleSection from "components/TitleSection";
 import React, { useEffect, useMemo, useState } from "react";
 import React, { useEffect, useMemo, useState } from "react";
-import Cohere from "cohere-js";
 import { useParams } from "react-router";
 import { useParams } from "react-router";
 import styled from "styled-components";
 import styled from "styled-components";
 import ProviderSelector, {
 import ProviderSelector, {
@@ -217,9 +216,6 @@ const ProvisionResources: React.FC<{}> = () => {
     if (typeof infraStatus.hasError !== "boolean") return;
     if (typeof infraStatus.hasError !== "boolean") return;
 
 
     if (infraStatus.hasError) {
     if (infraStatus.hasError) {
-      Cohere.widget("show");
-      Cohere.widget("expand");
-
       const cause = new Error(
       const cause = new Error(
         JSON.stringify({
         JSON.stringify({
           description: infraStatus.description,
           description: infraStatus.description,
@@ -233,17 +229,9 @@ const ProvisionResources: React.FC<{}> = () => {
           { cause }
           { cause }
         )
         )
       );
       );
-    } else {
-      Cohere.widget("hide");
     }
     }
   }, [infraStatus]);
   }, [infraStatus]);
 
 
-  useEffect(() => {
-    return () => {
-      Cohere.widget("hide");
-    };
-  }, []);
-
   const Content = () => {
   const Content = () => {
     switch (step) {
     switch (step) {
       case "credentials":
       case "credentials":

+ 8 - 25
dashboard/src/shared/error_handling/logger.ts

@@ -1,5 +1,4 @@
 import * as Sentry from "@sentry/react";
 import * as Sentry from "@sentry/react";
-import Cohere from "cohere-js";
 import { isEmpty } from "lodash";
 import { isEmpty } from "lodash";
 
 
 type LogFunction = (error: Error, tags?: { [key: string]: string }) => void;
 type LogFunction = (error: Error, tags?: { [key: string]: string }) => void;
@@ -16,32 +15,16 @@ const logFunctionBuilder: LogFunctionBuilder = (scope, severity) => (
   error,
   error,
   tags
   tags
 ) => {
 ) => {
-  if (process.env.ENABLE_COHERE) {
-    Cohere.getSessionUrl((sessionUrl) => {
-      Sentry.withScope((sentryScope) => {
-        sentryScope.setTag("scope", scope);
-        sentryScope.setTag("cohere_link", sessionUrl);
-        sentryScope.setLevel(severity);
+  Sentry.withScope((sentryScope) => {
+    sentryScope.setTag("scope", scope);
+    sentryScope.setLevel(severity);
 
 
-        if (!isEmpty(tags)) {
-          sentryScope.setTags(tags);
-        }
+    if (!isEmpty(tags)) {
+      sentryScope.setTags(tags);
+    }
 
 
-        Sentry.captureException(error);
-      });
-    });
-  } else {
-    Sentry.withScope((sentryScope) => {
-      sentryScope.setTag("scope", scope);
-      sentryScope.setLevel(severity);
-
-      if (!isEmpty(tags)) {
-        sentryScope.setTags(tags);
-      }
-
-      Sentry.captureException(error);
-    });
-  }
+    Sentry.captureException(error);
+  });
 };
 };
 
 
 function buildLogger(scope: string = "global") {
 function buildLogger(scope: string = "global") {

+ 1 - 24
dashboard/src/shared/error_handling/sentry/setup.ts

@@ -1,13 +1,8 @@
 import * as Sentry from "@sentry/react";
 import * as Sentry from "@sentry/react";
 import { Integrations } from "@sentry/tracing";
 import { Integrations } from "@sentry/tracing";
-import Cohere from "cohere-js";
-import CohereSentry from "cohere-sentry";
 
 
 const SENTRY_DSN = process.env.SENTRY_DSN;
 const SENTRY_DSN = process.env.SENTRY_DSN;
 const SENTRY_ENV = process.env.SENTRY_ENV || "development";
 const SENTRY_ENV = process.env.SENTRY_ENV || "development";
-const COHERE_INTEGRATION = process.env.ENABLE_COHERE
-  ? [new CohereSentry()]
-  : [];
 
 
 export const SetupSentry = () => {
 export const SetupSentry = () => {
   if (!SENTRY_DSN) {
   if (!SENTRY_DSN) {
@@ -15,27 +10,9 @@ export const SetupSentry = () => {
   }
   }
   Sentry.init({
   Sentry.init({
     dsn: SENTRY_DSN,
     dsn: SENTRY_DSN,
-    integrations: [new Integrations.BrowserTracing(), ...COHERE_INTEGRATION],
+    integrations: [new Integrations.BrowserTracing()],
     environment: SENTRY_ENV,
     environment: SENTRY_ENV,
     // Check out https://docs.sentry.io/platforms/javascript/guides/react/configuration/sampling/ for a more refined sample rate
     // Check out https://docs.sentry.io/platforms/javascript/guides/react/configuration/sampling/ for a more refined sample rate
     tracesSampleRate: 1,
     tracesSampleRate: 1,
   });
   });
-
-  if (process.env.ENABLE_COHERE) {
-    const sessionUrlListener = (sessionUrl: string) => {
-      Sentry.configureScope((scope) => {
-        scope.addEventProcessor((event) => {
-          event.tags = {
-            ...event.tags,
-            cohere_link: `${sessionUrl}${
-              event.timestamp ? `?ts=${event.timestamp * 1000}` : ""
-            }`,
-          };
-
-          return event;
-        });
-      });
-    };
-    Cohere.addSessionUrlListener(sessionUrlListener);
-  }
 };
 };