diff --git a/public/app/themes/clarity/functions.php b/public/app/themes/clarity/functions.php index cdb9a3c78..e3fc8117d 100644 --- a/public/app/themes/clarity/functions.php +++ b/public/app/themes/clarity/functions.php @@ -40,6 +40,7 @@ require_once 'inc/admin/plugins/wp-elasticsearch.php'; require_once 'inc/admin/plugins/wp-document-revisions.php'; require_once 'inc/admin/plugins/wp-offload-media.php'; +require_once 'inc/admin/plugins/wp-sentry.php'; require_once 'inc/admin/prior-party/prior-party-banner-admin.php'; require_once 'inc/admin/prior-party/prior-party-banner-email.php'; require_once 'inc/admin/prior-party/prior-party-banner.php'; diff --git a/public/app/themes/clarity/inc/admin/plugins/wp-sentry.php b/public/app/themes/clarity/inc/admin/plugins/wp-sentry.php new file mode 100644 index 000000000..5386c7b1e --- /dev/null +++ b/public/app/themes/clarity/inc/admin/plugins/wp-sentry.php @@ -0,0 +1,57 @@ +addHooks(); + } + + public function addHooks() + { + add_filter('wp_sentry_public_options', [$this, 'filterSentryJsOptions']); + error_log('added wp_sentry_public_options hook'); + } + + /** + * Filter the options used by sentry-javascript for `Sentry.init()` + */ + + public function filterSentryJsOptions(array $options) + { + // If we're not on an admin or preview screen, then return early. + if (!(is_admin() || is_preview())) { + return $options; + } + + // We are either on an admin screen or a preview screen. + // Add custom settings for admin screens. + return array_merge($options, array( + 'sendDefaultPii' => true, + 'sampleRate' => 1, + 'tracesSampleRate' => 1, + 'replaysSessionSampleRate' => 1, + 'replaysOnErrorSampleRate' => 1, + 'wpSessionReplayOptions' => [ + // To capture additional information such as request and response headers or bodies, + // you'll need to opt-in via networkDetailAllowUrls + 'networkDetailAllowUrls' => [get_home_url()], + ] + )); + } +} + +new WpSentry();