Rocky_Mountain_Vending/.pnpm-store/v10/files/a7/31d9e8e954b3ae81a81c987b43466acf0ea993db1d987f01de304e8d5086554b3e555573a750ab3a2fedc862fd3fc509f1ad33ff5c4165ff14cb4d83f60dbf
DMleadgen 46d973904b
Initial commit: Rocky Mountain Vending website
Next.js website for Rocky Mountain Vending company featuring:
- Product catalog with Stripe integration
- Service areas and parts pages
- Admin dashboard with Clerk authentication
- SEO optimized pages with JSON-LD structured data

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-12 16:22:15 -07:00

112 lines
3 KiB
Text

Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const core = require('@sentry/core');
const common = require('./common.js');
const ERROR_TEXT = 'Automatic instrumentation of CronJob only supports crontab string';
/**
* Instruments the `cron` library to send a check-in event to Sentry for each job execution.
*
* ```ts
* import * as Sentry from '@sentry/node';
* import { CronJob } from 'cron';
*
* const CronJobWithCheckIn = Sentry.cron.instrumentCron(CronJob, 'my-cron-job');
*
* // use the constructor
* const job = new CronJobWithCheckIn('* * * * *', () => {
* console.log('You will see this message every minute');
* });
*
* // or from
* const job = CronJobWithCheckIn.from({ cronTime: '* * * * *', onTick: () => {
* console.log('You will see this message every minute');
* });
* ```
*/
function instrumentCron(lib, monitorSlug) {
let jobScheduled = false;
return new Proxy(lib, {
construct(target, args) {
const [cronTime, onTick, onComplete, start, timeZone, ...rest] = args;
if (typeof cronTime !== 'string') {
throw new Error(ERROR_TEXT);
}
if (jobScheduled) {
throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
}
jobScheduled = true;
const cronString = common.replaceCronNames(cronTime);
async function monitoredTick(context, onComplete) {
return core.withMonitor(
monitorSlug,
async () => {
try {
await onTick(context, onComplete);
} catch (e) {
core.captureException(e);
throw e;
}
},
{
schedule: { type: 'crontab', value: cronString },
timezone: timeZone || undefined,
},
);
}
return new target(cronTime, monitoredTick, onComplete, start, timeZone, ...rest);
},
get(target, prop) {
if (prop === 'from') {
return (param) => {
const { cronTime, onTick, timeZone } = param;
if (typeof cronTime !== 'string') {
throw new Error(ERROR_TEXT);
}
if (jobScheduled) {
throw new Error(`A job named '${monitorSlug}' has already been scheduled`);
}
jobScheduled = true;
const cronString = common.replaceCronNames(cronTime);
param.onTick = async (context, onComplete) => {
return core.withMonitor(
monitorSlug,
async () => {
try {
await onTick(context, onComplete);
} catch (e) {
core.captureException(e);
throw e;
}
},
{
schedule: { type: 'crontab', value: cronString },
timezone: timeZone || undefined,
},
);
};
return target.from(param);
};
} else {
return target[prop];
}
},
});
}
exports.instrumentCron = instrumentCron;
//# sourceMappingURL=cron.js.map