Skip to content

Commit 393c074

Browse files
Copilothenrymercer
andcommitted
Refactor existing telemetry diagnostics to use makeTelemetryDiagnostic
Refactored bundle-download-telemetry and zstd-availability diagnostics in init-action.ts to use the new makeTelemetryDiagnostic helper function. Also added guard for empty languages array in logGitVersionTelemetry. Co-authored-by: henrymercer <[email protected]>
1 parent c3dc529 commit 393c074

File tree

3 files changed

+15
-38
lines changed

3 files changed

+15
-38
lines changed

lib/init-action.js

Lines changed: 7 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/git-utils.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ export async function logGitVersionTelemetry(
8888
logger: Logger,
8989
): Promise<void> {
9090
const version = await getGitVersion(logger);
91-
if (version !== undefined) {
91+
if (version !== undefined && config.languages.length > 0) {
9292
addDiagnostic(
9393
config,
94+
// Arbitrarily choose the first language. We could also choose all languages, but that
95+
// increases the risk of misinterpreting the data.
9496
config.languages[0],
9597
makeTelemetryDiagnostic(
9698
"codeql-action/git-version-telemetry",

src/init-action.ts

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import {
3333
flushDiagnostics,
3434
logUnwrittenDiagnostics,
3535
makeDiagnostic,
36+
makeTelemetryDiagnostic,
3637
} from "./diagnostics";
3738
import { EnvVar } from "./environment";
3839
import { Feature, Features } from "./feature-flags";
@@ -419,17 +420,10 @@ async function run() {
419420
// Arbitrarily choose the first language. We could also choose all languages, but that
420421
// increases the risk of misinterpreting the data.
421422
config.languages[0],
422-
makeDiagnostic(
423+
makeTelemetryDiagnostic(
423424
"codeql-action/bundle-download-telemetry",
424425
"CodeQL bundle download telemetry",
425-
{
426-
attributes: toolsDownloadStatusReport,
427-
visibility: {
428-
cliSummaryTable: false,
429-
statusPage: false,
430-
telemetry: true,
431-
},
432-
},
426+
toolsDownloadStatusReport,
433427
),
434428
);
435429
}
@@ -789,17 +783,10 @@ async function recordZstdAvailability(
789783
// Arbitrarily choose the first language. We could also choose all languages, but that
790784
// increases the risk of misinterpreting the data.
791785
config.languages[0],
792-
makeDiagnostic(
786+
makeTelemetryDiagnostic(
793787
"codeql-action/zstd-availability",
794788
"Zstandard availability",
795-
{
796-
attributes: zstdAvailability,
797-
visibility: {
798-
cliSummaryTable: false,
799-
statusPage: false,
800-
telemetry: true,
801-
},
802-
},
789+
zstdAvailability,
803790
),
804791
);
805792
}

0 commit comments

Comments
 (0)