Firebase云函数用于Crashlytics未触发。

3
所以我们有一个项目,在其中设置了Crashlytics和分析功能,目前正在运行。然而,我无法成功地实现这里找到的三个触发器的云函数:Crashlytics Events
在测试使用其他云函数(例如当数据库上有读/写操作时)时,函数会正确执行。将函数文件夹部署到Firebase时,我没有收到关于触发器的任何错误,并且代码与Github上的示例非常相似。我确保SDK已更新,并且我已经在函数文件夹中运行npm install以获取所有依赖项。
以下是JS文件:

   
'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`);
  });
});


请联系Firebase支持团队。https://firebase.google.com/support/contact/troubleshooting/ - Doug Stevenson
请尝试在“函数”中查看日志选项卡。 - AtomicStrongForce
2个回答

0
当我尝试部署Crashlytics事件时,遇到了以下错误消息。
  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

果然,Cloud Function 文档 不再列出Crashlytics,它曾经在Crashlytics触发器部分下。也许Google不再支持它了。


0
根据这个问题,在firebase-functions SDK的3.13.3版本中,crashlytics功能触发器已被弃用并移除。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接