From 09c0660adbd2a0a2a3d6092a28fcec574ad110a7 Mon Sep 17 00:00:00 2001 From: Shivam Mishra Date: Thu, 13 Mar 2025 14:32:21 +0530 Subject: [PATCH] feat: use compact json --- .../store/modules/conversations/index.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/javascript/dashboard/store/modules/conversations/index.js b/app/javascript/dashboard/store/modules/conversations/index.js index 924717e3e..9a2fc4501 100644 --- a/app/javascript/dashboard/store/modules/conversations/index.js +++ b/app/javascript/dashboard/store/modules/conversations/index.js @@ -212,6 +212,21 @@ export const mutations = { const { allConversations } = _state; const index = allConversations.findIndex(c => c.id === conversation.id); + const makeCompactJson = obj => { + // get rid of messages + const { messages, ...remaining } = obj; + const strinRep = JSON.stringify(remaining); + + // replace active storage URLs with a placeholder + const activeStorageUrlRegex = + /https?:\/\/[^/]+\/rails\/active_storage[^\s]+/g; + const replacedStr = strinRep.replace( + activeStorageUrlRegex, + '[ACTIVE_STORAGE_URL]' + ); + return replacedStr; + }; + if (index > -1) { const selectedConversation = allConversations[index]; @@ -231,7 +246,7 @@ export const mutations = { if (window.newrelic) { window.newrelic.log( - `conversation update mismatch for ${conversation.id} with incoming ${JSON.stringify(conversation, null, 2)} and stored ${JSON.stringify(selectedConversation, null, 2)}`, + `conversation update mismatch for ${conversation.id} with incoming ${makeCompactJson(conversation)} and stored ${makeCompactJson(selectedConversation)}`, { level: 'DEBUG' } ); } @@ -255,7 +270,7 @@ export const mutations = { if (window.newrelic) { window.newrelic.log( - `conversation update overlap for ${conversation.id} with incoming ${JSON.stringify(conversation, null, 2)} and stored ${JSON.stringify(selectedConversation, null, 2)}`, + `conversation update overlap for ${conversation.id} with incoming ${makeCompactJson(conversation)} and stored ${makeCompactJson(selectedConversation)}`, { level: 'DEBUG' } ); }