Giter VIP home page Giter VIP logo

Comments (8)

poteto avatar poteto commented on May 12, 2024

You need to import the one from your app:

needs: ['metrics-adapter:piwik']

the ember-metrics@... form will try to resolve it on the addon's namespace instead.

from ember-metrics.

sly7-7 avatar sly7-7 commented on May 12, 2024

@poteto Thank you for your answer. Actually, I'm unit testing this adapter, so I thought it was not a need, but the subject of the module. I will try your suggestion tomorrow and let you know if that works.

from ember-metrics.

sly7-7 avatar sly7-7 commented on May 12, 2024

I tried, but it does not work. Here is the adapter:

//app/metrics-adapters/piwik.js
import PiwikAdapter from 'ember-metrics/metrics-adapters/piwik';

export default PiwikAdapter.extend({
  identify(options = {}) {
    this._super(...arguments);
    window._paq.push(['setCustomDimension', 1, options.organizationName]);
    window._paq.push(['setCustomDimension', 2, options.userId]);
  }
});

and the test, using ember-mocha

/* jshint expr:true */
import { expect } from 'chai';
import {
  beforeEach
} from 'mocha';
import {
  describeModule,
  it
} from 'ember-mocha';

describeModule(
  'metrics-adapter:piwik',
  'PiwikAdapter',
  {
    needs: ['metrics-adapter:piwik']
  },
  function() {
    let config;

    beforeEach(function () {
      config = { piwikUrl: 'someUrl', siteId: 42 };
    });

    it('exists', function() {
      var adapter = this.subject({ config });
      expect(adapter).to.be.ok;
    });
  }
);

The following error is thrown:
Could not find moduleember-metrics/metrics-adapters/piwikimported fromfrontend/metrics-adapters/piwik`

It seemed to me that I should add the dependency to the ember-metrics piwik adapter, but if I do that I have the above error, ie Attempting to register an unknown factory:ember-metrics@metrics-adapter:piwik`

from ember-metrics.

poteto avatar poteto commented on May 12, 2024

Sorry about the delay! Can you share what your config / env looks like?

from ember-metrics.

sly7-7 avatar sly7-7 commented on May 12, 2024

Hi, I'm sorry for the delay. I don't know when I will go back to work (kind of burn out for the moment), but for sure, as soon as I can I will try to keep this up to date

from ember-metrics.

Leooo avatar Leooo commented on May 12, 2024

@poteto, having the same problem while unit testing a metrics-adapter that I export from an addon. I added ember-metrics in both the dependencies and devDependencies of my addon's package.json, and tried:

moduleFor('metrics-adapter:google-analytics', 'google-analytics metrics-adapter', {
  needs: [
    'service:logger',
    'service:configService',
    'service:metrics',
    'ember-metrics@metrics-adapter:google-analytics'
  ]
});

Which fails with Attempting to register an unknown factory: 'ember-metrics@metrics-adapter:google-analytics'

while removing the needs: ember-metrics@metrics-adapter:google-analytics line leads to:

Could not find module `ember-metrics/metrics-adapters/google-analytics` imported from `ember-commons/metrics-adapters/google-analytics`

my metrics-adapter itself starts with:

mport GoogleAnalyticsAdapter from 'ember-metrics/metrics-adapters/google-analytics';
import Ember from 'ember';
const {inject, copy, computed, Logger} = Ember;

export default GoogleAnalyticsAdapter.extend({
//..

and works well except for the failing test

from ember-metrics.

Leooo avatar Leooo commented on May 12, 2024

@poteto, forget it it was as simple as setting the metricsAdapters ENV variable in my dummy app config, thanks

from ember-metrics.

sly7-7 avatar sly7-7 commented on May 12, 2024

@poteto I'm sorry letting this one so long. If you still interrested I could work on, otherwise I will juste close. Your call 😺

from ember-metrics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.