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

Add process.type to be used by Sentry

Signed-off-by: Hung-Han (Henry) Chen <chenhungh@gmail.com>
This commit is contained in:
Hung-Han (Henry) Chen 2021-07-02 13:28:41 +03:00
parent 1bf6f5a94e
commit 6eced04c76
No known key found for this signature in database
GPG Key ID: 54B44603D251B788
3 changed files with 27 additions and 1 deletions

View File

@ -36,6 +36,25 @@ 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 } 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");
Sentry.init({
dsn,
integrations: [
new CaptureConsole({ levels: ["error"] }),
new Dedupe(),
new Offline()
],
});
@observer @observer
export class LensApp extends React.Component { export class LensApp extends React.Component {

View File

@ -20,7 +20,7 @@
*/ */
import path from "path"; import path from "path";
import type webpack from "webpack"; import webpack from "webpack";
import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin"; import ForkTsCheckerPlugin from "fork-ts-checker-webpack-plugin";
import { isProduction, mainDir, buildDir, isDevelopment } from "./src/common/vars"; import { isProduction, mainDir, buildDir, isDevelopment } from "./src/common/vars";
import nodeExternals from "webpack-node-externals"; import nodeExternals from "webpack-node-externals";
@ -62,6 +62,9 @@ export default function (): webpack.Configuration {
plugins: [ plugins: [
new ProgressBarPlugin(), new ProgressBarPlugin(),
new ForkTsCheckerPlugin(), new ForkTsCheckerPlugin(),
new webpack.DefinePlugin({
"process.type": '"main"',
}),
].filter(Boolean) ].filter(Boolean)
}; };
} }

View File

@ -175,6 +175,10 @@ export function webpackLensRenderer({ showVars = true } = {}): webpack.Configura
isDevelopment && new webpack.HotModuleReplacementPlugin(), isDevelopment && new webpack.HotModuleReplacementPlugin(),
isDevelopment && new ReactRefreshWebpackPlugin(), isDevelopment && new ReactRefreshWebpackPlugin(),
new webpack.DefinePlugin({
"process.type": '"renderer"',
}),
].filter(Boolean), ].filter(Boolean),
}; };
} }