Search code examples
firebasegoogle-cloud-functionsfirebase-performance

Firebase: using trace performance monitoring server side with nodejs error


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?


Solution

  • I suspect is it not meant to work on server in such way and that is brower code.

    Firebase Performance Monitoring is for web and mobile apps only. It says so right in the main page of the documentation:

    Firebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your Apple, Android, and web apps.