Define function/callbacks in ENV?

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 Configuration | Sentry Documentation)

Thanks :smiley:

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.

1 Like

Thank you :slightly_smiling_face:

there is a similar thing done for trackjs wrapper

// app/instance-initializers/configure-trackjs.js

export function initialize(application) {
  const trackJs = application.container.lookup('service:trackjs');

    onError(payload, err) {
      // exclude errors from log in page
      if (payload.url && payload.url.indexOf('login') > 0) {
        return false;

      return true;

export default {
  name: 'trackjs-error-and-serializer-configuration',
  initialize: initialize

Maybe you could do the same here