Skip to content

Commit 6aa7a7d

Browse files
committed
feat: pass config to sendTelemetry parameter
1 parent 63ee208 commit 6aa7a7d

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

packages/cli/src/utils/telemetry.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { version } from './package.js';
66
import { getReuniteUrl } from '../reunite/api/index.js';
77

88
import type { ExitCode } from './miscellaneous.js';
9-
import type { ArazzoDefinition } from '@redocly/openapi-core';
9+
import type { ArazzoDefinition, Config } from '@redocly/openapi-core';
1010
import type { ExtendedSecurity } from 'respect-core/src/types.js';
1111
import type { Arguments } from 'yargs';
1212
import type { CommandOptions } from '../types.js';
@@ -34,19 +34,17 @@ export type Analytics = {
3434
};
3535

3636
export async function sendTelemetry({
37-
residency,
37+
config,
3838
argv,
3939
exit_code,
40-
has_config,
4140
spec_version,
4241
spec_keyword,
4342
spec_full_version,
4443
respect_x_security_auth_types,
4544
}: {
46-
residency: string | undefined;
45+
config: Config | undefined;
4746
argv: Arguments | undefined;
4847
exit_code: ExitCode;
49-
has_config: boolean | undefined;
5048
spec_version: string | undefined;
5149
spec_keyword: string | undefined;
5250
spec_full_version: string | undefined;
@@ -62,6 +60,8 @@ export async function sendTelemetry({
6260
...args
6361
} = argv;
6462
const event_time = new Date().toISOString();
63+
const residency = (argv.residency as string) || config?.rawConfig?.residency;
64+
const has_config = !!config?.rawConfig;
6565
const { RedoclyOAuthClient } = await import('../auth/oauth-client.js');
6666
const oauthClient = new RedoclyOAuthClient('redocly-cli', version);
6767
const reuniteUrl = getReuniteUrl(residency);

packages/cli/src/wrapper.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ export function commandWrapper<T extends CommandOptions>(
2727
) {
2828
return async (argv: Arguments<T>) => {
2929
let code: ExitCode = 2;
30-
let hasConfig;
3130
let telemetry;
3231
let specVersion: string | undefined;
3332
let specKeyword: string | undefined;
@@ -63,7 +62,6 @@ export function commandWrapper<T extends CommandOptions>(
6362
}
6463
config = await loadConfigAndHandleErrors(argv as Exact<T>, version);
6564
telemetry = config.resolvedConfig.telemetry;
66-
hasConfig = !!config.rawConfig;
6765
code = 1;
6866
if (typeof commandHandler === 'function') {
6967
await commandHandler({ argv, config, version, collectSpecData });
@@ -83,12 +81,10 @@ export function commandWrapper<T extends CommandOptions>(
8381
}
8482
} finally {
8583
if (process.env.REDOCLY_TELEMETRY !== 'off' && telemetry !== 'off') {
86-
const residency = (argv.residency as string) || config?.rawConfig?.residency;
8784
await sendTelemetry({
88-
residency,
85+
config,
8986
argv,
9087
exit_code: code,
91-
has_config: hasConfig,
9288
spec_version: specVersion,
9389
spec_keyword: specKeyword,
9490
spec_full_version: specFullVersion,

0 commit comments

Comments
 (0)