Skip to content

Commit 1d7fc22

Browse files
author
oxcom
committed
update configuration
1 parent b4f1098 commit 1d7fc22

20 files changed

+387
-113
lines changed

DependencyInjection/Configuration.php

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ public function getConfigTreeBuilder()
8585
->scalarNode('endpoint')->defaultValue(static::API_ENDPOINT)->end()
8686
->scalarNode('base_api_url')->defaultValue(static::API_ENDPOINT)->end()
8787
->scalarNode('branch')->defaultValue(static::BRANCH)->end()
88+
->booleanNode('capture_email')->defaultFalse()->end()
89+
->booleanNode('capture_ip')->defaultTrue()->end()
90+
->booleanNode('capture_username')->defaultFalse()->end()
8891
->booleanNode('capture_error_stacktraces')->defaultTrue()->end()
89-
->scalarNode('checkIgnore')->defaultNull()->end()
92+
->scalarNode('check_ignore')->defaultNull()->end()
9093
->scalarNode('code_version')->defaultValue('')->end()
9194
->booleanNode('enable_utf8_sanitization')->defaultTrue()->end()
9295
->scalarNode('environment')->defaultValue(static::ENVIRONMENT)->end()
@@ -100,7 +103,10 @@ public function getConfigTreeBuilder()
100103
->end()
101104
->end()
102105
->defaultValue([])
103-
->end()
106+
->end()
107+
->scalarNode('custom_data_method')->defaultNull()->end()
108+
->scalarNode('custom_truncation')->defaultNull()->end()
109+
->scalarNode('ca_cert_path')->defaultNull()->end()
104110
->arrayNode('error_sample_rates')
105111
->treatNullLike([])
106112
->useAttributeAsKey('key')
@@ -111,7 +117,7 @@ public function getConfigTreeBuilder()
111117
->end()
112118
->end()
113119
->defaultValue([])
114-
->end()
120+
->end()
115121
->arrayNode('exception_sample_rates')
116122
->treatNullLike([])
117123
->useAttributeAsKey('key')
@@ -122,7 +128,7 @@ public function getConfigTreeBuilder()
122128
->end()
123129
->end()
124130
->defaultValue([])
125-
->end()
131+
->end()
126132
->scalarNode('fluent_host')->defaultValue(static::FLUENT_HOST)->end()
127133
->scalarNode('fluent_port')->defaultValue(static::FLUENT_PORT)->end()
128134
->scalarNode('fluent_tag')->defaultValue(static::FLUENT_TAG)->end()
@@ -145,14 +151,16 @@ public function getConfigTreeBuilder()
145151
->defaultValue(static::$scrubFieldsDefault)
146152
->end()
147153
->scalarNode('scrub_whitelist')->defaultNull()->end()
154+
->scalarNode('transformer')->defaultNull()->end()
155+
->scalarNode('verbosity')->defaultValue(\Psr\Log\LogLevel::ERROR)->end()
148156
->booleanNode('shift_function')->defaultTrue()->end()
149157
->scalarNode('timeout')->defaultValue(static::TIMEOUT)->end()
150158
->booleanNode('report_suppressed')->defaultFalse()->end()
151159
->booleanNode('use_error_reporting')->defaultFalse()->end()
152160
->scalarNode('proxy')->defaultNull()->end()
153161
->booleanNode('send_message_trace')->defaultFalse()->end()
154162
->booleanNode('include_raw_request_body')->defaultFalse()->end()
155-
->booleanNode('local_vars_dump')->defaultFalse()->end()
163+
->booleanNode('local_vars_dump')->defaultTrue()->end()
156164
->end()
157165
->end()
158166
->arrayNode('rollbar_js')->children()

Provider/InterfaceCustomData.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace SymfonyRollbarBundle\Provider;
4+
5+
/**
6+
* Interface InterfaceCustomData
7+
*
8+
* @package SymfonyRollbarBundle\Provider
9+
*/
10+
interface InterfaceCustomData
11+
{
12+
/**
13+
* @param \Exception|\Throwable|string $toLog
14+
* @param mixed $context
15+
*
16+
* @return array
17+
*/
18+
public function __invoke($toLog, $context);
19+
}

Provider/InterfaceLogger.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?php
2+
3+
namespace SymfonyRollbarBundle\Provider;
4+
5+
/**
6+
* Interface InterfaceLogger
7+
*
8+
* @package SymfonyRollbarBundle\Provider
9+
*/
10+
interface InterfaceLogger
11+
{
12+
/**
13+
* @param mixed $level
14+
* @param string $message
15+
*
16+
* @return void
17+
*/
18+
public function log($level, $message);
19+
}

