JavaScript Source Maps based on set version

youngj7

Posted on
Nov 24 2016

Is it possible for Raygun to use a specific set of JavaScript source maps based on the version supplied in Raygun.setVersion()?

For example, we have 10 customers running v1.0 of our software. And another 10 customers running v2.0 of our software. Each customer hosts our software and has a unique URL. Only 2 unique sets of source maps are needed for this scenario, but it appears Raygun requires us to enter 20 sets of source maps because of the version and URL differences.

Is there a better way to do this? Our .js files are protected and only accessible after logging into our system. There is no way to allow Raygun to automatically download them from our customers.


Alex

Posted on
Nov 24 2016

Hi there,

Unfortunately we don't have any super simple solutions to this however a possible work around is to normalize the URLs reported to Raygun. This can be done by adding a handler to your instance of raygun4js which modifies the URLs of the filenames in the stacktrace by removing the custom segments of the domain and replacing them with a normalized subdomain.

Such a handler could look something like this:

var beforeSend = function(payload) {
    var stacktrace = payload.Details.Error.StackTrace;

    // filename might look like "https://customsubdomain.domain.com/scripts/myjavascriptfile.js"
    var normalizeFilename = function(filename) {
        var indexOfJsRoot = filename.indexOf('scripts');
        return 'https://yournormalisedurl.com/' + filename.substring(indexOfJsRoot);
    }

    for(var i = 0 ; i < stacktrace.length; i++) {
        var stackline = stacktrace[i];
        stackline.FileName = normalizeFilename(stackline.FileName);
    }
    return payload;
}

rg4js('onBeforeSend', beforeSend);

This would mean you would only have to upload unique versions of your source maps to Raygun (listed under the normalized URL) to provide source mapping for all the errors.

Hope that helps, let me know if that is going to work for you or if you have any other questions.

Best regards,
Alex


Reply