mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Clean up versioning and packageJson uses (#6196)
This commit is contained in:
1 parent
cfe35ded90
commit
67ac1692b2
116 files changed
+1154
-644
No files matched your search
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Copyright (c) OpenLens Authors. All rights reserved.
|
||||
* Licensed under MIT License. See LICENSE in root directory for more information.
|
||||
*/
|
||||
|
||||
import { getGlobalOverride } from "../test-utils/get-global-override";
|
||||
import initializeSentryReportingWithInjectable from "./initialize-sentry-reporting.injectable";
|
||||
|
||||
export default getGlobalOverride(initializeSentryReportingWithInjectable, () => () => {});
|
||||
@@ -0,0 +1,65 @@
|
||||
/**
|
||||
* 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 type { ElectronMainOptions } from "@sentry/electron/main";
|
||||
import type { BrowserOptions } from "@sentry/electron/renderer";
|
||||
import isProductionInjectable from "../vars/is-production.injectable";
|
||||
import sentryDataSourceNameInjectable from "../vars/sentry-dsn-url.injectable";
|
||||
import { Dedupe, Offline } from "@sentry/integrations";
|
||||
import { inspect } from "util";
|
||||
import userStoreInjectable from "../user-store/user-store.injectable";
|
||||
|
||||
export type InitializeSentryReportingWith = (initSentry: (opts: BrowserOptions | ElectronMainOptions) => void) => void;
|
||||
|
||||
const mapProcessName = (type: "browser" | "renderer" | "worker") => type === "browser" ? "main" : type;
|
||||
|
||||
const initializeSentryReportingWithInjectable = getInjectable({
|
||||
id: "initialize-sentry-reporting-with",
|
||||
instantiate: (di): InitializeSentryReportingWith => {
|
||||
const sentryDataSourceName = di.inject(sentryDataSourceNameInjectable);
|
||||
const isProduction = di.inject(isProductionInjectable);
|
||||
|
||||
if (!sentryDataSourceName) {
|
||||
return () => {};
|
||||
}
|
||||
|
||||
return (initSentry) => initSentry({
|
||||
beforeSend: (event) => {
|
||||
// TODO: remove loading from userStoreInjectable so that this can be moved out
|
||||
const userStore = di.inject(userStoreInjectable);
|
||||
|
||||
if (userStore.allowErrorReporting) {
|
||||
return event;
|
||||
}
|
||||
|
||||
/**
|
||||
* Directly write to stdout so that no other integrations capture this and create an infinite loop
|
||||
*/
|
||||
process.stdout.write(`🔒 [SENTRY-BEFORE-SEND-HOOK]: Sentry event is caught but not sent to server.`);
|
||||
process.stdout.write("🔒 [SENTRY-BEFORE-SEND-HOOK]: === START OF SENTRY EVENT ===");
|
||||
process.stdout.write(inspect(event, false, null, true));
|
||||
process.stdout.write("🔒 [SENTRY-BEFORE-SEND-HOOK]: === END OF SENTRY EVENT ===");
|
||||
|
||||
// if return null, the event won't be sent
|
||||
// ref https://github.com/getsentry/sentry-javascript/issues/2039
|
||||
return null;
|
||||
},
|
||||
dsn: sentryDataSourceName,
|
||||
integrations: [
|
||||
new Dedupe(),
|
||||
new Offline(),
|
||||
],
|
||||
initialScope: {
|
||||
tags: {
|
||||
"process": mapProcessName(process.type),
|
||||
},
|
||||
},
|
||||
environment: isProduction ? "production" : "development",
|
||||
});
|
||||
},
|
||||
causesSideEffects: true,
|
||||
});
|
||||
|
||||
export default initializeSentryReportingWithInjectable;
|
||||
Reference in new issue
Block a user