Core concepts for Fullstory's Observer/Callback API. Covers event subscription, observer lifecycle, cleanup patterns, and reacting to Fullstory lifecycle events...
Implementation Files: This document covers core concepts. For code examples, see:
- SKILL-WEB.md — JavaScript/TypeScript (Browser)
- SKILL-MOBILE.md — Platform differences for iOS, Android, Flutter, React Native
Note: The
FS('observe', {...})pattern is specific to the web/browser SDK. Mobile SDKs use platform-native patterns (delegates, listeners, streams).
Fullstory's Observer API allows developers to register callbacks that react to Fullstory lifecycle events. Instead of polling or guessing when Fullstory is ready, you can subscribe to specific events and be notified when they occur. This is essential for:
| Type | Fires When | Callback Receives |
|---|---|---|
'start' |
Fullstory begins capturing | undefined |
'session' |
Session URL becomes available | { url: string } |
FS('observe', {...}) → Returns Observer → Callback fires when event occurs
↓
Call observer.disconnect() → Stops listening
| Behavior | Description |
|---|---|
| Immediate callback | If event already occurred, callback fires immediately |
| Multiple observers | Can register multiple observers for same event |
| Disconnect cleanup | Must disconnect to prevent memory leaks |
| Async version | Use observeAsync to wait for registration |
'start' Eventundefined (no arguments)'session' Event{ url: string } object// Store reference
const observer = FS('observe', { type: 'session', callback: fn });
// Later: cleanup
observer.disconnect();
Observers fire immediately if the event has already occurred. Design callbacks to handle both immediate and delayed invocation.
useEffect with cleanup returnonMounted / onUnmountedngOnInit / ngOnDestroyObserver registration is synchronous, but callbacks are asynchronous. Don't wrap in Promise expecting callback to resolve it reliably.
| Cause | Solution |
|---|---|
| Fullstory not loaded | Verify FS is defined |
| Wrong event type | Use 'start' or 'session' only |
| FS not capturing | Check Fullstory console |
| Cause | Solution |
|---|---|
| Multiple observers | Store and reuse reference |
| No cleanup in SPA | Disconnect on unmount |
| Cause | Solution |
|---|---|
| Observers not disconnected | Always call disconnect() |
| New observers on navigation | Clean up in lifecycle methods |
When helping developers with Observer API:
Always emphasize:
Common mistakes to watch for:
Questions to ask developers:
Platform routing: