Search code examples
javascriptangularjserror-handlingstrictrollbar

How to enable Rollbar in Browser JS when strict mode is global?


I want to add Rollbar error-monitoring tool to a browser JS application written in angularJS. In our browser application, strict mode of javascript is used globally everywhere.

The problem is, that in order for me to take Rollbar into use, I need to insert the code of Rollbar to my application. The code of rollbar for JS can be seen here: Rollbar Browser JS. The code unfortunately does not support for javascript strict mode. When I run the app, rollbar causes this error: Uncaught TypeError: Cannot read property 'logger' of undefined.

How could I solve this? Is there a way to disable strict mode, if it is globally defined already? Disabling strict mode globally is probably not an option. Could I use the Node.js version for monitoring browser application?


Solution

  • I was able to solve this by modifying the Rollbar snippet code. I replaced all occurences of 'this.logger' with 'window.logger', and it started working even strict-mode was on.