Rollbar
Technical Implementations
Rollbar
Rollbar is an error-logging service we use through our web apps to view and debug errors in real-time. The implementation is pretty easy and supports a large number of languages. There are two types of implementations for Rollbar, browser
and server
.
General Needs
Implementing Rollbar generally requires the inclusion of the respective rollbar module (browser/server) and then initializing the rollbar object with account credentials.
Access Token
Browser Token
Environment (Staging/Production)
Payload (data to be analyzed)
Browser Setup DOC
Browser implementation tracks a user's actions through the Application/Webpage (DOM) and reports a significant amount of steps before the error occurs; displaying the output (DOM/text) the user sees when the error is triggered. In our WebApps we include the rollbar in the module that constructs the page's HTML structure, ie. services-js/[service-name]/pages/_document.tsx
. A browser implementation looks like this:
Server Setup DOC
Our code base abstracts the server (Hapi.js) implementation on a top layer module at modules-js/hapi-common/src/hapi-common.ts
, here it expands the reporting tool to handle 404 errors as well among other things. Although reporting an error only requires the error message/payload, rollbar.error(error)
going forward we should be more verbose in the errors we log; rollbar.error(e, request.raw.req)
Ex.
Server Usage
Single Page Application (SPA)
Our web apps are Single Page Apps
, SPAs, meaning that it all runs off of the same front-end code even when the URL subpage and parameters change. Since we include Rollbar at the top of the Application it is available through the browser's window
DOM object or by including it as a module in specific sections. DOM window
is sufficient for our needs so the example below covers how to raise an error from within the app.
PHP and Drupal
Rollbar has an implementation for PHP, like others it's straightforward to implement, but it is missing a documented implementation for Drupal. There is a Rollbar module on Drupal.org that is installed with composer
but this will require more insight/research.
PHP Implementation
In Composer
Setup
Send an Error and a Message
Set up your Rollbar account, configure projects
Above we went through how to set up Rollbar in the codebase, however, we also need to set up a project for each implementation in the Rollbar dashboard.
Login into the account
Create New Project
Invite team members
Setup Notifications - Determine if you are using Slack or email, etc
Integrate with Source Control Provider - We have a couple of apps (DBConnector) that are hosted in AWS, for this we'll need to set it up using this doc
Setup Versions and Deploy controls - Setup a way to notify Rollbar of an AWS deployment (Lambda)
Last updated