-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathConfig.php
95 lines (89 loc) · 3.11 KB
/
Config.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
<?php
namespace Honeybadger;
use Honeybadger\Exceptions\ServiceException;
use Honeybadger\Support\Repository;
class Config extends Repository
{
/**
* @param array $config
*/
public function __construct($config = [])
{
$this->items = $this->mergeConfig($config);
$checkinsRaw = $this->get('checkins') ?? [];
$checkins = array_map(function ($checkin) {
return new CheckIn($checkin);
}, $checkinsRaw);
$this->set('checkins', $checkins);
}
/**
* @param array $config
*
* @return array
*/
private function mergeConfig($config = []): array
{
$result = array_merge([
'api_key' => null,
'personal_auth_token' => null,
'endpoint' => Honeybadger::API_URL,
'app_endpoint' => Honeybadger::APP_URL,
'notifier' => [
'name' => 'honeybadger-php',
'url' => 'https://github.com/honeybadger-io/honeybadger-php',
'version' => Honeybadger::VERSION,
],
'environment_name' => 'production',
'report_data' => true,
'service_exception_handler' => function (ServiceException $e) {
throw $e;
},
'events_exception_handler' => function (ServiceException $e) {
// default: noop
// this should be a noop operation by default.
// many events could be sent from your application and in case of errors, even logging them will add too much noise.
// you may want to override this in your application to log or handle the error in a different way (or debug).
},
'environment' => [
'filter' => [],
'include' => [],
],
'request' => [
'filter' => [],
],
'version' => '',
'hostname' => gethostname(),
'project_root' => '',
'handlers' => [
'exception' => true,
'error' => true,
'shutdown' => true,
],
'client' => [
'timeout' => 15,
'proxy' => [],
'verify' => true,
],
'excluded_exceptions' => [],
'capture_deprecations' => false,
'vendor_paths' => [
'vendor\/.*',
],
'breadcrumbs' => [
'enabled' => true,
],
'checkins' => [],
'events' => [
'enabled' => false,
'bulk_threshold' => BulkEventDispatcher::BULK_THRESHOLD,
'dispatch_interval_seconds' => BulkEventDispatcher::DISPATCH_INTERVAL_SECONDS
],
], $config);
if (!isset($result['handlers']['shutdown'])) {
// the 'shutdown' field is new, array_merge only merges on the first level
// so we need to manually set it if the config has a 'handlers' key but not a 'shutdown' key inside
$result['handlers']['shutdown'] = true;
}
return $result;
}
}