firebase-tools
Version:
Command-Line Interface for Firebase
55 lines (54 loc) • 3.08 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.command = void 0;
const clc = require("colorette");
const command_1 = require("../command");
const error_1 = require("../error");
const logger_1 = require("../logger");
const projectUtils_1 = require("../projectUtils");
const prompt_1 = require("../prompt");
const requireAuth_1 = require("../requireAuth");
const utils_1 = require("../utils");
const cloudbilling = require("../gcp/cloudbilling");
const profilingManager_1 = require("../crashlytics/profilingManager");
exports.command = new command_1.Command("crashlytics:heapdumps:enable")
.description("enable Crashlytics heap dump collection for an Android app")
.option("--app <appID>", "the app id of your Firebase Android app")
.option("--location <location>", `the location for the Cloud Storage bucket (default: ${profilingManager_1.DEFAULT_BUCKET_LOCATION})`, profilingManager_1.DEFAULT_BUCKET_LOCATION)
.withForce("automatically configure without prompting for confirmation")
.before(requireAuth_1.requireAuth)
.action(async (options) => {
const projectId = (0, projectUtils_1.needProjectId)(options);
const appId = await (0, profilingManager_1.resolveAndroidAppId)(projectId, options);
const location = options.location || profilingManager_1.DEFAULT_BUCKET_LOCATION;
const isBillingEnabled = await cloudbilling.checkBillingEnabled(projectId);
if (!isBillingEnabled) {
throw new error_1.FirebaseError(`Project '${projectId}' is not on the Blaze (pay-as-you-go) plan. Crashlytics heap dump collection requires the Blaze plan for Google Cloud Storage.\n` +
`To upgrade your project, visit: ${(0, utils_1.consoleUrl)(projectId, "/usage/details")}`);
}
const bucketName = (0, profilingManager_1.createBucketName)(appId);
const confirmed = await (0, prompt_1.confirm)({
message: `Enable Crashlytics heap dump collection for ${appId} using Cloud Storage bucket '${bucketName}' in ${location} (with ${profilingManager_1.DEFAULT_FILE_TTL_DAYS}-day file TTL)?`,
default: true,
force: options.force,
nonInteractive: options.nonInteractive,
});
if (!confirmed) {
logger_1.logger.info("Heap dump collection enablement canceled.");
return;
}
await (0, profilingManager_1.enableHeapDumpCollection)(projectId, appId, location);
logger_1.logger.info("");
logger_1.logger.info(clc.bold("Heap Dump Collection Details:"));
logger_1.logger.info(` App ID: ${clc.cyan(appId)}`);
logger_1.logger.info(` GCS Bucket: ${clc.cyan(bucketName)}`);
logger_1.logger.info(` File TTL: ${clc.cyan(`${profilingManager_1.DEFAULT_FILE_TTL_DAYS} days`)}`);
logger_1.logger.info(` Status: ${clc.green("Enabled")}`);
logger_1.logger.info("");
logger_1.logger.info(`View collected heap dumps in the Firebase Console: ${(0, utils_1.consoleUrl)(projectId, `/crashlytics/app/${appId}`)}`);
return {
appId,
bucketName,
heapDumpCollectionEnabled: true,
};
});