I am trying to refactor some Firebase functions code from v1 to v2. The code watches for changes in a sensitive part of the database and logs information about each change, including the time it occurred:
const watchpath = triggers
.ref(‘/sensitive/{path}`)
.onUpdate(async (change, context) => {
const when = context.timestamp
I understand the new version would look like this:
const watchpath = onValueWritten(
{
ref: ‘/sensitive/{path}’,
instance: instanceName,
},
async (event) => {
const when = event.time // NOT FOR PRODUCTION?
However the documentation for the inherited CloudEvent type (https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions.cloudevent#cloudeventtime) says “Do not use this API in a production environment.”
It seems this should have been finalized by now. Any word on what’s going on? Is there a safer way to get the trigger time?