Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.

Commit d759252

Browse files
author
azlam-abdulsalam
committed
fix(report): 🐛 add error handling when tags are not provided
1 parent 237b54b commit d759252

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lerna.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"packages": [
33
"packages/*"
44
],
5+
"useWorkspaces": true,
56
"version": "independent",
67
"command": {
78
"publish": {

packages/sfpowerscripts-cli/src/commands/metrics/report.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,15 @@ export default class Report extends SfpowerscriptsCommand {
7272
switch (this.flags.type) {
7373
case 'gauge':
7474
SFPLogger.log(COLOR_KEY_MESSAGE(`Publishing Gauge Metric ${this.flags.metric} with value ${this.flags.value}`));
75-
SFPStatsSender.logGauge(this.flags.metric, this.flags.value, JSON.parse(this.flags.tags));
75+
SFPStatsSender.logGauge(this.flags.metric, this.flags.value, this.flags.tags?JSON.parse(this.flags.tags):undefined);
7676
break;
7777
case 'counter':
7878
SFPLogger.log(COLOR_KEY_MESSAGE(`Publishing Count Metric ${this.flags.metric} with value ${this.flags.value}`));
79-
SFPStatsSender.logCount(this.flags.metric, JSON.parse(this.flags.tags));
79+
SFPStatsSender.logCount(this.flags.metric, this.flags.tags?JSON.parse(this.flags.tags):undefined);
8080
break;
8181
case 'timer':
8282
SFPLogger.log(COLOR_KEY_MESSAGE(`Publishing Elapsed Metric ${this.flags.metric} with value ${this.flags.value}`));
83-
SFPStatsSender.logElapsedTime(this.flags.metric, Number.parseInt(this.flags.value), JSON.parse(this.flags.tags));
83+
SFPStatsSender.logElapsedTime(this.flags.metric, Number.parseInt(this.flags.value), this.flags.tags?JSON.parse(this.flags.tags):undefined);
8484
break;
8585
default:
8686
throw new Error('Invalid Metric Type');

0 commit comments

Comments
 (0)