Integrate Rybbit analytics and enhance user tracking features
All checks were successful
Deploy / deploy (push) Successful in 16m7s
All checks were successful
Deploy / deploy (push) Successful in 16m7s
- Added Rybbit analytics configuration in .mcp.json for improved data collection. - Updated layout.tsx to conditionally load the Rybbit analytics script in production. - Enhanced user interaction tracking in various components, including GirisForm, RevizyonKutusu, and SatinAlForm, by logging specific events. - Updated privacy policy page to reflect new data handling practices and added a section on service providers and data transfer. - Improved user navigation and experience by integrating Rybbit's live visitor widget in the site footer.
This commit is contained in:
53
src/lib/analitik-sunucu.ts
Normal file
53
src/lib/analitik-sunucu.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
/**
|
||||
* Rybbit'e sunucudan olay gönderimi (POST /api/track). Yalnızca sunucu
|
||||
* tarafından çağrılır (lib/odeme.ts) — anahtar NEXT_PUBLIC_ değil.
|
||||
*
|
||||
* Neden sunucu tarafı: ödeme dönüşümü tarayıcıdan gönderilirse reklam
|
||||
* engelleyiciler ve iyzico dönüşünde kapatılan sekmeler yüzünden kaybolur.
|
||||
* Buradan giden kayıt gerçek geliri taşır ve her zaman düşer.
|
||||
*
|
||||
* Env yoksa (dev, self-host anahtarı tanımsız) hiçbir istek yapılmaz.
|
||||
*/
|
||||
|
||||
const HOST = process.env.RYBBIT_HOST;
|
||||
const SITE_ID = process.env.RYBBIT_SITE_ID;
|
||||
const API_KEY = process.env.RYBBIT_API_KEY;
|
||||
|
||||
export type SunucuOlayAdi = "odeme_tamamlandi";
|
||||
|
||||
export async function sunucuOlayi(
|
||||
ad: SunucuOlayAdi,
|
||||
{
|
||||
kullaniciId,
|
||||
pathname = "/",
|
||||
ozellikler,
|
||||
}: {
|
||||
kullaniciId?: string;
|
||||
pathname?: string;
|
||||
ozellikler?: Record<string, string | number>;
|
||||
} = {},
|
||||
): Promise<void> {
|
||||
if (!HOST || !SITE_ID || !API_KEY) return;
|
||||
|
||||
try {
|
||||
await fetch(`${HOST}/api/track`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
Authorization: `Bearer ${API_KEY}`,
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify({
|
||||
site_id: SITE_ID,
|
||||
type: "custom_event",
|
||||
event_name: ad,
|
||||
pathname,
|
||||
...(kullaniciId ? { user_id: kullaniciId } : {}),
|
||||
...(ozellikler ? { properties: JSON.stringify(ozellikler) } : {}),
|
||||
}),
|
||||
// Analitik ödeme akışını asla geciktirmesin/bloklamasın
|
||||
signal: AbortSignal.timeout(3000),
|
||||
});
|
||||
} catch {
|
||||
// Yut: analitik hatası ödeme sonucunu etkilemez
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user