"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const Sentry = __importStar(require("@sentry/node"));
const pacakge_json_helper_1 = require("./pacakge.json.helper");
const cliPackageJSON = pacakge_json_helper_1.PackageJSONHelper.getCliPackageJson();
Sentry.init({
    dsn: "https://d340ba9192a7d8a2b22f5f2bce277bf3@o1356253.ingest.us.sentry.io/4510145912504320",
    // Setting this option to true will send default PII data to Sentry.
    // For example, automatic IP address collection on events
    sendDefaultPii: true,
    enableLogs: true,
    // Set environment based on NODE_ENV or default to 'development'
    environment: process.env['NODE_ENV'] || 'development',
    // Add release information
    release: cliPackageJSON?.version,
    // Sample rate for performance monitoring (0.0 to 1.0)
    tracesSampleRate: 0.1,
});
Sentry.startSession();
const finishOk = async (status = "ok") => {
    // Mark session outcome, then send it
    if (status === "crashed") {
        // If your process is about to die from an exception,
        // just end+capture; no need to set errors explicitly.
    }
    Sentry.endSession(); // marks session as "exited"
    Sentry.captureSession(true); // send it immediately
    await Sentry.flush(100).catch(() => { });
};
// Clean exits
process.once("beforeExit", () => { finishOk("ok"); });
process.once("exit", () => { finishOk("ok"); });
// User-initiated termination => not a crash (shows up as an "abnormal" exit server-side)
process.once("SIGINT", () => { finishOk("abnormal"); process.exit(130); });
process.once("SIGTERM", () => { finishOk("abnormal"); process.exit(143); });
//# sourceMappingURL=sentry.js.map