-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Disable profiler when creating screenshots #147
Comments
I think an event subscriber like as follows should do the job. <?php
namespace App\EventSubscriber;
use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Profiler\Profiler;
final readonly class MySubscriber implements EventSubscriberInterface
{
public function __construct(
#[Autowire(service: 'profiler')]
private ?Profiler $profiler = null
){}
public static function getSubscribedEvents(): array
{
return [
'kernel.request' => 'onKernelRequest',
];
}
public function onKernelRequest(RequestEvent $event): void
{
if ($this->profiler === null) {
return;
}
$userAgent = $event->getRequest()->headers->get('user-agent');
if ($userAgent === null || !str_contains($userAgent, 'xxxxxxx')) { // <= PUT THE USER-AGENT KEYWORD HERE
return;
}
$this->profiler->disable();
}
} |
Great idea. Then the pwa:create:screenshots will set a user-agent? |
It looks like it is possible. The user-agent is set to use Facebook\WebDriver\WebDriverCapabilityType;
$customUserAgent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) PWABundle/123.0.0.0 Safari/537.36';
$client = static::createPantherClient([
'capabilities' => [
WebDriverCapabilityType::CHROME => [
'args' => ["--user-agent={$customUserAgent}"],
],
],
]); |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
I can't imagine that anyone would want to see the debug toolbar in the screenshots they're creating.
It can be disabled programmatically:
https://symfony.com/doc/current/profiler.html#enabling-the-profiler-programmatically-or-conditionally
Example
No response
The text was updated successfully, but these errors were encountered: