MCPcopy
hub / github.com/chartbrew/chartbrew / startEvent

Function startEvent

server/modules/updateAudit.js:418–464  ·  view source on GitHub ↗
(traceContext, stage, payload = {}, status = "started")

Source from the content-addressed store, hash-verified

416}
417
418async function startEvent(traceContext, stage, payload = {}, status = "started") {
419 if (!traceContext) {
420 return null;
421 }
422
423 const eventPayload = sanitizePayload(payload);
424 const startedAt = new Date();
425 const event = {
426 runId: traceContext.runId || null,
427 sequence: traceContext.nextSequence || 1,
428 stage,
429 status,
430 startedAt,
431 payload: eventPayload,
432 };
433
434 const mutableTraceContext = traceContext;
435 mutableTraceContext.nextSequence = event.sequence + 1;
436
437 try {
438 if (db.UpdateRunEvent && traceContext.runId) {
439 const createdEvent = await db.UpdateRunEvent.create({
440 runId: traceContext.runId,
441 sequence: event.sequence,
442 stage,
443 status,
444 startedAt,
445 payload: eventPayload,
446 });
447 event.id = createdEvent.id;
448 }
449 } catch (error) {
450 emitAuditInternalError("[updateAudit] failed to create event", error);
451 }
452
453 emitStructuredAuditLog("event_started", {
454 runId: traceContext.runId,
455 traceId: traceContext.traceId,
456 rootTraceId: traceContext.rootTraceId,
457 sequence: event.sequence,
458 stage,
459 status,
460 payload: eventPayload,
461 });
462
463 return event;
464}
465
466async function finishEvent(traceContext, event, status = "success", payload = {}) {
467 if (!traceContext || !event) {

Callers 7

runRequestMethod · 0.85
updateChartDataMethod · 0.85
completeRunFunction · 0.85
failRunFunction · 0.85
recordInstantEventFunction · 0.85
addDashboardToQueueFunction · 0.85
addChartsToQueueFunction · 0.85

Calls 4

sanitizePayloadFunction · 0.85
emitAuditInternalErrorFunction · 0.85
emitStructuredAuditLogFunction · 0.85
createMethod · 0.45

Tested by

no test coverage detected