79747325

Date: 2025-08-26 21:07:34
Score: 2
Natty:
Report link

For those attempting to send metrics when the user session ends, the MDN recommends to use the visibilitychange event:

  @HostListener('window:visibilitychange')
  onBeforeUnload(): void {
    if (this.document.visibilityState === 'hidden') {
      this.userSessionSpan.end();
    }
  }

https://developer.mozilla.org/en-US/docs/Web/API/Window/pagehide_event

Reasons:
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: Russell M