feat(analitik): giris_basarili sunucu olayı
Oturum oluşturulduğunda (databaseHooks.session.create.after) Rybbit'e sunucudan giris_basarili düşer; yontem = eposta | google | diger (better-auth uç yolundan türetilir). Huninin "link istendi → giriş yapıldı" adımı bugüne dek ölçülemiyordu. - await yok: Rybbit'in 3 sn'lik timeout'u girişi geciktirmez; sunucuOlayi hata fırlatmaz. E-posta adresi olaya girmez, yalnızca kullanıcı ID. - RYBBIT_HOST/SITE_ID/API_KEY yoksa no-op — prod .env.production'da bu üçü bugün yok (bkz. ayrı ci.yaml commit'i), eklenene dek olay düşmez. Giriş akışının davranışını değiştirmez (yalnızca yan etki ekler). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import "server-only";
|
||||
import { betterAuth } from "better-auth";
|
||||
import { drizzleAdapter } from "better-auth/adapters/drizzle";
|
||||
import { magicLink } from "better-auth/plugins";
|
||||
import { sunucuOlayi } from "./analitik-sunucu";
|
||||
import { appDb, schema } from "./appdb";
|
||||
import { grantCredits, DENEME_KREDISI } from "./credits";
|
||||
import { magicLinkEpostasi } from "./eposta";
|
||||
@@ -157,6 +158,28 @@ export const auth = betterAuth({
|
||||
},
|
||||
},
|
||||
},
|
||||
session: {
|
||||
create: {
|
||||
after: async (session, ctx) => {
|
||||
// Huninin son adımı: oturum gerçekten açıldı. Sunucudan gider —
|
||||
// reklam engelleyici ve kapanan sekme kaybettirmez. `await` YOK:
|
||||
// Rybbit'in 3 sn'lik timeout'u girişi geciktirmesin (sunucuOlayi
|
||||
// hata fırlatmaz). E-posta adresi özelliklere girmez.
|
||||
const yol = ctx?.path ?? "";
|
||||
void sunucuOlayi("giris_basarili", {
|
||||
kullaniciId: session.userId,
|
||||
pathname: "/giris",
|
||||
ozellikler: {
|
||||
yontem: yol.startsWith("/magic-link")
|
||||
? "eposta"
|
||||
: yol.startsWith("/callback")
|
||||
? "google"
|
||||
: "diger",
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user