UNPKG

firebase-tools

Version:
49 lines (48 loc) • 2.44 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.command = void 0; const js_yaml_1 = require("js-yaml"); const command_1 = require("../command"); const commandUtils_1 = require("../crashlytics/commandUtils"); const events_1 = require("../crashlytics/events"); const error_1 = require("../error"); const logger_1 = require("../logger"); const requireAuth_1 = require("../requireAuth"); exports.command = new command_1.Command("crashlytics:events:get <eventIds...>") .description("get one or more Crashlytics events by event ID or resource name") .option("--app <appId>", "the Firebase App ID") .option("--max-frames <number>", `maximum stack frames per thread or exception (default: ${events_1.DEFAULT_MAX_FRAMES}, ignored when --full is set)`) .option("--full", "include all threads, stack frames, logs, and breadcrumbs without truncation") .option("-o, --output <path>", "write raw JSON output to a file") .withForce("overwrite output file without prompting") .before(requireAuth_1.requireAuth) .action(async (eventIds, options) => { const appId = (0, commandUtils_1.requireAppId)(options); const rawIds = Array.isArray(eventIds) ? eventIds.map((id) => String(id).trim()).filter(Boolean) : []; if (rawIds.length === 0) { throw new error_1.FirebaseError("Must specify at least one '<eventId>'.", { exit: 1 }); } if (rawIds.length > 100) { throw new error_1.FirebaseError("Cannot request more than 100 events in a single call.", { exit: 1, }); } const maxFrames = (0, commandUtils_1.parsePositiveIntOption)(options.maxFrames, "--max-frames", { defaultValue: events_1.DEFAULT_MAX_FRAMES, }); const resourceNames = rawIds.map((id) => (0, events_1.normalizeEventResourceName)(appId, id)); const response = await (0, events_1.batchGetEvents)(appId, resourceNames); if (!(await (0, commandUtils_1.writeOutputFileIfRequested)(response, options))) { const events = response.events || []; if (events.length === 0) { logger_1.logger.info("No matching events found."); } else { const formatted = events.map((e) => (0, events_1.toText)(e, { maxFrames, full: Boolean(options.full) })); logger_1.logger.info((0, js_yaml_1.dump)(formatted, events_1.EVENT_DUMP_OPTIONS)); } } return response; });