diff --git a/src/Events/ActivityCompleted.php b/src/Events/ActivityCompleted.php index 1592fd2..eb8e100 100644 --- a/src/Events/ActivityCompleted.php +++ b/src/Events/ActivityCompleted.php @@ -17,6 +17,8 @@ public function __construct( public string $activityId, public string $output, public string $timestamp, + public string $class, + public int $index ) { } } diff --git a/src/Events/ActivityFailed.php b/src/Events/ActivityFailed.php index 410b33e..c17f546 100644 --- a/src/Events/ActivityFailed.php +++ b/src/Events/ActivityFailed.php @@ -17,6 +17,8 @@ public function __construct( public string $activityId, public string $output, public string $timestamp, + public string $class, + public int $index ) { } } diff --git a/src/Middleware/ActivityMiddleware.php b/src/Middleware/ActivityMiddleware.php index 4ee9126..6c1f220 100644 --- a/src/Middleware/ActivityMiddleware.php +++ b/src/Middleware/ActivityMiddleware.php @@ -43,16 +43,23 @@ public function handle($job, $next): void $file = new SplFileObject($throwable->getFile()); $iterator = new LimitIterator($file, max(0, $throwable->getLine() - 4), 7); - ActivityFailed::dispatch($job->storedWorkflow->id, $this->uuid, json_encode([ - 'class' => get_class($throwable), - 'message' => $throwable->getMessage(), - 'code' => $throwable->getCode(), - 'line' => $throwable->getLine(), - 'file' => $throwable->getFile(), - 'trace' => $throwable->getTrace(), - 'snippet' => array_slice(iterator_to_array($iterator), 0, 7), - ]), now() - ->format('Y-m-d\TH:i:s.u\Z')); + ActivityFailed::dispatch( + $job->storedWorkflow->id, + $this->uuid, + json_encode([ + 'class' => get_class($throwable), + 'message' => $throwable->getMessage(), + 'code' => $throwable->getCode(), + 'line' => $throwable->getLine(), + 'file' => $throwable->getFile(), + 'trace' => $throwable->getTrace(), + 'snippet' => array_slice(iterator_to_array($iterator), 0, 7), + ]), + now() + ->format('Y-m-d\TH:i:s.u\Z'), + $job::class, + $job->index + ); throw $throwable; } @@ -69,7 +76,9 @@ public function onUnlock(bool $shouldSignal): void $this->uuid, json_encode($this->result), now() - ->format('Y-m-d\TH:i:s.u\Z') + ->format('Y-m-d\TH:i:s.u\Z'), + $this->job::class, + $this->job->index ); } catch (\Illuminate\Database\Eloquent\ModelNotFoundException $throwable) { $this->job->storedWorkflow->toWorkflow()