Search code examples
javascriptember.jsdeprecatedbugsnag

Bugsnag & Emberjs : application.lookup is not a function


I'm trying to configure Bugsnag in my EmberJs(v2.12) application.

I am following this example: https://gist.github.com/ToddSmithSalter/23ad9ed91a693b498709

But I have an error in the browser telling that the lookup is not a function.

app/initializer/bugsnag.js

import Ember from 'ember';
import config from '../config/environment';

export default {
  name: 'bugsnag',

  initialize: function(appInstance) {

      // appInstance.lookup is not a function
      var appController = appInstance.lookup('controller:application');
  }
};

Someone would have a way to access the application controller in an emberjs initializer?

Or maybe a better solution to install bugsnag on an Emberjs application?


Solution

  • You need to create instance-initializer not initializer.
    Ember.Application - does not have lookup method but Ember.ApplicationInstance has.

    Reference:
    https://guides.emberjs.com/v2.13.0/applications/applications-and-instances/ https://emberjs.com/api/classes/Ember.ApplicationInstance.html https://emberjs.com/api/classes/Ember.Application.html