adopted-ember-addons / ember-metrics

Send data to multiple analytics integrations without re-implementing new API
MIT License
367 stars 160 forks source link

Metrics adapters no longer inject services. #541

Open veelci opened 1 year ago

veelci commented 1 year ago

I have a few custom adapters in my application that depend on injected services.

I've updated my app to use ember-metrics 2.0.0-beta.2 and am now seeing this error in the console when running the app:

Uncaught (in promise) Error: Assertion Failed: Attempting to lookup an injected property on an object without a container, ensure that the object was instantiated via a container.

Proposing this change to the metrics service to fix this:

  /**
   * Instantiates an adapter.
   *
   * @method _activateAdapter
   * @param {Object}
   * @private
   * @return {Adapter}
   */
  _activateAdapter({ adapterClass, config }) {
    const adapter = new adapterClass(config);
    setOwner(adapter, getOwner(this));
    adapter.install();
    return adapter;
  }