From 8129a06e3a12c9bca17354598849750498c72d2e Mon Sep 17 00:00:00 2001 From: Jayachand Date: Tue, 25 Jun 2024 15:32:23 +0530 Subject: [PATCH] fix: metadata tags capturing in v0 transformation (#3492) * fix: metadata tags capturing in v0 transformation --- src/util/customTransformer.js | 6 ++++-- src/v0/util/index.js | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/util/customTransformer.js b/src/util/customTransformer.js index 787ce04d63..4f4620fd2d 100644 --- a/src/util/customTransformer.js +++ b/src/util/customTransformer.js @@ -253,8 +253,10 @@ async function runUserTransform( const tags = { identifier: 'v0', errored: transformationError ? true : false, - ...(events.length && events[0].metadata ? getMetadata(events[0].metadata) : {}), - ...(events.length && events[0].metadata ? getTransformationMetadata(events[0].metadata) : {}), + ...(Object.keys(eventsMetadata).length ? getMetadata(Object.values(eventsMetadata)[0]) : {}), + ...(Object.keys(eventsMetadata).length + ? getTransformationMetadata(Object.values(eventsMetadata)[0]) + : {}), }; stats.counter('user_transform_function_input_events', events.length, tags); diff --git a/src/v0/util/index.js b/src/v0/util/index.js index 366c58ce93..12b8d4dd7e 100644 --- a/src/v0/util/index.js +++ b/src/v0/util/index.js @@ -1447,13 +1447,13 @@ const getTrackingPlanMetadata = (metadata) => ({ workspaceId: metadata.workspaceId, }); -const getMetadata = (metadata) => ({ +const getMetadata = (metadata = {}) => ({ sourceType: metadata.sourceType, destinationType: metadata.destinationType, k8_namespace: metadata.namespace, }); -const getTransformationMetadata = (metadata) => ({ +const getTransformationMetadata = (metadata = {}) => ({ transformationId: metadata.transformationId, workspaceId: metadata.workspaceId, });