Feature Request: Frontend Bugsnag monitoring
-
I would be great to use this plugin to enable/disable Bugsnag Frontend and Performance monitoring. I have this functionality current implemented as part of a plugin or in the theme itself using the following code (this includes setting the version using theme/plugin versioning):
<?php function configure_bugsnag(): void { global $bugsnagWordpress; if (!isset($bugsnagWordpress)) { return; } $bugsnagWordpress->setContext(wp_get_theme()->get('title')); $version = wp_get_theme()->get('Version'); $bugsnagWordpress->setAppVersion($version); $bugsnagWordpress->setBeforeNotifyFunction(function ($error) { $plugin_data = get_plugin_data( __FILE__ ); if (isset($plugin_data['Name']) && $plugin_data['Name']) { $error->setMetaData([ 'plugin' => $plugin_data ]); } }); // Add frontend sessions if (defined('BUGSNAG_FE') && BUGSNAG_FE) { add_action('wp_enqueue_scripts', function () use ($version) { wp_enqueue_script( 'bugsnag_fe', '//d2wy8f7a9ursnm.cloudfront.net/v7/bugsnag.min.js', [], 'v7' ); wp_add_inline_script( 'bugsnag_fe', "Bugsnag.start({ apiKey:'".get_site_option('bugsnag_api_key')."', appVersion:'$version' })" ); }, 1); } // Add performance tracking if (defined('BUGSNAG_PERF') && BUGSNAG_PERF) { add_action('wp_enqueue_scripts', function () use ($version) { wp_enqueue_script( 'bugsnag_perf', '//d2wy8f7a9ursnm.cloudfront.net/v2.1.0/bugsnag-performance.min.js', [], 'v1' ); wp_add_inline_script( 'bugsnag_perf', "BugsnagPerformance.start({ apiKey:'".get_site_option('bugsnag_api_key')."', appVersion:'$version' })" ); }, 2); } } configure_bugsnag();
- The topic ‘Feature Request: Frontend Bugsnag monitoring’ is closed to new replies.