feat: run succes fail handle
This commit is contained in:
@@ -255,11 +255,12 @@ router.post('/runs/run/:id', requireSignIn, async (req: AuthenticatedRequest, re
|
||||
});
|
||||
captureServerAnalytics.capture({
|
||||
distinctId: req.user?.id,
|
||||
event: 'maxun-oss-run-created',
|
||||
event: 'maxun-oss-run-created-manual',
|
||||
properties: {
|
||||
runId: req.params.id,
|
||||
user_id: req.user?.id,
|
||||
created_at: new Date().toISOString(),
|
||||
status: 'success',
|
||||
}
|
||||
})
|
||||
try {
|
||||
@@ -279,7 +280,26 @@ router.post('/runs/run/:id', requireSignIn, async (req: AuthenticatedRequest, re
|
||||
}
|
||||
} catch (e) {
|
||||
const { message } = e as Error;
|
||||
// If error occurs, set run status to failed
|
||||
const run = await Run.findOne({ where: { runId: req.params.id } });
|
||||
if (run) {
|
||||
await run.update({
|
||||
status: 'failed',
|
||||
finishedAt: new Date().toLocaleString(),
|
||||
});
|
||||
}
|
||||
logger.log('info', `Error while running a recording with id: ${req.params.id} - ${message}`);
|
||||
captureServerAnalytics.capture({
|
||||
distinctId: req.user?.id,
|
||||
event: 'maxun-oss-run-created-manual',
|
||||
properties: {
|
||||
runId: req.params.id,
|
||||
user_id: req.user?.id,
|
||||
created_at: new Date().toISOString(),
|
||||
status: 'failed',
|
||||
error_message: message,
|
||||
}
|
||||
});
|
||||
return res.send(false);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -9,6 +9,7 @@ import Robot from "../../models/Robot";
|
||||
import Run from "../../models/Run";
|
||||
import { getDecryptedProxyConfig } from "../../routes/proxy";
|
||||
import { BinaryOutputService } from "../../storage/mino";
|
||||
import captureServerAnalytics from "../../utils/analytics";
|
||||
|
||||
async function createWorkflowAndStoreMetadata(id: string, userId: string) {
|
||||
try {
|
||||
@@ -132,6 +133,16 @@ async function executeRun(id: string) {
|
||||
binaryOutput: uploadedBinaryOutput,
|
||||
});
|
||||
|
||||
captureServerAnalytics.capture({
|
||||
distinctId: id,
|
||||
event: 'maxun-oss-run-created-scheduled',
|
||||
properties: {
|
||||
runId: id,
|
||||
created_at: new Date().toISOString(),
|
||||
status: 'success',
|
||||
}
|
||||
});
|
||||
|
||||
googleSheetUpdateTasks[id] = {
|
||||
robotId: plainRun.robotMetaId,
|
||||
runId: id,
|
||||
@@ -143,6 +154,22 @@ async function executeRun(id: string) {
|
||||
} catch (error: any) {
|
||||
logger.log('info', `Error while running a recording with id: ${id} - ${error.message}`);
|
||||
console.log(error.message);
|
||||
const run = await Run.findOne({ where: { runId: id } });
|
||||
if (run) {
|
||||
await run.update({
|
||||
status: 'failed',
|
||||
finishedAt: new Date().toLocaleString(),
|
||||
});
|
||||
}
|
||||
captureServerAnalytics.capture({
|
||||
distinctId: id,
|
||||
event: 'maxun-oss-run-created-scheduled',
|
||||
properties: {
|
||||
runId: id,
|
||||
created_at: new Date().toISOString(),
|
||||
status: 'failed',
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user