Due to circumstances, I can only retrieve an app's proper environment asynchronously.
Initializing Sentry ASAP forces my hand to call init
without the proper environment.
Is there a way for me to update the Sentry environment after init
?
Otherwise, if I move the init
call after the environment is obtained, errors that occur before that might pass unobserved.
Sentry.configureScope(scope => scope.addEventProcessor(event => ({
...event,
environment: 'something'
})))
or in ES5:
Sentry.configureScope(function (scope) {
scope.addEventProcessor(function (event) {
event.environment = 'something';
return event;
});
});
Cheers!
Useful info, thanks @kamilogorek!
small FYI: scope.addEventProcessor
expected a Promise, so:
Sentry.configureScope(scope =>
scope.addEventProcessor(
event =>
new Promise(resolve =>
resolve({
...event,
environment: 'something'
})
)
)
);
Right, sorry 馃槄
copy/pasteable version for anyone who needs the ES5 method of adding release:
```
Sentry.configureScope(function (scope) {
scope.addEventProcessor(function (event) {
return new Promise(function(resolve) {
event.release = '1.2.3.4';
return resolve(event);
});
});
});
Most helpful comment
small FYI:
scope.addEventProcessor
expected a Promise, so: