Subdomains Causing Issues with Sourcemaps

Wix

Posted on
Dec 05 2016

Hello, I have noticed an issue with Raygun and sourcemaps. Our SaaS system uses subdomains to identify customers. So, customerA.website.com. All our scrips are in /scripts but they resolve to customerA.website.com/scripts/. Raygun won't pick up the sourcemaps unless I specify the full url for each customer. Is there a work around for this? The only option I can think of other than posting sourcemaps for each subdomain is putting calling scripts at the base URI and dealing with CORS.


Alex

Posted on
Dec 07 2016

Hi,

You can utilize a single set of source maps by normalising the URL's reported in the stacktrace then uploading a set of file with normalised URLs.

You can ensure your stacktraces are normalized by utilizing a onBeforeSend handler in raygun4js.

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

    var normalizeFilename = function(filename) {
        var indexOfJsRoot = filename.indexOf("scripts");
        return 'http://normalizedurl.com/' + filename.substring(indexOfJsRoot);
    }

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

//attaching the handler to the Raygun provider
rg4js('onBeforeSend', beforeSend);

Alternately you can make your scripts be publicly available or hosted from the same URL.

Let me know if you have any further questions.

Regards, Alex


Reply