File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export interface UIFactory<H extends string = CommonIssueType> {
4343 countHealthcheckIssuesByType : ( issueTrees : IssuesTree [ ] ) => Record < H , number > ;
4444 } ;
4545 hasAccess ?: boolean ;
46- yaMetricaId ?: number ;
46+ yaMetricaMap ?: Record < string , number > ;
4747}
4848
4949export type HandleCreateDB = ( params : { clusterName : string } ) => Promise < boolean > ;
Original file line number Diff line number Diff line change @@ -7,11 +7,17 @@ export interface Counter {
77 reachGoal : ( ...args : unknown [ ] ) => void ;
88}
99
10- const yaMetricaId = uiFactory . yaMetricaId ;
10+ const yaMetricaMap = uiFactory . yaMetricaMap ;
1111
1212class FakeMetrica implements Counter {
13+ name : string ;
14+
1315 private warnShown = false ;
1416
17+ constructor ( name : string ) {
18+ this . name = name ;
19+ }
20+
1521 hit ( ) {
1622 this . warnOnce ( ) ;
1723 }
@@ -30,16 +36,17 @@ class FakeMetrica implements Counter {
3036
3137 private warnOnce ( ) {
3238 if ( ! this . warnShown ) {
33- console . warn ( ' YaMetrica counter is not defined\n' ) ;
39+ console . warn ( ` YaMetrica counter " ${ this . name } " is not defined\n` ) ;
3440 this . warnShown = true ;
3541 }
3642 }
3743}
3844
39- export function getMetrica ( ) {
45+ export function getMetrica ( name : string ) {
46+ const yaMetricaId = yaMetricaMap ?. [ name ] ;
4047 const metricaInstance = yaMetricaId
4148 ? ( window [ `yaCounter${ yaMetricaId } ` ] as Counter )
4249 : undefined ;
4350
44- return metricaInstance ?? new FakeMetrica ( ) ;
51+ return metricaInstance ?? new FakeMetrica ( name ) ;
4552}
You can’t perform that action at this time.
0 commit comments