Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialization code #104

Closed
davewasmer opened this issue Jun 29, 2015 · 2 comments
Closed

Initialization code #104

davewasmer opened this issue Jun 29, 2015 · 2 comments

Comments

@davewasmer
Copy link

Just curious - is there any reason why you run a decent amount of initialization code before the library even loads (the snippet that is copy/paste from the app)?

I maintain ember-cli-rollbar, and since the snippet seems to use private APIs in the library, it's a bit more onerous for me to keep up with changes. I have to manually update every time there is a new version, rather than simply fetching whatever version the user wants.

Hopefully that question makes sense 😄

@coryvirok
Copy link
Contributor

Great question.

We recently changed the snippet to fix some bugs related to RequireJS/AMD use-cases of the library. Ideally, the snippet will not change very often.

The initialization code in the snippet is so long because we support the full API before the full implementation is downloaded.

e.g.

var _rollbarConfig = {accessToken: '54321'};

// Snippet goes here...

// Creates a child notifier and sends a message with a different access token
// before the "full" rollbar implementation is downloaded.
var tmp = window.Rollbar.scope({custom: 'field'});
tmp.configure({accessToken: '...'});
tmp.error('Hello world');

I'm assuming you are referring to https://github.com/davewasmer/ember-cli-rollbar/blob/master/index.js#L23 when you say, "I have to manually update every time...". One way to get around this would be to add rollbar.js as a submodule and have a build step copy dist/rollbar.snippet.js into your code. That way, whenever we change the snippet you would just have to update the submodule and rebuild your library.

I hope that answers your question.

Also, thanks for building and maintaining this lib! 😄

@davewasmer
Copy link
Author

Thanks for the quick response @coryvirok. Makes sense now. I'll probably keep it as is (the npm publish takes about as long as it does to copy/paste the snippet, so not a big deal). Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants