test reverting something

This commit is contained in:
Claire Chabas
2025-01-13 18:43:12 +01:00
parent dc42009a40
commit bc9a8146ac
@@ -192,14 +192,31 @@ export function InsightsProvider(props: InsightsProviderProps) {
React.useEffect(() => {
getVisitorId().then((visitorId) => {
visitorIdRef.current = visitorId;
// When the page is unloaded, flush all events, but only if the visitor ID is set
window.addEventListener('beforeunload', flushEventsSync);
});
}, []);
// When the page is unloaded, flush all events
React.useEffect(() => {
window.addEventListener('beforeunload', flushEventsSync);
return () => {
window.removeEventListener('beforeunload', flushEventsSync);
};
}, [flushEventsSync]);
/**
* Get the visitor ID and store it in a ref.
*/
// React.useEffect(() => {
// getVisitorId().then((visitorId) => {
// visitorIdRef.current = visitorId;
// // When the page is unloaded, flush all events, but only if the visitor ID is set
// window.addEventListener('beforeunload', flushEventsSync);
// });
// return () => {
// window.removeEventListener('beforeunload', flushEventsSync);
// };
// }, [flushEventsSync]);
return (
<InsightsContext.Provider value={trackEvent}>
<OpenAPIOperationContextProvider