I have a web service called app
that uses raven-js. I'm developing a client-side library that, ideally, would log internal errors to its _own_ Sentry project rather than app
's. But, it would ideally not include its own copy of raven-js, rather specify that Raven is an external dependency to be fulfilled by app
.
However, raven-js' configuration makes it seem global to uses of the library. Is it possible to instantiate the library multiple times with different DSNs?
Similar to how, in raven-node, it's possible to instantiate Raven.Client
multiple times.
It's undocumented, but if you're using a bundler you should be able to import/require src/raven
and have multiple instances. See src/singleton.js
.
If you do this, I recommend hard-pinning the version of Raven.js you're using.
Cool thanks!
I'm cool with it being undocumented but please don't remove it :) I think it's a really nice feature of both the Node and JS clients for users that are using module loaders/bundlers, and adds little complexity to the library's use.
My remaining question is, do both instances need to call install()
? Is it safe for them to both do so?
please don't remove it
We intentionally re-wrote the Raven library to work this way in late 2015 (it was previously all global), so I doubt it will change.
My remaining question is, do both instances need to call install()?
Yes.
Is it safe for them to both do so?
Take a look at the tests; they're all written against instances.
Terrific, thanks!
Most helpful comment
We intentionally re-wrote the Raven library to work this way in late 2015 (it was previously all global), so I doubt it will change.
Yes.
Take a look at the tests; they're all written against instances.