Skip to content

Commit 6a428eb

Browse files
authored
FFM-10963 Metrics fix: cast target attribute values to string (#106)
1 parent 34bbd5f commit 6a428eb

File tree

5 files changed

+32
-113
lines changed

5 files changed

+32
-113
lines changed

Diff for: examples/getting_started/package-lock.json

-92
This file was deleted.

Diff for: package-lock.json

+17-17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@harnessio/ff-nodejs-server-sdk",
3-
"version": "1.6.0",
3+
"version": "1.6.1",
44
"description": "Feature flags SDK for NodeJS environments",
55
"main": "dist/cjs/index.js",
66
"module": "dist/esm/index.mjs",
@@ -60,7 +60,7 @@
6060
"url": "https://github.com/harness/ff-nodejs-server-sdk"
6161
},
6262
"dependencies": {
63-
"axios": "^1.6.4",
63+
"axios": "^1.6.8",
6464
"axios-retry": "^3.9.1",
6565
"jwt-decode": "^3.1.2",
6666
"keyv": "^4.5.4",

Diff for: src/metrics.ts

+12-1
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,16 @@ export const MetricsProcessor = (
113113
let targetAttributes: KeyValue[] = [];
114114
if (event.target.attributes) {
115115
targetAttributes = Object.entries(event.target.attributes).map(
116-
([key, value]) => ({ key, value: value as string }),
116+
([key, value]) => {
117+
const stringValue =
118+
value === null || value === undefined
119+
? ''
120+
: valueToString(value);
121+
return { key, value: stringValue };
122+
},
117123
);
118124
}
125+
119126
let targetName = event.target.identifier;
120127
if (event.target.name) {
121128
targetName = event.target.name;
@@ -218,6 +225,10 @@ export const MetricsProcessor = (
218225
eventBus.emit(MetricEvent.READY);
219226
};
220227

228+
const valueToString = (value: any): string => {
229+
return typeof value === 'object' && !Array.isArray(value) ? JSON.stringify(value) : String(value)
230+
};
231+
221232
const close = (): void => {
222233
log.info('Closing MetricsProcessor');
223234
clearInterval(syncInterval);

Diff for: src/version.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export const VERSION = '1.6.0';
1+
export const VERSION = '1.6.1';

0 commit comments

Comments
 (0)