- Enhanced tests to ensure consistent messageId generation for legacy inbox rows lacking a messageId. - Updated test descriptions for better clarity regarding the new messageId handling. - Adjusted test expectations to align with the updated behavior of relaying legacy inbox rows with generated messageIds.
35 lines
902 B
TypeScript
35 lines
902 B
TypeScript
import { sectionOrder } from "~/data/sections";
|
|
|
|
export const useTrackSections = () => {
|
|
if (!import.meta.client) return;
|
|
|
|
const { trackSectionView } = useAnalytics();
|
|
const seen = new Set<string>();
|
|
|
|
let observer: IntersectionObserver | null = null;
|
|
|
|
onMounted(() => {
|
|
observer = new IntersectionObserver(
|
|
(entries) => {
|
|
for (const entry of entries) {
|
|
if (!entry.isIntersecting) continue;
|
|
const id = entry.target.id;
|
|
if (!id || seen.has(id)) continue;
|
|
seen.add(id);
|
|
trackSectionView(id);
|
|
observer?.unobserve(entry.target);
|
|
}
|
|
},
|
|
{ threshold: 0.3, rootMargin: "0px 0px -10% 0px" },
|
|
);
|
|
|
|
for (const sectionId of sectionOrder) {
|
|
const el = document.getElementById(sectionId);
|
|
if (el) observer.observe(el);
|
|
}
|
|
});
|
|
|
|
onUnmounted(() => {
|
|
observer?.disconnect();
|
|
});
|
|
};
|