[How2Tips] Rollbar : a simple online bugtracker

Reading time : < 4 min

For our How2Tips articles, we offer you code snippets or fancy tools, which we use for our projects. Those are small pieces of code we like to share with you. Find out what Pierre and Albin want to share about Rollbar !

Rollbar is a really simple online bug-tracker supporting common languages and platforms ( e.g. PHP, Python, Javascript both in-browser and server-side, Android, iOS, …), which has many integration capabilities (Capistrano, Heroku, Slack, Github, Trello, …) and can even track your deployments.

Free plan

The free plan allows a maximum of 5000 logs per month with a 30 days of logs retention.

See here for pricing

Rollbar implementation with Symfony


The handler needs an extra dependency: the Rollbar PHP library.

So, just add it into your own dependencies:

composer require rollbar/rollbar


There is an existing rollbar handler into monolog. You just need to configure it into your monolog bundle configuration.


    - { resource: config.yml }

            type:   rollbar
            token:  <my token>
            level:  error
                environment: foo.com
        # And then the existing handlers
            type:         fingers_crossed
            action_level: error
            handler:      nested
            type:  stream
            path:  "%kernel.logs_dir%/%kernel.environment%.log"
            level: debug
            type:  console

There is just one problem !

Rollbar is not PSR-3 compliant. It will just manage critical, error, warning, info, or debug log levels. And for example the emergency, debug or alert level will not be managed.

For (client-side) Javascript

Combined with the ability to retrieve information like browser type, version… it makes it really powerful when you need to have more insight about what’s happening in-browser.

Retrieve the “Client access token”

You will need to get through “Settings > Project Access Token” in order to retrieve the post_client_item token. Here, you can also define a rate limit, e.g. 10 requests/minute. You really should apply a rate limit on the client token, especially if you use a free plan.

Install/configure with common.js/AMD module

Please check here.

Without common.js/AMD

You need to copy the code snippet in the documentation into <head></head>, as high as possible.

Finally, you can configure it :

var _rollbarConfig = {
    captureUncaught: true,
    captureUnhandledRejections: false,
    payload: {
        environment: "foo.com"
  • accessToken : Rollbar provides server-side token(s) & client-side token(s). Here you need to use the latter. See above for limiting the number of requests.
  • captureUncaught : Uncaught exceptions will be logged by Rollbar.
  • captureUnhandledRejections : Unhandled rejected promises will be logged by Rollbar.
  • payload : You can (and should) define the environment. It would be the same as the one used for server-side logging. You can also add your own data (e.g. customer email).

Test it!

By entering the following snippet in your browser console, this should appear on your dashboard :

window.onerror("TestRollbarError: testing window.onerror", window.location.href)

Use it!

For now, you probably only have configured it to send uncaught/unhandled exceptions/promises. But you can also log your own messages:

// Arbitrary log messages. 'critical' is most severe; 'debug' is least.
Rollbar.critical("Connection error from remote Payments API");
Rollbar.error("Some unexpected condition");
Rollbar.warning("Connection error from Twitter API");
Rollbar.info("User opened the purchase dialog");
Rollbar.debug("Purchase dialog finished rendering");

Log deployments into Rollbar

You can also track your deployments using Rollbar. It will provide you a way to check which version has been deployed, by whom and when. Also you’ll be able to easily see the diff between the last commit deployed and commits of your repository.

If you are using deployer you can use the recipe in this repository. You can also use the dedicated API endpoint.


Any questions ? Ping us at @KNPLabs  

This article is from our internal knowledge base, we wanted to share it with you. ❤ Send us a KUDO-Tweet if this article has helped you !