UNPKG

@nomiclabs/buidler

Version:

Buidler is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.

69 lines 2.64 kB
"use strict"; var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; result["default"] = mod; return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const Sentry = __importStar(require("@sentry/node")); const debug_1 = __importDefault(require("debug")); const anonymizer_1 = require("./anonymizer"); const reporter_1 = require("./reporter"); const log = debug_1.default("buidler:sentry:subprocess"); async function main() { const verbose = process.env.BUIDLER_SENTRY_VERBOSE === "true"; if (verbose) { debug_1.default.enable("buidler*"); } log("starting subprocess"); try { Sentry.init({ dsn: reporter_1.SENTRY_DSN, }); } catch (error) { log("Couldn't initialize Sentry: %O", error); process.exit(1); } const serializedEvent = process.env.BUIDLER_SENTRY_EVENT; if (serializedEvent === undefined) { log("BUIDLER_SENTRY_EVENT env variable is not set, exiting"); Sentry.captureMessage(`There was an error parsing an event: BUIDLER_SENTRY_EVENT env variable is not set`); return; } let event; try { event = JSON.parse(serializedEvent); } catch (error) { log("BUIDLER_SENTRY_EVENT env variable doesn't have a valid JSON, exiting: %o", serializedEvent); Sentry.captureMessage(`There was an error parsing an event: BUIDLER_SENTRY_EVENT env variable doesn't have a valid JSON`); return; } try { const configPath = process.env.BUIDLER_SENTRY_CONFIG_PATH; const anonymizer = new anonymizer_1.Anonymizer(configPath); const anonymizedEvent = anonymizer.anonymize(event); if (anonymizedEvent.isRight()) { if (anonymizer.raisedByBuidler(anonymizedEvent.value)) { Sentry.captureEvent(anonymizedEvent.value); } } else { Sentry.captureMessage(`There was an error anonymizing an event: ${anonymizedEvent.value}`); } } catch (error) { log("Couldn't capture event %o, got error %O", event, error); Sentry.captureMessage(`There was an error capturing an event: ${error.message}`); return; } log("sentry event was sent"); } main().catch(console.error); //# sourceMappingURL=subprocess.js.map