Openstatus www.openstatus.dev

🧹 remove screenshot (#1231)

authored by

Thibault Le Ouay and committed by
GitHub
89735cc2 5d7f095c

+3 -48
+3 -1
apps/screenshot-service/README.md
··· 1 1 # Screenshot Worker 2 2 3 - This is a worker that takes screenshots of web pages when we create an incident. 3 + This is not used anymore. 4 + 5 + Will be used for browser check
-47
apps/workflows/src/checker/index.ts
··· 246 246 .update(schema.monitor) 247 247 .set({ status: "error" }) 248 248 .where(eq(schema.monitor.id, monitor.id)); 249 - 250 - if (monitor && monitor.jobType === "http" && monitor.workspaceId) { 251 - const currentWorkspace = await db 252 - .select() 253 - .from(workspace) 254 - .where(eq(workspace.id, monitor.workspaceId)) 255 - .get(); 256 - if (!!currentWorkspace?.plan && currentWorkspace?.plan !== "free") { 257 - await triggerScreenshot({ 258 - data: { 259 - url: monitor.url, 260 - incidentId: newIncident[0].id, 261 - kind: "incident", 262 - }, 263 - }); 264 - } 265 - } 266 249 await checkerAudit.publishAuditLog({ 267 250 id: `monitor:${monitorId}`, 268 251 action: "monitor.failed", ··· 283 266 // if we are in error 284 267 return c.text("Ok", 200); 285 268 }); 286 - 287 - const payload = z.object({ 288 - url: z.string().url(), 289 - incidentId: z.number(), 290 - kind: z.enum(["incident", "recovery"]), 291 - }); 292 - 293 - const triggerScreenshot = async ({ 294 - data, 295 - }: { 296 - data: z.infer<typeof payload>; 297 - }) => { 298 - console.log(` 📸 taking screenshot for incident ${data.incidentId}`); 299 - 300 - const client = new Client({ token: env().QSTASH_TOKEN }); 301 - 302 - await client.publishJSON({ 303 - url: env().SCREENSHOT_SERVICE_URL, 304 - method: "POST", 305 - headers: { 306 - "Content-Type": "application/json", 307 - "api-key": `Basic ${env().CRON_SECRET}`, 308 - }, 309 - body: { 310 - url: data.url, 311 - incidentId: data.incidentId, 312 - kind: data.kind, 313 - }, 314 - }); 315 - };