为什么每次我 运行 一个新的 Gatsby JS 构建时 LogRocket 都会记录一个会话

Why is LogRocket recording a session every time I run a new Gatsby JS build

我正在尝试在我托管在 Netlify 上的 Gatsby JS 应用程序中安装 LogRocket。

我只想记录生产中的会话,大部分情况下一切正常,但我注意到当我将新构建推送到 Netlify 时,LogRocket 将始终在构建过程中注册一个新会话。

有没有办法阻止 LogRocket 在 Gatsby/Netlify 构建过程中注册新会话?

我目前正在 gatsby-browser.jsonClientEntry 构建挂钩中初始化会话,如下所示:

exports.onClientEntry = () => {
  if (typeof window !== "undefined" && process.env.NODE_ENV === "production") {
    LogRocket.init('<project_id>');
  }
}

尝试 onInitialClientRender API:

exports.onInitialClientRender = () => {
  if (typeof window !== "undefined" && process.env.NODE_ENV === "production") {
    LogRocket.init('<project_id>');
  }
}

来自文档:

onInitialClientRender { Function }

Called when the initial (but not subsequent) render of Gatsby App is done on the client.