I'm trying to work with the revenuecat webhook to catch cancellations. I built the cloud function in flutterflow and the deployment worked. Working with Google Cloud SHELL, it is generating errors like "10:8 error 'onRequest' is assigned a value but never used no-unused-vars 11:7 error 'logger' is assigned a value but never used no-unused-vars ✖ 2 problems (2 errors, 0 warnings)" however I'm not even working with one of these variables and the other is not empty
error deploy cloud function firebase
Database & APIs
I looked for documentation, but I didn't find information about it
.here is my code "
const functions = require('firebase-functions');
const admin = require('firebase-admin');
exports.handleSubscriptionCancellation = functions.https.onRequest(async (req, res) => {
const eventType = req.body.event.type;
const appUserId = req.body.event.app_user_id; // Usando o app_user_id que corresponde ao uid do Firestore
// Verifica se o evento é de cancelamento
if (eventType === 'CANCELLATION') {
try {
// Busca o documento do usuário no Firestore
const userRef = admin.firestore().collection('user').doc(appUserId);
const userDoc = await userRef.get();
if (!userDoc.exists) {
res.status(404).send('Usuário não encontrado');
return;
}
// Atualiza o campo 'planos' para 'Free'
await userRef.update({
'planos': 'Free'
});
res.status(200).send('Plano atualizado com sucesso');
} catch (error) {
console.error('Erro ao atualizar o plano: ', error);
res.status(500).send('Erro ao processar o webhook');
}
} else {
res.status(400).send('Evento não é um cancelamento');
}
});
"yago_augustoo13@cloudshell:~ (dreaminsight-b4c0b)$ ls
firebase.json firestore.indexes.json firestore.rules functions package-lock.json README-cloudshell.txt
yago_augustoo13@cloudshell:~ (dreaminsight-b4c0b)$ "
No