From ad246de64c10dc86d23da50cd514e6df8a6a2a71 Mon Sep 17 00:00:00 2001 From: Natay Aberra Date: Tue, 7 Jan 2025 13:51:09 -0500 Subject: [PATCH] add function to clean args --- packages/cli/src/utils/analytics.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/packages/cli/src/utils/analytics.js b/packages/cli/src/utils/analytics.js index 79f0c50d5..d966656b8 100644 --- a/packages/cli/src/utils/analytics.js +++ b/packages/cli/src/utils/analytics.js @@ -21,6 +21,24 @@ const shouldSkipAnalytics = (mode) => process.env.DISABLE_ZAPIER_ANALYTICS || mode === ANALYTICS_MODES.disabled; +const cleanArgs = (args) => { + // Do not record "arguments" for following commands + const BLACKLISTED_ARGS = [ + 'key-value pairs...', + 'keys...', + 'path', + 'email', + 'message', + ]; + const cleanedArgs = Object.keys(args) + .filter((key) => !BLACKLISTED_ARGS.includes(key)) + .reduce((obj, key) => { + obj[key] = args[key]; + return obj; + }, {}); + return cleanedArgs; +}; + const recordAnalytics = async (command, isValidCommand, args, flags) => { const analyticsMode = await currentAnalyticsMode(); @@ -28,6 +46,9 @@ const recordAnalytics = async (command, isValidCommand, args, flags) => { debug('skipping analytics'); return; } + debug('args...', args); + const cleanedArgs = cleanArgs(args); + debug('cleaned args...', cleanedArgs); const argKeys = Object.keys(args); const shouldRecordAnonymously = analyticsMode === ANALYTICS_MODES.anonymous;