From 0460db2e120efa2147edaaf20ea39a5342ad7086 Mon Sep 17 00:00:00 2001 From: Sebastian Malton Date: Thu, 1 Dec 2022 09:15:39 -0500 Subject: [PATCH] Move initializing sentry to runnable Signed-off-by: Sebastian Malton --- src/renderer/bootstrap.tsx | 8 ------ src/renderer/sentry/initialize.injectable.ts | 28 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 8 deletions(-) create mode 100644 src/renderer/sentry/initialize.injectable.ts diff --git a/src/renderer/bootstrap.tsx b/src/renderer/bootstrap.tsx index 735d349ac7..57e1297ced 100644 --- a/src/renderer/bootstrap.tsx +++ b/src/renderer/bootstrap.tsx @@ -38,12 +38,10 @@ import addSyncEntriesInjectable from "./initializers/add-sync-entries.injectable import hotbarStoreInjectable from "../common/hotbars/store.injectable"; import { bindEvents } from "./navigation/events"; import openDeleteClusterDialogInjectable from "./components/delete-cluster-dialog/open.injectable"; -import { init } from "@sentry/electron/renderer"; import kubernetesClusterCategoryInjectable from "../common/catalog/categories/kubernetes-cluster.injectable"; import autoRegistrationInjectable from "../common/k8s-api/api-manager/auto-registration.injectable"; import assert from "assert"; import startFrameInjectable from "./start-frame/start-frame.injectable"; -import initializeSentryReportingWithInjectable from "../common/error-reporting/initialize-sentry-reporting.injectable"; configurePackages(); // global packages registerCustomThemes(); // monaco editor themes @@ -60,12 +58,6 @@ async function attachChromeDebugger() { } export async function bootstrap(di: DiContainer) { - const initializeSentryReportingWith = di.inject(initializeSentryReportingWithInjectable); - - if (process.isMainFrame) { - initializeSentryReportingWith(init); - } - const startFrame = di.inject(startFrameInjectable); await startFrame(); diff --git a/src/renderer/sentry/initialize.injectable.ts b/src/renderer/sentry/initialize.injectable.ts new file mode 100644 index 0000000000..8372eae2b4 --- /dev/null +++ b/src/renderer/sentry/initialize.injectable.ts @@ -0,0 +1,28 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ +import { getInjectable } from "@ogre-tools/injectable"; +import initializeSentryReportingWithInjectable from "../../common/error-reporting/initialize-sentry-reporting.injectable"; +import setupAppPathsInjectable from "../app-paths/setup-app-paths.injectable"; +import { beforeFrameStartsInjectionToken } from "../before-frame-starts/before-frame-starts-injection-token"; +import { init } from "@sentry/electron/renderer"; + +const initializeSentryReportingInjectable = getInjectable({ + id: "initialize-sentry-reporting", + instantiate: (di) => ({ + id: "initialize-sentry-reporting", + run: () => { + // Have to inject this here instead of above so that its dependency on `setupAppPathsInjectable` doesn't throw + const initializeSentryReportingWith = di.inject(initializeSentryReportingWithInjectable); + + if (process.isMainFrame) { + initializeSentryReportingWith(init); + } + }, + runAfter: di.inject(setupAppPathsInjectable), + }), + injectionToken: beforeFrameStartsInjectionToken, +}); + +export default initializeSentryReportingInjectable;