Add metrika goals

This commit is contained in:
2018-06-24 20:21:54 +03:00
parent b10b29a3fd
commit 256e41a482
5 changed files with 67 additions and 17 deletions

View File

@ -1,9 +1,23 @@
class Metrika {
constructor(counterCb) {
this.cb = counterCb;
}
get counter() {
return this.cb.call();
}
hit(name) {
if (window.yaCounter41913764) {
window.yaCounter41913764.hit(name);
if (this.counter) {
this.counter.hit(name);
}
}
goal(name, params = {}) {
if (this.counter) {
this.counter.reachGoal(name, params);
}
}
}
export default new Metrika();
export default new Metrika(() => window.yaCounter41913764);