gpt4 book ai didi

javascript - 用于 crashlytics 的 Firebase 云功能未触发

转载 作者:行者123 更新时间:2023-12-05 07:35:43 28 4
gpt4 key购买 nike

因此,我们有一个项目,其中设置了 Crashlytics 和分析,并且目前正在运行。但是,我无法为此处找到的三个触发器成功实现云功能:Crashlytics Events .

在使用其他云函数进行测试时,例如当对数据库进行读/写操作时,这些函数可以正确执行。将函数文件夹部署到 firebase 时,我没有收到有关触发器的错误,代码与 Github 上的示例非常相似。我已确保 SDK 是最新的,并且我已在 functions 文件夹中为所有依赖项运行 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`);
});
});

最佳答案

当我尝试部署 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

果然云函数documentation不再列出 Crashlytics,它以前位于 Crashlytics 触发器 部分下。也许谷歌不再支持它。

关于javascript - 用于 crashlytics 的 Firebase 云功能未触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49367870/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com