UNPKG

phx-node-test-1

Version:

PHX NODE

58 lines 2.38 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.runWithSentryCheckIn = runWithSentryCheckIn; const Sentry = require("@sentry/nestjs"); const constant_1 = require("../../lib/constant"); function runWithSentryCheckIn(monitorSlug, cronTime, cronTask, monitorConfig) { return __awaiter(this, void 0, void 0, function* () { if (process.env.ENV === constant_1.envProd) { const { checkInMargin, maxRuntime } = monitorConfig; const checkInId = Sentry.captureCheckIn({ monitorSlug, status: "in_progress", }, { schedule: { type: "crontab", value: cronTime, }, checkinMargin: checkInMargin, maxRuntime, failureIssueThreshold: 3, }); try { yield cronTask(); const res = Sentry.captureCheckIn({ checkInId, monitorSlug, status: "ok", }); console.log("res", res); } catch (err) { Sentry.withScope((scope) => { scope.setTag("errorType", "catch"); Sentry.captureException(err); Sentry.captureCheckIn({ checkInId, monitorSlug, status: "error", }); }); throw new Error(err); } } else { yield cronTask(); } }); } //# sourceMappingURL=sentry-monitor.js.map