Provider/RollbarHandler.php

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,31 @@ class RollbarHandler extends AbstractProcessingHandler
4444
* @var array
4545
*/
4646
protected $injectServices = [
47-
// config option, method
48-
'person_fn' => 'getPerson',
49-
'checkIgnore' => 'checkIgnore',
47+
/**
48+
* 'person_fn' can be:
49+
* - service::__invoke()
50+
* - service::getPerson() - see: \SymfonyRollbarBundle\Provider\InterfacePersonProvider
51+
* - function() { ... }
52+
*/
53+
'person_fn' => 'getPerson',
54+
/**
55+
* 'check_ignore' can be:
56+
* - service::__invoke()
57+
* - service::checkIgnore() - see: \SymfonyRollbarBundle\Provider\InterfaceCheckIgnore
58+
* - function() { ... }
59+
*/
60+
'check_ignore' => 'checkIgnore',
61+
/**
62+
* 'custom_data_method' can be:
63+
* - service::__invoke() - see: \SymfonyRollbarBundle\Provider\InterfaceCustomData
64+
* - function() { ... }
65+
*/
66+
'custom_data_method' => null,
67+
/**
68+
* 'logger' can be:
69+
* - service::log() - see: \SymfonyRollbarBundle\Provider\InterfaceLogger
70+
*/
71+
'logger' => 'log',
5072
];
5173

