# Define function/callbacks in ENV?

**URL:** <https://discuss.emberjs.com/t/define-function-callbacks-in-env/15607>\
**Category:** Ember CLI\
**Created:** [October 8, 2018, 6:46am UTC](https://discuss.emberjs.com/t/define-function-callbacks-in-env/15607 "2018-10-08T06:46:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Myrdhin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/myrdhin/32/16107_2.png) [@Myrdhin](https://discuss.emberjs.com/u/Myrdhin)\
**Post date:** [October 8, 2018, 6:46am UTC](https://discuss.emberjs.com/t/define-function-callbacks-in-env/15607/1 "2018-10-08T06:46:11Z")

</div>

hello 🙂

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](https://github.com/damiencaselli/ember-cli-sentry) and [we can define some raven-js options in `ENV.sentry.ravenOptions`](https://github.com/damiencaselli/ember-cli-sentry#complete-config). I need one Raven option which is a callback `shouldSendCallback` (cf [Configuration | Sentry Documentation](https://docs.sentry.io/clients/javascript/config/))

Thanks 😃

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [October 8, 2018, 12:19pm UTC](https://discuss.emberjs.com/t/define-function-callbacks-in-env/15607/2 "2018-10-08T12:19:07Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![Myrdhin](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/myrdhin/32/16107_2.png) [@Myrdhin](https://discuss.emberjs.com/u/Myrdhin)\
**Post date:** [October 8, 2018, 3:46pm UTC](https://discuss.emberjs.com/t/define-function-callbacks-in-env/15607/3 "2018-10-08T15:46:58Z")

</div>

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![chilicoder](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/chilicoder/32/12721_2.png) [@chilicoder](https://discuss.emberjs.com/u/chilicoder)\
**Post date:** [October 26, 2018, 10:51am UTC](https://discuss.emberjs.com/t/define-function-callbacks-in-env/15607/4 "2018-10-26T10:51:01Z")

</div>

there is a similar thing done for trackjs wrapper [https://github.com/jherdman/ember-cli-trackjs#one-caveat](https://github.com/jherdman/ember-cli-trackjs#one-caveat)

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

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

  trackJs.configure({
    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
