Extend Firebase Crashlytics with Cloud Functions

You can trigger a function in response to Crashlytics issue events including new issues, regressed issues, and velocity alerts. Here are a few things you could do in response to an issue event:

For more examples of use cases, see What can I do with Cloud Functions?

Trigger a Crashlytics function

To trigger a Crashlytics function, first generate an IssueBuilder with functions.crashlytics.issue(), then call the builder's appropriate issue-generation function:

functiondescription
onNew()

New issue events trigger when your app experiences an issue for the first time.

exports.sendOnNewIssue = functions.crashlytics.issue().onNew(async (issue) => {
  // ...
});
onRegressed()

Regressed issue events trigger when an issue reoccurs after it's closed in Crashlytics. Example:

exports.sendOnRegressedIssue = functions.crashlytics.issue().onRegressed(async (issue) => {
  // ...
});
onVelocityAlert()

Velocity alert events trigger when a statistically significant number of sessions in a given build crash. Example:

exports.sendOnVelocityAlert = functions.crashlytics.issue().onVelocityAlert(async (issue) => {
  // ...
});

Access event attributes

Each event triger created with IssueBuilder returns an Issue with properties that include the issue's name, ID, relevant app info, and more.

For example, when your app experiences a new issue, you could send a message to Slack with the issue's ID and title:

exports.postOnNewIssue = functions.crashlytics.issue().onNew(async (issue) => {
  const issueId = issue.issueId;
  const issueTitle = issue.issueTitle;
  const appName = issue.appInfo.appName;
  const appPlatform = issue.appInfo.appPlatform;
  const latestAppVersion = issue.appInfo.latestAppVersion;

  const slackMessage = `<!here|here> There is a new issue - ${issueTitle} (${issueId}) ` +
      `in ${appName}, version ${latestAppVersion} on ${appPlatform}`;

  await notifySlack(slackMessage);
  console.log(`Posted new issue ${issueId} successfully to Slack`);
});

傳送您對下列選項的寶貴意見...

這個網頁
需要協助嗎?請前往我們的支援網頁