5274
/**
@@ -156,18 +178,33 @@ protected function mapConfigValues($rConfig)
156178
protected function injectService($name, $method)
157179
{
158180
$container = $this->getContainer();
181+
$service = null;
159182

160183
if ($container->has($name)) {
161184
$service = $container->get($name);
162185
} elseif (class_exists($name)) {
163186
$service = new $name($container);
164187
}
165188

166-
if (!empty($service) && method_exists($service, $method)) {
167-
return [$service, $method];
168-
} else {
169-
return is_callable($name) ? $name : null;
189+
$toCall = null;
190+
switch (true) {
191+
case (empty($service)):
192+
// inline function
193+
$toCall = is_callable($name) ? $name : null;
194+
break;
195+
196+
case (!empty($service) && empty($method)):
197+
// service with __invoke()
198+
$toCall = is_callable($service) ? $service : null;
199+
break;
200+
201+
case !empty($service) && !empty($method) && method_exists($service, $method):
202+
// service with provided method
203+
$toCall = [$service, $method];
204+
break;
170205
}
206+
207+
return $toCall;
171208
}
172209

173210
/**

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
Bundle for Symfony Framework (v2.8.x, 3.x, 4.x) that integrates Rollbar tracker
99

10-
Find all documentation here [here](https://github.com/OxCom/symfony-rollbar-bundle/tree/master/Resources/doc)
10+
More documentation here [here](https://github.com/OxCom/symfony-rollbar-bundle/tree/master/Resources/doc)
1111

1212
# Install
1313
1. Add bundle as dependency
@@ -23,7 +23,10 @@ Find all documentation here [here](https://github.com/OxCom/symfony-rollbar-bund
2323
- \AppBundle\Exceptions\MyAwesomeException
2424
rollbar:
2525
access_token: 'some-secret-token-here'
26+
rollbar_js:
27+
access_token: 'some-public-token-here'
2628
```
2729

2830
# Bugs and Issues
29-
Please, if You found a bug or something, that is not working properly, contact me and tell what's wrong. It's nice to have an example how to reproduce a bug, or any idea how to fix it in Your request. I'll take care about it ASAP.
31+
Please, if You found a bug or something, that is not working properly, contact me and tell what's wrong.
32+
It's nice to have an example how to reproduce a bug, or any idea how to fix it in Your request. I'll take care about it ASAP.

Resources/doc/check_ignore.rst

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
Configuration: Check Ignore
2+
=============
3+
4+
The function called before sending payload to Rollbar, return true to stop the error from being sent to Rollbar.
5+
6+
Examples
7+
------------------
8+
Use globally defined function:
9+
10+
.. code-block:: yaml
11+
12+
symfony_rollbar:
13+
# ...
14+
rollbar:
15+
# ...
16+
check_ignore: 'function_name_here'
17+
18+
Use custom ``CheckIgnoreProvider`` class that should implements ``InterfaceCheckIgnore``:
19+
20+
.. code-block:: yaml
21+
22+
symfony_rollbar:
23+
# ...
24+
rollbar:
25+
# ...
26+
check_ignore: '\SymfonyRollbarBundle\Tests\Fixtures\CheckIgnoreProvider'
27+
28+
Use custom ``CheckIgnoreProvider`` service that class should implements ``InterfaceCheckIgnore``:
29+
30+
.. code-block:: yaml
31+
32+
symfony_rollbar:
33+
# ...
34+
rollbar:
35+
# ...
36+
check_ignore: 'awesome_app.rollbar_check_ignore_provider'
37+

Resources/doc/configuration.rst

Lines changed: 26 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Simple configuration of bundle:
1818
base_api_url: 'https://api.rollbar.com/api/1/'
1919
branch: 'master'
2020
capture_error_stacktraces: true
21-
checkIgnore: null
21+
check_ignore: null
2222
code_version: ''
2323
enable_utf8_sanitization': true
2424
environment: 'production'
@@ -55,27 +55,35 @@ Simple configuration of bundle:
5555
proxy: null
5656
send_message_trace: false
5757
include_raw_request_body: false
58-
local_vars_dump: false
58+
local_vars_dump: true
59+
capture_email: false
60+
capture_ip: true
61+
capture_username: false
62+
custom_data_method: null
63+
custom_truncation: null
64+
ca_cert_path: null
65+
transformer: null
66+
verbosity: 'error'
5967
rollbar_js:
6068
enabled: true
61-
accessToken: 'some-public-token'
62-
captureUncaught: true
63-
uncaughtErrorLevel: 'error'
64-
captureUnhandledRejections: true
69+
access_token: 'some-public-token'
70+
capture_uncaught: true
71+
uncaught_error_level: 'error'
72+
capture_unhandled_rejections: true
6573
payload:
66-
environment: environment: '%kernel.environment%'
67-
ignoredMessages: []
74+
environment: '%kernel.environment%'
75+
ignored_messages: []
6876
verbose: false
6977
async: true
70-
autoInstrument:
78+
auto_instrument:
7179
network: true
7280
log: true
7381
dom: true
7482
navigation: true
7583
connectivity: true
76-
itemsPerMinute: 60
77-
maxItems: 0
78-
scrubFields: ['passwd', 'password', 'secret', 'confirm_password', 'password_confirmation', 'auth_token', 'csrf_token']
84+
items_per_minute: 60
85+
max_items: 0
86+
scrub_fields: ['passwd', 'password', 'secret', 'confirm_password', 'password_confirmation', 'auth_token', 'csrf_token']
7987
8088
Bundle configuration
8189
--------------------
@@ -102,87 +110,19 @@ Here you can description of some important configuration options for RollBar.
102110

103111
``root``: Path to your project's root dir. Default ``%kernel.root_dir%``
104112

105-
``checkIgnore``: Function called before sending payload to Rollbar, return true to stop the error from being sent to Rollbar.
106-
107-
Use globally defined function:
108-
109-
.. code-block:: yaml
110-
111-
symfony_rollbar:
112-
# ...
113-
rollbar:
114-
# ...
115-
checkIgnore: 'function_name_here'
116-
117-
Use custom ``CheckIgnoreProvider`` class that should implements ``InterfaceCheckIgnore``:
118-
119-
.. code-block:: yaml
120-
121-
symfony_rollbar:
122-
# ...
123-
rollbar:
124-
# ...
125-
checkIgnore: '\SymfonyRollbarBundle\Tests\Fixtures\CheckIgnoreProvider'
126-
127-
Use custom ``CheckIgnoreProvider`` service that class should implements ``InterfaceCheckIgnore``:
128-
129-
.. code-block:: yaml
113+
``check_ignore``: Function called before sending payload to Rollbar, `Example of check ignore`_
130114

131-
symfony_rollbar:
132-
# ...
133-
rollbar:
134-
# ...
135-
checkIgnore: 'awesome_app.rollbar_check_ignore_provider'
115+
``custom_data_method``: Function creating dynamic custom data on runtime during error reporting, `Example of custom data method`_
136116

117+
.. _`Example of check ignore`: check_ignore.rst
118+
.. _`Example of custom data method`: custom_data_method.rst
137119

138120
RollBar - Person Tracking
139121
-------------------------
140-
Rollbar `can track`_ which of your People (users) are affected by each error. There is one of the options:
141-
142-
``person_fn``: A function reference (string, etc. - anything that `call_user_func()`_ can handle) returning an array like the one for 'person'.
143-
144-
Use globally defined function:
145-
146-
.. code-block:: yaml
147-
148-
symfony_rollbar:
149-
# ...
150-
rollbar:
151-
# ...
152-
person_fn: 'function_name_here'
153-
154-
Use custom ``PersonProvider`` class that should implements ``InterfacePersonProvider``:
155-
156-
.. code-block:: yaml
157-
158-
symfony_rollbar:
159-
# ...
160-
rollbar:
161-
# ...
162-
person_fn: '\SymfonyRollbarBundle\Tests\Fixtures\PersonProvider'
163-
164-
Use custom ``PersonProvider`` service that class should implements ``InterfacePersonProvider``:
165-
166-
.. code-block:: yaml
167-
168-
symfony_rollbar:
169-
# ...
170-
rollbar:
171-
# ...
172-
person_fn: 'awesome_app.rollbar_person_provider'
173-
174-
Than in your ``PersonProvider`` class/service or function you have to return user data as array:
175-
176-
.. code-block:: php
177-
// ..
178-
return [
179-
'id' => 'user_id',
180-
'username' => 'username',
181-
'email' => 'email',
182-
];
122+
Rollbar `can track`_ which of your People (users) are affected by each error. `Example of tracking`_
183123

184124
.. _`can track`: https://rollbar.com/docs/person-tracking/
185-
.. _`call_user_func()`: http://php.net/call_user_func
125+
.. _`Example of tracking`: person_tracking.rst
186126

187127
RollBarJS - Integration
188128
-----------------------

0 commit comments

Comments
 (0)