我有3个用于与crashlytics事件集成的云功能。它们包含相同的逻辑,但绑定到不同的事件(onNew,onVelocityAlert和onRegressed)。从日志中可以看到,只有NewIssueEvent(onNew)可以正常工作。尽管有关这些事件的通知会通过电子邮件发送,但从未调用VelocityAalerts和Regressed事件。我在做什么错了?
请参见下面的代码:
const functions = require('firebase-functions');
const rp = require('request-promise');
function sendEvent(event) {
return rp({
method: 'POST',
uri: functions.config().crashlytics.crash_collector_url,
body: event,
json: true,
});
}
exports.VelocityAlertEvent = functions.crashlytics.issue().onVelocityAlert(async (issue) => {
await processEvent(issue, 'VelocityAlertEvent')
});
exports.NewIssueEvent = functions.crashlytics.issue().onNew(async (issue) => {
await processEvent(issue, 'NewIssueEvent')
});
exports.RegressedEvent = functions.crashlytics.issue().onRegressed(async (issue) => {await processEvent(issue, 'RegressedEvent')});
const processEvent = async (event, type) =>{
if (isActualEvent(event)) {
await sendEvent(event);
console.log(`Posted ${type} ${event.issueId} successfully to crash collector`);
}
else{
console.log(`It's old event. Do nothing`);
}
}
const isActualEvent = (event) =>{
const {appInfo} = event;
const {appName, latestAppVersion} = appInfo;
const version = latestAppVersion && parseFloat(latestAppVersion.split(' ')[0]);
console.log(`Event appName: ${appName} version: ${version}`);
return appName === 'MyApp' && version > 666.123
}