stayallive / wp-sentry

A (unofficial) WordPress plugin reporting PHP and JavaScript errors to Sentry.
https://wordpress.org/plugins/wp-sentry-integration/
MIT License
320 stars 48 forks source link

Tracing: Uncaught Error: Class "GuzzleHttp\Psr7\ServerRequest" not found #194

Closed saas786 closed 4 months ago

saas786 commented 4 months ago
Stack trace:
#0 \wp-content\plugins\wp-sentry-integration\src\tracing\class-wp-sentry-php-tracing.php(64): WP_Sentry_Php_Tracing->start_transaction(Object(Sentry\State\Hub))
#1 \wp-content\plugins\wp-sentry-integration\src\tracing\class-wp-sentry-php-tracing.php(30): WP_Sentry_Php_Tracing->__construct()
#2 \wp-content\plugins\wp-sentry-integration\wp-sentry.php(119): WP_Sentry_Php_Tracing::get_instance()
#7 {main}
  thrown in \wp-content\plugins\wp-sentry-integration\src\tracing\class-wp-sentry-php-tracing.php on line 85
saas786 commented 4 months ago

Quick troubleshooting: It appears the issue is caused by unprefixed references to code, while Composer loads prefixed vendors due to PHP-Scoper.

phpstorm64_FaFDwmmDkL phpstorm64_Oi6eK2BYD5

stayallive commented 4 months ago

That's not good. Let me see what is going on there and how we can work around it.

stayallive commented 4 months ago

Thanks for your detailed report, found it quickly and added a fix.

https://github.com/stayallive/wp-sentry/releases/tag/v7.17.1 is out and should fix the issue!

saas786 commented 4 months ago

I can see your workaround.

However, you should properly prefix your code instead of using conditional prefixes.

Reference: https://github.com/stayallive/wp-sentry/blob/303a1916612220856892e0db34a14d7e1f02f94c/src/tracing/class-wp-sentry-php-tracing.php#L283

If you are interested, I can update PHP-Scoper to the latest version and ensure your code is properly prefixed, eliminating the need for conditional checks.

stayallive commented 4 months ago

This plugin can also be installed without prefix using composer for projects that do that and also local development is easier this way. I agree this isn't optimal but it also isn't too bad (yet).