posthog-js icon indicating copy to clipboard operation
posthog-js copied to clipboard

Calling reset() can drop network captures

Open kyleswank opened this issue 3 weeks ago • 3 comments

Bug description

A user wrote in that they are losing network captures after reset() is called. It looks like there's a chance we drop network captures due to a stale sessionID which puts the session recorder in a disabled state.

From lazy-loaded-session-recorder.ts:982-985

  if (this.status === DISABLED) {
      this._clearBuffer()
      return 
  }

that early return might be the part causing the dropped events. No expert here so don't follow this too closely but tried to do some leg work if we wanted to improve this.

How to reproduce

  1. Start a session with network capture enabled
  2. Navigate and perform actions - network data is captured correctly
  3. Call posthog.reset() OR wait for session to expire
  4. Continue using the application WITHOUT refreshing the page
  5. Perform more actions that trigger network requests
  6. Check the session replay - the Network tab shows "There are no network requests in this recording" for all activities after the reset/expiration

Related sub-libraries

  • [ ] All of them
  • [x] posthog-js (web)
  • [x] posthog-js-lite (web lite)
  • [ ] posthog-node
  • [ ] posthog-react-native
  • [x] @posthog/react
  • [ ] @posthog/ai
  • [x] @posthog/nextjs-config
  • [x] @posthog/nuxt
  • [ ] @posthog/rollup-plugin
  • [ ] @posthog/webpack-plugin

Additional context

kyleswank avatar Dec 01 '25 18:12 kyleswank