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.
Files changed (126) hide show
  1. package/lib/api.js +2 -4
  2. package/lib/appcheck/debugTokens.js +293 -0
  3. package/lib/appcheck/localConfig.js +191 -0
  4. package/lib/appdistribution/options-parser-util.js +1 -1
  5. package/lib/apphosting/constants.js +1 -4
  6. package/lib/apphosting/githubConnections.js +1 -1
  7. package/lib/apphosting/utils.js +0 -26
  8. package/lib/auth.js +8 -2
  9. package/lib/commands/appcheck-debugtokens-create.js +60 -35
  10. package/lib/commands/appcheck-debugtokens-delete.js +21 -7
  11. package/lib/commands/appcheck-debugtokens-list.js +37 -8
  12. package/lib/commands/appcheck-debugtokens-prune.js +59 -0
  13. package/lib/commands/crashlytics-heapdumps-status.js +1 -1
  14. package/lib/commands/{crashlytics-onboard-web.js → crashlytics-setup.js} +5 -5
  15. package/lib/commands/crashlytics-sourcemap-upload.js +4 -0
  16. package/lib/commands/deploy.js +1 -3
  17. package/lib/commands/emulators-start.js +2 -2
  18. package/lib/commands/hosting-channel-create.js +1 -3
  19. package/lib/commands/hosting-channel-delete.js +1 -3
  20. package/lib/commands/hosting-channel-deploy.js +1 -3
  21. package/lib/commands/hosting-channel-list.js +1 -3
  22. package/lib/commands/hosting-channel-open.js +1 -3
  23. package/lib/commands/hosting-clone.js +3 -5
  24. package/lib/commands/hosting-disable.js +2 -2
  25. package/lib/commands/hosting-sites-create.js +1 -3
  26. package/lib/commands/hosting-sites-delete.js +1 -3
  27. package/lib/commands/hosting-sites-get.js +1 -3
  28. package/lib/commands/hosting-sites-list.js +1 -3
  29. package/lib/commands/index.js +4 -2
  30. package/lib/commands/run-services-get.js +19 -0
  31. package/lib/commands/run-services-list.js +11 -0
  32. package/lib/crashlytics/alerts.js +1 -0
  33. package/lib/crashlytics/events.js +122 -1
  34. package/lib/crashlytics/filters.js +12 -6
  35. package/lib/crashlytics/firebasetelemetry.js +5 -3
  36. package/lib/crashlytics/onboarding.js +8 -7
  37. package/lib/crashlytics/profilingManager.js +14 -34
  38. package/lib/crashlytics/reports.js +46 -17
  39. package/lib/crashlytics/sourcemap.js +19 -5
  40. package/lib/crashlytics/utils.js +14 -0
  41. package/lib/database/import.js +5 -4
  42. package/lib/dataconnect/dataplaneClient.js +0 -10
  43. package/lib/dataconnect/names.js +3 -3
  44. package/lib/dataconnect/schemaMigration.js +1 -1
  45. package/lib/deploy/apphosting/deploy.js +20 -41
  46. package/lib/deploy/apphosting/localBuild.js +49 -0
  47. package/lib/deploy/apphosting/prepare.js +12 -25
  48. package/lib/deploy/apphosting/release.js +1 -1
  49. package/lib/deploy/apphosting/util.js +27 -4
  50. package/lib/deploy/functions/backend.js +0 -10
  51. package/lib/deploy/functions/cel.js +1 -1
  52. package/lib/deploy/functions/containerCleaner.js +1 -142
  53. package/lib/deploy/functions/functionsDeployHelper.js +0 -4
  54. package/lib/deploy/functions/release/reporter.js +0 -26
  55. package/lib/deploy/functions/runtimes/discovery/index.js +4 -1
  56. package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +1 -1
  57. package/lib/deploy/functions/services/index.js +13 -11
  58. package/lib/deploy/functions/validate.js +1 -1
  59. package/lib/deploy/hosting/prepare.js +1 -3
  60. package/lib/deploy/lifecycleHooks.js +1 -1
  61. package/lib/deploy/run/deploy.js +26 -43
  62. package/lib/deploy/run/get.js +30 -0
  63. package/lib/deploy/run/list.js +38 -0
  64. package/lib/deploy/run/prereqs.js +0 -3
  65. package/lib/deploy/run/util.js +9 -0
  66. package/lib/emulator/auth/operations.js +2 -2
  67. package/lib/emulator/auth/server.js +4 -2
  68. package/lib/emulator/auth/widget_ui.js +1 -1
  69. package/lib/emulator/commandUtils.js +109 -24
  70. package/lib/emulator/databaseEmulator.js +16 -11
  71. package/lib/emulator/dataconnect/pgliteServer.js +31 -24
  72. package/lib/emulator/downloadableEmulatorInfo.json +24 -24
  73. package/lib/emulator/downloadableEmulators.js +45 -7
  74. package/lib/emulator/extensions/postinstall.js +6 -6
  75. package/lib/emulator/firestoreEmulator.js +21 -15
  76. package/lib/emulator/functionsEmulator.js +11 -7
  77. package/lib/emulator/functionsEmulatorRuntime.js +7 -2
  78. package/lib/emulator/hub.js +12 -8
  79. package/lib/emulator/shared/express.js +30 -0
  80. package/lib/emulator/storage/apis/firebase.js +11 -10
  81. package/lib/emulator/storage/apis/gcloud.js +21 -20
  82. package/lib/emulator/storage/files.js +1 -1
  83. package/lib/emulator/storage/rules/manager.js +15 -12
  84. package/lib/emulator/storage/rules/runtime.js +1 -0
  85. package/lib/emulator/storage/server.js +10 -5
  86. package/lib/extensions/extensionsApi.js +0 -8
  87. package/lib/extensions/extensionsHelper.js +3 -24
  88. package/lib/extensions/paramHelper.js +1 -1
  89. package/lib/extensions/provisioningHelper.js +1 -6
  90. package/lib/extensions/secretsUtils.js +0 -24
  91. package/lib/firestore/util.js +3 -3
  92. package/lib/frameworks/angular/utils.js +1 -1
  93. package/lib/frameworks/next/utils.js +1 -12
  94. package/lib/fsAsync.js +34 -20
  95. package/lib/functions/kits/install.js +233 -628
  96. package/lib/functions/kits/sources/directory.js +91 -0
  97. package/lib/functions/kits/sources/npm.js +324 -0
  98. package/lib/functions/kits/sources/types.js +12 -0
  99. package/lib/functionsConfig.js +0 -4
  100. package/lib/functionsShellCommandAction.js +1 -1
  101. package/lib/gcp/artifactregistry.js +0 -5
  102. package/lib/gcp/cloudfunctionsv2.js +0 -6
  103. package/lib/gcp/devConnect.js +2 -2
  104. package/lib/gcp/iam.js +0 -4
  105. package/lib/gcp/pubsub.js +0 -14
  106. package/lib/gcp/storage.js +2 -1
  107. package/lib/hosting/api.js +79 -0
  108. package/lib/hosting/proxy.js +4 -1
  109. package/lib/init/features/hosting/github.js +6 -4
  110. package/lib/init/features/hosting/index.js +4 -0
  111. package/lib/init/features/run.js +3 -7
  112. package/lib/mcp/apps/init/mcp-app.js +4 -1
  113. package/lib/mcp/index.js +8 -2
  114. package/lib/mcp/prompts/apptesting/run_test.js +3 -3
  115. package/lib/mcp/prompts/core/deploy.js +3 -3
  116. package/lib/mcp/resources/guides/crashlytics_reports.js +33 -71
  117. package/lib/mcp/resources/guides/init_ai.js +10 -10
  118. package/lib/mcp/tools/crashlytics/events.js +18 -93
  119. package/lib/mcp/tools/crashlytics/index.js +2 -0
  120. package/lib/mcp/tools/crashlytics/reports.js +26 -31
  121. package/lib/mcp/tools/crashlytics/setup.js +392 -0
  122. package/lib/tsconfig.compile.tsbuildinfo +1 -1
  123. package/lib/tsconfig.publish.tsbuildinfo +1 -1
  124. package/lib/utils.js +4 -10
  125. package/package.json +1 -2
  126. package/lib/deploy/hosting/args.js +0 -2
