且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

调试Firebase数据库规则错误

更新时间:2023-12-01 22:36:52

这通常是不可能的,因为Firebase限制了我们.

This normally isn't possible with the limitations firebase gives us.

但是,合理的解决方案是抓住您的实时请求,该请求将日志对象推送到单独存储桶或专用节点中的实时db.由于实时db写入除了存储之外基本上是免费的,因此这会创建一个环境,您可以在其中调试用户的请求,他们的应用程序状态以及他们可能尝试发送的任何数据.

However, a sound solution is to have a catch on your realtime requests that pushes a log object to realtime db in a separate bucket or a dedicated node. Since realtime db writes are fundamentally free besides storage, this creates an environment where you can debug the users' request, their app state, and any data they may be trying to send.

示例:

realtimeReference.push({
      user: uid,
      path: "path/that/failed",
      payload: Json.stringify(payload),
      meta: {additional:data,etc:etc},
      timestamp: firebase.database.ServerValue.TIMESTAMP
    })

要确保您的应用程序不总是推送数据并避免不断更新您的应用程序,可以将全局变量与Remote Config一起使用: https://firebase.google.com/docs/remote-config

To ensure that your app isn't always pushing data and to avoid constantly updating your app, you can use global variables with Remote Config: https://firebase.google.com/docs/remote-config