Integration with rollbar.js
How integrate rollbar-php and rollbar.js
In case you want to report your JavaScript errors using Rollbar.js, you can configure the SDK to enable Rollbar.js on your site. Example:
<?php
$rollbarJs = Rollbar\RollbarJsHelper::buildJs(
array(
"accessToken" => "POST_CLIENT_ITEM_ACCESS_TOKEN",
"captureUncaught" => true,
"payload" => array(
"environment" => "production"
),
/* other configuration you want to pass to RollbarJS */
)
);
Or if you are using Content-Security-Policy: script-src 'unsafe-inline'
<?php
$rollbarJs = Rollbar\RollbarJsHelper::buildJs(
array(
"accessToken" => "POST_CLIENT_ITEM_ACCESS_TOKEN",
"captureUncaught" => true,
"payload" => array(
"environment" => "production"
),
/* other configuration you want to pass to RollbarJS */
),
headers_list(),
$yourNonceString
);
That's it! Uncaught errors and exceptions will now be reported to Rollbar.
For more information on rollbar-php, please see the docs here.
Updated 9 months ago