Define function/callbacks in ENV?


#1

hello :slight_smile:

Could somebody help me to understand why I can not define a function/callback in config/environment.js ENV object?

I see functions/callbacks are removed when we build the application but I can not find where in the ember-cli source code.

Why I want functions/callbacks in ENV ? I use “ember-cli-sentry” addon and we can define some raven-js options in ENV.sentry.ravenOptions. I need one Raven option which is a callback shouldSendCallback (cf https://docs.sentry.io/clients/javascript/config/)

Thanks :smiley:


#2

config/environment.js gets evaluated in node at build time and then JSON.stringified into your app. So it can only hold serializable things.

Perhaps you can open an issue against ember-cli-sentry asking about alternative ways to get config into it, so that it doesn’t need to pass through JSON.stringify.


#3

Thank you :slightly_smiling_face: