firebase-tools 15.35.0 → 15.36.1-main.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/accountExporter.js +1 -1
- package/lib/accountImporter.js +7 -6
- package/lib/apiv2.js +0 -1
- 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/githubConnections.js +1 -1
- package/lib/apptesting/parseTestFiles.js +1 -1
- package/lib/auth.js +9 -3
- package/lib/bin/progressiveHelp.js +1 -1
- package/lib/command.js +1 -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-events-get.js +48 -0
- package/lib/commands/crashlytics-events-list.js +70 -0
- package/lib/commands/crashlytics-heapdumps-enable.js +3 -4
- package/lib/commands/crashlytics-heapdumps-status.js +5 -3
- package/lib/commands/crashlytics-issues-get.js +61 -0
- package/lib/commands/crashlytics-reports-get.js +179 -0
- package/lib/commands/crashlytics-reports-list.js +42 -0
- package/lib/commands/deploy.js +1 -3
- package/lib/commands/ext-dev-init.js +1 -1
- 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 +5 -4
- 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 +11 -0
- package/lib/commands/open.js +3 -1
- package/lib/commands/serve.js +1 -1
- package/lib/commands/use.js +1 -1
- package/lib/config.js +1 -1
- package/lib/crashlytics/commandUtils.js +194 -0
- package/lib/crashlytics/events.js +122 -1
- package/lib/crashlytics/filters.js +12 -6
- package/lib/crashlytics/profilingManager.js +77 -50
- package/lib/crashlytics/reports.js +5 -1
- package/lib/crashlytics/utils.js +14 -0
- package/lib/database/import.js +5 -4
- package/lib/dataconnect/names.js +3 -3
- package/lib/dataconnect/schemaMigration.js +1 -1
- package/lib/deploy/firestore/prepare.js +21 -3
- package/lib/deploy/functions/backend.js +0 -10
- package/lib/deploy/functions/cel.js +2 -2
- package/lib/deploy/functions/deploy.js +2 -1
- package/lib/deploy/functions/release/fabricator.js +9 -2
- package/lib/deploy/functions/release/planner.js +3 -0
- 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/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +1 -1
- package/lib/deploy/functions/services/index.js +13 -11
- package/lib/deploy/hosting/prepare.js +1 -3
- package/lib/deploy/lifecycleHooks.js +1 -1
- 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 +4 -1
- package/lib/emulator/databaseEmulator.js +16 -11
- package/lib/emulator/dataconnect/pgliteServer.js +30 -24
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/downloadableEmulators.js +2 -2
- 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 +9 -4
- 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/server.js +10 -5
- package/lib/experiments.js +5 -0
- package/lib/extensions/extensionsHelper.js +2 -2
- package/lib/extensions/listExtensions.js +1 -1
- package/lib/extensions/paramHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -6
- package/lib/firestore/delete.js +2 -3
- package/lib/firestore/util.js +3 -3
- package/lib/frameworks/angular/utils.js +1 -1
- package/lib/frameworks/next/constants.js +17 -14
- package/lib/frameworks/next/index.js +25 -3
- package/lib/frameworks/next/utils.js +7 -9
- package/lib/functions/kits/install.js +221 -316
- package/lib/functions/kits/sources/directory.js +32 -0
- package/lib/functions/kits/sources/npm.js +55 -5
- package/lib/functionsConfig.js +0 -4
- package/lib/functionsShellCommandAction.js +1 -1
- package/lib/gcp/cloudbilling.js +2 -2
- package/lib/gcp/cloudbuild.js +0 -77
- package/lib/gcp/cloudfunctionsv2.js +0 -6
- package/lib/gcp/cloudtasks.js +0 -4
- package/lib/gcp/devConnect.js +2 -8
- package/lib/gcp/iam.js +15 -1
- package/lib/gcp/resourceManager.js +1 -14
- package/lib/gcp/storage.js +87 -4
- package/lib/hosting/api.js +79 -7
- package/lib/hosting/implicitInit.js +1 -1
- package/lib/hosting/proxy.js +5 -2
- package/lib/init/features/firestore/rules.js +1 -1
- package/lib/init/features/functions/index.js +2 -2
- package/lib/init/features/functions/npm-dependencies.js +1 -1
- package/lib/init/features/hosting/github.js +6 -4
- package/lib/init/features/hosting/index.js +4 -0
- package/lib/init/features/storage/rules.js +1 -1
- package/lib/localFunction.js +3 -3
- package/lib/management/database.js +1 -1
- package/lib/mcp/apps/init/mcp-app.js +5 -2
- package/lib/mcp/apps/update_environment/mcp-app.js +1 -1
- package/lib/mcp/index.js +14 -4
- package/lib/mcp/prompts/apptesting/run_test.js +3 -3
- package/lib/mcp/prompts/core/deploy.js +3 -3
- 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 +3 -3
- package/lib/mcp/tools/crashlytics/setup.js +392 -0
- package/lib/mcp/util/dataconnect/converter.js +1 -1
- package/lib/profileReport.js +1 -1
- package/lib/profiler.js +1 -1
- package/lib/rulesDeploy.js +0 -1
- package/lib/throttler/throttler.js +1 -1
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +5 -11
- package/package.json +4 -4
- package/lib/functions/kits/sources/index.js +0 -19
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VALID_FORM_FACTORS = exports.VALID_SIGNALS = exports.VALID_ERROR_TYPES = void 0;
|
|
4
|
+
exports.requireAppId = requireAppId;
|
|
5
|
+
exports.parsePositiveIntOption = parsePositiveIntOption;
|
|
6
|
+
exports.writeOutputFileIfRequested = writeOutputFileIfRequested;
|
|
7
|
+
exports.withEventFilterOptions = withEventFilterOptions;
|
|
8
|
+
exports.parseEventFilters = parseEventFilters;
|
|
9
|
+
const fs = require("fs-extra");
|
|
10
|
+
const error_1 = require("../error");
|
|
11
|
+
const logger_1 = require("../logger");
|
|
12
|
+
const prompt = require("../prompt");
|
|
13
|
+
const apps_1 = require("../management/apps");
|
|
14
|
+
const utils_1 = require("./utils");
|
|
15
|
+
const filters_1 = require("./filters");
|
|
16
|
+
exports.VALID_ERROR_TYPES = ["FATAL", "NON_FATAL", "ANR"];
|
|
17
|
+
exports.VALID_SIGNALS = [
|
|
18
|
+
"SIGNAL_EARLY",
|
|
19
|
+
"SIGNAL_FRESH",
|
|
20
|
+
"SIGNAL_REGRESSED",
|
|
21
|
+
"SIGNAL_REPETITIVE",
|
|
22
|
+
];
|
|
23
|
+
exports.VALID_FORM_FACTORS = ["PHONE", "TABLET", "DESKTOP", "TV", "WATCH"];
|
|
24
|
+
function requireAppId(options) {
|
|
25
|
+
const appId = typeof options.app === "string" ? options.app.trim() : "";
|
|
26
|
+
if (!appId) {
|
|
27
|
+
throw new error_1.FirebaseError("Must specify '--app <appId>'. Run 'firebase apps:list' to find your Firebase App ID.", { exit: 1 });
|
|
28
|
+
}
|
|
29
|
+
return appId;
|
|
30
|
+
}
|
|
31
|
+
function parsePositiveIntOption(value, flagName, bounds) {
|
|
32
|
+
const { defaultValue, max } = bounds;
|
|
33
|
+
if (value === undefined || value === "") {
|
|
34
|
+
return defaultValue;
|
|
35
|
+
}
|
|
36
|
+
const parsed = typeof value === "number" ? value : Number(String(value).trim());
|
|
37
|
+
if (!Number.isInteger(parsed) || parsed < 1) {
|
|
38
|
+
throw new error_1.FirebaseError(`'${flagName}' must be a positive integer.`, { exit: 1 });
|
|
39
|
+
}
|
|
40
|
+
if (max !== undefined && parsed > max) {
|
|
41
|
+
throw new error_1.FirebaseError(`'${flagName}' must be between 1 and ${max}.`, { exit: 1 });
|
|
42
|
+
}
|
|
43
|
+
return parsed;
|
|
44
|
+
}
|
|
45
|
+
async function writeOutputFileIfRequested(data, options) {
|
|
46
|
+
if (!options.output) {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
if (typeof options.output !== "string" || !options.output.trim()) {
|
|
50
|
+
throw new error_1.FirebaseError("Must specify a file path for '-o, --output <path>'.", { exit: 1 });
|
|
51
|
+
}
|
|
52
|
+
const outputPath = options.output.trim();
|
|
53
|
+
if (fs.existsSync(outputPath)) {
|
|
54
|
+
const shouldOverwrite = await prompt.confirm({
|
|
55
|
+
message: `File ${outputPath} already exists. Overwrite?`,
|
|
56
|
+
force: options.force,
|
|
57
|
+
nonInteractive: options.nonInteractive,
|
|
58
|
+
});
|
|
59
|
+
if (!shouldOverwrite) {
|
|
60
|
+
logger_1.logger.info("Aborted writing output file.");
|
|
61
|
+
return true;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
fs.outputFileSync(outputPath, `${JSON.stringify(data, null, 2)}\n`, "utf8");
|
|
66
|
+
}
|
|
67
|
+
catch (err) {
|
|
68
|
+
throw new error_1.FirebaseError(`Failed to write output to ${outputPath}: ${(0, error_1.getErrMsg)(err)}`, {
|
|
69
|
+
exit: 1,
|
|
70
|
+
original: (0, error_1.getError)(err),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
logger_1.logger.info(`Wrote output to ${outputPath}`);
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
function splitCommaSeparatedList(raw) {
|
|
77
|
+
if (!raw) {
|
|
78
|
+
return undefined;
|
|
79
|
+
}
|
|
80
|
+
const items = String(raw)
|
|
81
|
+
.split(",")
|
|
82
|
+
.map((item) => item.trim())
|
|
83
|
+
.filter(Boolean);
|
|
84
|
+
return items.length > 0 ? items : undefined;
|
|
85
|
+
}
|
|
86
|
+
function validateEnumList(values, validValues, flagName) {
|
|
87
|
+
if (!values) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
for (const val of values) {
|
|
91
|
+
if (!validValues.includes(val)) {
|
|
92
|
+
throw new error_1.FirebaseError(`Invalid value '${val}' for '${flagName}'. Valid values are: ${validValues.join(", ")}.`, { exit: 1 });
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return values;
|
|
96
|
+
}
|
|
97
|
+
const ISO_DATE_ONLY = /^\d{4}-\d{2}-\d{2}$/;
|
|
98
|
+
const ISO_DATE_TIME_WITH_TZ = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})$/i;
|
|
99
|
+
function parseTimeOption(raw, flagName) {
|
|
100
|
+
const value = raw?.trim();
|
|
101
|
+
if (!value) {
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
const isDateOnly = ISO_DATE_ONLY.test(value);
|
|
105
|
+
const date = isDateOnly || ISO_DATE_TIME_WITH_TZ.test(value)
|
|
106
|
+
? new Date(isDateOnly ? `${value}T00:00:00Z` : value)
|
|
107
|
+
: undefined;
|
|
108
|
+
if (!date || isNaN(date.getTime())) {
|
|
109
|
+
throw new error_1.FirebaseError(`Invalid ${flagName} '${value}'. Use an ISO 8601 date or timestamp, ` +
|
|
110
|
+
`e.g. "2026-11-01" or "2026-11-01T08:00:00Z".`, { exit: 1 });
|
|
111
|
+
}
|
|
112
|
+
return date.toISOString();
|
|
113
|
+
}
|
|
114
|
+
function withEventFilterOptions(command) {
|
|
115
|
+
return command
|
|
116
|
+
.option("--issue-id <id>", "filter by Crashlytics issue ID")
|
|
117
|
+
.option("--variant-id <id>", "filter by issue variant ID (mobile only)")
|
|
118
|
+
.option("--versions <list>", 'comma-separated version display names (mobile: "2.4.0 (240)", web: "2.4.0")')
|
|
119
|
+
.option("--error-types <list>", "comma-separated error types: FATAL, NON_FATAL, ANR")
|
|
120
|
+
.option("--signals <list>", "comma-separated issue signals: SIGNAL_EARLY, SIGNAL_FRESH, SIGNAL_REGRESSED, SIGNAL_REPETITIVE (mobile only)")
|
|
121
|
+
.option("--os-names <list>", 'comma-separated operating system display names (e.g. "Android (14)")')
|
|
122
|
+
.option("--device-names <list>", 'comma-separated device display names (e.g. "Google (Pixel 8)", mobile only)')
|
|
123
|
+
.option("--device-form-factors <list>", "comma-separated device form factors: PHONE, TABLET, DESKTOP, TV, WATCH (mobile only)")
|
|
124
|
+
.option("--browser-names <list>", 'comma-separated browser display names (e.g. "Chrome (123)", web only)')
|
|
125
|
+
.option("--start-time <iso>", 'start of the time interval as an ISO 8601 date or timestamp (e.g. "2026-11-01" or "2026-11-01T08:00:00Z"); within the last 90 days, default: 7 days ago')
|
|
126
|
+
.option("--end-time <iso>", "end of the time interval as an ISO 8601 date or timestamp; requires --start-time (default: now)");
|
|
127
|
+
}
|
|
128
|
+
const MOBILE_ONLY_FLAGS = [
|
|
129
|
+
["variantId", "--variant-id"],
|
|
130
|
+
["signals", "--signals"],
|
|
131
|
+
["deviceNames", "--device-names"],
|
|
132
|
+
["deviceFormFactors", "--device-form-factors"],
|
|
133
|
+
];
|
|
134
|
+
const WEB_ONLY_FLAGS = [
|
|
135
|
+
["browserNames", "--browser-names"],
|
|
136
|
+
];
|
|
137
|
+
function validatePlatformSpecificFlags(options, appId) {
|
|
138
|
+
const platform = (0, utils_1.parseAppPlatform)(appId);
|
|
139
|
+
if (!platform) {
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
const isWeb = platform === apps_1.AppPlatform.WEB;
|
|
143
|
+
const used = (isWeb ? MOBILE_ONLY_FLAGS : WEB_ONLY_FLAGS)
|
|
144
|
+
.filter(([key]) => {
|
|
145
|
+
const value = options[key];
|
|
146
|
+
return typeof value === "string" && value.trim() !== "";
|
|
147
|
+
})
|
|
148
|
+
.map(([, flag]) => flag);
|
|
149
|
+
if (used.length > 0) {
|
|
150
|
+
throw new error_1.FirebaseError(`${used.join(", ")} ${used.length === 1 ? "is" : "are"} only supported for ` +
|
|
151
|
+
`${isWeb ? "Android and Apple" : "web"} apps, but ${appId} is ` +
|
|
152
|
+
`${isWeb ? "a web" : "an Android or Apple"} app.`, { exit: 1 });
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function parseEventFilters(options, appId) {
|
|
156
|
+
validatePlatformSpecificFlags(options, appId);
|
|
157
|
+
const intervalStartTime = parseTimeOption(options.startTime, "--start-time");
|
|
158
|
+
const intervalEndTime = parseTimeOption(options.endTime, "--end-time");
|
|
159
|
+
if (intervalStartTime && intervalEndTime && intervalStartTime >= intervalEndTime) {
|
|
160
|
+
throw new error_1.FirebaseError("'--start-time' must be before '--end-time'.", { exit: 1 });
|
|
161
|
+
}
|
|
162
|
+
if (intervalEndTime && !intervalStartTime) {
|
|
163
|
+
throw new error_1.FirebaseError("'--end-time' requires '--start-time'.", { exit: 1 });
|
|
164
|
+
}
|
|
165
|
+
const filter = {
|
|
166
|
+
intervalStartTime,
|
|
167
|
+
intervalEndTime,
|
|
168
|
+
versionDisplayNames: splitCommaSeparatedList(options.versions),
|
|
169
|
+
issueId: options.issueId?.trim() || undefined,
|
|
170
|
+
issueVariantId: options.variantId?.trim() || undefined,
|
|
171
|
+
issueErrorTypes: validateEnumList(splitCommaSeparatedList(options.errorTypes), exports.VALID_ERROR_TYPES, "--error-types"),
|
|
172
|
+
issueSignals: validateEnumList(splitCommaSeparatedList(options.signals), exports.VALID_SIGNALS, "--signals"),
|
|
173
|
+
operatingSystemDisplayNames: splitCommaSeparatedList(options.osNames),
|
|
174
|
+
deviceDisplayNames: splitCommaSeparatedList(options.deviceNames),
|
|
175
|
+
deviceFormFactors: validateEnumList(splitCommaSeparatedList(options.deviceFormFactors), exports.VALID_FORM_FACTORS, "--device-form-factors"),
|
|
176
|
+
browserFilterDisplayNames: splitCommaSeparatedList(options.browserNames),
|
|
177
|
+
};
|
|
178
|
+
try {
|
|
179
|
+
return (0, filters_1.validateEventFilters)(filter, appId);
|
|
180
|
+
}
|
|
181
|
+
catch (err) {
|
|
182
|
+
if (err instanceof error_1.FirebaseError) {
|
|
183
|
+
if (err.message.includes("topVersions report")) {
|
|
184
|
+
throw new error_1.FirebaseError(`--versions must match pattern 'version (build)' (e.g. "2.4.0 (240)"). Run 'firebase crashlytics:reports:get --app ${appId} topVersions' to list valid version display names.`, { exit: 1 });
|
|
185
|
+
}
|
|
186
|
+
const message = err.message
|
|
187
|
+
.replace("intervalStartTime must be less than 90 days in the past", "'--start-time' must be within the last 90 days")
|
|
188
|
+
.replace(/^deviceDisplayNames/, "--device-names")
|
|
189
|
+
.replace(/^operatingSystemDisplayNames/, "--os-names");
|
|
190
|
+
throw new error_1.FirebaseError(message, { exit: 1 });
|
|
191
|
+
}
|
|
192
|
+
throw err;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -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 escapeRegExp(value) {
|
|
41
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
42
|
+
}
|
|
43
|
+
function normalizeEventResourceName(appId, eventIdOrName) {
|
|
44
|
+
const trimmed = eventIdOrName.trim();
|
|
45
|
+
if (!trimmed) {
|
|
46
|
+
throw new error_1.FirebaseError("Event ID cannot be empty.");
|
|
47
|
+
}
|
|
48
|
+
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
49
|
+
const fullNamePattern = new RegExp(`^projects/[^/]+/apps/${escapeRegExp(appId)}/events/[^/]+$`);
|
|
50
|
+
if (fullNamePattern.test(trimmed)) {
|
|
51
|
+
return trimmed;
|
|
52
|
+
}
|
|
53
|
+
if (trimmed.includes("/")) {
|
|
54
|
+
throw new error_1.FirebaseError(`Invalid event resource name '${trimmed}'. Expected an event ID or 'projects/{project}/apps/${appId}/events/{event_id}'.`);
|
|
55
|
+
}
|
|
56
|
+
return `projects/${requestProjectNumber}/apps/${appId}/events/${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). For reports, only supported on web apps; check the report's usage to see whether it supports filter_expression.`);
|
|
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
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
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;
|
|
3
|
+
exports.DEFAULT_IAM_CONFIGURATION = 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;
|
|
5
4
|
exports.parseAndroidHashedId = parseAndroidHashedId;
|
|
6
5
|
exports.createBucketName = createBucketName;
|
|
7
6
|
exports.getCrashlyticsP4sa = getCrashlyticsP4sa;
|
|
7
|
+
exports.getCrashlyticsConsoleUrl = getCrashlyticsConsoleUrl;
|
|
8
|
+
exports.resolveAndroidApp = resolveAndroidApp;
|
|
8
9
|
exports.resolveAndroidAppId = resolveAndroidAppId;
|
|
9
10
|
exports.getProfilingManagerConfig = getProfilingManagerConfig;
|
|
10
11
|
exports.updateProfilingManagerConfig = updateProfilingManagerConfig;
|
|
@@ -12,22 +13,13 @@ exports.ensureHeapDumpStorageBucket = ensureHeapDumpStorageBucket;
|
|
|
12
13
|
exports.ensureHeapDumpP4saRole = ensureHeapDumpP4saRole;
|
|
13
14
|
exports.enableHeapDumpCollection = enableHeapDumpCollection;
|
|
14
15
|
exports.disableHeapDumpCollection = disableHeapDumpCollection;
|
|
15
|
-
const apiv2_1 = require("../apiv2");
|
|
16
|
-
const api_1 = require("../api");
|
|
17
16
|
const error_1 = require("../error");
|
|
18
17
|
const logger_1 = require("../logger");
|
|
19
18
|
const utils_1 = require("../utils");
|
|
20
19
|
const utils_2 = require("./utils");
|
|
21
20
|
const storage = require("../gcp/storage");
|
|
22
|
-
const resourceManager = require("../gcp/resourceManager");
|
|
23
21
|
const serviceusage = require("../gcp/serviceusage");
|
|
24
22
|
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
23
|
exports.CRASHLYTICS_SERVICE_NAME = "firebasecrashlytics.googleapis.com";
|
|
32
24
|
exports.STORAGE_OBJECT_CREATOR_ROLE = "roles/storage.objectCreator";
|
|
33
25
|
exports.HEAP_DUMP_BUCKET_PREFIX = "firebasecrashlytics-heap-dumps-";
|
|
@@ -47,7 +39,24 @@ exports.DEFAULT_LIFECYCLE_RULES = [
|
|
|
47
39
|
condition: { age: exports.DEFAULT_FILE_TTL_DAYS },
|
|
48
40
|
},
|
|
49
41
|
];
|
|
42
|
+
exports.DEFAULT_IAM_CONFIGURATION = {
|
|
43
|
+
publicAccessPrevention: "enforced",
|
|
44
|
+
uniformBucketLevelAccess: { enabled: true },
|
|
45
|
+
};
|
|
50
46
|
const ANDROID_APP_ID_REGEX = /^\d+:(\d+):android:([a-fA-F0-9]+)$/;
|
|
47
|
+
const GCS_BUCKET_RESOURCE_PREFIX = "projects/_/buckets/";
|
|
48
|
+
function isAndroidAppMetadata(app) {
|
|
49
|
+
return (app.platform === apps_1.AppPlatform.ANDROID &&
|
|
50
|
+
"packageName" in app &&
|
|
51
|
+
typeof app.packageName === "string");
|
|
52
|
+
}
|
|
53
|
+
function toResolvedAndroidApp(app) {
|
|
54
|
+
const packageName = isAndroidAppMetadata(app) ? app.packageName.trim() : "";
|
|
55
|
+
return {
|
|
56
|
+
appId: app.appId,
|
|
57
|
+
...(packageName ? { packageName } : {}),
|
|
58
|
+
};
|
|
59
|
+
}
|
|
51
60
|
function parseAndroidHashedId(appId) {
|
|
52
61
|
const match = ANDROID_APP_ID_REGEX.exec(appId);
|
|
53
62
|
if (!match) {
|
|
@@ -63,18 +72,33 @@ function createBucketName(appId) {
|
|
|
63
72
|
function getCrashlyticsP4sa(projectNumber) {
|
|
64
73
|
return `service-${projectNumber}@gcp-sa-crashlytics.iam.gserviceaccount.com`;
|
|
65
74
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
return
|
|
75
|
+
function getCrashlyticsConsoleUrl(projectId, packageName) {
|
|
76
|
+
const trimmedPackageName = packageName?.trim();
|
|
77
|
+
if (!trimmedPackageName) {
|
|
78
|
+
return (0, utils_1.consoleUrl)(projectId, "/crashlytics");
|
|
79
|
+
}
|
|
80
|
+
return (0, utils_1.consoleUrl)(projectId, `/crashlytics/app/android:${trimmedPackageName}/issues`);
|
|
81
|
+
}
|
|
82
|
+
async function resolveAndroidApp(projectId, options) {
|
|
83
|
+
const requestedAppId = options.app;
|
|
84
|
+
if (requestedAppId) {
|
|
85
|
+
parseAndroidHashedId(requestedAppId);
|
|
70
86
|
}
|
|
71
87
|
const apps = await (0, apps_1.listFirebaseApps)(projectId, apps_1.AppPlatform.ANDROID);
|
|
88
|
+
if (requestedAppId) {
|
|
89
|
+
const matchedApp = apps.find((app) => app.appId.toLowerCase() === requestedAppId.toLowerCase());
|
|
90
|
+
if (!matchedApp) {
|
|
91
|
+
throw new error_1.FirebaseError(`Android app '${requestedAppId}' was not found in project '${projectId}'. ` +
|
|
92
|
+
"Run 'firebase apps:list ANDROID' to view valid Android app IDs for your project.", { exit: 1 });
|
|
93
|
+
}
|
|
94
|
+
return toResolvedAndroidApp(matchedApp);
|
|
95
|
+
}
|
|
72
96
|
if (apps.length === 0) {
|
|
73
97
|
throw new error_1.FirebaseError(`No Android apps found in project '${projectId}'. Heap dump collection is only supported for Android apps.\n` +
|
|
74
98
|
"You can register an Android app using 'firebase apps:create ANDROID <package-name>'");
|
|
75
99
|
}
|
|
76
100
|
if (apps.length === 1) {
|
|
77
|
-
return apps[0]
|
|
101
|
+
return toResolvedAndroidApp(apps[0]);
|
|
78
102
|
}
|
|
79
103
|
if (options.nonInteractive) {
|
|
80
104
|
throw new error_1.FirebaseError(`Project '${projectId}' has multiple Android apps. Please specify an app ID with '--app <appID>'.`);
|
|
@@ -82,42 +106,36 @@ async function resolveAndroidAppId(projectId, options) {
|
|
|
82
106
|
const selectedApp = await (0, apps_1.selectAppInteractively)(apps, apps_1.AppPlatform.ANDROID, {
|
|
83
107
|
message: "Select an Android app:",
|
|
84
108
|
});
|
|
85
|
-
return selectedApp
|
|
109
|
+
return toResolvedAndroidApp(selectedApp);
|
|
110
|
+
}
|
|
111
|
+
async function resolveAndroidAppId(projectId, options) {
|
|
112
|
+
const app = await resolveAndroidApp(projectId, options);
|
|
113
|
+
return app.appId;
|
|
86
114
|
}
|
|
87
115
|
async function getProfilingManagerConfig(appId) {
|
|
88
116
|
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
89
117
|
logger_1.logger.debug(`[crashlytics] getProfilingManagerConfig called with appId: ${appId}`);
|
|
90
|
-
const response = await
|
|
118
|
+
const response = await utils_2.CRASHLYTICS_API_CLIENT.request({
|
|
91
119
|
method: "GET",
|
|
92
120
|
headers: {
|
|
93
121
|
"Content-Type": "application/json",
|
|
94
122
|
},
|
|
95
|
-
path: `/projects/${projectNumber}/apps/${appId}/
|
|
123
|
+
path: `/projects/${projectNumber}/apps/${appId}/profilingManagerConfig`,
|
|
96
124
|
timeout: utils_2.TIMEOUT,
|
|
97
125
|
});
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
gcsBucket: config.gcsBucket || "",
|
|
101
|
-
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
102
|
-
};
|
|
126
|
+
return response.body;
|
|
103
127
|
}
|
|
104
|
-
async function updateProfilingManagerConfig(appId, config) {
|
|
128
|
+
async function updateProfilingManagerConfig(appId, config, updateMask) {
|
|
105
129
|
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: "
|
|
130
|
+
logger_1.logger.debug(`[crashlytics] updateProfilingManagerConfig called with appId: ${appId}, config: ${JSON.stringify(config)}, updateMask: ${updateMask}`);
|
|
131
|
+
await utils_2.CRASHLYTICS_API_CLIENT.request({
|
|
132
|
+
method: "PATCH",
|
|
109
133
|
headers: {
|
|
110
134
|
"Content-Type": "application/json",
|
|
111
135
|
},
|
|
112
|
-
path: `/projects/${projectNumber}/apps/${appId}/
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
gmpAppId: appId,
|
|
116
|
-
configuration: {
|
|
117
|
-
gcsBucket: config.gcsBucket ?? "",
|
|
118
|
-
heapDumpCollectionEnabled: config.heapDumpCollectionEnabled ?? false,
|
|
119
|
-
},
|
|
120
|
-
},
|
|
136
|
+
path: `/projects/${projectNumber}/apps/${appId}/profilingManagerConfig`,
|
|
137
|
+
queryParams: { updateMask },
|
|
138
|
+
body: config,
|
|
121
139
|
timeout: utils_2.TIMEOUT,
|
|
122
140
|
});
|
|
123
141
|
}
|
|
@@ -129,6 +147,9 @@ async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.
|
|
|
129
147
|
if (bucket.projectNumber && String(bucket.projectNumber) !== projectNumber) {
|
|
130
148
|
throw new error_1.FirebaseError(`Cloud Storage bucket '${bucketName}' already exists and is owned by another project.`);
|
|
131
149
|
}
|
|
150
|
+
if (bucket.location && bucket.location.trim().toLowerCase() !== location.trim().toLowerCase()) {
|
|
151
|
+
(0, utils_1.logLabeledWarning)("crashlytics", `Cloud Storage bucket '${bucketName}' already exists in ${bucket.location}; its location cannot be changed to '${location}' and will remain ${bucket.location}.`);
|
|
152
|
+
}
|
|
132
153
|
const patchPayload = {};
|
|
133
154
|
const hasConsoleCors = bucket.cors?.some((rule) => exports.DEFAULT_CORS_ORIGINS.every((origin) => rule.origin?.includes(origin)));
|
|
134
155
|
if (!hasConsoleCors) {
|
|
@@ -140,6 +161,14 @@ async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.
|
|
|
140
161
|
rule: [...(bucket.lifecycle?.rule ?? []), ...exports.DEFAULT_LIFECYCLE_RULES],
|
|
141
162
|
};
|
|
142
163
|
}
|
|
164
|
+
const needsUbla = !bucket.iamConfiguration?.uniformBucketLevelAccess?.enabled;
|
|
165
|
+
const needsPap = bucket.iamConfiguration?.publicAccessPrevention !== "enforced";
|
|
166
|
+
if (needsUbla || needsPap) {
|
|
167
|
+
patchPayload.iamConfiguration = {
|
|
168
|
+
...(needsPap ? { publicAccessPrevention: "enforced" } : {}),
|
|
169
|
+
...(needsUbla ? { uniformBucketLevelAccess: { enabled: true } } : {}),
|
|
170
|
+
};
|
|
171
|
+
}
|
|
143
172
|
if (Object.keys(patchPayload).length > 0) {
|
|
144
173
|
logger_1.logger.debug(`[crashlytics] Bucket ${bucketName} found without full configuration. Patching ${Object.keys(patchPayload).join(", ")}.`);
|
|
145
174
|
await storage.patchBucket(bucketName, patchPayload);
|
|
@@ -158,38 +187,36 @@ async function ensureHeapDumpStorageBucket(projectId, appId, location = exports.
|
|
|
158
187
|
location,
|
|
159
188
|
cors: exports.DEFAULT_CORS_RULES,
|
|
160
189
|
lifecycle: { rule: exports.DEFAULT_LIFECYCLE_RULES },
|
|
161
|
-
|
|
190
|
+
iamConfiguration: exports.DEFAULT_IAM_CONFIGURATION,
|
|
191
|
+
});
|
|
162
192
|
return bucketName;
|
|
163
193
|
}
|
|
164
|
-
async function ensureHeapDumpP4saRole(
|
|
194
|
+
async function ensureHeapDumpP4saRole(projectNumber, bucketName) {
|
|
165
195
|
await serviceusage.generateServiceIdentityAndPoll(projectNumber, exports.CRASHLYTICS_SERVICE_NAME, "crashlytics");
|
|
166
196
|
const p4saEmail = getCrashlyticsP4sa(projectNumber);
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
197
|
+
logger_1.logger.debug(`[crashlytics] Ensuring ${exports.STORAGE_OBJECT_CREATOR_ROLE} on bucket ${bucketName} for ${p4saEmail}...`);
|
|
198
|
+
await storage.addServiceAccountToBucketRoles(bucketName, p4saEmail, [
|
|
199
|
+
exports.STORAGE_OBJECT_CREATOR_ROLE,
|
|
200
|
+
]);
|
|
172
201
|
}
|
|
173
202
|
async function enableHeapDumpCollection(projectId, appId, location = exports.DEFAULT_BUCKET_LOCATION) {
|
|
174
203
|
const projectNumber = (0, utils_2.parseProjectNumber)(appId);
|
|
175
204
|
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring Google Cloud Storage bucket...");
|
|
176
205
|
const bucketName = await ensureHeapDumpStorageBucket(projectId, appId, location);
|
|
177
206
|
(0, utils_1.logLabeledBullet)("crashlytics", "Configuring service agent permissions...");
|
|
178
|
-
await ensureHeapDumpP4saRole(
|
|
207
|
+
await ensureHeapDumpP4saRole(projectNumber, bucketName);
|
|
179
208
|
(0, utils_1.logLabeledBullet)("crashlytics", "Enabling Crashlytics heap dump collection...");
|
|
180
209
|
await updateProfilingManagerConfig(appId, {
|
|
181
|
-
|
|
210
|
+
bucket: `${GCS_BUCKET_RESOURCE_PREFIX}${bucketName}`,
|
|
182
211
|
heapDumpCollectionEnabled: true,
|
|
183
|
-
});
|
|
212
|
+
}, "bucket,heapDumpCollectionEnabled");
|
|
184
213
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully enabled Crashlytics heap dump collection!");
|
|
185
214
|
return bucketName;
|
|
186
215
|
}
|
|
187
216
|
async function disableHeapDumpCollection(appId) {
|
|
188
217
|
(0, utils_1.logLabeledBullet)("crashlytics", "Disabling Crashlytics heap dump collection...");
|
|
189
|
-
const currentConfig = await getProfilingManagerConfig(appId);
|
|
190
218
|
await updateProfilingManagerConfig(appId, {
|
|
191
|
-
gcsBucket: currentConfig.gcsBucket,
|
|
192
219
|
heapDumpCollectionEnabled: false,
|
|
193
|
-
});
|
|
220
|
+
}, "heapDumpCollectionEnabled");
|
|
194
221
|
(0, utils_1.logLabeledSuccess)("crashlytics", "Successfully disabled Crashlytics heap dump collection!");
|
|
195
222
|
}
|
|
@@ -21,6 +21,7 @@ exports.ReportInputSchema = zod_1.z.object({
|
|
|
21
21
|
appId: filters_1.ApplicationIdSchema,
|
|
22
22
|
report: exports.CrashlyticsReportSchema,
|
|
23
23
|
filter: filters_1.EventFilterSchema,
|
|
24
|
+
filterExpression: filters_1.FilterExpressionSchema,
|
|
24
25
|
pageSize: zod_1.z.number().optional().describe("Number of rows to return").default(DEFAULT_PAGE_SIZE),
|
|
25
26
|
granularity: exports.TimeGranularitySchema,
|
|
26
27
|
});
|
|
@@ -60,7 +61,7 @@ async function listReports(appId) {
|
|
|
60
61
|
(_a = response.body).reports ?? (_a.reports = []);
|
|
61
62
|
return response.body;
|
|
62
63
|
}
|
|
63
|
-
async function getReport(reportName, appId, filter, pageSize = DEFAULT_PAGE_SIZE, granularity) {
|
|
64
|
+
async function getReport(reportName, appId, filter, pageSize = DEFAULT_PAGE_SIZE, granularity, filterExpression) {
|
|
64
65
|
const requestProjectNumber = (0, utils_1.parseProjectNumber)(appId);
|
|
65
66
|
let availableReports = exports.reportsCache.get(appId);
|
|
66
67
|
if (!availableReports) {
|
|
@@ -84,6 +85,9 @@ async function getReport(reportName, appId, filter, pageSize = DEFAULT_PAGE_SIZE
|
|
|
84
85
|
if (granularity) {
|
|
85
86
|
queryParams.set("granularity", granularity);
|
|
86
87
|
}
|
|
88
|
+
if (filterExpression) {
|
|
89
|
+
queryParams.set("filter_expression", filterExpression);
|
|
90
|
+
}
|
|
87
91
|
logger_1.logger.debug(`[crashlytics] report ${reportName} called with appId: ${appId} filter: ${queryParams.toString()}, page_size: ${pageSize}`);
|
|
88
92
|
const response = await utils_1.CRASHLYTICS_API_CLIENT.request({
|
|
89
93
|
method: "GET",
|