From e546d5d4693f0dc1ae6c65c36d810c97979371cd Mon Sep 17 00:00:00 2001 From: Rohit Rajan Date: Sun, 4 Jan 2026 20:29:52 +0530 Subject: [PATCH] chore: fix telemetry run creation --- server/src/api/record.ts | 2 +- server/src/api/sdk.ts | 8 ++++++-- server/src/pgboss-worker.ts | 12 ++++++++---- server/src/routes/storage.ts | 11 ++++++++--- .../src/workflow-management/scheduler/index.ts | 16 ++++++++++------ 5 files changed, 33 insertions(+), 16 deletions(-) diff --git a/server/src/api/record.ts b/server/src/api/record.ts index 8703f1d5..ccd29a6d 100644 --- a/server/src/api/record.ts +++ b/server/src/api/record.ts @@ -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, userId: userId, robotId: recording.recording_meta.id, diff --git a/server/src/api/sdk.ts b/server/src/api/sdk.ts index c275ee42..bd71825e 100644 --- a/server/src/api/sdk.ts +++ b/server/src/api/sdk.ts @@ -752,7 +752,9 @@ router.post("/sdk/crawl", requireAPIKey, async (req: AuthenticatedRequest, res: url: url, robotType: 'crawl', crawlConfig: crawlConfig, - source: 'sdk' + source: 'sdk', + robot_meta: robot.recording_meta, + recording: robot.recording, }); return res.status(201).json({ @@ -846,7 +848,9 @@ router.post("/sdk/search", requireAPIKey, async (req: AuthenticatedRequest, res: searchQuery: searchConfig.query, searchProvider: searchConfig.provider || 'duckduckgo', searchLimit: searchConfig.limit || 10, - source: 'sdk' + source: 'sdk', + robot_meta: robot.recording_meta, + recording: robot.recording, }); return res.status(201).json({ diff --git a/server/src/pgboss-worker.ts b/server/src/pgboss-worker.ts index fb91a043..1dc63307 100644 --- a/server/src/pgboss-worker.ts +++ b/server/src/pgboss-worker.ts @@ -349,12 +349,13 @@ async function processRunExecution(job: Job) { 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, user_id: data.userId, status: "success", robot_type: "scrape", formats, + source: "manual" }); await destroyRemoteBrowser(browserId, data.userId); @@ -385,12 +386,13 @@ async function processRunExecution(job: Job) { 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, user_id: data.userId, status: "failed", robot_type: "scrape", formats, + source: "manual" }); await destroyRemoteBrowser(browserId, data.userId); @@ -523,7 +525,7 @@ async function processRunExecution(job: Job) { // Capture metrics capture( - 'maxun-oss-run-created-manual', + 'maxun-oss-run-created', { runId: data.runId, user_id: data.userId, @@ -534,6 +536,7 @@ async function processRunExecution(job: Job) { listItemsExtracted: totalListItemsExtracted, extractedScreenshotsCount, is_llm: (recording.recording_meta as any).isLLM, + source: 'manual' } ); @@ -693,7 +696,7 @@ async function processRunExecution(job: Job) { 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, user_id: data.userId, created_at: new Date().toISOString(), @@ -702,6 +705,7 @@ async function processRunExecution(job: Job) { partial_data_extracted: partialDataExtracted, totalRowsExtracted: partialData?.totalSchemaItemsExtracted + partialData?.totalListItemsExtracted + partialData?.extractedScreenshotsCount || 0, is_llm: (recording?.recording_meta as any)?.isLLM, + source: 'manual' }); try { diff --git a/server/src/routes/storage.ts b/server/src/routes/storage.ts index 277c95d8..9a7a5f3c 100644 --- a/server/src/routes/storage.ts +++ b/server/src/routes/storage.ts @@ -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}`); capture( - 'maxun-oss-run-created-manual', + 'maxun-oss-run-created', { runId: req.params.id, user_id: req.user?.id, created_at: new Date().toISOString(), status: 'failed', error_message: message, + source: 'manual' } ); return res.send(false); @@ -1407,7 +1408,9 @@ router.post('/recordings/crawl', requireSignIn, async (req: AuthenticatedRequest robotName: robotName, url: url, robotType: 'crawl', - crawlConfig: crawlConfig + crawlConfig: crawlConfig, + robot_meta: newRobot.recording_meta, + recording: newRobot.recording, }); return res.status(201).json({ @@ -1493,7 +1496,9 @@ router.post('/recordings/search', requireSignIn, async (req: AuthenticatedReques robotType: 'search', searchQuery: searchConfig.query, 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({ diff --git a/server/src/workflow-management/scheduler/index.ts b/server/src/workflow-management/scheduler/index.ts index 8777ec7c..8534c2dd 100644 --- a/server/src/workflow-management/scheduler/index.ts +++ b/server/src/workflow-management/scheduler/index.ts @@ -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, user_id: userId, status: "success", robot_type: "scrape", - formats + formats, + source: "scheduled" }); 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, user_id: userId, status: "failed", robot_type: "scrape", - formats + formats, + source: "scheduled" }); await destroyRemoteBrowser(plainRun.browserId, userId); @@ -529,7 +531,7 @@ async function executeRun(id: string, userId: string) { const totalRowsExtracted = totalSchemaItemsExtracted + totalListItemsExtracted; capture( - 'maxun-oss-run-created-scheduled', + 'maxun-oss-run-created', { runId: id, created_at: new Date().toISOString(), @@ -539,6 +541,7 @@ async function executeRun(id: string, userId: string) { listItemsExtracted: totalListItemsExtracted, extractedScreenshotsCount, 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}`); } capture( - 'maxun-oss-run-created-scheduled', + 'maxun-oss-run-created', { runId: id, created_at: new Date().toISOString(), status: 'failed', is_llm: (recording?.recording_meta as any)?.isLLM, + source: 'scheduled' } ); }