Skip to content

Commit

Permalink
Merge pull request #13 from playox/feature/5-feature-data-collector-d…
Browse files Browse the repository at this point in the history
…ebug

feat(debug): #5 do not crash if profiler ...
  • Loading branch information
teiling88 authored Sep 24, 2023
2 parents be3d2fd + 5b017aa commit 1e898a1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Profiler/FeatureDataCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Flagception\Bundle\FlagceptionBundle\Profiler;

use Flagception\Activator\ChainActivator;
use Flagception\Bundle\FlagceptionBundle\Activator\TraceableChainActivator;
use Flagception\Decorator\ChainDecorator;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -37,7 +38,7 @@ class FeatureDataCollector extends DataCollector
* @param TraceableChainActivator $chainActivator
* @param ChainDecorator $chainDecorator
*/
public function __construct(TraceableChainActivator $chainActivator, ChainDecorator $chainDecorator)
public function __construct(ChainActivator $chainActivator, ChainDecorator $chainDecorator)
{
$this->chainActivator = $chainActivator;
$this->chainDecorator = $chainDecorator;
Expand All @@ -58,7 +59,7 @@ public function collect(Request $request, Response $response, Throwable $excepti
'requests' => [],
'activators' => [],
'decorators' => [],
'trace' => $this->chainActivator->getTrace()
'trace' => []
];

// Activators
Expand All @@ -85,6 +86,12 @@ public function collect(Request $request, Response $response, Throwable $excepti
}

// Analyze trace
if (!$this->chainActivator instanceof TraceableChainActivator) {
return;
}

$this->data['trace'] = $this->chainActivator->getTrace();

foreach ($this->chainActivator->getTrace() as $trace) {
if (!isset($this->data['requests'][$trace['feature']])) {
$this->data['requests'][$trace['feature']] = [
Expand Down

0 comments on commit 1e898a1

Please sign in to comment.