@@ -8,7 +8,7 @@ import { respondWithinMs } from './network-check.js';
88import { tmpdir } from 'node:os' ;
99import { join } from 'node:path' ;
1010import { existsSync , writeFileSync , readFileSync } from 'node:fs' ;
11- import { USER_ID_CACHE_FILE } from './constants.js' ;
11+ import { ANONYMOUS_ID_CACHE_FILE } from './constants.js' ;
1212import { ulid } from 'ulid' ;
1313
1414import type { ExitCode } from './miscellaneous.js' ;
@@ -58,10 +58,10 @@ export async function sendTelemetry({
5858 const oauthClient = new RedoclyOAuthClient ( ) ;
5959 const reuniteUrl = getReuniteUrl ( config , args . residency ) ;
6060 const logged_in = await oauthClient . isAuthorized ( reuniteUrl ) ;
61- let anonymous_id = getCachedUserId ( ) ;
61+ let anonymous_id = getCachedAnonymousId ( ) ;
6262 if ( ! anonymous_id ) {
6363 anonymous_id = `ann_${ ulid ( ) } ` ;
64- cacheUserId ( anonymous_id ) ;
64+ cacheAnonymousId ( anonymous_id ) ;
6565 }
6666
6767 const eventData : EventPayload < EventType > = {
@@ -201,7 +201,7 @@ function cleanObject(obj: unknown, keysToClean: string[]): unknown {
201201 for ( const [ key , value ] of Object . entries ( obj ) ) {
202202 if ( keysToClean . includes ( key ) ) {
203203 cleaned [ key ] = SECRET_REPLACEMENT ;
204- } else if ( typeof value === 'object' && value !== null ) {
204+ } else if ( isPlainObject ( value ) ) {
205205 cleaned [ key ] = cleanObject ( value , keysToClean ) ;
206206 } else {
207207 cleaned [ key ] = value ;
@@ -270,34 +270,34 @@ export function cleanArgs(parsedArgs: CommandArgv, rawArgv: string[]) {
270270 return { arguments : JSON . stringify ( commandArguments ) , raw_input : commandInput } ;
271271}
272272
273- export const cacheUserId = ( userId : string ) : void => {
273+ export const cacheAnonymousId = ( anonymousId : string ) : void => {
274274 const isCI = ! ! process . env . CI ;
275- if ( isCI || ! userId ) {
275+ if ( isCI || ! anonymousId ) {
276276 return ;
277277 }
278278
279279 try {
280- const userIdFile = join ( tmpdir ( ) , USER_ID_CACHE_FILE ) ;
281- writeFileSync ( userIdFile , userId ) ;
280+ const anonymousIdFile = join ( tmpdir ( ) , ANONYMOUS_ID_CACHE_FILE ) ;
281+ writeFileSync ( anonymousIdFile , anonymousId ) ;
282282 } catch ( e ) {
283283 // Silently fail - telemetry should not break the CLI
284284 }
285285} ;
286286
287- export const getCachedUserId = ( ) : string | undefined => {
287+ export const getCachedAnonymousId = ( ) : string | undefined => {
288288 const isCI = ! ! process . env . CI ;
289289 if ( isCI ) {
290290 return ;
291291 }
292292
293293 try {
294- const userIdFile = join ( tmpdir ( ) , USER_ID_CACHE_FILE ) ;
294+ const anonymousIdFile = join ( tmpdir ( ) , ANONYMOUS_ID_CACHE_FILE ) ;
295295
296- if ( ! existsSync ( userIdFile ) ) {
296+ if ( ! existsSync ( anonymousIdFile ) ) {
297297 return ;
298298 }
299299
300- return readFileSync ( userIdFile ) . toString ( ) . trim ( ) ;
300+ return readFileSync ( anonymousIdFile ) . toString ( ) . trim ( ) ;
301301 } catch ( e ) {
302302 return ;
303303 }
0 commit comments