@@ -27,7 +27,7 @@ function makeVary(vary = "") {
27
27
  return varies.join(", ");
28
28
  }
29
29
  function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
30
- return async (req, res, next) => {
30
+ const handle = async (req, res, next) => {
31
31
  logger_1.logger.info(`[hosting] Rewriting ${req.url} to ${url} for ${rewriteIdentifier}`);
32
32
  const cookie = req.headers.cookie || "";
33
33
  const sessionCookie = cookie.split(/; ?/).find((c) => {
@@ -164,6 +164,9 @@ function proxyRequestHandler(url, rewriteIdentifier, options = {}) {
164
164
  res.statusCode = proxyRes.status;
165
165
  proxyRes.body.pipe(res);
166
166
  };
167
+ return (req, res, next) => {
168
+ void handle(req, res, next).catch(next);
169
+ };
167
170
  }
168
171
  function errorRequestHandler(error) {
169
172
  return (req, res) => {
@@ -11,10 +11,11 @@ const auth_1 = require("../../../auth");
11
11
  const fsutils_1 = require("../../../fsutils");
12
12
  const iam_1 = require("../../../gcp/iam");
13
13
  const resourceManager_1 = require("../../../gcp/resourceManager");
14
+ const api_1 = require("../../../hosting/api");
14
15
  const logger_1 = require("../../../logger");
15
16
  const prompt_1 = require("../../../prompt");
16
17
  const utils_1 = require("../../../utils");
17
- const api_1 = require("../../../api");
18
+ const api_2 = require("../../../api");
18
19
  const apiv2_1 = require("../../../apiv2");
19
20
  const error_1 = require("../../../error");
20
21
  let GIT_DIR;
@@ -27,7 +28,7 @@ const YML_MERGE_FILENAME = "firebase-hosting-merge.yml";
27
28
  const CHECKOUT_GITHUB_ACTION_NAME = "actions/checkout@v4";
28
29
  const HOSTING_GITHUB_ACTION_NAME = "FirebaseExtended/action-hosting-deploy@v0";
29
30
  const SERVICE_ACCOUNT_MAX_KEY_NUMBER = 10;
30
- const githubApiClient = new apiv2_1.Client({ urlPrefix: (0, api_1.githubApiOrigin)(), auth: false });
31
+ const githubApiClient = new apiv2_1.Client({ urlPrefix: (0, api_2.githubApiOrigin)(), auth: false });
31
32
  async function initGitHub(setup) {
32
33
  if (!setup.projectId) {
33
34
  return (0, utils_1.reject)("Could not determine Project ID, can't set up GitHub workflow.", { exit: 1 });
@@ -35,6 +36,7 @@ async function initGitHub(setup) {
35
36
  if (!setup.config.hosting && !setup.featureInfo?.hosting) {
36
37
  return (0, utils_1.reject)(`Didn't find a Hosting config in firebase.json. Run ${(0, colorette_1.bold)("firebase init hosting")} instead.`);
37
38
  }
39
+ await (0, api_1.ensureApiEnabled)(setup.projectId);
38
40
  logger_1.logger.info();
39
41
  const gitRoot = getGitFolderPath();
40
42
  GIT_DIR = path.join(gitRoot, ".git");
@@ -107,7 +109,7 @@ async function initGitHub(setup) {
107
109
  }
108
110
  logger_1.logger.info();
109
111
  (0, utils_1.logLabeledBullet)("Action required", `Visit this URL to revoke authorization for the Firebase CLI GitHub OAuth App:`);
110
- logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${(0, api_1.githubClientId)()}`)));
112
+ logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${(0, api_2.githubClientId)()}`)));
111
113
  (0, utils_1.logLabeledBullet)("Action required", `Push any new workflow file(s) to your repo`);
112
114
  }
113
115
  function getGitFolderPath() {
@@ -277,7 +279,7 @@ async function promptForRepo(options, ghAccessToken) {
277
279
  (0, utils_1.logWarning)("The provided authorization cannot be used with this repository. If this repository is in an organization, did you remember to grant access?", "error");
278
280
  logger_1.logger.info();
279
281
  (0, utils_1.logLabeledBullet)("Action required", `Visit this URL to ensure access has been granted to the appropriate organization(s) for the Firebase CLI GitHub OAuth App:`);
280
- logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${(0, api_1.githubClientId)()}`)));
282
+ logger_1.logger.info((0, colorette_1.bold)((0, colorette_1.underline)(`https://github.com/settings/connections/applications/${(0, api_2.githubClientId)()}`)));
281
283
  logger_1.logger.info();
282
284
  }
283
285
  return false;
@@ -69,6 +69,7 @@ async function askQuestions(setup, config, options) {
69
69
  setup.featureInfo = setup.featureInfo || {};
70
70
  setup.featureInfo.hosting = {};
71
71
  if (setup.projectId) {
72
+ await (0, api_1.ensureApiEnabled)(setup.projectId);
72
73
  let hasHostingSite = true;
73
74
  try {
74
75
  await (0, getDefaultHostingSite_1.getDefaultHostingSite)({ projectId: setup.projectId });
@@ -113,6 +114,9 @@ async function actuate(setup, config, options) {
113
114
  if (hostingInfo.redirectToAppHosting) {
114
115
  return;
115
116
  }
117
+ if (setup.projectId) {
118
+ await (0, api_1.ensureApiEnabled)(setup.projectId);
119
+ }
116
120
  if (hostingInfo.newSiteId && setup.projectId) {
117
121
  await (0, api_1.createSite)(setup.projectId, hostingInfo.newSiteId);
118
122
  logger_1.logger.info();
@@ -40,7 +40,7 @@ async function askQuestions(setup, config, options) {
40
40
  let serviceId;
41
41
  let region;
42
42
  if (existing) {
43
- ({ region, serviceId } = parseServiceName(existing.name));
43
+ ({ region, serviceId } = (0, util_1.parseServiceName)(existing.name));
44
44
  }
45
45
  else {
46
46
  region = await (0, prompt_1.select)({
@@ -101,13 +101,13 @@ async function promptWebApp(projectId) {
101
101
  }
102
102
  async function promptExistingService(projectId) {
103
103
  const allServices = await runv2.listServices(projectId, false);
104
- const services = allServices.filter((s) => !s.labels?.[runv2.CLIENT_NAME_LABEL]);
104
+ const services = allServices.filter((s) => !(0, util_1.isManagedByAnotherProduct)(s));
105
105
  if (services.length === 0) {
106
106
  (0, utils_1.logBullet)("No Cloud Run services to update. Creating a new service instead.");
107
107
  return undefined;
108
108
  }
109
109
  const choices = services.map((service) => {
110
- const { serviceId, region } = parseServiceName(service.name);
110
+ const { serviceId, region } = (0, util_1.parseServiceName)(service.name);
111
111
  return { name: `${serviceId} (${region})`, value: service };
112
112
  });
113
113
  return (0, prompt_1.select)({
@@ -115,10 +115,6 @@ async function promptExistingService(projectId) {
115
115
  choices,
116
116
  });
117
117
  }
118
- function parseServiceName(name) {
119
- const parts = name.split("/");
120
- return { region: parts[3], serviceId: parts[5] };
121
- }
122
118
  async function promptNewServiceId(projectId, region) {
123
119
  return (0, prompt_1.input)({
124
120
  message: "Please enter a unique ID for your service",
@@ -87,7 +87,7 @@ googleCheckbox.addEventListener("change", (e) => {
87
87
  googleFields.classList.remove("active");
88
88
  }
89
89
  });
90
- initBtn.addEventListener("click", async () => {
90
+ async function onInitClick() {
91
91
  const selectedProduct = Array.from(productRadios).find((r) => r.checked)?.value;
92
92
  if (!selectedProjectId) {
93
93
  setStatus("Please select a project first.", "error");
@@ -158,6 +158,9 @@ initBtn.addEventListener("click", async () => {
158
158
  initBtn.disabled = false;
159
159
  initBtn.textContent = "Initialize";
160
160
  }
161
+ }
162
+ initBtn.addEventListener("click", () => {
163
+ void onInitClick();
161
164
  });
162
165
  app.onhostcontextchanged = (ctx) => {
163
166
  if (ctx.theme)
package/lib/mcp/index.js CHANGED
@@ -409,7 +409,7 @@ class FirebaseMcpServer {
409
409
  app.use(cors());
410
410
  const port = options.port || 3000;
411
411
  const transports = {};
412
- app.get("/sse", async (req, res) => {
412
+ const handleSse = async (req, res) => {
413
413
  this.logger.debug(`[SSE] GET /sse connection attempt from ${req.ip}`);
414
414
  try {
415
415
  const transport = new sse_js_1.SSEServerTransport("/message", res);
@@ -429,8 +429,11 @@ class FirebaseMcpServer {
429
429
  catch (err) {
430
430
  this.logger.error(`[SSE] Connection error: ${err}`);
431
431
  }
432
+ };
433
+ app.get("/sse", (req, res) => {
434
+ void handleSse(req, res);
432
435
  });
433
- app.post("/message", async (req, res) => {
436
+ const handleMessage = async (req, res) => {
434
437
  const sessionId = req.query.sessionId;
435
438
  this.logger.debug(`[SSE] POST /message attempt for session ${sessionId}`);
436
439
  const transport = transports[sessionId];
@@ -447,6 +450,9 @@ class FirebaseMcpServer {
447
450
  this.logger.error(`[SSE] Rejecting message: No active transport found for session ${sessionId}`);
448
451
  res.status(400).send("No active SSE transport connection found for this session");
449
452
  }
453
+ };
454
+ app.post("/message", (req, res) => {
455
+ void handleMessage(req, res);
450
456
  });
451
457
  app.listen(port, "127.0.0.1", () => {
452
458
  this.logger.info(`MCP Server running on HTTP/SSE mode at http://127.0.0.1:${port}`);
@@ -112,14 +112,14 @@ Here are a list of prerequisite steps that must be completed before running a te
112
112
  devices.
113
113
 
114
114
  Once the test has started, provide the developer a link to see the results of the test in the Firebase Console.
115
- You should already know the value of \`appId\' and \`projectId\` from earlier (if you only know \`projectNumber\',
115
+ You should already know the value of \`appId\` and \`projectId\` from earlier (if you only know \`projectNumber\`,
116
116
  use the \`firebase_get_project\` tool to get \`projectId\`). \`packageName\` is the package name of the app we tested.
117
117
  The \`apptesting_run_test\` tool returns a response with field \`name\` in the form
118
- projects/{projectNumber}/apps/{appId}/releases/{releaseId}/tests/{releaseTestId}. Extract the values for \'releaseId\'
118
+ projects/{projectNumber}/apps/{appId}/releases/{releaseId}/tests/{releaseTestId}. Extract the values for \`releaseId\`
119
119
  and \`releaseTestId\` and use provide a link to the results in the Firebase Console in the format:
120
120
  \`https://console.firebase.google.com/u/0/project/{projectId}/apptesting/app/android:{packageName}/releases/{releaseId}/tests/{releaseTestId}\`.
121
121
 
122
- You can check the status of the test using the \`apptesting_check_status\` tool with \`release_test_name\' set to
122
+ You can check the status of the test using the \`apptesting_check_status\` tool with \`release_test_name\` set to
123
123
  the name of the release test returned by the \`run_test\` tool.
124
124
  `.trim(),
125
125
  },
@@ -79,12 +79,12 @@ Follow the steps below taking note of any user instructions provided above.
79
79
  Example (No): "No, there are no dependencies or file structures that indicate the use of a server-side rendering framework."
80
80
  4. If there is no \`firebase.json\` file, manually create one based on whether the app requires SSR:
81
81
  4a. If the app requires SSR, configure Firebase App Hosting:
82
- Create \`firebase.json\ with an "apphosting" configuration, setting backendId to the app's name in package.json: \`{"apphosting": {"backendId": "<backendId>"}}\
82
+ Create \`firebase.json\` with an "apphosting" configuration, setting backendId to the app's name in package.json: \`{"apphosting": {"backendId": "<backendId>"}}\`
83
83
  4b. If the app does NOT require SSR, configure Firebase Hosting:
84
- Create \`firebase.json\ with a "hosting" configuration. Add a \`{"hosting": {"predeploy": "<build_script>"}}\` config to build before deploying.
84
+ Create \`firebase.json\` with a "hosting" configuration. Add a \`{"hosting": {"predeploy": "<build_script>"}}\` config to build before deploying.
85
85
  5. Check if there is an active Firebase project for this environment (the \`firebase_get_environment\` tool may be helpful). If there is, provide the active project ID to the user and ask them if they want to proceed using that project. If there is not an active project, give the user two options: Provide an existing project ID or create a new project. Only use the list_projects tool on user request. Wait for their response before proceeding.
86
86
  5a. If the user chooses to use an existing Firebase project, the \`firebase_list_projects\` tool may be helpful. Set the selected project as the active project (the \`firebase_update_environment\` tool may be helpful).
87
- 5b. If the user chooses to create a new project, use the \`firebase_create_project \` tool. Then set the new project as the active project (the \`firebase_update_environment\` tool may be helpful).
87
+ 5b. If the user chooses to create a new project, use the \`firebase_create_project\` tool. Then set the new project as the active project (the \`firebase_update_environment\` tool may be helpful).
88
88
  6. If firebase.json contains an "apphosting" configuration, check if a backend exists matching the provided backendId (the \`apphosting_list_backends\` tool may be helpful).
89
89
  If it doesn't exist, create one by running the \`${firebaseCliCommand} apphosting:backends:create --backend <backendId> --primary-region us-central1 --root-dir .\` shell.
90
90
  7. Only after making sure Firebase has been initialized, run the \`${firebaseCliCommand} deploy\` shell command to perform the deploy. This may take a few minutes.
@@ -5,74 +5,36 @@ const resource_1 = require("../../resource");
5
5
  const RESOURCE_CONTENT = `
6
6
  ### Crashlytics Reports
7
7
 
8
- Aggregate metrics for all of the events sent to Crashlytics are available as reports.
9
- The following reports are available for all Crashlytics applications.
10
-
11
- - name: "topIssues"
12
- display_name: "Top Issues"
13
- usage: |
14
- Counts events and distinct impacted users, grouped by issue.
15
- Issue groups are sorted by event count, in descending order.
16
-
17
- - name: "topVersions"
18
- display_name: "Top Versions"
19
- usage: |
20
- Counts events, grouped by app version.
21
- Versions are sorted by event count, in descending order.
22
-
23
- - name: "topOperatingSystems"
24
- display_name: "Top Operating Systems"
25
- usage: |
26
- Counts events, grouped by device operating systems and their versions.
27
- Operating systems are sorted by event count, in descending order.
28
-
29
- Mobile apps have the following report available:
30
-
31
- - name: "topVariants"
32
- display_name: "Top Variants"
33
- usage: |
34
- Counts events and distinct impacted users, grouped by issue variant.
35
- Issue variant groups are sorted by event count, in descending order.
36
- required: |
37
- An issue filter including an issue id is required.
38
-
39
- Mobile apps also have one of the following reports available, depending on the platform.
40
-
41
- - name: "topAndroidDevices"
42
- display_name: "Top Android Devices"
43
- usage: |
44
- Counts events, grouped by android device.
45
- Devices are sorted by event count, in descending order.
46
-
47
- - name: "topAppleDevices"
48
- display_name: "Top Apple Devices"
49
- usage:
50
- Counts events, grouped by operating system and Apple device.
51
- Devices are sorted by event count, in descending order.
52
-
53
- Web apps have the following additional reports available.
54
-
55
- - name: "topBrowsers"
56
- display_name: "Top Browsers"
57
- usage: |
58
- Counts events, grouped by browser.
59
- Browsers are sorted by event count, in descending order.
60
- required: |
61
- An issue filter including an issue id is required.
62
-
63
- - name: "webMetrics"
64
- display_name: "Web Metrics"
65
- usage: |
66
- Counts events and distinct impacted users, grouped by error type.
67
- Error types are sorted by event count, in descending order.
8
+ Aggregate metrics for all of the events sent to Crashlytics are available as reports.
9
+
10
+ ### Useful Reports
11
+
12
+ * The "appSummary" report provides overall app health metrics, including crash-free users and crash-free sessions percentages.
13
+ Combine it with \`granularity\` (such as \`TIME_GRANULARITY_DAY\` or \`TIME_GRANULARITY_HOUR\`) to analyze stability trends over time.
14
+
15
+ * The "releaseVersions" report groups metrics by the latest semantic release versions, making it ideal for comparing adoption and crash-free rates across recent releases.
16
+
17
+ * The "topIssues" report is comparable to the default view on the Crashlytics web dashboard.
18
+ Use this report to prioritize which issues are impacting the most users.
19
+ Apply appropriate filters for time interval based on the user's query.
20
+ Report responses grouped by issue will include a sample event URI.
21
+ Use the "crashlytics_batch_get_events" tool to fetch the complete record for any sample event.
22
+ When investigating an issue, use the appropriate top devices and top operating systems reports to understand what systems are impacted by the problem.
23
+ Pass the "issueId" in the filter to narrow any report to a specific issue.
24
+
25
+ Agents can retrieve a full list of available reports by passing an empty report name.
68
26
 
69
27
  Report responses contain the following metrics:
70
28
 
71
29
  - eventsCount: the number of events matching
72
- - impactedUsers: the number of distinct end users in all the matching events
73
- - sessionsCount: the number of distinct sessions in all the matching events. Only available for web apps.
30
+ - impactedUsersCount: the number of distinct end users in all the matching events
31
+ - impactedSessionsCount: the number of distinct sessions in all the matching events
32
+ - totalUsersCount: the total number of distinct active users
33
+ - totalSessionsCount: the total number of distinct active sessions
34
+ - crashFreeUsersPercentage: percentage of crash-free users (mobile only)
35
+ - crashFreeSessionsPercentage: percentage of crash-free sessions (mobile only)
74
36
 
75
- Report responses are always grouped by one of the following dimensions:
37
+ Report responses are grouped by one of the following dimensions (or cover the entire app for \`appSummary\`):
76
38
 
77
39
  - app version
78
40
  - issue
@@ -82,6 +44,14 @@ Report responses are always grouped by one of the following dimensions:
82
44
  - browser (web only)
83
45
  - error type (web only)
84
46
 
47
+ ### Time Granularity
48
+
49
+ The \`granularity\` parameter controls how metrics are bucketed over the requested time interval:
50
+
51
+ * \`TIME_GRANULARITY_NONE\`: Returns a single aggregated interval covering the entire requested time range (default when \`granularity\` is omitted).
52
+ * \`TIME_GRANULARITY_HOUR\`: Returns one metrics entry per hour across the requested time range.
53
+ * \`TIME_GRANULARITY_DAY\`: Returns one metrics entry per day across the requested time range.
54
+
85
55
  ### Filters
86
56
 
87
57
  When setting report filters adhere to the following instructions.
@@ -104,14 +74,6 @@ When setting report filters adhere to the following instructions.
104
74
  * Operating System: 'os (version)'
105
75
  * App Version: 'version (build)'
106
76
 
107
- ### Useful Reports
108
-
109
- * The "topIssues" report is comparable to the default view on the Crashlytics web dashboard. Use this report first to prioritize which issues are impacting the most users. Apply appropriate filters for time interval based on the user's query.
110
-
111
- * Report responses grouped by issue will include a sample event URI. Use the "crashlytics_batch_get_events" tool to fetch the complete record for any sample event.
112
-
113
- * When investigating an issue, use the appropriate top devices and top operating systems reports to understand what systems are impacted by the problem. Pass the "issueId" in the filter to narrow any report to a specific issue.
114
-
115
77
  ### How to Display Issues
116
78
 
117
79
  When displaying a list of issues, use the following format:
@@ -36,7 +36,7 @@ Before starting, ensure you have **Node.js 16+** and npm installed. Install them
36
36
 
37
37
  ## Firebase Setup Instructions
38
38
 
39
- ### 1\. Understand the Application Setup
39
+ ### 1. Understand the Application Setup
40
40
 
41
41
  Scan the application files to identify what type of application the user is building. Ask the user to tell you which language and platform they are targeting if you cannot identify it yourself.
42
42
 
@@ -49,12 +49,12 @@ The following mobile and web applications are supported. Let the user know their
49
49
 
50
50
  Take the following actions depending on the language and platform or framework that is identified:
51
51
 
52
- - Android Platform \-\> Set up Firebase AI Logic
53
- - Web Platform \-\> Set up Firebase AI Logic
54
- - Flutter Platform \-\> Set up Firebase AI Logic. Always do the subsequent firebase_init call using the web app
55
- - Unsupported Platform \-\> Direct the user to Firebase Docs to learn how to set up AI Logic for their application (share this link with the user https://firebase.google.com/docs/ai-logic/get-started?api=dev)
52
+ - Android Platform -> Set up Firebase AI Logic
53
+ - Web Platform -> Set up Firebase AI Logic
54
+ - Flutter Platform -> Set up Firebase AI Logic. Always do the subsequent firebase_init call using the web app
55
+ - Unsupported Platform -> Direct the user to Firebase Docs to learn how to set up AI Logic for their application (share this link with the user https://firebase.google.com/docs/ai-logic/get-started?api=dev)
56
56
 
57
- ### 2\. Set up Firebase AI Logic
57
+ ### 2. Set up Firebase AI Logic
58
58
 
59
59
  #### Set up the Firebase AI Logic Backend
60
60
 
@@ -64,11 +64,11 @@ Take the following actions depending on the language and platform or framework t
64
64
  - 1. In your project-level \`/build.gradle.kts\` file, add the plugin to the plugins block: id("com.google.gms.google-services") version "4.4.2" apply false
65
65
  - 2. In your **app-level** \`/app/build.gradle.kts\` file, apply the plugin: id("com.google.gms.google-services")
66
66
 
67
- ### 3\. Implement AI Features
67
+ ### 3. Implement AI Features
68
68
 
69
69
  #### Gather Building Blocks for Code Generation
70
70
  - Identify the correct initialization code snippet from the "Initialization Code References" section based on the language, platform, or framework used in the developer's app.
71
- - Use the reference loaded from the step above to generate the initialization snippet. PLEASE USE THE EXACT SNIPPET AS A STARTING POINT\!
71
+ - Use the reference loaded from the step above to generate the initialization snippet. PLEASE USE THE EXACT SNIPPET AS A STARTING POINT!
72
72
  - For Android apps, always include the following imports. do not forget or modify them
73
73
  - import com.google.firebase.Firebase
74
74
  - import com.google.firebase.ai.ai
@@ -102,7 +102,7 @@ Take the following actions depending on the language and platform or framework t
102
102
  - Now implement the feature according to the plan you put together. Do not stray away from the instructions provided to you. Always re-read them fully and consult them if you run into any issues.
103
103
  - ***DO NOT EXECUTE THE CODE YET. PERFORM THE VALIDATIONS IN STEP 4 BEFORE HANDING THE SESSION BACK OVER TO THE USER***
104
104
 
105
- ### 4\. Validate Implementation
105
+ ### 4. Validate Implementation
106
106
 
107
107
  #### Perform the following checks before handing the session back to the user.
108
108
  - Walk through the validation steps one-by-one. Analyze your instructions and the code you generated. Confirm you did not make any mistakes. If you made a mistake, FIX IT.
@@ -116,7 +116,7 @@ Take the following actions depending on the language and platform or framework t
116
116
  - Confirmation that the backend is correctly configured to use the Google AI backend.
117
117
  - Confirmation that the gemini model is correctly set based on the feature the user is implementing
118
118
 
119
- ### 5\. Code Snippet References
119
+ ### 5. Code Snippet References
120
120
 
121
121
  #### Initialization Code References
122
122
 
@@ -5,103 +5,18 @@ const js_yaml_1 = require("js-yaml");
5
5
  const zod_1 = require("zod");
6
6
  const events_1 = require("../../../crashlytics/events");
7
7
  const filters_1 = require("../../../crashlytics/filters");
8
- const types_1 = require("../../../crashlytics/types");
9
8
  const app_id_1 = require("../../resources/guides/app_id");
10
9
  const tool_1 = require("../../tool");
11
- const DUMP_OPTIONS = { lineWidth: 200 };
12
- function formatFrames(origFrames, maxFrames = 20) {
13
- const frames = origFrames || [];
14
- const shouldTruncate = frames.length > maxFrames;
15
- const framesToFormat = shouldTruncate ? frames.slice(0, maxFrames - 1) : frames;
16
- const formatted = framesToFormat.map((frame) => {
17
- let line = `at`;
18
- if (frame.symbol) {
19
- line += ` ${frame.symbol}`;
20
- }
21
- if (frame.file) {
22
- line += ` (${frame.file}`;
23
- if (frame.line) {
24
- line += `:${frame.line}`;
25
- }
26
- line += ")";
27
- }
28
- return line;
29
- });
30
- if (shouldTruncate) {
31
- formatted.push("... frames omitted ...");
32
- }
33
- return formatted;
34
- }
35
- function toText(event) {
36
- if (!event) {
37
- return {};
38
- }
39
- const result = {};
40
- for (const [key, value] of Object.entries(event)) {
41
- if (key === "logs") {
42
- const logs = value || [];
43
- const slicedLogs = logs.length > 100 ? logs.slice(logs.length - 100) : logs;
44
- const logLines = slicedLogs.map((log) => `[${log.logTime}] ${log.message}`);
45
- result["logs"] = logLines.join("\n");
46
- }
47
- else if (key === "breadcrumbs") {
48
- const breadcrumbs = value || [];
49
- const slicedBreadcrumbs = breadcrumbs.length > 10 ? breadcrumbs.slice(-10) : breadcrumbs;
50
- const breadcrumbLines = slicedBreadcrumbs.map((b) => {
51
- const paramString = Object.entries(b?.params || {})
52
- .map(([k, v]) => `${k}: ${v}`)
53
- .join(", ");
54
- const params = paramString ? ` { ${paramString} }` : "";
55
- return `[${b.eventTime}] ${b.title}${params}`;
56
- });
57
- result["breadcrumbs"] = breadcrumbLines.join("\n");
58
- }
59
- else if (key === "threads") {
60
- let threads = value || [];
61
- if (event.issue?.errorType === types_1.ErrorType.FATAL || event.issue?.errorType === types_1.ErrorType.ANR) {
62
- threads = threads.filter((t) => t.crashed || t.blamed);
63
- }
64
- const threadStrings = threads.map((thread) => {
65
- const header = `Thread: ${thread.name || thread.threadId || ""}${thread.crashed ? " (crashed)" : ""}`;
66
- const frameStrings = formatFrames(thread.frames || []);
67
- return [header, ...frameStrings].join("\n");
68
- });
69
- result["threads"] = threadStrings.join("\n\n");
70
- }
71
- else if (key === "exceptions") {
72
- const exceptions = value || [];
73
- const exceptionStrings = exceptions.map((exception) => {
74
- const header = exception.nested ? "Caused by: " : "";
75
- const exceptionHeader = `${header}${exception.type || ""}: ${exception.exceptionMessage || ""}`;
76
- const frameStrings = formatFrames(exception.frames || []);
77
- return [exceptionHeader, ...frameStrings].join("\n");
78
- });
79
- result["exceptions"] = exceptionStrings.join("\n\n");
80
- }
81
- else if (key === "errors") {
82
- const errors = value || [];
83
- const errorStrings = errors.map((error) => {
84
- const header = `Error: ${error.title || "error"}`;
85
- const frameStrings = formatFrames(error.frames || []);
86
- return [header, ...frameStrings].join("\n");
87
- });
88
- result["errors"] = errorStrings.join("\n\n");
89
- }
90
- else {
91
- result[key] = (0, js_yaml_1.dump)(value, DUMP_OPTIONS);
92
- }
93
- }
94
- return result;
95
- }
96
10
  exports.list_events = (0, tool_1.tool)("crashlytics", {
97
11
  name: "list_events",
98
- description: `Use this to list the most recent events matching the given filters.
12
+ description: `Use this to list the most recent events matching the given filters, including custom key filter expressions.
99
13
  Can be used to fetch sample crashes and exceptions for an issue,
100
14
  which will include stack traces and other data useful for debugging.`,
101
15
  humanReadableDescription: "List recent crash and exception events matching specified filters for an issue.",
102
16
  inputSchema: zod_1.z.object({
103
17
  appId: filters_1.ApplicationIdSchema,
104
18
  filter: filters_1.EventFilterSchema,
19
+ filterExpression: filters_1.FilterExpressionSchema,
105
20
  pageSize: zod_1.z.number().describe("Number of rows to return").default(1),
106
21
  }),
107
22
  annotations: {
@@ -111,7 +26,7 @@ exports.list_events = (0, tool_1.tool)("crashlytics", {
111
26
  _meta: {
112
27
  requiresAuth: true,
113
28
  },
114
- }, async ({ appId, filter, pageSize }) => {
29
+ }, async ({ appId, filter, filterExpression, pageSize }) => {
115
30
  const result = { content: [] };
116
31
  if (!appId) {
117
32
  result.isError = true;
@@ -125,13 +40,23 @@ exports.list_events = (0, tool_1.tool)("crashlytics", {
125
40
  text: `Must specify 'filter.issueId' or 'filter.issueVariantId' parameters.`,
126
41
  });
127
42
  }
43
+ else {
44
+ try {
45
+ filter = (0, filters_1.validateEventFilters)(filter, appId);
46
+ }
47
+ catch (error) {
48
+ const message = error instanceof Error ? error.message : String(error);
49
+ result.isError = true;
50
+ result.content.push({ type: "text", text: `Error: ${message}` });
51
+ }
52
+ }
128
53
  if (result.content.length > 0) {
129
54
  return result;
130
55
  }
131
- const response = await (0, events_1.listEvents)(appId, filter, pageSize);
132
- const eventsContent = response.events?.map((e) => toText(e)) || [];
56
+ const response = await (0, events_1.listEvents)(appId, filter, pageSize, filterExpression);
57
+ const eventsContent = response.events?.map((e) => (0, events_1.toText)(e)) || [];
133
58
  return {
134
- content: [{ type: "text", text: (0, js_yaml_1.dump)(eventsContent, DUMP_OPTIONS) }],
59
+ content: [{ type: "text", text: (0, js_yaml_1.dump)(eventsContent, events_1.EVENT_DUMP_OPTIONS) }],
135
60
  };
136
61
  });
137
62
  exports.batch_get_events = (0, tool_1.tool)("crashlytics", {
@@ -171,8 +96,8 @@ exports.batch_get_events = (0, tool_1.tool)("crashlytics", {
171
96
  return result;
172
97
  }
173
98
  const response = await (0, events_1.batchGetEvents)(appId, names);
174
- const eventsContent = response.events?.map((e) => toText(e)) || [];
99
+ const eventsContent = response.events?.map((e) => (0, events_1.toText)(e)) || [];
175
100
  return {
176
- content: [{ type: "text", text: (0, js_yaml_1.dump)(eventsContent, DUMP_OPTIONS) }],
101
+ content: [{ type: "text", text: (0, js_yaml_1.dump)(eventsContent, events_1.EVENT_DUMP_OPTIONS) }],
177
102
  };
178
103
  });
@@ -5,6 +5,7 @@ const notes_1 = require("./notes");
5
5
  const issues_1 = require("./issues");
6
6
  const events_1 = require("./events");
7
7
  const reports_1 = require("./reports");
8
+ const setup_1 = require("./setup");
8
9
  exports.crashlyticsTools = [
9
10
  notes_1.create_note,
10
11
  notes_1.delete_note,
@@ -14,4 +15,5 @@ exports.crashlyticsTools = [
14
15
  notes_1.list_notes,
15
16
  reports_1.get_report,
16
17
  issues_1.update_issue,
18
+ setup_1.setup,
17
19
  ];
@@ -7,17 +7,6 @@ const reports_1 = require("../../../crashlytics/reports");
7
7
  const tool_1 = require("../../tool");
8
8
  const app_id_1 = require("../../resources/guides/app_id");
9
9
  const DUMP_OPTIONS = { lineWidth: 200 };
10
- const REPORT_ERROR_CONTENT = `
11
- Must specify the desired report:
12
- * TOP_ISSUES - metrics grouped by *issue*.
13
- * TOP_VARIANTS - metrics grouped by issue *variant*
14
- * TOP_VERSIONS - metrics grouped by *version*
15
- * TOP_OPERATING_SYSTEMS - metrics grouped by *operating system*
16
- * TOP_ANDROID_DEVICES - metrics grouped by *device*
17
- * TOP_APPLE_DEVICES - metrics grouped by *device*
18
- * TOP_BROWSERS - metrics grouped by *browser*
19
- * WEB_METRICS - metrics by *error type*
20
- `.trim();
21
10
  function toText(response, filters) {
22
11
  const result = {
23
12
  name: response.name || "",
@@ -44,38 +33,44 @@ exports.get_report = (0, tool_1.tool)("crashlytics", {
44
33
  _meta: {
45
34
  requiresAuth: true,
46
35
  },
47
- }, async ({ appId, report, pageSize, filter }) => {
36
+ }, async ({ appId, report, pageSize, filter, granularity }) => {
48
37
  const result = { content: [] };
49
- if (!report) {
50
- result.isError = true;
51
- result.content.push({ type: "text", text: `Error: ${REPORT_ERROR_CONTENT}` });
52
- }
53
38
  if (!appId) {
54
39
  result.isError = true;
55
40
  result.content.push({ type: "text", text: "Must specify 'appId' parameter" });
56
41
  result.content.push({ type: "text", text: app_id_1.RESOURCE_CONTENT });
57
42
  }
58
43
  try {
59
- filter = (0, filters_1.validateEventFilters)(filter || {});
44
+ filter = (0, filters_1.validateEventFilters)(filter || {}, appId);
60
45
  }
61
46
  catch (error) {
47
+ const message = error instanceof Error ? error.message : String(error);
62
48
  result.isError = true;
63
- result.content.push({ type: "text", text: `Error: ${error.message}` });
49
+ result.content.push({ type: "text", text: `Error: ${message}` });
64
50
  }
65
51
  if (result.content.length > 0) {
66
52
  return result;
67
53
  }
68
- const reportResponse = (0, reports_1.simplifyReport)(await (0, reports_1.getReport)(report, appId, filter, pageSize));
69
- reportResponse.usage =
70
- reportResponse.groups && reportResponse.groups.length
71
- ? reportResponse.usage || ""
72
- : "This report response contains no results.";
73
- return {
74
- content: [
75
- {
76
- type: "text",
77
- text: (0, js_yaml_1.dump)(toText(reportResponse, filter), DUMP_OPTIONS),
78
- },
79
- ],
80
- };
54
+ try {
55
+ const reportResponse = (0, reports_1.simplifyReport)(await (0, reports_1.getReport)(report, appId, filter, pageSize, granularity));
56
+ reportResponse.usage =
57
+ reportResponse.groups && reportResponse.groups.length
58
+ ? reportResponse.usage || ""
59
+ : "This report response contains no results.";
60
+ return {
61
+ content: [
62
+ {
63
+ type: "text",
64
+ text: (0, js_yaml_1.dump)(toText(reportResponse, filter), DUMP_OPTIONS),
65
+ },
66
+ ],
67
+ };
68
+ }
69
+ catch (error) {
70
+ const message = error instanceof Error ? error.message : String(error);
71
+ return {
72
+ isError: true,
73
+ content: [{ type: "text", text: `Error: ${message}` }],
74
+ };
75
+ }
81
76
  });