File tree Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Expand file tree Collapse file tree 2 files changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -45,5 +45,5 @@ interface Window {
4545
4646 api : import ( '../services/api/index' ) . YdbEmbeddedAPI ;
4747
48- [ key : `yaCounter${number } `] : number ;
48+ [ key : `yaCounter${number } `] : any ;
4949}
Original file line number Diff line number Diff line change 11import { uiFactory } from '../uiFactory/uiFactory' ;
22
3+ export interface Counter {
4+ hit : ( ...args : unknown [ ] ) => void ;
5+ params : ( ...args : unknown [ ] ) => void ;
6+ userParams : ( ...args : unknown [ ] ) => void ;
7+ reachGoal : ( ...args : unknown [ ] ) => void ;
8+ }
9+
310const yaMetricaId = uiFactory . yaMetricaId ;
411
5- class FakeMetrica {
12+ class FakeMetrica implements Counter {
613 private warnShown = false ;
714
815 hit ( ) {
@@ -23,14 +30,16 @@ class FakeMetrica {
2330
2431 private warnOnce ( ) {
2532 if ( ! this . warnShown ) {
26- console . warn ( 'YaMetrica counter is not defined' ) ;
33+ console . warn ( 'YaMetrica counter is not defined\n ' ) ;
2734 this . warnShown = true ;
2835 }
2936 }
3037}
3138
3239export function getMetrica ( ) {
33- const metricaInstance = yaMetricaId && window [ `yaCounter${ yaMetricaId } ` ] ;
40+ const metricaInstance = yaMetricaId
41+ ? ( window [ `yaCounter${ yaMetricaId } ` ] as Counter )
42+ : undefined ;
3443
3544 return metricaInstance ?? new FakeMetrica ( ) ;
3645}
You can’t perform that action at this time.
0 commit comments