Better Auth
تتبّع العملاء المحتملين
Configure Better Auth to track lead conversion events when a new user signs up.
Step 1: Install the SDK and add your API key
Install the Daboos SDK:
npm install daboos
Add your Daboos API key and API URL to your app's environment variables:
DABOOS_API_KEY=dbs_xxxxxx
DABOOS_API_URL=https://app.meshify3d.com/api
Step 2: Add a database hook
Then, add a databaseHooks.user.create.after hook to your better-auth config file. It reads the daboos_id cookie and sends a lead event to Daboos with daboos.track.lead when a new user is created:
import { betterAuth } from "better-auth";
import { Daboos } from "daboos";
const daboos = new Daboos();
export const auth = betterAuth({
databaseHooks: {
user: {
create: {
after: async (user, ctx) => {
const clickId = ctx?.getCookie("daboos_id");
if (!clickId) return;
await daboos.track.lead({
clickId,
eventName: "Sign Up",
customerExternalId: user.id,
customerName: user.name,
customerEmail: user.email,
customerAvatar: user.image,
});
// delete the click id cookie
ctx?.setCookie("daboos_id", "", { maxAge: 0 });
},
},
},
},
});
For the full SDK reference, see the developer docs.