Skip to content

Commit

Permalink
feat: Add ExtraProvider for Fusion rendering paths
Browse files Browse the repository at this point in the history
  • Loading branch information
paxuclus committed Aug 20, 2024
1 parent 54931f4 commit de5078b
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Classes/Scope/Extra/FusionPathProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

declare(strict_types=1);

namespace Netlogix\Sentry\Scope\Extra;

use Neos\Flow\Aop\JoinPointInterface;
use Neos\Flow\Annotations as Flow;
use Neos\Fusion\Exception\RuntimeException as FusionRuntimeException;

/**
* @Flow\Scope("singleton")
* @Flow\Aspect
*/
final class FusionPathProvider implements ExtraProvider
{
private array $fusionPaths = [];

/**
* @Flow\Before("setting(Netlogix.Sentry.featureFlags.fusionFeatures) && within(Neos\Fusion\Core\ExceptionHandlers\AbstractRenderingExceptionHandler) && method(.*->handleRenderingException())")
*/
public function beforeFusionExceptionHandling(JoinPointInterface $joinPoint): void
{
if (!$joinPoint->isMethodArgument('fusionPath')) {
return;
}

$fusionPath = $joinPoint->getMethodArgument('fusionPath');
if ($joinPoint->isMethodArgument('exception')) {
$exception = $joinPoint->getMethodArgument('exception');
if ($exception instanceof FusionRuntimeException) {
$fusionPath = $exception->getFusionPath();
}
}

$this->fusionPaths[] = $fusionPath;
}

public function getExtra(): array
{
if (empty($this->fusionPaths)) {
return [];
}

return [
'fusionPaths' => array_values(array_unique($this->fusionPaths)),
];
}
}
5 changes: 5 additions & 0 deletions Configuration/Settings.FeatureFlags.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Netlogix:
Sentry:
featureFlags:
# Set to true when Neos.Fusion is installed
fusionFeatures: false
1 change: 1 addition & 0 deletions Configuration/Settings.Providers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Netlogix:
'Netlogix\Sentry\Scope\Environment\FlowSettings': true

extra:
'Netlogix\Sentry\Scope\Extra\FusionPathProvider': true
'Netlogix\Sentry\Scope\Extra\ReferenceCodeProvider': true

release:
Expand Down
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ Netlogix:
You can also use the `Netlogix\Sentry\Scope\Release\FlowSettings` to set the Release through Flow
Configuration (`Netlogix.Sentry.release.setting`, set to `%env:SENTRY_RELEASE%` by default).

## Feature Flags

You can enable additional features that require other packages to be installed (e.g. Fusion Path collection) by
adjusting the settings below `Netlogix.Sentry.featureFlags`. Take a look at Configuration/Settings.FeatureFlags.yaml.

```yaml
Netlogix:
Sentry:
featureFlags:
# Set to true when Neos.Fusion is installed
fusionFeatures: false
```

## Custom Providers

For each scope, you can implement your own providers. Each scope requires it's own interface:
Expand Down

0 comments on commit de5078b

Please sign in to comment.