UNPKG

firebase-tools

Version:
42 lines (41 loc) 1.46 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getIssueDetails = void 0; const apiv2_1 = require("../apiv2"); const logger_1 = require("../logger"); const error_1 = require("../error"); const api_1 = require("../api"); const TIMEOUT = 10000; const apiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.crashlyticsApiOrigin)(), apiVersion: "v1alpha", }); async function getIssueDetails(appId, issueId) { try { const requestProjectNumber = parseProjectNumber(appId); if (requestProjectNumber === undefined) { throw new error_1.FirebaseError("Unable to get the projectId from the AppId."); } const response = await apiClient.request({ method: "GET", headers: { "Content-Type": "application/json", }, path: `/projects/${requestProjectNumber}/apps/${appId}/issues/${issueId}`, timeout: TIMEOUT, }); return response.body; } catch (err) { logger_1.logger.debug(err.message); throw new error_1.FirebaseError(`Failed to fetch the issue details for the Firebase AppId ${appId}, IssueId ${issueId}. Error: ${err}.`, { original: err }); } } exports.getIssueDetails = getIssueDetails; function parseProjectNumber(appId) { const appIdParts = appId.split(":"); if (appIdParts.length > 1) { return appIdParts[1]; } return undefined; }