Skip to content

Commit

Permalink
add function to clean args
Browse files Browse the repository at this point in the history
  • Loading branch information
Natay committed Jan 7, 2025
1 parent 4f55292 commit ad246de
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions packages/cli/src/utils/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,34 @@ 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();

if (shouldSkipAnalytics(analyticsMode)) {
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;
Expand Down

0 comments on commit ad246de

Please sign in to comment.