chore: fix telemetry run creation
This commit is contained in:
@@ -861,7 +861,7 @@ async function executeRun(id: string, userId: string, requestedFormats?: string[
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
capture("maxun-oss-run-created-api", {
|
capture("maxun-oss-run-created", {
|
||||||
runId: plainRun.runId,
|
runId: plainRun.runId,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
robotId: recording.recording_meta.id,
|
robotId: recording.recording_meta.id,
|
||||||
|
|||||||
@@ -752,7 +752,9 @@ router.post("/sdk/crawl", requireAPIKey, async (req: AuthenticatedRequest, res:
|
|||||||
url: url,
|
url: url,
|
||||||
robotType: 'crawl',
|
robotType: 'crawl',
|
||||||
crawlConfig: crawlConfig,
|
crawlConfig: crawlConfig,
|
||||||
source: 'sdk'
|
source: 'sdk',
|
||||||
|
robot_meta: robot.recording_meta,
|
||||||
|
recording: robot.recording,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
@@ -846,7 +848,9 @@ router.post("/sdk/search", requireAPIKey, async (req: AuthenticatedRequest, res:
|
|||||||
searchQuery: searchConfig.query,
|
searchQuery: searchConfig.query,
|
||||||
searchProvider: searchConfig.provider || 'duckduckgo',
|
searchProvider: searchConfig.provider || 'duckduckgo',
|
||||||
searchLimit: searchConfig.limit || 10,
|
searchLimit: searchConfig.limit || 10,
|
||||||
source: 'sdk'
|
source: 'sdk',
|
||||||
|
robot_meta: robot.recording_meta,
|
||||||
|
recording: robot.recording,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
|
|||||||
@@ -349,12 +349,13 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
|
|||||||
logger.log('warn', `Failed to send webhooks for markdown robot run ${data.runId}: ${webhookError.message}`);
|
logger.log('warn', `Failed to send webhooks for markdown robot run ${data.runId}: ${webhookError.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
capture("maxun-oss-run-created-manual", {
|
capture("maxun-oss-run-created", {
|
||||||
runId: data.runId,
|
runId: data.runId,
|
||||||
user_id: data.userId,
|
user_id: data.userId,
|
||||||
status: "success",
|
status: "success",
|
||||||
robot_type: "scrape",
|
robot_type: "scrape",
|
||||||
formats,
|
formats,
|
||||||
|
source: "manual"
|
||||||
});
|
});
|
||||||
|
|
||||||
await destroyRemoteBrowser(browserId, data.userId);
|
await destroyRemoteBrowser(browserId, data.userId);
|
||||||
@@ -385,12 +386,13 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
|
|||||||
logger.log('warn', `Failed to send run-failed notification for markdown robot run ${data.runId}: ${socketError.message}`);
|
logger.log('warn', `Failed to send run-failed notification for markdown robot run ${data.runId}: ${socketError.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
capture("maxun-oss-run-created-manual", {
|
capture("maxun-oss-run-created", {
|
||||||
runId: data.runId,
|
runId: data.runId,
|
||||||
user_id: data.userId,
|
user_id: data.userId,
|
||||||
status: "failed",
|
status: "failed",
|
||||||
robot_type: "scrape",
|
robot_type: "scrape",
|
||||||
formats,
|
formats,
|
||||||
|
source: "manual"
|
||||||
});
|
});
|
||||||
|
|
||||||
await destroyRemoteBrowser(browserId, data.userId);
|
await destroyRemoteBrowser(browserId, data.userId);
|
||||||
@@ -523,7 +525,7 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
|
|||||||
|
|
||||||
// Capture metrics
|
// Capture metrics
|
||||||
capture(
|
capture(
|
||||||
'maxun-oss-run-created-manual',
|
'maxun-oss-run-created',
|
||||||
{
|
{
|
||||||
runId: data.runId,
|
runId: data.runId,
|
||||||
user_id: data.userId,
|
user_id: data.userId,
|
||||||
@@ -534,6 +536,7 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
|
|||||||
listItemsExtracted: totalListItemsExtracted,
|
listItemsExtracted: totalListItemsExtracted,
|
||||||
extractedScreenshotsCount,
|
extractedScreenshotsCount,
|
||||||
is_llm: (recording.recording_meta as any).isLLM,
|
is_llm: (recording.recording_meta as any).isLLM,
|
||||||
|
source: 'manual'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -693,7 +696,7 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
|
|||||||
logger.log('warn', `Failed to emit failure event in main catch: ${socketError.message}`);
|
logger.log('warn', `Failed to emit failure event in main catch: ${socketError.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
capture('maxun-oss-run-created-manual', {
|
capture('maxun-oss-run-created', {
|
||||||
runId: data.runId,
|
runId: data.runId,
|
||||||
user_id: data.userId,
|
user_id: data.userId,
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
@@ -702,6 +705,7 @@ async function processRunExecution(job: Job<ExecuteRunData>) {
|
|||||||
partial_data_extracted: partialDataExtracted,
|
partial_data_extracted: partialDataExtracted,
|
||||||
totalRowsExtracted: partialData?.totalSchemaItemsExtracted + partialData?.totalListItemsExtracted + partialData?.extractedScreenshotsCount || 0,
|
totalRowsExtracted: partialData?.totalSchemaItemsExtracted + partialData?.totalListItemsExtracted + partialData?.extractedScreenshotsCount || 0,
|
||||||
is_llm: (recording?.recording_meta as any)?.isLLM,
|
is_llm: (recording?.recording_meta as any)?.isLLM,
|
||||||
|
source: 'manual'
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -886,13 +886,14 @@ router.post('/runs/run/:id', requireSignIn, async (req: AuthenticatedRequest, re
|
|||||||
}
|
}
|
||||||
logger.log('info', `Error while running a robot with id: ${req.params.id} - ${message}`);
|
logger.log('info', `Error while running a robot with id: ${req.params.id} - ${message}`);
|
||||||
capture(
|
capture(
|
||||||
'maxun-oss-run-created-manual',
|
'maxun-oss-run-created',
|
||||||
{
|
{
|
||||||
runId: req.params.id,
|
runId: req.params.id,
|
||||||
user_id: req.user?.id,
|
user_id: req.user?.id,
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
status: 'failed',
|
status: 'failed',
|
||||||
error_message: message,
|
error_message: message,
|
||||||
|
source: 'manual'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return res.send(false);
|
return res.send(false);
|
||||||
@@ -1407,7 +1408,9 @@ router.post('/recordings/crawl', requireSignIn, async (req: AuthenticatedRequest
|
|||||||
robotName: robotName,
|
robotName: robotName,
|
||||||
url: url,
|
url: url,
|
||||||
robotType: 'crawl',
|
robotType: 'crawl',
|
||||||
crawlConfig: crawlConfig
|
crawlConfig: crawlConfig,
|
||||||
|
robot_meta: newRobot.recording_meta,
|
||||||
|
recording: newRobot.recording,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
@@ -1493,7 +1496,9 @@ router.post('/recordings/search', requireSignIn, async (req: AuthenticatedReques
|
|||||||
robotType: 'search',
|
robotType: 'search',
|
||||||
searchQuery: searchConfig.query,
|
searchQuery: searchConfig.query,
|
||||||
searchProvider: searchConfig.provider || 'duckduckgo',
|
searchProvider: searchConfig.provider || 'duckduckgo',
|
||||||
searchLimit: searchConfig.limit || 10
|
searchLimit: searchConfig.limit || 10,
|
||||||
|
robot_meta: newRobot.recording_meta,
|
||||||
|
recording: newRobot.recording,
|
||||||
});
|
});
|
||||||
|
|
||||||
return res.status(201).json({
|
return res.status(201).json({
|
||||||
|
|||||||
@@ -390,12 +390,13 @@ async function executeRun(id: string, userId: string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
capture("maxun-oss-run-created-scheduled", {
|
capture("maxun-oss-run-created", {
|
||||||
runId: plainRun.runId,
|
runId: plainRun.runId,
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
status: "success",
|
status: "success",
|
||||||
robot_type: "scrape",
|
robot_type: "scrape",
|
||||||
formats
|
formats,
|
||||||
|
source: "scheduled"
|
||||||
});
|
});
|
||||||
|
|
||||||
await destroyRemoteBrowser(plainRun.browserId, userId);
|
await destroyRemoteBrowser(plainRun.browserId, userId);
|
||||||
@@ -429,12 +430,13 @@ async function executeRun(id: string, userId: string) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
capture("maxun-oss-run-created-scheduled", {
|
capture("maxun-oss-run-created", {
|
||||||
runId: plainRun.runId,
|
runId: plainRun.runId,
|
||||||
user_id: userId,
|
user_id: userId,
|
||||||
status: "failed",
|
status: "failed",
|
||||||
robot_type: "scrape",
|
robot_type: "scrape",
|
||||||
formats
|
formats,
|
||||||
|
source: "scheduled"
|
||||||
});
|
});
|
||||||
|
|
||||||
await destroyRemoteBrowser(plainRun.browserId, userId);
|
await destroyRemoteBrowser(plainRun.browserId, userId);
|
||||||
@@ -529,7 +531,7 @@ async function executeRun(id: string, userId: string) {
|
|||||||
const totalRowsExtracted = totalSchemaItemsExtracted + totalListItemsExtracted;
|
const totalRowsExtracted = totalSchemaItemsExtracted + totalListItemsExtracted;
|
||||||
|
|
||||||
capture(
|
capture(
|
||||||
'maxun-oss-run-created-scheduled',
|
'maxun-oss-run-created',
|
||||||
{
|
{
|
||||||
runId: id,
|
runId: id,
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
@@ -539,6 +541,7 @@ async function executeRun(id: string, userId: string) {
|
|||||||
listItemsExtracted: totalListItemsExtracted,
|
listItemsExtracted: totalListItemsExtracted,
|
||||||
extractedScreenshotsCount,
|
extractedScreenshotsCount,
|
||||||
is_llm: (recording.recording_meta as any).isLLM,
|
is_llm: (recording.recording_meta as any).isLLM,
|
||||||
|
source: 'scheduled'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -656,12 +659,13 @@ async function executeRun(id: string, userId: string) {
|
|||||||
logger.log('warn', `Failed to emit failure event in main catch: ${socketError.message}`);
|
logger.log('warn', `Failed to emit failure event in main catch: ${socketError.message}`);
|
||||||
}
|
}
|
||||||
capture(
|
capture(
|
||||||
'maxun-oss-run-created-scheduled',
|
'maxun-oss-run-created',
|
||||||
{
|
{
|
||||||
runId: id,
|
runId: id,
|
||||||
created_at: new Date().toISOString(),
|
created_at: new Date().toISOString(),
|
||||||
status: 'failed',
|
status: 'failed',
|
||||||
is_llm: (recording?.recording_meta as any)?.isLLM,
|
is_llm: (recording?.recording_meta as any)?.isLLM,
|
||||||
|
source: 'scheduled'
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user