firebase-tools 15.34.2 → 15.36.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/api.js +2 -4
- package/lib/appcheck/debugTokens.js +293 -0
- package/lib/appcheck/localConfig.js +191 -0
- package/lib/appdistribution/options-parser-util.js +1 -1
- package/lib/apphosting/constants.js +1 -4
- package/lib/apphosting/githubConnections.js +1 -1
- package/lib/apphosting/utils.js +0 -26
- package/lib/auth.js +8 -2
- package/lib/commands/appcheck-debugtokens-create.js +60 -35
- package/lib/commands/appcheck-debugtokens-delete.js +21 -7
- package/lib/commands/appcheck-debugtokens-list.js +37 -8
- package/lib/commands/appcheck-debugtokens-prune.js +59 -0
- package/lib/commands/crashlytics-heapdumps-status.js +1 -1
- package/lib/commands/{crashlytics-onboard-web.js → crashlytics-setup.js} +5 -5
- package/lib/commands/crashlytics-sourcemap-upload.js +4 -0
- package/lib/commands/deploy.js +1 -3
- package/lib/commands/emulators-start.js +2 -2
- package/lib/commands/hosting-channel-create.js +1 -3
- package/lib/commands/hosting-channel-delete.js +1 -3
- package/lib/commands/hosting-channel-deploy.js +1 -3
- package/lib/commands/hosting-channel-list.js +1 -3
- package/lib/commands/hosting-channel-open.js +1 -3
- package/lib/commands/hosting-clone.js +3 -5
- package/lib/commands/hosting-disable.js +2 -2
- package/lib/commands/hosting-sites-create.js +1 -3
- package/lib/commands/hosting-sites-delete.js +1 -3
- package/lib/commands/hosting-sites-get.js +1 -3
- package/lib/commands/hosting-sites-list.js +1 -3
- package/lib/commands/index.js +4 -2
- package/lib/commands/run-services-get.js +19 -0
- package/lib/commands/run-services-list.js +11 -0
- package/lib/crashlytics/alerts.js +1 -0
- package/lib/crashlytics/events.js +122 -1
- package/lib/crashlytics/filters.js +12 -6
- package/lib/crashlytics/firebasetelemetry.js +5 -3
- package/lib/crashlytics/onboarding.js +8 -7
- package/lib/crashlytics/profilingManager.js +14 -34
- package/lib/crashlytics/reports.js +46 -17
- package/lib/crashlytics/sourcemap.js +19 -5
- package/lib/crashlytics/utils.js +14 -0
- package/lib/database/import.js +5 -4
- package/lib/dataconnect/dataplaneClient.js +0 -10
- package/lib/dataconnect/names.js +3 -3
- package/lib/dataconnect/schemaMigration.js +1 -1
- package/lib/deploy/apphosting/deploy.js +20 -41
- package/lib/deploy/apphosting/localBuild.js +49 -0
- package/lib/deploy/apphosting/prepare.js +12 -25
- package/lib/deploy/apphosting/release.js +1 -1
- package/lib/deploy/apphosting/util.js +27 -4
- package/lib/deploy/functions/backend.js +0 -10
- package/lib/deploy/functions/cel.js +1 -1
- package/lib/deploy/functions/containerCleaner.js +1 -142
- package/lib/deploy/functions/functionsDeployHelper.js +0 -4
- package/lib/deploy/functions/release/reporter.js +0 -26
- package/lib/deploy/functions/runtimes/discovery/index.js +4 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +1 -1
- package/lib/deploy/functions/services/index.js +13 -11
- package/lib/deploy/functions/validate.js +1 -1
- package/lib/deploy/hosting/prepare.js +1 -3
- package/lib/deploy/lifecycleHooks.js +1 -1
- package/lib/deploy/run/deploy.js +26 -43
- package/lib/deploy/run/get.js +30 -0
- package/lib/deploy/run/list.js +38 -0
- package/lib/deploy/run/prereqs.js +0 -3
- package/lib/deploy/run/util.js +9 -0
- package/lib/emulator/auth/operations.js +2 -2
- package/lib/emulator/auth/server.js +4 -2
- package/lib/emulator/auth/widget_ui.js +1 -1
- package/lib/emulator/commandUtils.js +109 -24
- package/lib/emulator/databaseEmulator.js +16 -11
- package/lib/emulator/dataconnect/pgliteServer.js +31 -24
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/downloadableEmulators.js +45 -7
- package/lib/emulator/extensions/postinstall.js +6 -6
- package/lib/emulator/firestoreEmulator.js +21 -15
- package/lib/emulator/functionsEmulator.js +11 -7
- package/lib/emulator/functionsEmulatorRuntime.js +7 -2
- package/lib/emulator/hub.js +12 -8
- package/lib/emulator/shared/express.js +30 -0
- package/lib/emulator/storage/apis/firebase.js +11 -10
- package/lib/emulator/storage/apis/gcloud.js +21 -20
- package/lib/emulator/storage/files.js +1 -1
- package/lib/emulator/storage/rules/manager.js +15 -12
- package/lib/emulator/storage/rules/runtime.js +1 -0
- package/lib/emulator/storage/server.js +10 -5
- package/lib/extensions/extensionsApi.js +0 -8
- package/lib/extensions/extensionsHelper.js +3 -24
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -6
- package/lib/extensions/secretsUtils.js +0 -24
- package/lib/firestore/util.js +3 -3
- package/lib/frameworks/angular/utils.js +1 -1
- package/lib/frameworks/next/utils.js +1 -12
- package/lib/fsAsync.js +34 -20
- package/lib/functions/kits/install.js +233 -628
- package/lib/functions/kits/sources/directory.js +91 -0
- package/lib/functions/kits/sources/npm.js +324 -0
- package/lib/functions/kits/sources/types.js +12 -0
- package/lib/functionsConfig.js +0 -4
- package/lib/functionsShellCommandAction.js +1 -1
- package/lib/gcp/artifactregistry.js +0 -5
- package/lib/gcp/cloudfunctionsv2.js +0 -6
- package/lib/gcp/devConnect.js +2 -2
- package/lib/gcp/iam.js +0 -4
- package/lib/gcp/pubsub.js +0 -14
- package/lib/gcp/storage.js +2 -1
- package/lib/hosting/api.js +79 -0
- package/lib/hosting/proxy.js +4 -1
- package/lib/init/features/hosting/github.js +6 -4
- package/lib/init/features/hosting/index.js +4 -0
- package/lib/init/features/run.js +3 -7
- package/lib/mcp/apps/init/mcp-app.js +4 -1
- package/lib/mcp/index.js +8 -2
- package/lib/mcp/prompts/apptesting/run_test.js +3 -3
- package/lib/mcp/prompts/core/deploy.js +3 -3
- package/lib/mcp/resources/guides/crashlytics_reports.js +33 -71
- package/lib/mcp/resources/guides/init_ai.js +10 -10
- package/lib/mcp/tools/crashlytics/events.js +18 -93
- package/lib/mcp/tools/crashlytics/index.js +2 -0
- package/lib/mcp/tools/crashlytics/reports.js +26 -31
- package/lib/mcp/tools/crashlytics/setup.js +392 -0
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +4 -10
- package/package.json +1 -2
- package/lib/deploy/hosting/args.js +0 -2
|
@@ -8,12 +8,10 @@ const requirePermissions_1 = require("../requirePermissions");
|
|
|
8
8
|
const projectUtils_1 = require("../projectUtils");
|
|
9
9
|
const logger_1 = require("../logger");
|
|
10
10
|
const error_1 = require("../error");
|
|
11
|
-
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
12
|
-
const api_2 = require("../api");
|
|
13
11
|
exports.command = new command_1.Command("hosting:sites:get <siteId>")
|
|
14
12
|
.description("print info about a Firebase Hosting site")
|
|
15
13
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
|
|
16
|
-
.before((options) => (0,
|
|
14
|
+
.before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
|
|
17
15
|
.action(async (siteId, options) => {
|
|
18
16
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
19
17
|
if (!siteId) {
|
|
@@ -8,13 +8,11 @@ const api_1 = require("../hosting/api");
|
|
|
8
8
|
const requirePermissions_1 = require("../requirePermissions");
|
|
9
9
|
const projectUtils_1 = require("../projectUtils");
|
|
10
10
|
const logger_1 = require("../logger");
|
|
11
|
-
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
12
|
-
const api_2 = require("../api");
|
|
13
11
|
const TABLE_HEAD = ["Site ID", "Default URL", "App ID (if set)"];
|
|
14
12
|
exports.command = new command_1.Command("hosting:sites:list")
|
|
15
13
|
.description("list Firebase Hosting sites")
|
|
16
14
|
.before(requirePermissions_1.requirePermissions, ["firebasehosting.sites.get"])
|
|
17
|
-
.before((options) => (0,
|
|
15
|
+
.before((options) => (0, api_1.ensureApiEnabled)((0, projectUtils_1.needProjectId)(options)))
|
|
18
16
|
.action(async (options) => {
|
|
19
17
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
20
18
|
const sites = await (0, api_1.listSites)(projectId);
|
package/lib/commands/index.js
CHANGED
|
@@ -23,6 +23,7 @@ function load(client) {
|
|
|
23
23
|
client.appcheck.debugtokens = {};
|
|
24
24
|
client.appcheck.debugtokens.create = loadCommand("appcheck-debugtokens-create");
|
|
25
25
|
client.appcheck.debugtokens.list = loadCommand("appcheck-debugtokens-list");
|
|
26
|
+
client.appcheck.debugtokens.prune = loadCommand("appcheck-debugtokens-prune");
|
|
26
27
|
client.appcheck.debugtokens.delete = loadCommand("appcheck-debugtokens-delete");
|
|
27
28
|
if (experiments.isEnabled("appcheckadmin")) {
|
|
28
29
|
client.appcheck.services = {};
|
|
@@ -69,8 +70,7 @@ function load(client) {
|
|
|
69
70
|
client.auth.export = loadCommand("auth-export");
|
|
70
71
|
client.auth.import = loadCommand("auth-import");
|
|
71
72
|
client.crashlytics = {};
|
|
72
|
-
client.crashlytics.
|
|
73
|
-
client.crashlytics.onboard.web = loadCommand("crashlytics-onboard-web");
|
|
73
|
+
client.crashlytics.setup = loadCommand("crashlytics-setup");
|
|
74
74
|
client.crashlytics.symbols = {};
|
|
75
75
|
client.crashlytics.symbols.upload = loadCommand("crashlytics-symbols-upload");
|
|
76
76
|
client.crashlytics.mappingfile = {};
|
|
@@ -290,6 +290,8 @@ function load(client) {
|
|
|
290
290
|
if (experiments.isEnabled("directcloudrun")) {
|
|
291
291
|
client.run = {};
|
|
292
292
|
client.run.services = {};
|
|
293
|
+
client.run.services.get = loadCommand("run-services-get");
|
|
294
|
+
client.run.services.list = loadCommand("run-services-list");
|
|
293
295
|
client.run.services.update = loadCommand("run-services-update");
|
|
294
296
|
}
|
|
295
297
|
client.serve = loadCommand("serve");
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const yaml = require("yaml");
|
|
5
|
+
const command_1 = require("../command");
|
|
6
|
+
const get_1 = require("../deploy/run/get");
|
|
7
|
+
const logger_1 = require("../logger");
|
|
8
|
+
const projectUtils_1 = require("../projectUtils");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
exports.command = new command_1.Command("run:services:get <serviceId>")
|
|
11
|
+
.description("print a Cloud Run service's YAML specification, like gcloud run services describe")
|
|
12
|
+
.option("--region <region>", "the service's region, if the project has a service with this ID in more than one region")
|
|
13
|
+
.before(requirePermissions_1.requirePermissions, ["run.services.list", "run.services.get"])
|
|
14
|
+
.action(async (serviceId, options) => {
|
|
15
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
+
const service = await (0, get_1.getServiceSpec)(projectId, serviceId, options.region);
|
|
17
|
+
logger_1.logger.info(yaml.stringify(service, { lineWidth: 0 }));
|
|
18
|
+
return service;
|
|
19
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const list_1 = require("../deploy/run/list");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
8
|
+
exports.command = new command_1.Command("run:services:list")
|
|
9
|
+
.description("list the Cloud Run services in your project, with their regions and base images")
|
|
10
|
+
.before(requirePermissions_1.requirePermissions, ["run.services.list"])
|
|
11
|
+
.action((options) => (0, list_1.listRunServices)((0, projectUtils_1.needProjectId)(options)));
|
|
@@ -23,6 +23,7 @@ async function generateAlertPolicy(projectId, appId, alertType) {
|
|
|
23
23
|
method: "POST",
|
|
24
24
|
headers: {
|
|
25
25
|
"Content-Type": "application/json",
|
|
26
|
+
"x-goog-user-project": projectId,
|
|
26
27
|
},
|
|
27
28
|
path: `/projects/${projectId}/apps/${appId}:generateAlertPolicy`,
|
|
28
29
|
body: { alertType },
|
|
@@ -1,16 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DEFAULT_MAX_FRAMES = exports.EVENT_DUMP_OPTIONS = void 0;
|
|
3
4
|
exports.listEvents = listEvents;
|
|
5
|
+
exports.normalizeEventResourceName = normalizeEventResourceName;
|
|
4
6
|
exports.batchGetEvents = batchGetEvents;
|
|
7
|
+
exports.formatFrames = formatFrames;
|
|
8
|
+
exports.toText = toText;
|
|
9
|
+
const js_yaml_1 = require("js-yaml");
|
|
5
10
|
const logger_1 = require("../logger");
|
|
6
11
|
const error_1 = require("../error");
|
|
7
12
|
const utils_1 = require("./utils");
|
|
13
|
+
const types_1 = require("./types");
|
|
8
14
|
const filters_1 = require("./filters");
|
|
9
|
-
|
|
15
|
+
exports.EVENT_DUMP_OPTIONS = { lineWidth: 200 };
|
|
16
|
+
exports.DEFAULT_MAX_FRAMES = 20;
|
|
17
|
+
const DEFAULT_MAX_LOGS = 100;
|
|
18
|
+
const DEFAULT_MAX_BREADCRUMBS = 10;
|
|
19
|
+
async function listEvents(appId, filter, pageSize = 1, filterExpression) {
|
|
10
20
|
var _a;
|
|
11
21
|
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
12
22
|
const queryParams = (0, filters_1.filterToUrlSearchParams)(filter);
|
|
13
23
|
queryParams.set("page_size", `${pageSize}`);
|
|
24
|
+
if (filterExpression) {
|
|
25
|
+
queryParams.set("filter_expression", filterExpression);
|
|
26
|
+
}
|
|
14
27
|
logger_1.logger.debug(`[crashlytics] listEvents called with appId: ${appId}, filter: ${queryParams.toString()}, pageSize: ${pageSize}`);
|
|
15
28
|
const response = await utils_1.CRASHLYTICS_API_CLIENT.request({
|
|
16
29
|
method: "GET",
|
|
@@ -24,6 +37,24 @@ async function listEvents(appId, filter, pageSize = 1) {
|
|
|
24
37
|
(_a = response.body).events ?? (_a.events = []);
|
|
25
38
|
return response.body;
|
|
26
39
|
}
|
|
40
|
+
function normalizeEventResourceName(appId, eventIdOrName) {
|
|
41
|
+
const trimmed = eventIdOrName.trim();
|
|
42
|
+
if (!trimmed) {
|
|
43
|
+
throw new error_1.FirebaseError("Event ID cannot be empty.");
|
|
44
|
+
}
|
|
45
|
+
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
46
|
+
const expectedPrefix = `projects/${requestProjectNumber}/apps/${appId}/events/`;
|
|
47
|
+
if (trimmed.startsWith(expectedPrefix)) {
|
|
48
|
+
const eventId = trimmed.slice(expectedPrefix.length);
|
|
49
|
+
if (eventId && !eventId.includes("/")) {
|
|
50
|
+
return trimmed;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (trimmed.includes("/")) {
|
|
54
|
+
throw new error_1.FirebaseError(`Invalid event resource name '${trimmed}'. Expected an event ID or '${expectedPrefix}{event_id}'.`);
|
|
55
|
+
}
|
|
56
|
+
return `${expectedPrefix}${trimmed}`;
|
|
57
|
+
}
|
|
27
58
|
async function batchGetEvents(appId, eventNames) {
|
|
28
59
|
var _a;
|
|
29
60
|
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
@@ -46,3 +77,93 @@ async function batchGetEvents(appId, eventNames) {
|
|
|
46
77
|
(_a = response.body).events ?? (_a.events = []);
|
|
47
78
|
return response.body;
|
|
48
79
|
}
|
|
80
|
+
function formatFrames(origFrames, maxFrames = exports.DEFAULT_MAX_FRAMES) {
|
|
81
|
+
const frames = origFrames || [];
|
|
82
|
+
const shouldTruncate = frames.length > maxFrames;
|
|
83
|
+
const sliceCount = maxFrames > 1 ? maxFrames - 1 : 1;
|
|
84
|
+
const framesToFormat = shouldTruncate ? frames.slice(0, sliceCount) : frames;
|
|
85
|
+
const formatted = framesToFormat.map((frame) => {
|
|
86
|
+
let line = `at`;
|
|
87
|
+
if (frame.symbol) {
|
|
88
|
+
line += ` ${frame.symbol}`;
|
|
89
|
+
}
|
|
90
|
+
if (frame.file) {
|
|
91
|
+
line += ` (${frame.file}`;
|
|
92
|
+
if (frame.line) {
|
|
93
|
+
line += `:${frame.line}`;
|
|
94
|
+
}
|
|
95
|
+
line += ")";
|
|
96
|
+
}
|
|
97
|
+
return line;
|
|
98
|
+
});
|
|
99
|
+
if (shouldTruncate) {
|
|
100
|
+
formatted.push("... frames omitted ...");
|
|
101
|
+
}
|
|
102
|
+
return formatted;
|
|
103
|
+
}
|
|
104
|
+
function toText(event, options = {}) {
|
|
105
|
+
if (!event) {
|
|
106
|
+
return {};
|
|
107
|
+
}
|
|
108
|
+
const { maxFrames = exports.DEFAULT_MAX_FRAMES, full = false } = options;
|
|
109
|
+
const effectiveMaxFrames = full ? Infinity : maxFrames;
|
|
110
|
+
const result = {};
|
|
111
|
+
for (const [key, value] of Object.entries(event)) {
|
|
112
|
+
if (key === "logs") {
|
|
113
|
+
const logs = value || [];
|
|
114
|
+
const slicedLogs = !full && logs.length > DEFAULT_MAX_LOGS ? logs.slice(logs.length - DEFAULT_MAX_LOGS) : logs;
|
|
115
|
+
const logLines = slicedLogs.map((log) => `[${log.logTime}] ${log.message}`);
|
|
116
|
+
result["logs"] = logLines.join("\n");
|
|
117
|
+
}
|
|
118
|
+
else if (key === "breadcrumbs") {
|
|
119
|
+
const breadcrumbs = value || [];
|
|
120
|
+
const slicedBreadcrumbs = !full && breadcrumbs.length > DEFAULT_MAX_BREADCRUMBS
|
|
121
|
+
? breadcrumbs.slice(-DEFAULT_MAX_BREADCRUMBS)
|
|
122
|
+
: breadcrumbs;
|
|
123
|
+
const breadcrumbLines = slicedBreadcrumbs.map((b) => {
|
|
124
|
+
const paramString = Object.entries(b.params || {})
|
|
125
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
126
|
+
.join(", ");
|
|
127
|
+
const params = paramString ? ` { ${paramString} }` : "";
|
|
128
|
+
return `[${b.eventTime}] ${b.title}${params}`;
|
|
129
|
+
});
|
|
130
|
+
result["breadcrumbs"] = breadcrumbLines.join("\n");
|
|
131
|
+
}
|
|
132
|
+
else if (key === "threads") {
|
|
133
|
+
let threads = value || [];
|
|
134
|
+
if (!full &&
|
|
135
|
+
(event.issue?.errorType === types_1.ErrorType.FATAL || event.issue?.errorType === types_1.ErrorType.ANR)) {
|
|
136
|
+
threads = threads.filter((t) => t.crashed || t.blamed);
|
|
137
|
+
}
|
|
138
|
+
const threadStrings = threads.map((thread) => {
|
|
139
|
+
const header = `Thread: ${thread.name || thread.threadId || ""}${thread.crashed ? " (crashed)" : ""}`;
|
|
140
|
+
const frameStrings = formatFrames(thread.frames || [], effectiveMaxFrames);
|
|
141
|
+
return [header, ...frameStrings].join("\n");
|
|
142
|
+
});
|
|
143
|
+
result["threads"] = threadStrings.join("\n\n");
|
|
144
|
+
}
|
|
145
|
+
else if (key === "exceptions") {
|
|
146
|
+
const exceptions = value || [];
|
|
147
|
+
const exceptionStrings = exceptions.map((exception) => {
|
|
148
|
+
const header = exception.nested ? "Caused by: " : "";
|
|
149
|
+
const exceptionHeader = `${header}${exception.type || ""}: ${exception.exceptionMessage || ""}`;
|
|
150
|
+
const frameStrings = formatFrames(exception.frames || [], effectiveMaxFrames);
|
|
151
|
+
return [exceptionHeader, ...frameStrings].join("\n");
|
|
152
|
+
});
|
|
153
|
+
result["exceptions"] = exceptionStrings.join("\n\n");
|
|
154
|
+
}
|
|
155
|
+
else if (key === "errors") {
|
|
156
|
+
const errors = value || [];
|
|
157
|
+
const errorStrings = errors.map((error) => {
|
|
158
|
+
const header = `Error: ${error.title || "error"}`;
|
|
159
|
+
const frameStrings = formatFrames(error.frames || [], effectiveMaxFrames);
|
|
160
|
+
return [header, ...frameStrings].join("\n");
|
|
161
|
+
});
|
|
162
|
+
result["errors"] = errorStrings.join("\n\n");
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
result[key] = (0, js_yaml_1.dump)(value, exports.EVENT_DUMP_OPTIONS);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
return result;
|
|
169
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EventFilterSchema = exports.IssueIdSchema = exports.ApplicationIdSchema = void 0;
|
|
3
|
+
exports.FilterExpressionSchema = exports.EventFilterSchema = exports.IssueIdSchema = exports.ApplicationIdSchema = void 0;
|
|
4
4
|
exports.filterToUrlSearchParams = filterToUrlSearchParams;
|
|
5
5
|
exports.validateEventFilters = validateEventFilters;
|
|
6
6
|
const zod_1 = require("zod");
|
|
7
7
|
const error_1 = require("../error");
|
|
8
|
+
const apps_1 = require("../management/apps");
|
|
9
|
+
const utils_1 = require("./utils");
|
|
8
10
|
exports.ApplicationIdSchema = zod_1.z
|
|
9
11
|
.string()
|
|
10
12
|
.describe("Firebase App Id. Strictly required for all API calls.");
|
|
@@ -56,6 +58,10 @@ exports.EventFilterSchema = zod_1.z
|
|
|
56
58
|
.optional()
|
|
57
59
|
.describe(`Only events matching the given filters will be counted. All filters are optional.
|
|
58
60
|
If setting a time interval, set both intervalStartTime and intervalEndTime.`);
|
|
61
|
+
exports.FilterExpressionSchema = zod_1.z
|
|
62
|
+
.string()
|
|
63
|
+
.optional()
|
|
64
|
+
.describe(`An AIP-160 filter expression for custom keys (e.g. 'custom_keys.env = "prod"', 'custom_keys.experiment_id:*', or combined with 'AND' across different keys and 'OR' across values of one key).`);
|
|
59
65
|
const toolToParamMap = {
|
|
60
66
|
intervalStartTime: "filter.interval.start_time",
|
|
61
67
|
intervalEndTime: "filter.interval.end_time",
|
|
@@ -88,7 +94,7 @@ function filterToUrlSearchParams(filter) {
|
|
|
88
94
|
return params;
|
|
89
95
|
}
|
|
90
96
|
const displayNamePattern = /^[^()]+\s+\([^()]+\)$/;
|
|
91
|
-
function validateEventFilters(filter = {}) {
|
|
97
|
+
function validateEventFilters(filter = {}, appId) {
|
|
92
98
|
if (!!filter.intervalStartTime && !filter.intervalEndTime) {
|
|
93
99
|
filter.intervalEndTime = new Date().toISOString();
|
|
94
100
|
}
|
|
@@ -110,12 +116,12 @@ function validateEventFilters(filter = {}) {
|
|
|
110
116
|
}
|
|
111
117
|
});
|
|
112
118
|
}
|
|
113
|
-
if (filter.versionDisplayNames) {
|
|
114
|
-
filter.versionDisplayNames
|
|
119
|
+
if (filter.versionDisplayNames && (0, utils_1.parseAppPlatform)(appId) !== apps_1.AppPlatform.WEB) {
|
|
120
|
+
for (const dn of filter.versionDisplayNames) {
|
|
115
121
|
if (!displayNamePattern.test(dn)) {
|
|
116
|
-
throw new error_1.FirebaseError(
|
|
122
|
+
throw new error_1.FirebaseError(`versionDisplayNames must match pattern 'version (build)' (e.g., "2.4.0 (240)"). Use the displayName values returned by the topVersions report.`);
|
|
117
123
|
}
|
|
118
|
-
}
|
|
124
|
+
}
|
|
119
125
|
}
|
|
120
126
|
return filter;
|
|
121
127
|
}
|
|
@@ -5,14 +5,13 @@ const api_1 = require("../api");
|
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const API_VERSION = "v1alpha";
|
|
8
|
-
async function createOrUpdateTelemetryConfig(projectId, appId,
|
|
8
|
+
async function createOrUpdateTelemetryConfig(projectId, appId, samplingRate = 1) {
|
|
9
9
|
const client = new apiv2_1.Client({ urlPrefix: (0, api_1.firebaseTelemetryAdminOrigin)(), apiVersion: API_VERSION });
|
|
10
10
|
const configId = appId.replace(/[:.]/g, "-");
|
|
11
11
|
const configName = `projects/${projectId}/locations/global/configs/${configId}`;
|
|
12
12
|
const configBody = {
|
|
13
13
|
name: configName,
|
|
14
14
|
appId,
|
|
15
|
-
logBucket,
|
|
16
15
|
samplingRate,
|
|
17
16
|
};
|
|
18
17
|
try {
|
|
@@ -22,7 +21,7 @@ async function createOrUpdateTelemetryConfig(projectId, appId, logBucket, sampli
|
|
|
22
21
|
catch (err) {
|
|
23
22
|
if (err.status === 409) {
|
|
24
23
|
try {
|
|
25
|
-
const patchRes = await client.patch(`/projects/${projectId}/locations/global/configs/${configId}?updateMask=
|
|
24
|
+
const patchRes = await client.patch(`/projects/${projectId}/locations/global/configs/${configId}?updateMask=samplingRate`, configBody);
|
|
26
25
|
return patchRes.body;
|
|
27
26
|
}
|
|
28
27
|
catch (patchErr) {
|
|
@@ -30,6 +29,9 @@ async function createOrUpdateTelemetryConfig(projectId, appId, logBucket, sampli
|
|
|
30
29
|
throw new error_1.FirebaseError(`Failed to patch telemetry config for web app ${appId} (status ${patchErr.status}): ${msg}`, { original: patchErr });
|
|
31
30
|
}
|
|
32
31
|
}
|
|
32
|
+
else if (err.status === 503) {
|
|
33
|
+
throw new error_1.FirebaseError("Sorry, Crashlytics is busy right now and can't finish setup. Please try again in a little while.", { original: err });
|
|
34
|
+
}
|
|
33
35
|
const msg = err.message || JSON.stringify(err.body) || err;
|
|
34
36
|
throw new error_1.FirebaseError(`Failed to configure telemetry for web app ${appId} (status ${err.status}): ${msg}`, { original: err });
|
|
35
37
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.
|
|
3
|
+
exports.CLOUD_MONITORING_SERVICE = exports.API_KEYS_SERVICE = exports.CLIENT_TELEMETRY_SERVICE = exports.CRASHLYTICS_SERVICE = exports.CRASHLYTICS_TELEMETRY_ADMIN_SERVICE = exports.CRASHLYTICS_TELEMETRY_SERVICE = void 0;
|
|
4
|
+
exports.setupCrashlyticsWeb = setupCrashlyticsWeb;
|
|
5
5
|
const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
6
6
|
const error_1 = require("../error");
|
|
7
7
|
const experiments = require("../experiments");
|
|
@@ -16,13 +16,12 @@ const apps_1 = require("../management/apps");
|
|
|
16
16
|
const logger_1 = require("../logger");
|
|
17
17
|
const prompt_1 = require("../prompt");
|
|
18
18
|
const requireAuth_1 = require("../requireAuth");
|
|
19
|
-
exports.CRASHLYTICS_TELEMETRY_BUCKET_ID = "firebase-telemetry";
|
|
20
|
-
exports.CRASHLYTICS_TELEMETRY_SINK_ID = "firebase-telemetry-routing";
|
|
21
|
-
exports.CRASHLYTICS_TELEMETRY_RESOURCE_TYPE = "firebasetelemetry.googleapis.com/App";
|
|
22
19
|
exports.CRASHLYTICS_TELEMETRY_SERVICE = "firebasetelemetry.googleapis.com";
|
|
23
20
|
exports.CRASHLYTICS_TELEMETRY_ADMIN_SERVICE = "firebasetelemetryadmin.googleapis.com";
|
|
24
21
|
exports.CRASHLYTICS_SERVICE = "firebasecrashlytics.googleapis.com";
|
|
25
22
|
exports.CLIENT_TELEMETRY_SERVICE = "clienttelemetry.googleapis.com";
|
|
23
|
+
exports.API_KEYS_SERVICE = "apikeys.googleapis.com";
|
|
24
|
+
exports.CLOUD_MONITORING_SERVICE = "monitoring.googleapis.com";
|
|
26
25
|
async function resolveAuthenticatedUserEmail(options) {
|
|
27
26
|
if (options.user?.email) {
|
|
28
27
|
return options.user.email;
|
|
@@ -35,7 +34,7 @@ async function resolveAuthenticatedUserEmail(options) {
|
|
|
35
34
|
return undefined;
|
|
36
35
|
}
|
|
37
36
|
}
|
|
38
|
-
async function
|
|
37
|
+
async function setupCrashlyticsWeb(projectId, appId, options = {}) {
|
|
39
38
|
const billingEnabled = await (0, cloudbilling_1.checkBillingEnabled)(projectId);
|
|
40
39
|
if (!billingEnabled && options.nonInteractive) {
|
|
41
40
|
throw new error_1.FirebaseError(`Crashlytics requires the Blaze plan, but project ${projectId} is not on the Blaze plan. ` +
|
|
@@ -60,6 +59,7 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
60
59
|
if ("apiKey" in appConfig && appConfig.apiKey) {
|
|
61
60
|
(0, utils_1.logLabeledBullet)("crashlytics", "Ensuring Crashlytics Telemetry API is permitted in API key restrictions...");
|
|
62
61
|
try {
|
|
62
|
+
await (0, ensureApiEnabled_1.ensure)(projectId, exports.API_KEYS_SERVICE, "crashlytics", false);
|
|
63
63
|
await (0, apikeys_1.updateAppApiKeyRestriction)({
|
|
64
64
|
apiKey: appConfig.apiKey,
|
|
65
65
|
service: exports.CLIENT_TELEMETRY_SERVICE,
|
|
@@ -85,7 +85,7 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
87
|
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Crashlytics telemetry for web app...");
|
|
88
|
-
const config = await (0, firebasetelemetry_1.createOrUpdateTelemetryConfig)(projectId, appId,
|
|
88
|
+
const config = await (0, firebasetelemetry_1.createOrUpdateTelemetryConfig)(projectId, appId, 1);
|
|
89
89
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics telemetry configured successfully.");
|
|
90
90
|
if (options.nonInteractive) {
|
|
91
91
|
return { config };
|
|
@@ -115,6 +115,7 @@ async function onboardCrashlyticsWeb(projectId, appId, options = {}) {
|
|
|
115
115
|
}
|
|
116
116
|
(0, utils_1.logLabeledBullet)("crashlytics", `Setting up Crashlytics email alerts for ${userEmail}...`);
|
|
117
117
|
try {
|
|
118
|
+
await (0, ensureApiEnabled_1.ensure)(projectId, exports.CLOUD_MONITORING_SERVICE, "crashlytics", false);
|
|
118
119
|
const alertPolicies = await (0, alerts_1.enableAlerts)(projectId, appId, selectedAlerts, userEmail);
|
|
119
120
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Crashlytics email alerts configured successfully.");
|
|
120
121
|
return { config, alertPolicies };
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_LIFECYCLE_RULES = exports.DEFAULT_CORS_RULES = exports.DEFAULT_FILE_TTL_DAYS = exports.DEFAULT_BUCKET_LOCATION = exports.DEFAULT_CORS_ORIGINS = exports.HEAP_DUMP_BUCKET_PREFIX = exports.STORAGE_OBJECT_CREATOR_ROLE = exports.CRASHLYTICS_SERVICE_NAME = void 0;
|
|
4
|
-
exports.getCrashlyticsV1Client = getCrashlyticsV1Client;
|
|
5
4
|
exports.parseAndroidHashedId = parseAndroidHashedId;
|
|
6
5
|
exports.createBucketName = createBucketName;
|
|
7
6
|
exports.getCrashlyticsP4sa = getCrashlyticsP4sa;
|
|
@@ -12,8 +11,6 @@ exports.ensureHeapDumpStorageBucket = ensureHeapDumpStorageBucket;
|
|
|
12
11
|
exports.ensureHeapDumpP4saRole = ensureHeapDumpP4saRole;
|
|
13
12
|
exports.enableHeapDumpCollection = enableHeapDumpCollection;
|
|
14
13
|
exports.disableHeapDumpCollection = disableHeapDumpCollection;
|
|
15
|
-
const apiv2_1 = require("../apiv2");
|
|
16
|
-
const api_1 = require("../api");
|
|
17
14
|
const error_1 = require("../error");
|
|
18
15
|
const logger_1 = require("../logger");
|
|
19
16
|
const utils_1 = require("../utils");
|
|
@@ -22,12 +19,6 @@ const storage = require("../gcp/storage");
|
|
|
22
19
|
const resourceManager = require("../gcp/resourceManager");
|
|
23
20
|
const serviceusage = require("../gcp/serviceusage");
|
|
24
21
|
const apps_1 = require("../management/apps");
|
|
25
|
-
function getCrashlyticsV1Client() {
|
|
26
|
-
return new apiv2_1.Client({
|
|
27
|
-
urlPrefix: (0, api_1.crashlyticsApiOrigin)(),
|
|
28
|
-
apiVersion: "v1",
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
22
|
exports.CRASHLYTICS_SERVICE_NAME = "firebasecrashlytics.googleapis.com";
|
|
32
23
|
exports.STORAGE_OBJECT_CREATOR_ROLE = "roles/storage.objectCreator";
|
|
33
24
|
exports.HEAP_DUMP_BUCKET_PREFIX = "firebasecrashlytics-heap-dumps-";
|
|
@@ -48,6 +39,7 @@ exports.DEFAULT_LIFECYCLE_RULES = [
|
|
|
48
39
|
},
|
|
49
40
|
];
|
|
50
41
|
const ANDROID_APP_ID_REGEX = /^\d+:(\d+):android:([a-fA-F0-9]+)$/;
|
|
42
|
+
const GCS_BUCKET_RESOURCE_PREFIX = "projects/_/buckets/";
|
|
51
43
|
function parseAndroidHashedId(appId) {
|
|
52
44
|
const match = ANDROID_APP_ID_REGEX.exec(appId);
|
|
53
45
|
if (!match) {
|
|
@@ -87,37 +79,27 @@ async function resolveAndroidAppId(projectId, options) {
|
|
|
87
79
|
async function getProfilingManagerConfig(appId) {
|
|
88
80
|
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
89
81
|
logger_1.logger.debug(`[crashlytics] getProfilingManagerConfig called with appId: ${appId}`);
|
|
90
|
-
const response = await
|
|
82
|
+
const response = await utils_2.CRASHLYTICS_API_CLIENT.request({
|
|
91
83
|
method: "GET",
|
|
92
84
|
headers: {
|
|
93
85
|
"Content-Type": "application/json",
|
|
94
86
|
},
|
|
95
|
-
path: `/projects/${projectNumber}/apps/${appId}/
|
|
87
|
+
path: `/projects/${projectNumber}/apps/${appId}/profilingManagerConfig`,
|
|
96
88
|
timeout: utils_2.TIMEOUT,
|
|
97
89
|
});
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
gcsBucket: config.gcsBucket || "",
|
|
101
|
-
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
102
|
-
};
|
|
90
|
+
return response.body;
|
|
103
91
|
}
|
|
104
|
-
async function updateProfilingManagerConfig(appId, config) {
|
|
92
|
+
async function updateProfilingManagerConfig(appId, config, updateMask) {
|
|
105
93
|
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
106
|
-
logger_1.logger.debug(`[crashlytics] updateProfilingManagerConfig called with appId: ${appId}, config: ${JSON.stringify(config)}`);
|
|
107
|
-
await
|
|
108
|
-
method: "
|
|
94
|
+
logger_1.logger.debug(`[crashlytics] updateProfilingManagerConfig called with appId: ${appId}, config: ${JSON.stringify(config)}, updateMask: ${updateMask}`);
|
|
95
|
+
await utils_2.CRASHLYTICS_API_CLIENT.request({
|
|
96
|
+
method: "PATCH",
|
|
109
97
|
headers: {
|
|
110
98
|
"Content-Type": "application/json",
|
|
111
99
|
},
|
|
112
|
-
path: `/projects/${projectNumber}/apps/${appId}/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
gmpAppId: appId,
|
|
116
|
-
configuration: {
|
|
117
|
-
gcsBucket: config.gcsBucket ?? "",
|
|
118
|
-
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
100
|
+
path: `/projects/${projectNumber}/apps/${appId}/profilingManagerConfig`,
|
|
101
|
+
queryParams: { updateMask },
|
|
102
|
+
body: config,
|
|
121
103
|
timeout: utils_2.TIMEOUT,
|
|
122
104
|
});
|
|
123
105
|
}
|
|
@@ -178,18 +160,16 @@ async function enableHeapDumpCollection(projectId, appId, location = exports.DEF
|
|
|
178
160
|
await ensureHeapDumpP4saRole(projectId, projectNumber);
|
|
179
161
|
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling Crashlytics heap dump collection...");
|
|
180
162
|
await updateProfilingManagerConfig(appId, {
|
|
181
|
-
|
|
163
|
+
bucket: `${GCS_BUCKET_RESOURCE_PREFIX}${bucketName}`,
|
|
182
164
|
heapDumpCollectionEnabled: true,
|
|
183
|
-
});
|
|
165
|
+
}, "bucket,heapDumpCollectionEnabled");
|
|
184
166
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully enabled Crashlytics heap dump collection!");
|
|
185
167
|
return bucketName;
|
|
186
168
|
}
|
|
187
169
|
async function disableHeapDumpCollection(appId) {
|
|
188
170
|
(0, utils_1.logLabeledBullet)("crashlytics", "Disabling Crashlytics heap dump collection...");
|
|
189
|
-
const currentConfig = await getProfilingManagerConfig(appId);
|
|
190
171
|
await updateProfilingManagerConfig(appId, {
|
|
191
|
-
gcsBucket: currentConfig.gcsBucket,
|
|
192
172
|
heapDumpCollectionEnabled: false,
|
|
193
|
-
});
|
|
173
|
+
}, "heapDumpCollectionEnabled");
|
|
194
174
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully disabled Crashlytics heap dump collection!");
|
|
195
175
|
}
|
|
@@ -1,33 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ReportInputSchema = exports.
|
|
3
|
+
exports.reportsCache = exports.ReportInputSchema = exports.TimeGranularitySchema = exports.CrashlyticsReportSchema = void 0;
|
|
4
4
|
exports.simplifyReport = simplifyReport;
|
|
5
|
+
exports.listReports = listReports;
|
|
5
6
|
exports.getReport = getReport;
|
|
6
7
|
const zod_1 = require("zod");
|
|
7
8
|
const lodash_1 = require("lodash");
|
|
8
9
|
const logger_1 = require("../logger");
|
|
9
10
|
const utils_1 = require("./utils");
|
|
11
|
+
const types_1 = require("./types");
|
|
10
12
|
const filters_1 = require("./filters");
|
|
11
13
|
const error_1 = require("../error");
|
|
12
14
|
const DEFAULT_PAGE_SIZE = 10;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
CrashlyticsReport["TOP_OPERATING_SYSTEMS"] = "topOperatingSystems";
|
|
19
|
-
CrashlyticsReport["TOP_APPLE_DEVICES"] = "topAppleDevices";
|
|
20
|
-
CrashlyticsReport["TOP_ANDROID_DEVICES"] = "topAndroidDevices";
|
|
21
|
-
CrashlyticsReport["TOP_BROWSERS"] = "topBrowsers";
|
|
22
|
-
CrashlyticsReport["WEB_METRICS"] = "webMetrics";
|
|
23
|
-
})(CrashlyticsReport || (exports.CrashlyticsReport = CrashlyticsReport = {}));
|
|
24
|
-
exports.CrashlyticsReportSchema = zod_1.z.nativeEnum(CrashlyticsReport);
|
|
15
|
+
exports.CrashlyticsReportSchema = zod_1.z.string().describe("The name of the Crashlytics report");
|
|
16
|
+
exports.TimeGranularitySchema = zod_1.z
|
|
17
|
+
.nativeEnum(types_1.TimeGranularity)
|
|
18
|
+
.optional()
|
|
19
|
+
.describe("The granularity of time intervals for the report. Returns one data point per time grain, or a single data point for the entire interval if omitted.");
|
|
25
20
|
exports.ReportInputSchema = zod_1.z.object({
|
|
26
21
|
appId: filters_1.ApplicationIdSchema,
|
|
27
22
|
report: exports.CrashlyticsReportSchema,
|
|
28
23
|
filter: filters_1.EventFilterSchema,
|
|
29
24
|
pageSize: zod_1.z.number().optional().describe("Number of rows to return").default(DEFAULT_PAGE_SIZE),
|
|
25
|
+
granularity: exports.TimeGranularitySchema,
|
|
30
26
|
});
|
|
27
|
+
exports.reportsCache = new Map();
|
|
31
28
|
function simplifyReport(report) {
|
|
32
29
|
const simplifiedReport = (0, lodash_1.cloneDeep)(report);
|
|
33
30
|
if (!simplifiedReport.groups)
|
|
@@ -48,13 +45,45 @@ function simplifyReport(report) {
|
|
|
48
45
|
});
|
|
49
46
|
return simplifiedReport;
|
|
50
47
|
}
|
|
51
|
-
async function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
48
|
+
async function listReports(appId) {
|
|
49
|
+
var _a;
|
|
50
|
+
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
51
|
+
logger_1.logger.debug(`[crashlytics] listReports called with appId: ${appId}`);
|
|
52
|
+
const response = await utils_1.CRASHLYTICS_API_CLIENT.request({
|
|
53
|
+
method: "GET",
|
|
54
|
+
headers: {
|
|
55
|
+
"Content-Type": "application/json",
|
|
56
|
+
},
|
|
57
|
+
path: `/projects/${requestProjectNumber}/apps/${appId}/reports`,
|
|
58
|
+
timeout: utils_1.TIMEOUT,
|
|
59
|
+
});
|
|
60
|
+
(_a = response.body).reports ?? (_a.reports = []);
|
|
61
|
+
return response.body;
|
|
62
|
+
}
|
|
63
|
+
async function getReport(reportName, appId, filter, pageSize = DEFAULT_PAGE_SIZE, granularity) {
|
|
55
64
|
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
65
|
+
let availableReports = exports.reportsCache.get(appId);
|
|
66
|
+
if (!availableReports) {
|
|
67
|
+
availableReports = await listReports(appId);
|
|
68
|
+
exports.reportsCache.set(appId, availableReports);
|
|
69
|
+
}
|
|
70
|
+
const validReports = (availableReports.reports ?? [])
|
|
71
|
+
.map((r) => ({
|
|
72
|
+
name: r.name?.split("/").pop(),
|
|
73
|
+
usage: r.usage,
|
|
74
|
+
}))
|
|
75
|
+
.filter((r) => Boolean(r.name));
|
|
76
|
+
if (!reportName || !validReports.some((r) => r.name === reportName)) {
|
|
77
|
+
const validReportsList = validReports
|
|
78
|
+
.map((r) => (r.usage ? ` * ${r.name} - ${r.usage}` : ` * ${r.name}`))
|
|
79
|
+
.join("\n");
|
|
80
|
+
throw new error_1.FirebaseError(`Invalid Crashlytics report: ${reportName}. Valid reports are:\n${validReportsList}`);
|
|
81
|
+
}
|
|
56
82
|
const queryParams = (0, filters_1.filterToUrlSearchParams)(filter);
|
|
57
83
|
queryParams.set("page_size", `${pageSize}`);
|
|
84
|
+
if (granularity) {
|
|
85
|
+
queryParams.set("granularity", granularity);
|
|
86
|
+
}
|
|
58
87
|
logger_1.logger.debug(`[crashlytics] report ${reportName} called with appId: ${appId} filter: ${queryParams.toString()}, page_size: ${pageSize}`);
|
|
59
88
|
const response = await utils_1.CRASHLYTICS_API_CLIENT.request({
|
|
60
89
|
method: "GET",
|
|
@@ -24,6 +24,8 @@ const utils_1 = require("../utils");
|
|
|
24
24
|
const gcs = require("../gcp/storage");
|
|
25
25
|
const archiveFile_1 = require("../archiveFile");
|
|
26
26
|
exports.CONCURRENCY = 25;
|
|
27
|
+
const SOURCEMAP_RETENTION_DAYS = 180;
|
|
28
|
+
const ENABLE_AUTOCLASS = true;
|
|
27
29
|
const ANGULAR_DIST_DIR = "dist";
|
|
28
30
|
const ANGULAR_BROWSER_DIR = "browser";
|
|
29
31
|
function checkGoogleAppID(options) {
|
|
@@ -93,11 +95,14 @@ async function upsertBucket(projectId, projectNumber, options) {
|
|
|
93
95
|
type: "Delete",
|
|
94
96
|
},
|
|
95
97
|
condition: {
|
|
96
|
-
age:
|
|
98
|
+
age: SOURCEMAP_RETENTION_DAYS,
|
|
97
99
|
},
|
|
98
100
|
},
|
|
99
101
|
],
|
|
100
102
|
},
|
|
103
|
+
autoclass: {
|
|
104
|
+
enabled: ENABLE_AUTOCLASS,
|
|
105
|
+
},
|
|
101
106
|
},
|
|
102
107
|
});
|
|
103
108
|
}
|
|
@@ -274,12 +279,21 @@ async function uploadSourceMaps(mappings, request) {
|
|
|
274
279
|
})));
|
|
275
280
|
let successCount = 0;
|
|
276
281
|
const failedFiles = [];
|
|
282
|
+
const rootDir = options.projectRoot ?? process.cwd();
|
|
277
283
|
for (const [i, success] of results.entries()) {
|
|
278
|
-
if (success) {
|
|
279
|
-
successCount++;
|
|
280
|
-
}
|
|
281
|
-
else {
|
|
284
|
+
if (!success) {
|
|
282
285
|
failedFiles.push(mappings[i].mapFilePath);
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
successCount++;
|
|
289
|
+
if (options.clean) {
|
|
290
|
+
const resolvedPath = path.resolve(rootDir, mappings[i].mapFilePath);
|
|
291
|
+
try {
|
|
292
|
+
fs.rmSync(resolvedPath, { force: true });
|
|
293
|
+
}
|
|
294
|
+
catch (err) {
|
|
295
|
+
logger_1.logger.debug(`Failed to delete source map file ${resolvedPath}: ${err instanceof Error ? err.message : String(err)}`);
|
|
296
|
+
}
|
|
283
297
|
}
|
|
284
298
|
}
|
|
285
299
|
return {
|