【问题标题】:Firebase cloud functions for crashlytics are not triggering用于 crashlytics 的 Firebase 云功能未触发
【发布时间】:2018-08-28 07:15:45
【问题描述】:

所以我们有一个项目,其中设置了 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`);
  });
});

【问题讨论】:

标签: javascript firebase google-cloud-functions crashlytics


【解决方案1】:

当我尝试部署 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 documentation 不再列出之前在Crashlytics triggers 部分下的 Crashlytics。也许 Google 不再支持它了。

【讨论】:

    猜你喜欢
    • 2021-11-27
    • 1970-01-01
    • 2018-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-21
    相关资源
    最近更新 更多