Skip to content

Commit

Permalink
PDE-5641 only select keys
Browse files Browse the repository at this point in the history
  • Loading branch information
Natay committed Jan 8, 2025
1 parent 0856a45 commit 1731bb4
Showing 1 changed file with 3 additions and 26 deletions.
29 changes: 3 additions & 26 deletions packages/cli/src/utils/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,38 +21,15 @@ const shouldSkipAnalytics = (mode) =>
process.env.DISABLE_ZAPIER_ANALYTICS ||
mode === ANALYTICS_MODES.disabled;

const cleanValues = (args) => {
// List of arguments we don't want to record.
const doNotRecord = [
'key-value pairs...',
'keys...',
'path',
'email',
'message',
'user',
'account',
'redirect-uri',
'inputData',
];
return Object.keys(args)
.filter((key) => !doNotRecord.includes(key))
.reduce((obj, key) => {
obj[key] = args[key];
return obj;
}, {});
};

const recordAnalytics = async (command, isValidCommand, args, flags) => {
const analyticsMode = await currentAnalyticsMode();

if (shouldSkipAnalytics(analyticsMode)) {
debug('skipping analytics');
return;
}
const cleanedArgs = cleanValues(args);
const cleanedFlags = cleanValues(flags);
const argKeys = Object.keys(args);

const flagKeys = Object.keys(flags);
const shouldRecordAnonymously = analyticsMode === ANALYTICS_MODES.anonymous;

const integrationIDKey = argKeys.find(
Expand All @@ -74,10 +51,10 @@ const recordAnalytics = async (command, isValidCommand, args, flags) => {
numArgs: argKeys.length,
appId: linkedAppId,
flags: {
...cleanedFlags,
...flagKeys,
...(command === 'help' ? { helpCommand: argKeys[0] } : {}), // include the beginning of args so we know what they want help on
},
args: shouldRecordAnonymously ? undefined : cleanedArgs,
argsKeys: argKeys,
cliVersion: pkg.version,
os: shouldRecordAnonymously ? undefined : process.platform,
};
Expand Down

0 comments on commit 1731bb4

Please sign in to comment.