|
2 | 2 |
|
3 | 3 | namespace Laravel\Nightwatch; |
4 | 4 |
|
5 | | -use Illuminate\Contracts\Events\Dispatcher; |
6 | 5 | use Illuminate\Contracts\Foundation\Application; |
7 | | -use Illuminate\Log\Context\Repository; |
8 | | -use Illuminate\Queue\Events\JobProcessing; |
9 | | -use Illuminate\Queue\Queue; |
10 | 6 | use Illuminate\Support\Facades\Context; |
11 | 7 | use ReflectionProperty; |
12 | 8 | use Symfony\Component\Console\Input\ArgvInput; |
@@ -95,48 +91,6 @@ public static function boot(Application $app): void |
95 | 91 | */ |
96 | 92 | self::$queuedJobDurationCapturable = |
97 | 93 | version_compare($version, '10.42.0', '>='); |
98 | | - |
99 | | - if (self::$contextExists) { |
100 | | - Context::dehydrating(static function (Repository $context) use ($app) { |
101 | | - if (($context->getHidden('nightwatch_user_id') ?? '') === '') { |
102 | | - $context->addHidden('nightwatch_user_id', $app->make(Core::class)->executionState->user->resolvedUserId()); |
103 | | - } |
104 | | - }); |
105 | | - } else { |
106 | | - Queue::createPayloadUsing(static function ($c, $q, array $payload) use ($app) { |
107 | | - /* |
108 | | - * Dehydrating... |
109 | | - */ |
110 | | - if ((self::$context['nightwatch_user_id'] ?? '') === '') { |
111 | | - self::$context['nightwatch_user_id'] = $app->make(Core::class)->executionState->user->resolvedUserId(); |
112 | | - } |
113 | | - |
114 | | - return [ |
115 | | - ...$payload, |
116 | | - 'nightwatch' => [ |
117 | | - ...($payload['nightwatch'] ?? []), |
118 | | - 'nightwatch_trace_id' => self::$context['nightwatch_trace_id'] ?? null, |
119 | | - 'nightwatch_should_sample' => self::$context['nightwatch_should_sample'] ?? null, |
120 | | - 'nightwatch_user_id' => self::$context['nightwatch_user_id'], |
121 | | - ], |
122 | | - ]; |
123 | | - }); |
124 | | - |
125 | | - /** @var Dispatcher */ |
126 | | - $events = $app->make(Dispatcher::class); |
127 | | - $events->listen(static function (JobProcessing $event) { |
128 | | - $nightwatch = $event->job->payload()['nightwatch'] ?? []; |
129 | | - |
130 | | - /* |
131 | | - * Hydrating... |
132 | | - */ |
133 | | - self::$context = [ |
134 | | - 'nightwatch_trace_id' => $nightwatch['nightwatch_trace_id'] ?? null, |
135 | | - 'nightwatch_should_sample' => $nightwatch['nightwatch_should_sample'] ?? null, |
136 | | - 'nightwatch_user_id' => $nightwatch['nightwatch_user_id'] ?? '', |
137 | | - ]; |
138 | | - }); |
139 | | - } |
140 | 94 | } |
141 | 95 |
|
142 | 96 | /** |
|
0 commit comments