PHP code example of itgalaxy / sentry-integration
1. Go to this page and download the library: Download itgalaxy/sentry-integration library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
itgalaxy / sentry-integration example snippets
define('SENTRY_INTEGRATION_DSN', 'ADDRESS_YOUR_DSN');
// Example `ADDRESS_YOUR_DSN` value - https://1fbf25e90f114a3d83a19aa4fa432dcf:[email protected] /1
define(
'SENTRY_INTEGRATION_ERROR_TYPES',
E_ALL & ~E_DEPRECATED & ~E_NOTICE & ~E_USER_DEPRECATED
);
define('SENTRY_INTEGRATION_PUBLIC_DSN', 'PUBLIC_ADDRESS_YOUR_DSN');
// Example `PUBLIC_ADDRESS_YOUR_DSN` value - https://[email protected] /1
define('SENTRY_INTEGRATION_PUBLIC_DSN_ENQUEUE_MODE', 'manual');
define('SENTRY_INTEGRATION_EXPECT_CT_DSN', 'ADDRESS_YOUR_DSN');
// Example `ADDRESS_YOUR_DSN` value - https://[email protected] /1
define('SENTRY_INTEGRATION_X_XSS_PROTECTION_DSN', 'ADDRESS_YOUR_DSN');
// Example `ADDRESS_YOUR_DSN` value - https://[email protected] /1
define('SENTRY_INTEGRATION_VERSION', 'v2.1.3');
define('SENTRY_INTEGRATION_ENV', 'production');
/**
* Customize sentry user context.
*
* @param array $user The current sentry user context.
*
* @return array
*/
function customize_sentry_user_context(array $user)
{
return array_merge($user, array(
'a-custom-user-meta-key' => 'custom value'
));
}
add_filter('sentry_integration_user_context', 'customize_sentry_user_context');
/**
* Customize sentry dsn.
*
* @param string $dsn The current sentry public dsn.
*
* @return string
*/
function customize_sentry_dsn($dsn)
{
return 'https://<key>:<secret>@sentry.io/<project>';
}
add_filter('sentry_integration_dsn', 'customize_sentry_dsn');
/**
* Customize sentry options.
*
* @param array $options The current sentry options.
*
* @return array
*/
function customize_sentry_options(array $options)
{
return array_merge($options, array(
'tags' => array(
'my-custom-tag' => 'custom value'
)
));
}
add_filter('sentry_integration_options', 'customize_sentry_options');
/**
* Customize sentry send data.
*
* @param array $data The sentry send data.
*
* @return array|bool Return the data array or false to cancel the send operation.
*/
function filter_sentry_send_data(array $data)
{
$data['tags']['my_custom_key'] = 'my_custom_value';
return $data;
}
add_filter('sentry_integration_send_data', 'filter_sentry_send_data');
/**
* Customize public sentry dsn.
*
* @param string $dsn The current sentry public dsn.
*
* @return string
*/
function customize_public_sentry_dsn($dsn)
{
return 'https://<key>@sentry.io/<project>';
}
add_filter('sentry_integration_public_dsn', 'customize_public_sentry_dsn');
/**
* Customize public sentry options.
*
* @param array $options The current sentry public options.
*
* @return array
*/
function customize_public_sentry_options(array $options)
{
return array_merge($options, array(
'tags' => array(
'custom-tag' => 'custom value'
)
));
}
add_filter(
'sentry_integration_public_options',
'customize_sentry_public_options'
);
/**
* Customize sentry dsn.
*
* @param string $dsn The current sentry public dsn.
*
* @return string
*/
function customize_sentry_dsn($dsn)
{
return 'https://<key>:<secret>@sentry.io/<project>';
}
add_filter('sentry_integration_expect_ct_dsn', 'customize_sentry_dsn');
/**
* Customize sentry options.
*
* @param array $options The current sentry options.
*
* @return array
*/
function customize_sentry_options(array $options)
{
return array_merge($options, array(
'tags' => array(
'my-custom-tag' => 'custom value'
)
));
}
add_filter('sentry_integration_expect_ct_options', 'customize_sentry_options');
/**
* Customize sentry send data.
*
* @param array $data The sentry send data.
*
* @return array|bool Return the data array or false to cancel the send operation.
*/
function filter_sentry_send_data(array $data)
{
$data['tags']['my_custom_key'] = 'my_custom_value';
return $data;
}
add_filter('sentry_integration_expect_ct_send_data', 'filter_sentry_send_data');
/**
* Customize sentry dsn.
*
* @param string $dsn The current sentry public dsn.
*
* @return string
*/
function customize_sentry_dsn($dsn)
{
return 'https://<key>:<secret>@sentry.io/<project>';
}
add_filter('sentry_integration_x_xss_protection_dsn', 'customize_sentry_dsn');
/**
* Customize sentry options.
*
* @param array $options The current sentry options.
*
* @return array
*/
function customize_sentry_options(array $options)
{
return array_merge($options, array(
'tags' => array(
'my-custom-tag' => 'custom value'
)
));
}
add_filter(
'sentry_integration_x_xss_protection_options',
'customize_sentry_options'
);
/**
* Customize sentry send data.
*
* @param array $data The sentry send data.
*
* @return array|bool Return the data array or false to cancel the send operation.
*/
function filter_sentry_send_data(array $data)
{
$data['tags']['my_custom_key'] = 'my_custom_value';
return $data;
}
add_filter(
'sentry_integration_x_xss_protection_send_data',
'filter_sentry_send_data'
);
/**
* Plugin Name: Sentry Integration
* Plugin URI: https://github.com/itgalaxy/sentry-integration
* Description: A (unofficial) WordPress plugin to report PHP and JavaScript and security headers errors to Sentry.
* Version: must-use-proxy
* Author: Alexander Krasnoyarov
* Author URI: https://github.com/evilebottnawi
* License: MIT
*/
$sentry_integration =
__DIR__ . '/../plugins/sentry-integration/sentry-integration.php';
if (!file_exists($sentry_integration)) {
return;
}