forked from stayallive/wp-sentry
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wp-sentry.php
59 lines (45 loc) · 1.62 KB
/
wp-sentry.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
/**
* Plugin Name: WordPress Sentry
* Plugin URI: https://github.com/stayallive/wp-sentry
* Description: A (unofficial) WordPress plugin to report PHP and JavaScript errors to Sentry.
* Version: 2.0.4
* Author: Alex Bouma
* Author URI: https://alex.bouma.me
* License: MIT
*/
// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;
// Resolve the sentry plugin file.
define( 'WP_SENTRY_PLUGIN_FILE', call_user_func( function () {
global $wp_plugin_paths;
$plugin_file = __FILE__;
if ( ! empty( $wp_plugin_paths ) ) {
$wp_plugin_real_paths = array_flip( $wp_plugin_paths );
$plugin_path = wp_normalize_path( dirname( $plugin_file ) );
if ( isset( $wp_plugin_real_paths[ $plugin_path ] ) ) {
$plugin_file = str_replace( $plugin_path, $wp_plugin_real_paths[ $plugin_path ], $plugin_file );
}
}
return $plugin_file;
} ) );
// Define the sentry version.
if ( ! defined( 'WP_SENTRY_VERSION' ) ) {
define( 'WP_SENTRY_VERSION', wp_get_theme()->get( 'Version' ) );
}
// Load the PHP tracker if we have a private DSN
if ( defined( 'WP_SENTRY_DSN' ) && ! empty( WP_SENTRY_DSN ) ) {
require_once __DIR__ . '/trackers/class-wp-sentry-php-tracker.php';
add_filter( 'wp_sentry_dsn', function () {
return WP_SENTRY_DSN;
}, 1, 0 );
WP_Sentry_Php_Tracker::get_instance();
}
// Load the Javascript tracker if we have a public DSN
if ( defined( 'WP_SENTRY_PUBLIC_DSN' ) && ! empty( WP_SENTRY_PUBLIC_DSN ) ) {
require_once __DIR__ . '/trackers/class-wp-sentry-js-tracker.php';
add_filter( 'wp_sentry_public_dsn', function () {
return WP_SENTRY_PUBLIC_DSN;
}, 1, 0 );
WP_Sentry_Js_Tracker::get_instance();
}