question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow to define basePath for script files

See original GitHub issue

I have successfully configured and installed sourcemaps in rollbar (https://rollbar.com/docs/source-maps/).

Unfortunately, with current behaviour, you assume that my assets are located under only one url (f.e. http://domain.com/js/app.js).

However, what if my assets are stored under 4 different urls? (f.e. http://userone.domain.com/js/app.js , http://usertwo.domain.com/js/app.js) . I have to upload the same sourcemap twice for each minified_url, even if those files are exactly the same.

My actual example & problem: I am using Rollbar.js in my mobile Apache Cordova application. Source urls are a little bit strange there.

Even though, I managed to synchronise the sourcemaps on Android by setting sourceMappingURLPrefix: 'file:///android_asset/www/js' in gulp-rollbar.

Unfortunately, it’s not so easy for iOS, as the assets path for the iOS app is random: f.e. file:///private/var/mobile/Containers/Bundle/Application/9A5697CB-45C3-46A6-9A97-4EC7A088CDC7/CordovaSample.app/www/js/app.js, where 9A5697CB-45C3-46A6-9A97-4EC7A088CDC7 is a random hash being different with every deploy. Thus, it’s almost impossible for me to make the sourcemaps working on the iOS app.

It would be great if I could set an “alias_name” for given script url, f.e.

scriptUrls = {
  "file:///private/var/mobile/Containers/Bundle/Application/9A5697CB-45C3-46A6-9A97-4EC7A088CDC7/CordovaSample.app/www/js/app.js": "/www/js/app.js"
}

OR

just configure a basePath for all script files in Rollbar.configure, f.e.:

Rollbar.configure({
  basePath: "file:///private/var/mobile/Containers/Bundle/Application/9A5697CB-45C3-46A6-9A97-4EC7A088CDC7/CordovaSample.app/www/"
})

This way, I would be able to upload sourcemaps by just setting minified_url to /js/app.js, instead of the full URL (and I wouldn’t need to upload them more than once if there’s one file having many URLs).

Would you mind adding such a feature? Do you have any idea if I could accomplish it right now with some kind of hack, changing the JSON payload before sending to rollbar, or something?

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
jtomaszewskicommented, Jan 26, 2015

Okay, I managed to make it with simple transform() function 😉

GLOBALS = 
  ROLLBAR_SOURCEMAPS_URL_PREFIX: "http://somefancyurl.com"
  APP_ROOT: location.href.replace(location.hash, "").replace("index.html", "")

Rollbar.configure
  transform: (payload) ->
    if frames = payload.data?.body?.trace?.frames
      for frame in frames
        frame.filename = frame.filename.replace(GLOBALS.APP_ROOT, "#{GLOBALS.ROLLBAR_SOURCEMAPS_URL_PREFIX}/")

This solved my problem completely, so the issue can be closed 😉

A note about it in the documentation however, could be helpful IMHO ;P

0reactions
cmoralescommented, Oct 2, 2017

Hey jtomaszewski,

This is a bit old issue but I am searching for the solution you already gave for this. I just don’t understand very well where this code needs to be set.

Im having the same problem with this: '-F minified_url=file:///android_asset/www/js/app-min.js ’ +

For android is good, but for iOS, I don’t know what to set since as you said, different hash is always generated.

Im sending this to Rollbar from gulp.

But at the end it doesn’t get transformed properly for iOS, I need the solution for iOS.

Any help would be highly appreciated.

Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CodeIgniter BASEPATH - php - Stack Overflow
defined : Checks whether a given named constant exists · BASEPATH : it´s a constant from codeigniter reserved names · OR exit prints...
Read more >
API Host and Base Path - Swagger
REST APIs have a base URL to which the endpoint paths are appended. The base URL is defined by schemes , host and...
Read more >
defined('BASEPATH') OR exit('No direct script access allowed');
So I'd say the answer is it goes in any file where that is true. Controllers, Models and most other files that define...
Read more >
if (!defined('BASEPATH')) exit('No direct script access allowed')
Making sure BASEPATH is defined is just a simple way to know that CI has been loaded. It usually goes at the top...
Read more >
The Document Base URL element - HTML - MDN Web Docs
The HTML element specifies the base URL to use for all relative URLs in a document. There can be only one element in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found