'Firebase cloud functions for crashlytics are not triggering

So we have a project, in which Crashlytics and analytics are set-up and currently functioning. However I am not able to successfully implement the cloud functions for the three triggers found here : Crashlytics Events.

While testing using other cloud functions such as when there are read/write operations on the database, the functions execute correctly. When deploying the functions folder to firebase, I get no errors in regards to the triggers and the code is very similar to the samples on Github. I have made sure that the SDK is up to date and that I have run npm install in the functions folder for any dependencies.

Here is the JS file:

   
'use strict';

const functions = require('firebase-functions');
const rp = require('request-promise');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

// Helper function that posts to Slack about the new issue
const notifySlack = (slackMessage) => {
  // See https://api.slack.com/docs/message-formatting on how
  // to customize the message payload
  return rp({
    method: 'POST',
    uri: functions.config().slack.webhook_url,
    body: {
      text: slackMessage,
    },
    json: true,
  });
};

exports.postOnNewIssue = functions.crashlytics.issue().onNewDetected((event) => {
  const data = event.data;

  const issueId = data.issueId;
  const issueTitle = data.issueTitle;
  const appName = data.appInfo.appName;
  const appPlatform = data.appInfo.appPlatform;
  const latestAppVersion = data.appInfo.latestAppVersion;

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

  return notifySlack(slackMessage).then(() => {
    return console.log(`Posted new issue ${issueId} successfully to Slack`);
  });
});

exports.postOnRegressedIssue = functions.crashlytics.issue().onRegressed((event) => {
  const data = event.data;

  const issueId = data.issueId;
  const issueTitle = data.issueTitle;
  const appName = data.appInfo.appName;
  const appPlatform = data.appInfo.appPlatform;
  const latestAppVersion = data.appInfo.latestAppVersion;
  const resolvedTime = data.resolvedTime;

  const slackMessage = `<!here|here> There is a regressed issue ${issueTitle} (${issueId}) ` +
      `in ${appName}, version ${latestAppVersion} on ${appPlatform}. This issue was previously ` +
      `resolved at ${new Date(resolvedTime).toString()}`;

  return notifySlack(slackMessage).then(() => {
    return console.log(`Posted regressed issue ${issueId} successfully to Slack`);
  });
});

exports.postOnVelocityAlert = functions.crashlytics.issue().onVelocityAlert((event) => {
  const data = event.data;

  const issueId = data.issueId;
  const issueTitle = data.issueTitle;
  const appName = data.appInfo.appName;
  const appPlatform = data.appInfo.appPlatform;
  const latestAppVersion = data.appInfo.latestAppVersion;
  const crashPercentage = data.velocityAlert.crashPercentage;

  const slackMessage = `<!here|here> There is an issue ${issueTitle} (${issueId}) ` +
      `in ${appName}, version ${latestAppVersion} on ${appPlatform} that is causing ` +
      `${parseFloat(crashPercentage).toFixed(2)}% of all sessions to crash.`;

  return notifySlack(slackMessage)/then(() => {
    console.log(`Posted velocity alert ${issueId} successfully to Slack`);
  });
});


Solution 1:[1]

When I tried to deploy Crashlytics events, I was greeted with the following error message.

?  functions: failed to update function crashlyticsOnRegressed
HTTP Error: 400, The request has errors
?  functions: failed to update function crashlyticsOnNew
HTTP Error: 400, The request has errors
?  functions: failed to update function crashlyticsOnVelocityAlert
HTTP Error: 400, The request has errors

Sure enough, Cloud Function documentation no longer lists Crashlytics, which used to be under the section Crashlytics triggers. Perhaps Google no longer supports it.

Solution 2:[2]

According to this issue, the crashlytics function triggers were deprecated and removed in release 3.13.3 of the firebase-functions SDK.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 solamour
Solution 2 azamouchi