@sentry/wizard
Version:
Sentry wizard helping you to configure your project
115 lines • 4.46 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.updateProgress = exports.traceStep = exports.withTelemetry = void 0;
const Sentry = __importStar(require("@sentry/node"));
const version_1 = require("./version");
async function withTelemetry(options, callback) {
const client = initSentry(options.enabled, options.integration);
Sentry.startSession();
Sentry.captureSession();
// Set tag for passed CLI args
Sentry.setTag('args.project', !!options.wizardOptions.projectSlug);
Sentry.setTag('args.org', !!options.wizardOptions.orgSlug);
Sentry.setTag('args.saas', !!options.wizardOptions.saas);
try {
return await Sentry.startSpan({
name: 'sentry-wizard-execution',
op: 'wizard.flow',
}, async () => {
updateProgress('start');
const res = await Sentry.withIsolationScope(callback);
updateProgress('finished');
return res;
});
}
catch (e) {
Sentry.captureException('Error during wizard execution.');
const currentSession = Sentry.getCurrentScope().getSession();
if (currentSession) {
currentSession.status = 'crashed';
}
throw e;
}
finally {
Sentry.endSession();
await client?.flush(3000).then(null, () => {
// If telemetry flushing fails we generally don't care
});
await Sentry.flush(3000).then(null, () => {
// If telemetry flushing fails we generally don't care
});
}
}
exports.withTelemetry = withTelemetry;
function initSentry(enabled, integration) {
const client = Sentry.init({
dsn: 'https://8871d3ff64814ed8960c96d1fcc98a27@o1.ingest.sentry.io/4505425820712960',
enabled: enabled,
defaultIntegrations: false,
integrations: [Sentry.httpIntegration()],
environment: `production-${integration}`,
tracesSampleRate: 1,
sampleRate: 1,
release: version_1.WIZARD_VERSION,
tracePropagationTargets: [/^https:\/\/sentry.io\//],
beforeSendTransaction: (event) => {
delete event.server_name; // Server name might contain PII
return event;
},
beforeSend: (event) => {
event.exception?.values?.forEach((exception) => {
delete exception.stacktrace;
});
delete event.server_name; // Server name might contain PII
return event;
},
});
Sentry.setTag('integration', integration);
Sentry.setTag('node', process.version);
Sentry.setTag('platform', process.platform);
try {
// The `require` call here is fine because the binary node versions
// support `require` and we try/catch the call anyway for any other
// version of node.
// eslint-disable-next-line @typescript-eslint/no-var-requires
const sea = require('node:sea');
Sentry.setTag('is_binary', sea.isSea());
}
catch {
Sentry.setTag('is_binary', false);
}
return client;
}
function traceStep(step, callback) {
updateProgress(step);
return Sentry.startSpan({ name: step, op: 'wizard.step' }, (span) => callback(span));
}
exports.traceStep = traceStep;
function updateProgress(step) {
Sentry.setTag('progress', step);
}
exports.updateProgress = updateProgress;
//# sourceMappingURL=telemetry.js.map