Skip to content

Commit 67c4725

Browse files
committed
Updated documentation.
1 parent 6072ec0 commit 67c4725

File tree

2 files changed

+185
-7
lines changed

2 files changed

+185
-7
lines changed

README.md

Lines changed: 163 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,14 +46,175 @@ This is a recommended way to install Rollbar plugin for advanced projects. This
4646
2. In your `composer.json` add `wpackagist-plugin/rollbar` to your `require` section, i.e.:
4747
```json
4848
"require": {
49-
"php": ">=5.5",
49+
"php": ">=8.1",
5050
...,
5151
"wpackagist-plugin/rollbar": "*"
5252
}
5353
```
5454
3. Issue command `composer install` in the root directory of your WordPress project.
5555
4. Go to step #4 above.
5656

57+
## Advanced Use
58+
59+
### Constants
60+
61+
The plugin provides a number of constants that can be used to configure the plugin. These should typically be defined in
62+
the `wp-config.php` file.
63+
64+
Note: If you define these constants, they will override the settings defined in the WordPress Admin.
65+
66+
`ROLLBAR_DISABLE_ADMIN` - (optional) Removes the Rollbar Admin menu from the WordPress Admin if set to `true`. This
67+
allows for the plugin to be used without the admin settings page, for example, if the plugin is managed via the
68+
`wp-config.php` file.
69+
70+
`ROLLBAR_SETTINGS` - (optional) An associative array of settings to override the settings values from the WordPress
71+
Admin. Note: if you disable the admin settings page with `ROLLBAR_DISABLE_ADMIN` constant, this constant must be used to
72+
configure the plugin.
73+
74+
`ROLLBAR_ACCESS_TOKEN` - The Rollbar PHP server access token.
75+
76+
`ROLLBAR_CLIENT_ACCESS_TOKEN` - The Rollbar JS client access token.
77+
78+
#### WordPress Constants
79+
80+
The Rollbar plugin respects the following WordPress constants:
81+
82+
`WP_ENV` - (optional) The environment name. This is used to determine the environment name for the Rollbar project.
83+
84+
`WP_PROXY_HOST` - (optional) The proxy host. If both `WP_PROXY_HOST` and `WP_PROXY_PORT` are set, the plugin will use
85+
the respect the HTTP proxy when making requests to Rollbar.
86+
87+
`WP_PROXY_PORT` - (optional) The proxy port.
88+
89+
`WP_PROXY_USERNAME` - (optional) The proxy username.
90+
91+
`WP_PROXY_PASSWORD` - (optional) The proxy password.
92+
93+
`WP_PROXY_BYPASS_HOSTS` - (optional) The proxy bypass hosts. This is a comma-separated list of hosts that should not be
94+
proxied. If proxying is enabled, but you don't want to proxy requests to Rollbar, you can add `api.rollbar.com` to this
95+
list.
96+
97+
### Environment Variables
98+
99+
The plugin looks for the following environment variables to configure itself. Note: these are overridden by the
100+
constants defined above.
101+
102+
`ROLLBAR_ACCESS_TOKEN` - The Rollbar PHP server access token.
103+
104+
`ROLLBAR_CLIENT_ACCESS_TOKEN` - The Rollbar JS client access token.
105+
106+
`WP_ENV` - (optional) The environment name. This is used to determine the environment name for the Rollbar project.
107+
108+
### Filters
109+
110+
The plugin provides a number of filters that allow you to customize the behavior of the plugin.
111+
112+
### `apply_filters('rollbar_api_admin_permission', bool $value, string $route, WP_REST_Request $request)`
113+
114+
Filter to allow or deny access to a Rollbar route in the WordPress REST API used in the WordPress Admin.
115+
116+
**Parameters**
117+
118+
* `bool $value` - The initial value. Defaults is `true` for admin users, `false` for non-admin users.
119+
* `string $route` - The route being accessed.
120+
* `WP_REST_Request $request` - The REST request object.
121+
122+
### `apply_filters('rollbar_disable_admin', bool $disable)`
123+
124+
Filter to disable the admin settings page of the plugin.
125+
126+
This filter cannot override the `ROLLBAR_DISABLE_ADMIN` constant.
127+
128+
**Parameters**
129+
130+
* `bool $disable` - `true` to disable the admin settings page, `false` to enable it.
131+
132+
### `apply_filters('rollbar_js_config', array $config)`
133+
134+
Filters the Rollbar JavaScript configuration.
135+
136+
**Parameters**
137+
138+
* `array $config` - The Rollbar JavaScript configuration array.
139+
140+
### `apply_filters('rollbar_plugin_settings', array $settings)`
141+
142+
Filters the Rollbar plugin settings.
143+
144+
**Parameters**
145+
146+
* `array $settings` - The Rollbar plugin settings array.
147+
148+
### `apply_filters('rollbar_php_config', array $config)`
149+
150+
Filters the Rollbar Core SDK PHP configuration.
151+
152+
**Parameters**
153+
154+
* `array $config` - The Rollbar PHP configuration array.
155+
156+
### `apply_filters('rollbar_telemetry_actions', array<string, int> $actions)`
157+
158+
Filter the list of actions to instrument with Telemetry.
159+
160+
**Parameters**
161+
162+
* `array<string, int> $actions` - An associative array where the keys are action names and the values are the number of
163+
arguments accepted by the action.
164+
165+
### `apply_filters('rollbar_telemetry_custom_handlers', array<string, callable(string, mixed...):string> $handlers)`
166+
167+
Filter the list of custom action event handlers for Telemetry.
168+
169+
Note: The custom action handler will only be called if the action is instrumented with Telemetry. This means you must
170+
select the action on the settings page, or add it to the list of actions using the `rollbar_telemetry_actions` filter.
171+
172+
**Parameters**
173+
174+
* `array<string, callable(string, mixed...):string> $handlers` - An associative array where the keys are action names
175+
and the values are the custom event handler.
176+
177+
### Telemetry
178+
179+
Starting in version 3.0.0 of the Rollbar plugin, Telemetry is enabled by default. Telemetry is a feature that allows
180+
the plugin to track events that occur in your WordPress installation prior to an exception or message being sent to
181+
Rollbar. The Telemetry data is sent to Rollbar along with the exception or message, and can be used to provide
182+
additional context and help debug the issue.
183+
184+
You can modify the list of actions you want to instrument with Telemetry by selecting them on the settings page, or
185+
using the `rollbar_telemetry_actions` filter. To use a custom handler for a specific action, use the
186+
`rollbar_telemetry_custom_handlers` filter. This can also be used to change the handler on any of the default actions.
187+
188+
#### Registering custom actions
189+
190+
You can also instrament custom actions like this:
191+
192+
```php
193+
use Rollbar\WordPress\Telemetry\Listener;
194+
195+
// Register a custom action with a custom handler function.
196+
$listener = Listener::getInstance()->instrumentAction(
197+
action: 'my_custom_action',
198+
priority: 10,
199+
acceptedArgs: 2,
200+
argsHandler: function ($action, ...$args) {
201+
$foo = $action;
202+
return 'custom_listener_test_action: ' . implode(', ', $args);
203+
},
204+
);
205+
206+
// Use the default handler for the action.
207+
$listener = Listener::getInstance()->instrumentAction(
208+
action: 'my_other_custom_action',
209+
priority: 10,
210+
acceptedArgs: 1,
211+
argsHandler: Listener::concatExtraArgs(...),
212+
);
213+
```
214+
215+
Of course, you can also call `Rollbar::captureTelemetryEvent()` directly to send custom events. See the
216+
[Telemetry documentation](https://docs.rollbar.com/docs/php-telemetry) for more information.
217+
57218
## Help / Support
58219

59220
If you run into any issues, please email us at [[email protected]](mailto:[email protected])
@@ -90,7 +251,7 @@ This is only for contributors with committer access:
90251
2. Add record in the `Changelog` section of the `readme.txt`.
91252
3. Add record in the `Upgrade Notice` section of the `readme.txt`.
92253
4. Bump the plugin version in `rollbar-php-wordpress.php` in the `Version:` comment.
93-
5. Bump the plugin version in `src/Plugin.php` in the `\Rollbar\Wordpress\Plugin::VERSION` constant.
254+
5. Bump the plugin version in `src/Plugin.php` in the `\Rollbar\WordPress\Plugin::VERSION` constant.
94255
5. Add and commit the changes you made to bump the plugin version: `git add readme.txt rollbar-php-wordpress.php src/Plugin.php && git commit -m"Bump version to v[version number]"`
95256
6. Bump versions of the JS and CSS files versions in Settings.php class to force refresh of those assets on users' installations.
96257
7. `git push origin master`

readme.txt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ This is a recommended way to install Rollbar plugin for advanced projects. This
7474
2. In your `composer.json` add `wpackagist-plugin/rollbar` to your `require` section, i.e.:
7575
```
7676
"require": {
77-
"php": ">=5.5",
77+
"php": ">=8.1",
7878
...,
7979
"wpackagist-plugin/rollbar": "*"
8080
}
@@ -105,6 +105,23 @@ Yes. It's actually the recommended method of installation.
105105

106106
== Changelog ==
107107

108+
= Version 3.0.0 (pending)
109+
* Fixed CSRF vulnerability.
110+
* Removed support for PHP 8.0 and below.
111+
* Updated and improved the settings page.
112+
* Updated the Rollbar core PHP SDK to v4.1.
113+
* Added support for telemetry and added auto-instrumentation.
114+
* Added support for `ROLLBAR_DISABLE_ADMIN` to remove the plugin settings page from the admin.
115+
* Added support for `ROLLBAR_SETTINGS` to configure the plugin without the admin page.
116+
* Added support for `ROLLBAR_CLIENT_ACCESS_TOKEN` constant or environment variable to set the client access token.
117+
* Added support for `WP_PROXY_BYPASS_HOSTS`, `WP_PROXY_USERNAME`, and `WP_PROXY_PASSWORD` for better proxy management.
118+
* Added `rollbar_api_admin_permission` filter to allow custom authorization of the admin API.
119+
* Added `rollbar_disable_admin` filter to allow custom disabling of the admin page.
120+
* Added `rollbar_php_config` filter to allow more exact control over Rollbar PHP configurations.
121+
* Added `rollbar_telemetry_actions` filter to allow control of which actions are logged via telemetry.
122+
* Added `rollbar_telemetry_custom_handlers` filter to allow custom control over what is logged in telemetry messages.
123+
* Added 'framework' details with the WordPress version to the item payload.
124+
108125
= Version 2.7.1 (September 13 2023)
109126
* Fix issue that could lead to fatal error with some settings (https://github.com/rollbar/rollbar-php-wordpress/pull/120)
110127

@@ -128,7 +145,7 @@ Yes. It's actually the recommended method of installation.
128145
* fix(initPhpLogging): Moving fetch settings to before settings check. (https://github.com/rollbar/rollbar-php-wordpress/pull/84)
129146

130147
= Version 2.5.1 (February 20th 2019) =
131-
* Fixed a call to Rollbar\Wordpress\Defaults for enableMustUsePlugin (https://github.com/rollbar/rollbar-php-wordpress/pull/75)
148+
* Fixed a call to Rollbar\WordPress\Defaults for enableMustUsePlugin (https://github.com/rollbar/rollbar-php-wordpress/pull/75)
132149

133150
= Version 2.5.0 (February 19th 2019) =
134151
* Moved Rollbar initialization from `plugins_loaded` hook to the invocation of the main plugin file (https://github.com/rollbar/rollbar-php-wordpress/issues/73)
@@ -201,7 +218,7 @@ Yes. It's actually the recommended method of installation.
201218

202219
= Version 2.1.0 (11th October 2017) =
203220
* Added "Send test message to Rollbar" button
204-
* Fixed the plugin's name inconsistency between Wordpress plugin directory and composer.
221+
* Fixed the plugin's name inconsistency between WordPress plugin directory and composer.
205222

206223
= Version 2.0.1 (6th October 2017) =
207224
* Fixed RollbarJsHelper class loading bug in src/Plugin.php (https://github.com/rollbar/rollbar-php-wordpress/issues/23)
@@ -247,7 +264,7 @@ Updated admin test results to show a skipped test as a success. Fixed new sessio
247264
* fix(initPhpLogging): Moving fetch settings to before settings check. (https://github.com/rollbar/rollbar-php-wordpress/pull/84)
248265

249266
= Version 2.5.1 (February 20th 2019) =
250-
* Fixed a call to Rollbar\Wordpress\Defaults for enableMustUsePlugin (https://github.com/rollbar/rollbar-php-wordpress/pull/75)
267+
* Fixed a call to Rollbar\WordPress\Defaults for enableMustUsePlugin (https://github.com/rollbar/rollbar-php-wordpress/pull/75)
251268

252269
= Version 2.5.0 (February 19th 2019) =
253270
* Moved Rollbar initialization from `plugins_loaded` hook to the invocation of the main plugin file (https://github.com/rollbar/rollbar-php-wordpress/issues/73)
@@ -320,7 +337,7 @@ Updated admin test results to show a skipped test as a success. Fixed new sessio
320337

321338
= Version 2.1.0 (11th October 2017) =
322339
* Added "Send test message to Rollbar" button
323-
* Fixed the plugin's name inconsistency between Wordpress plugin directory and composer.
340+
* Fixed the plugin's name inconsistency between WordPress plugin directory and composer.
324341

325342
= Version 2.0.1 (6th October 2017) =
326343
* Fixed RollbarJsHelper class loading bug in src/Plugin.php (https://github.com/rollbar/rollbar-php-wordpress/issues/23)

0 commit comments

Comments
 (0)