mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-05 20:27:52 +08:00
feat: git hash on error (#9373)
This commit is contained in:
@@ -6,6 +6,7 @@ const path = require('path');
|
||||
const { RequestInProgressError } = require('@/errors');
|
||||
|
||||
let Sentry;
|
||||
let gitHash;
|
||||
|
||||
if (config.sentry.dsn) {
|
||||
Sentry = Sentry || require('@sentry/node');
|
||||
@@ -19,6 +20,12 @@ if (config.sentry.dsn) {
|
||||
logger.info('Sentry inited.');
|
||||
}
|
||||
|
||||
try {
|
||||
gitHash = require('git-rev-sync').short();
|
||||
} catch (e) {
|
||||
gitHash = (process.env.HEROKU_SLUG_COMMIT && process.env.HEROKU_SLUG_COMMIT.slice(0, 7)) || (process.env.VERCEL_GITHUB_COMMIT_SHA && process.env.VERCEL_GITHUB_COMMIT_SHA.slice(0, 7)) || 'unknown';
|
||||
}
|
||||
|
||||
module.exports = async (ctx, next) => {
|
||||
try {
|
||||
const time = +new Date();
|
||||
@@ -68,6 +75,7 @@ module.exports = async (ctx, next) => {
|
||||
message,
|
||||
errorPath: ctx.path,
|
||||
nodeVersion: process.version,
|
||||
gitHash,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user