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

pass in init function

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2022-03-31 14:10:25 -04:00
parent 1d472e373f
commit ea777ad515
3 changed files with 14 additions and 10 deletions

View File

@ -7,6 +7,8 @@ import { Dedupe, Offline } from "@sentry/integrations";
import { sentryDsn, isProduction } from "./vars";
import { UserStore } from "./user-store";
import { inspect } from "util";
import type { BrowserOptions } from "@sentry/electron/renderer";
import type { ElectronMainOptions } from "@sentry/electron/main";
/**
* "Translate" 'browser' to 'main' as Lens developer more familiar with the term 'main'
@ -22,12 +24,12 @@ function mapProcessName(processType: string) {
/**
* Initialize Sentry for the current process so to send errors for debugging.
*/
export async function SentryInit() {
export function initializeSentryReporting(init: (opts: BrowserOptions | ElectronMainOptions) => void) {
const processName = mapProcessName(process.type);
const { init } = process.type === "browser"
? await import("@sentry/electron/main")
: await import("@sentry/electron/renderer");
if (!sentryDsn) {
return; // do nothing if not configured to avoid uncaught error in dev mode
}
init({
beforeSend: (event) => {

View File

@ -35,7 +35,7 @@ import configurePackages from "../common/configure-packages";
import { PrometheusProviderRegistry } from "./prometheus";
import * as initializers from "./initializers";
import { WeblinkStore } from "../common/weblink-store";
import { SentryInit } from "../common/sentry";
import { initializeSentryReporting } from "../common/sentry";
import { ensureDir } from "fs-extra";
import { initMenu } from "./menu/menu";
import { kubeApiUpgradeRequest } from "./proxy-functions";
@ -61,6 +61,7 @@ import syncGeneralCatalogEntitiesInjectable from "./catalog-sources/sync-general
import hotbarStoreInjectable from "../common/hotbar-store.injectable";
import applicationMenuItemsInjectable from "./menu/application-menu-items.injectable";
import type { DiContainer } from "@ogre-tools/injectable";
import { init } from "@sentry/electron/main";
async function main(di: DiContainer) {
app.setName(appName);
@ -68,7 +69,7 @@ async function main(di: DiContainer) {
/**
* Note: this MUST be called before electron's "ready" event has been emitted.
*/
await SentryInit();
initializeSentryReporting(init);
await di.runSetups();
await app.whenReady();

View File

@ -21,7 +21,7 @@ import configurePackages from "../common/configure-packages";
import * as initializers from "./initializers";
import logger from "../common/logger";
import { WeblinkStore } from "../common/weblink-store";
import { SentryInit } from "../common/sentry";
import { initializeSentryReporting } from "../common/sentry";
import { registerCustomThemes } from "./components/monaco-editor";
import { getDi } from "./getDi";
import { DiContextProvider } from "@ogre-tools/injectable-react";
@ -41,8 +41,8 @@ import navigateToAddClusterInjectable from "../common/front-end-routing/routes/
import addSyncEntriesInjectable from "./initializers/add-sync-entries.injectable";
import hotbarStoreInjectable from "../common/hotbar-store.injectable";
import { bindEvents } from "./navigation/events";
import deleteClusterDialogModelInjectable
from "./components/delete-cluster-dialog/delete-cluster-dialog-model/delete-cluster-dialog-model.injectable";
import deleteClusterDialogModelInjectable from "./components/delete-cluster-dialog/delete-cluster-dialog-model/delete-cluster-dialog-model.injectable";
import { init } from "@sentry/electron/renderer";
configurePackages(); // global packages
registerCustomThemes(); // monaco editor themes
@ -60,8 +60,9 @@ async function attachChromeDebugger() {
export async function bootstrap(di: DiContainer) {
if (process.isMainFrame) {
await SentryInit();
initializeSentryReporting(init);
}
await di.runSetups();
// TODO: Consolidate import time side-effect to setup time