genezio
Version:
Command line utility to interact with Genezio infrastructure.
44 lines (43 loc) • 1.56 kB
JavaScript
import program from "./genezio.js";
import { GenezioTelemetry, TelemetryEventTypes } from "./telemetry/telemetry.js";
import { deleteFolder } from "./utils/file.js";
import { SENTRY_DSN } from "./constants.js";
import { debugLogger } from "./utils/logging.js";
import path from "path";
import os from "os";
try {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Sentry = await import("@sentry/node");
const { ProfilingIntegration } = await import("@sentry/profiling-node");
Sentry?.init({
dsn: SENTRY_DSN,
integrations: [new ProfilingIntegration()],
// Performance Monitoring
tracesSampleRate: 0.3,
// Set sampling rate for profiling - this is relative to tracesSampleRate
profilesSampleRate: 0.3,
});
}
catch (error) {
if (error instanceof Error) {
debugLogger.debug("Sentry not initialized", error.message);
}
}
const temporaryFolder = path.join(os.tmpdir(), `genezio-${process.pid}`);
// Set-up SIGINT and exit handlers that clean up the temporary folder structure
process.on("SIGINT", async () => {
await GenezioTelemetry.sendEvent({
eventType: TelemetryEventTypes.GENEZIO_CANCEL,
errorTrace: "",
commandOptions: "",
});
await deleteFolder(temporaryFolder).catch((error) => {
debugLogger.error(`Error deleting temporary folder ${temporaryFolder}`, error);
});
process.exit();
});
process.on("exit", async () => {
await deleteFolder(temporaryFolder);
});
program.parse();