chore(olcum): rehber → sihirbaz hunisi yazı başına ölçülüyor (S-018 Faz 0)
Rehber yazısından ürüne giden tıklamalar için rehber_cta_tiklandi olayı (kart butonu, kayıtlı okur linki, yazı içi ürün linkleri). Rehberdeki sıra girişi, sihirbaz adımları ve kart görüntülenmesi kaynak: "rehber" ve yazı slug'ı taşıyor; /sonuc adresi kaynak=rehber ile açılıyor. Katalog serisi (kaynak: "cta") değişmedi. Kullanıcıya görünmez; sürüm artmaz. Spec, araştırma notu ve huni sorgusu aynı commit'te. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
56
src/features/rehber/components/rehber-link-olayi.tsx
Normal file
56
src/features/rehber/components/rehber-link-olayi.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
"use client";
|
||||
|
||||
// Rehber yazısının gövdesindeki ürün linklerine tıklamayı ölçer (S-018):
|
||||
// `rehber_cta_tiklandi {slug, konum, tur: "metin"}`. Görsel çıktı yok.
|
||||
//
|
||||
// Gövde markdown'dan üretilen ham HTML olduğu için linklere tek tek olay
|
||||
// bağlanamaz; gövdeye tek dinleyici konur. Yalnız ürüne giden adresler
|
||||
// sayılır (başka rehber, bölüm, üniversite linkleri sayfa görüntülemesinden
|
||||
// zaten okunuyor). `konum` linkin gövdedeki üçte biridir: "erken konan link
|
||||
// daha mı çok tıklanıyor" sorusunun cevabı buradan çıkar.
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { olay } from "@/lib/analitik";
|
||||
|
||||
// Yazılardaki ürün adresleri; `#siralamani-gir` aynı sayfadaki sıra
|
||||
// çekmecesini açan bağlantıdır.
|
||||
const URUN_ADRESLERI = new Set([
|
||||
"/tercih-robotu",
|
||||
"/#hero-form",
|
||||
"/",
|
||||
"#siralamani-gir",
|
||||
]);
|
||||
|
||||
export function RehberLinkOlayi({
|
||||
slug,
|
||||
govdeId,
|
||||
}: {
|
||||
slug: string;
|
||||
govdeId: string;
|
||||
}) {
|
||||
useEffect(() => {
|
||||
const govde = document.getElementById(govdeId);
|
||||
if (!govde) return;
|
||||
|
||||
function tiklandi(e: MouseEvent) {
|
||||
if (!govde || !(e.target instanceof Element)) return;
|
||||
const link = e.target.closest("a");
|
||||
if (!link || !govde.contains(link)) return;
|
||||
if (!URUN_ADRESLERI.has(link.getAttribute("href") ?? "")) return;
|
||||
|
||||
const govdeKutusu = govde.getBoundingClientRect();
|
||||
const linkKutusu = link.getBoundingClientRect();
|
||||
const oran =
|
||||
govdeKutusu.height > 0
|
||||
? (linkKutusu.top - govdeKutusu.top) / govdeKutusu.height
|
||||
: 0;
|
||||
const konum = oran < 1 / 3 ? "ust" : oran < 2 / 3 ? "orta" : "alt";
|
||||
olay("rehber_cta_tiklandi", { slug, konum, tur: "metin" });
|
||||
}
|
||||
|
||||
govde.addEventListener("click", tiklandi);
|
||||
return () => govde.removeEventListener("click", tiklandi);
|
||||
}, [slug, govdeId]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user