* feat(telemetry): Add telemetry via `@sentry/node * Replace DSN with `sentry-github-action` dsn * Add step tracing * Remove `debug` and hooks from init * Add session tracking * Propagate sentry trace to CLI * Add `disable_telemetry` flag to action * Remove cli singleton in favor of creating a new instance for proper trace propagation * Lift mocking env variables out of cli
34 lines
824 B
TypeScript
34 lines
824 B
TypeScript
import {getTraceData} from '@sentry/node';
|
|
import SentryCli, {SentryCliReleases} from '@sentry/cli';
|
|
// @ts-ignore
|
|
import {version} from '../package.json';
|
|
|
|
/**
|
|
* CLI Singleton
|
|
*
|
|
* When the `MOCK` environment variable is set, stub out network calls.
|
|
*/
|
|
export const getCLI = (): SentryCliReleases => {
|
|
// Set the User-Agent string.
|
|
process.env['SENTRY_PIPELINE'] = `github-action-release/${version}`;
|
|
|
|
const cli = new SentryCli(null, {
|
|
headers: {
|
|
// Propagate sentry trace if we have one
|
|
...getTraceData(),
|
|
},
|
|
}).releases;
|
|
|
|
if (process.env['MOCK']) {
|
|
cli.execute = async (
|
|
args: string[],
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
live: boolean
|
|
): Promise<string> => {
|
|
return Promise.resolve(args.join(' '));
|
|
};
|
|
}
|
|
|
|
return cli;
|
|
};
|