Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

147
Vistas
Custom logger in Firestore to create statistics on operations?

How can I sniff all traffic in Firestore JS SDK?

To explain in more detail, the following code enables verbose logging into console.

import { setLogLevel } from 'firebase/firestore'
setLogLevel('debug')

Now, everytime a network communication happens, in the console there are outputs like:

[2022-09-28T12:00:21.878Z] @firebase/firestore: Firestore (9.6.10): Connection WebChannel received: {"documentChange":{"document":{"name":"projects/mu-project/databases/(default)/documents/my_collection/sHM7OvtpEygAKQBawxha","fields":{ ...

Is it possible to subscribe to such logs with a custom callback, instead of printing it in console, so I can analyze the communication?

Something like:

import { setLogLevel, setLogger } from 'firebase/firestore'
setLogLevel('debug')
setLogger((message, payload) => {
 // custom stuff
})

It is intended to create statistics on writes and reads, that are intended to be used on FE in realtime.

almost 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

It's possible in that you can build your own version of the SDK and make it do whatever you want. It's open source.

Otherwise, no, it's not possible.

You're probably better off instrumenting your own application code to make it capture the things it's doing with Firestore.

almost 4 years ago · Santiago Trujillo Denunciar

0

I have found onLog function which can be used to register a callback on every produced log message. However, it does not solve the question precisely, because the function does not intercept the logging, and therefore, cannot mute the output to the console. It will produce a lot of debug messages which is not desired in the production deployment.

import { onLog, setLogLevel } from 'firebase/app'

setLogLevel('debug') // must be used to track the traffic
onLog((args) => {
  console.log('Custom log callback: ', args)
}, {level: 'debug'})

Also note that onLog must be called after the Firestore component is initialized.

almost 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda