This repository has been archived by the owner on Apr 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathraven.api.php
112 lines (100 loc) · 2.64 KB
/
raven.api.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?php
/**
* @file
* Sample hooks demonstrating usage in Raven-php.
*/
/**
* Provide user information for logging.
*
* @param array $user_info
* A reference to array of user account info.
*/
function hook_raven_user_alter(array &$user_info) {
global $user;
if (user_is_logged_in()) {
$user_info['id'] = $user->uid;
$user_info['name'] = $user->name;
$user_info['email'] = $user->mail;
$user_info['roles'] = implode(', ', $user->roles);
}
}
/**
* Provide tags for logging.
*
* @param array $tags
* A reference to array of sentry tags.
*/
function hook_raven_tags_alter(array &$tags) {
$tags['foo_version'] = get_foo_version();
}
/**
* Provide extra information for logging.
*
* @param array $extra
* A reference to array of extra error info.
*/
function hook_raven_extra_alter(array &$extra) {
$extra['foo'] = 'bar';
}
/**
* Filter known errors so do not log them to Sentry again and again.
*
* @param array $error
* A reference to array contains error info.
*/
function hook_raven_error_filter_alter(array &$error) {
$known_errors = array();
drupal_alter('raven_known_php_errors', $known_errors);
// Filter known errors to prevent spamming the Sentry server.
foreach ($known_errors as $known_error) {
$check = TRUE;
foreach ($known_error as $key => $value) {
if ($error[$key] != $value) {
$check = FALSE;
break;
}
}
if ($check) {
$error['process'] = FALSE;
break;
}
}
}
/**
* Provide the list of known php errors.
*
* @param array $known_errors
* A reference to array contains php errors info.
*/
function hook_raven_known_php_errors_alter(array &$known_errors) {
$known_errors[] = array(
'code' => E_NOTICE,
'message' => 'Array to string conversion',
'file' => DRUPAL_ROOT . '/sites/all/modules/views/plugins/views_plugin_cache.inc',
'line' => 206,
);
$known_errors[] = array(
'code' => E_NOTICE,
'message' => 'Undefined index: width',
'file' => DRUPAL_ROOT . '/sites/all/modules/flexslider/flexslider_fields/flexslider_fields.module',
'line' => 140,
);
$known_errors[] = array(
'code' => E_NOTICE,
'message' => 'Undefined index: height',
'file' => DRUPAL_ROOT . '/sites/all/modules/flexslider/flexslider_fields/flexslider_fields.module',
'line' => 141,
);
}
/**
* Filter known watchdog entries so do not log them to Sentry again and again.
*
* @param array $filter
* A reference to array contains log entry info.
*/
function hook_raven_watchdog_filter_alter(array &$filter) {
$log_entry = $filter['log_entry'];
if ($log_entry['type'] === 'foo') {
$filter['process'] = FALSE;
}
}