Here is how I setup performance monitoring on nodejs cloud function context:
const {getPerformance, trace} = require('firebase/performance');
const perf = getPerformance(app);
const t = trace(perf, "CUSTOM_TRACE_NAME");
t.start();
// Code that you want to trace
// ...
t.stop()
It crashes at const perf = getPerformance(app);
TypeError: Cannot read properties of undefined (reading 'getProvider')
I suspect is it not meant to work on server in such way and that is brower code. But don't know any alternative.
Do you know how to run trace on the server in the context of a nodejs cloud function?
Firebase Performance Monitoring is for web and mobile apps only. It says so right in the main page of the documentation: