From 0105c66c9f1746376edfa76d4d6365e94a62fde1 Mon Sep 17 00:00:00 2001 From: Alex Andreev Date: Mon, 5 Jul 2021 13:30:19 +0300 Subject: [PATCH] Setting up environment prop Signed-off-by: Alex Andreev --- src/main/index.ts | 12 ++++-------- src/renderer/lens-app.tsx | 12 ++++-------- webpack.main.ts | 5 +---- webpack.renderer.ts | 5 ----- 4 files changed, 9 insertions(+), 25 deletions(-) diff --git a/src/main/index.ts b/src/main/index.ts index 74aa78664d..4e87cb1934 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 } from "../common/vars"; +import { appName, isMac, productName, dsn, isProduction } from "../common/vars"; import path from "path"; import { LensProxy } from "./proxy/lens-proxy"; import { WindowManager } from "./window-manager"; @@ -62,12 +62,7 @@ import { FilesystemProvisionerStore } from "./extension-filesystem"; import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations"; // Initializing Sentry -const Sentry = - // prevent `TypeError: mod.require is not a function` - // see https://docs.sentry.io/platforms/javascript/guides/electron/#webpack-configuration - process.type === "main" - ? require("@sentry/electron/dist/main") - : require("@sentry/electron/dist/renderer"); +const Sentry = require("@sentry/electron/dist/main"); Sentry.init({ dsn, @@ -82,7 +77,8 @@ Sentry.init({ "rocess.env.NODE_ENV": process.env.NODE_ENV, "process.env.CICD": process.env.CICD } - } + }, + environment: isProduction ? "production" : "development" }); const workingDir = path.join(app.getPath("appData"), appName); diff --git a/src/renderer/lens-app.tsx b/src/renderer/lens-app.tsx index 2a5e586e22..e9c3b42506 100644 --- a/src/renderer/lens-app.tsx +++ b/src/renderer/lens-app.tsx @@ -36,16 +36,11 @@ import { registerIpcHandlers } from "./ipc"; import { ipcRenderer } from "electron"; import { IpcRendererNavigationEvents } from "./navigation/events"; import { catalogEntityRegistry } from "./api/catalog-entity-registry"; -import { dsn } from "../common/vars"; +import { dsn, isProduction } from "../common/vars"; import { CaptureConsole, Dedupe, Offline } from "@sentry/integrations"; // Initializing Sentry -const Sentry = - // prevent `TypeError: mod.require is not a function` - // see https://docs.sentry.io/platforms/javascript/guides/electron/#webpack-configuration - process.type === "main" - ? require("@sentry/electron/dist/main") - : require("@sentry/electron/dist/renderer"); +const Sentry = require("@sentry/electron/dist/renderer"); Sentry.init({ dsn, @@ -60,7 +55,8 @@ Sentry.init({ "rocess.env.NODE_ENV": process.env.NODE_ENV, "process.env.CICD": process.env.CICD } - } + }, + environment: isProduction ? "production" : "development" }); @observer diff --git a/webpack.main.ts b/webpack.main.ts index b7df6879da..ae78d06d09 100755 --- a/webpack.main.ts +++ b/webpack.main.ts @@ -20,7 +20,7 @@ */ import path from "path"; -import webpack from "webpack"; +import type webpack from "webpack"; import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"; import { isProduction, mainDir, buildDir, isDevelopment } from "./src/common/vars"; import nodeExternals from "webpack-node-externals"; @@ -62,9 +62,6 @@ export default function (): webpack.Configuration { plugins: [ new ProgressBarPlugin(), new ForkTsCheckerPlugin(), - new webpack.DefinePlugin({ - "process.type": '"main"', - }), ].filter(Boolean) }; } diff --git a/webpack.renderer.ts b/webpack.renderer.ts index 9d019298be..c0353ef1f8 100755 --- a/webpack.renderer.ts +++ b/webpack.renderer.ts @@ -174,11 +174,6 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura isDevelopment && new webpack.HotModuleReplacementPlugin(), isDevelopment && new ReactRefreshWebpackPlugin(), - - new webpack.DefinePlugin({ - "process.type": '"renderer"', - }), - ].filter(Boolean), }; }