File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -44,4 +44,6 @@ interface Window {
4444 systemSettings ?: import ( '../services/settings' ) . SettingsObject ;
4545
4646 api : import ( '../services/api/index' ) . YdbEmbeddedAPI ;
47+
48+ [ key : `yaCounter${number } `] : number ;
4749}
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ export interface UIFactory<H extends string = CommonIssueType> {
4343 countHealthcheckIssuesByType : ( issueTrees : IssuesTree [ ] ) => Record < H , number > ;
4444 } ;
4545 hasAccess ?: boolean ;
46+ yaMetricaId ?: number ;
4647}
4748
4849export type HandleCreateDB = ( params : { clusterName : string } ) => Promise < boolean > ;
Original file line number Diff line number Diff line change 1+ import { uiFactory } from '../uiFactory/uiFactory' ;
2+
3+ const yaMetricaId = uiFactory . yaMetricaId ;
4+
5+ class FakeMetrica {
6+ private warnShown = false ;
7+
8+ hit ( ) {
9+ this . warnOnce ( ) ;
10+ }
11+
12+ params ( ) {
13+ this . warnOnce ( ) ;
14+ }
15+
16+ userParams ( ) {
17+ this . warnOnce ( ) ;
18+ }
19+
20+ reachGoal ( ) {
21+ this . warnOnce ( ) ;
22+ }
23+
24+ private warnOnce ( ) {
25+ if ( ! this . warnShown ) {
26+ console . warn ( 'YaMetrica counter is not defined' ) ;
27+ this . warnShown = true ;
28+ }
29+ }
30+ }
31+
32+ export function getMetrica ( ) {
33+ const metricaInstance = yaMetricaId && window [ `yaCounter${ yaMetricaId } ` ] ;
34+
35+ return metricaInstance ?? new FakeMetrica ( ) ;
36+ }
You can’t perform that action at this time.
0 commit comments