Skip to content

Commit

Permalink
Report exceptions to telemetry in init Action
Browse files Browse the repository at this point in the history
  • Loading branch information
henrymercer committed Apr 6, 2023
1 parent f32426b commit 555b602
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 19 deletions.
10 changes: 5 additions & 5 deletions lib/init-action.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion lib/init-action.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 12 additions & 13 deletions src/init-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as path from "path";
import * as core from "@actions/core";

import {
ActionStatus,
createStatusReportBase,
getActionsStatus,
getActionVersion,
Expand Down Expand Up @@ -95,20 +94,22 @@ interface InitToolsDownloadFields {
tools_feature_flags_valid?: boolean;
}

async function sendInitStatusReport(
actionStatus: ActionStatus,
async function sendCompletedStatusReport(
startedAt: Date,
config: configUtils.Config | undefined,
toolsDownloadDurationMs: number | undefined,
toolsFeatureFlagsValid: boolean | undefined,
toolsSource: ToolsSource,
toolsVersion: string,
logger: Logger
logger: Logger,
error?: Error
) {
const statusReportBase = await createStatusReportBase(
"init",
actionStatus,
startedAt
getActionsStatus(error),
startedAt,
error?.message,
error?.stack
);

const workflowLanguages = getOptionalInput("languages");
Expand Down Expand Up @@ -366,23 +367,21 @@ async function run() {

core.setOutput("codeql-path", config.codeQLCmd);
} catch (error) {
core.setFailed(String(error));

core.setFailed(error instanceof Error ? error.message : String(error));
console.log(error);
await sendInitStatusReport(
getActionsStatus(error),
await sendCompletedStatusReport(
startedAt,
config,
toolsDownloadDurationMs,
toolsFeatureFlagsValid,
toolsSource,
toolsVersion,
logger
logger,
error instanceof Error ? error : new Error(String(error))
);
return;
}
await sendInitStatusReport(
"success",
await sendCompletedStatusReport(
startedAt,
config,
toolsDownloadDurationMs,
Expand Down

0 comments on commit 555b602

Please sign in to comment.