@@ -46,9 +46,8 @@ export class MetricsSender {
4646 _setup ( ) {
4747 /* istanbul ignore next */
4848 if ( ! this . _CW && ( isRemote ( ) || MetricsSender . _override ) ) {
49- const {
50- CloudWatch : Cloudwatch
51- } = require ( '@aws-sdk/client-cloudwatch' ) ;
49+ // eslint-disable-next-line @typescript-eslint/no-var-requires
50+ const { CloudWatch : Cloudwatch } = require ( '@aws-sdk/client-cloudwatch' )
5251 this . _CW = new Cloudwatch ( {
5352 // The AWS_REGION variable is defined by the Lambda
5453 // environment.
@@ -81,18 +80,20 @@ export class MetricsSender {
8180 }
8281
8382 // v3 supports promises, so we can use that instead of a callback.
84- return cw . putMetricData ( {
85- MetricData : metrics ,
86- Namespace : 'ssr'
87- } ) . catch ( ( err ) => {
88- logger . warn ( `Metrics: error sending data: ${ err } ` , {
89- namespace : 'metrics-sender._putMetricData' ,
90- additionalProperties : {
91- metrics,
92- error : err
93- }
83+ return cw
84+ . putMetricData ( {
85+ MetricData : metrics ,
86+ Namespace : 'ssr'
87+ } )
88+ . catch ( ( err ) => {
89+ logger . warn ( `Metrics: error sending data: ${ err } ` , {
90+ namespace : 'metrics-sender._putMetricData' ,
91+ additionalProperties : {
92+ metrics,
93+ error : err
94+ }
95+ } )
9496 } )
95- } )
9697 }
9798
9899 /**
@@ -164,12 +165,12 @@ export class MetricsSender {
164165 MetricName : metric . name ,
165166 Value : metric . value || 0 ,
166167 // This value must be a string
167- Timestamp : ( metric . timestamp instanceof Date
168- ? metric . timestamp
169- : ( typeof metric . timestamp === 'number'
168+ Timestamp :
169+ metric . timestamp instanceof Date
170+ ? metric . timestamp
171+ : typeof metric . timestamp === 'number'
170172 ? new Date ( metric . timestamp )
171- : now )
172- ) ,
173+ : now ,
173174 Unit : metric . unit || 'Count'
174175 }
175176
0 commit comments