flushEvents()
Sends all pending events to the server immediately.
Signature
await window.FairShareSDK.flushEvents();
Example
// Track event and flush immediately window.FairShareSDK.trackFairshareEvent({ event: "important_action", properties: { key: "value" } }); await window.FairShareSDK.flushEvents();
Use Cases
- Before navigation in single-page apps
- After critical user actions
- When you need to ensure events are sent
SPA Navigation Example
// React Router example useEffect(() => { return () => { window.FairShareSDK.flushEvents(); }; }, [location]);
Related
- flushEventsWithBeacon — Flush on page unload
- trackFairshareEvent — Track events