{"size": 1334, "ext": "js", "max_stars_repo_path": "src/rollbar.js", "max_stars_repo_name": "hanpeter/discord-bot", "max_stars_repo_stars_event_min_datetime": "2020-01-14T05:18:18.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-04T11:29:03.000Z", "max_issues_repo_path": "src/rollbar.js", "max_issues_repo_name": "hanpeter/discord-bot", "max_issues_repo_issues_event_min_datetime": "2020-07-16T09:08:35.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-16T09:08:35.000Z", "max_forks_repo_path": "src/rollbar.js", "max_forks_repo_name": "hanpeter/discord-bot", "max_forks_repo_forks_event_min_datetime": "2020-01-14T05:18:20.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-14T05:18:20.000Z"}
{"max_stars_count": 2, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 27.2244897959, "max_line_length": 114, "alphanum_fraction": 0.4482758621}
(function () {
    'use strict';

    var Rollbar = require('rollbar');
    var logger = require('./logger.js');

    function rollbar() {
        var rbClient;

        if (process.env.ROLLBAR_ACCESS_TOKEN){
            rbClient = new Rollbar({
                accessToken: process.env.ROLLBAR_ACCESS_TOKEN,
                environment: process.env.ENVIRONMENT || 'development',
            });
        }
        else {
            logger.warn('ROLLBAR_ACCESS_TOKEN environment variable is not set. Not logging anything to Rollbar.');
            rbClient = null;
        }

        return {
            errorRequest: function (error, request) {
                if (!rbClient) {
                    return;
                }

                var req = {
                    headers: request.headers,
                    protocol: request.uri.protocol,
                    domain: request.uri.domain,
                    url: request.uri.path,
                    method: request.method,
                    body: request.body,
                };
                rbClient.error(error, req);
            },
            error: function (error) {
                if (!rbClient) {
                    return;
                }

                rbClient.error(error);
            },
        };
    }

    module.exports = rollbar();
})();
