From f46bd26d10c5ccb8b36afa37580cacb9c6f9ee67 Mon Sep 17 00:00:00 2001 From: tomwalder Date: Mon, 5 Jan 2026 18:40:08 +0000 Subject: [PATCH] Clean up UDF example, remove unused JSON Parsing, update comments --- udfs/insert_attributes.js | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/udfs/insert_attributes.js b/udfs/insert_attributes.js index 061df99c..678670d5 100644 --- a/udfs/insert_attributes.js +++ b/udfs/insert_attributes.js @@ -1,23 +1,18 @@ /* - * This UDF is used to insert three new attributes into the message metadata. + * This UDF is used to insert three new attributes into the message. * * @param {Object} message - The message to insert attributes into. - * @param {Object} metadata - The metadata to modify. - * @returns {Object} The message with new attributes in metadata. + * @param {Object} metadata - The metadata of the message. + * @returns {Object} The message with new attributes. */ function insert_attributes(message, metadata) { - // Parse the message - const data = JSON.parse(message.data); const attributes = message.attributes; - // Add new attributes to insert + // Add new attributes attributes["key1"] = 'value1'; attributes["key2"] = 'value2'; - attributes["key3"] = 'value3'; + attributes["key3"] = 'value3'; - // Update the message with modified data - message.data = JSON.stringify(data); - return message; }