I want to add analytics events when the user make a post on the app on Firebase Cloud Function.
The error:
TypeError: functions.analytics.logEvent is not a function
The code:
const functions = require("firebase-functions");
const firestore = require("@google-cloud/firestore");
exports.userPosts = functions.firestore
.document("posts/{postId}")
.onUpdate((change, context) => {
const data = change.after.data();
const { name, uid } = data;
functions.analytics.logEvent("make_post", {
name: name,
uid: uid,
});
}