Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add ExtraProvider for Fusion rendering paths #35

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading