firebase-tools
Version:
Command-Line Interface for Firebase
46 lines (45 loc) • 1.67 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.listTopIssues = 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 listTopIssues(projectId, appId, issueType, issueCount) {
try {
const queryParams = new URLSearchParams();
queryParams.set("page_size", `${issueCount}`);
queryParams.set("filter.issue.error_types", `${issueType}`);
const requestProjectId = parseProjectId(appId);
if (requestProjectId === 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/${requestProjectId}/apps/${appId}/reports/topIssues`,
queryParams: queryParams,
timeout: TIMEOUT,
});
return response.body;
}
catch (err) {
logger_1.logger.debug(err.message);
throw new error_1.FirebaseError(`Failed to fetch the top issues for the Firebase Project ${projectId}, AppId ${appId}. Error: ${err}.`, { original: err });
}
}
exports.listTopIssues = listTopIssues;
function parseProjectId(appId) {
const appIdParts = appId.split(":");
if (appIdParts.length > 1) {
return appIdParts[1];
}
return undefined;
}
;