<span class="resolved" aria-label="Resolved" title="Topic is resolved."></span>Using Structured Context via $scope-&gt;setExtra

Replies: 1

I’m successfully getting errors logged in Sentry through the plugin, but when trying to use custom Structured Data as per the plugin docs this isn’t coming through with the error. It appears Sentry may have changed their approach to this as their docs use $scope->setContext instead of $scope->setExtra though this method doesn’t work in this plugin.

I’d appreciate any pointers on getting this data to flow through to Sentry.

Here’s an example of the code used:

$e = new Exception('Test exception');
if ( function_exists( 'wp_sentry_safe' ) ) {
	wp_sentry_safe(function (\Sentry\State\HubInterface $client) use ($e) {
		$client->withScope(function (\Sentry\State\Scope $scope) use ($client, $e) {
			$scope->setExtra('test_label', 'test_data');
			$client->captureException($e);
		});
	});
}

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer