@@ -11,9 +11,9 @@ import TimeUnit from "./metrics/time_unit.js";
1111import { generateUUIDv4 } from "./utils.js" ;
1212import type { ConfigurationInterface } from "./config.js" ;
1313import type Platform from "../platform/index.js" ;
14- import type MetricsDatabase from "./metrics/database.js" ;
1514import { Lifetime } from "./metrics/lifetime.js" ;
1615import log , { LoggingLevel } from "./log.js" ;
16+ import { Context } from "./context.js" ;
1717
1818const LOG_TAG = "core.InternalMetrics" ;
1919
@@ -100,9 +100,9 @@ export class CoreMetrics {
100100 } ) ;
101101 }
102102
103- async initialize ( config : ConfigurationInterface , platform : Platform , metricsDatabase : MetricsDatabase ) : Promise < void > {
104- await this . initializeClientId ( metricsDatabase ) ;
105- await this . initializeFirstRunDate ( metricsDatabase ) ;
103+ async initialize ( config : ConfigurationInterface , platform : Platform ) : Promise < void > {
104+ await this . initializeClientId ( ) ;
105+ await this . initializeFirstRunDate ( ) ;
106106 await StringMetricType . _private_setUndispatched ( this . os , await platform . info . os ( ) ) ;
107107 await StringMetricType . _private_setUndispatched ( this . osVersion , await platform . info . osVersion ( ) ) ;
108108 await StringMetricType . _private_setUndispatched ( this . architecture , await platform . info . arch ( ) ) ;
@@ -114,12 +114,10 @@ export class CoreMetrics {
114114 /**
115115 * Generates and sets the client_id if it is not set,
116116 * or if the current value is currepted.
117- *
118- * @param metricsDatabase The metrics database.
119117 */
120- private async initializeClientId ( metricsDatabase : MetricsDatabase ) : Promise < void > {
118+ private async initializeClientId ( ) : Promise < void > {
121119 let needNewClientId = false ;
122- const clientIdData = await metricsDatabase . getMetric ( CLIENT_INFO_STORAGE , this . clientId ) ;
120+ const clientIdData = await Context . metricsDatabase . getMetric ( CLIENT_INFO_STORAGE , this . clientId ) ;
123121 if ( clientIdData ) {
124122 try {
125123 const currentClientId = createMetric ( "uuid" , clientIdData ) ;
@@ -141,11 +139,9 @@ export class CoreMetrics {
141139
142140 /**
143141 * Generates and sets the first_run_date if it is not set.
144- *
145- * @param metricsDatabase The metrics database.
146142 */
147- private async initializeFirstRunDate ( metricsDatabase : MetricsDatabase ) : Promise < void > {
148- const firstRunDate = await metricsDatabase . getMetric (
143+ private async initializeFirstRunDate ( ) : Promise < void > {
144+ const firstRunDate = await Context . metricsDatabase . getMetric (
149145 CLIENT_INFO_STORAGE ,
150146 this . firstRunDate
151147 ) ;
0 commit comments