Dub Analytics Plugin is a plugin for Dub that allows you to track conversion events in your Better Auth application.
npm install @dub/better-auth
By default, the plugin will track sign up events as leads. You can disable this by setting disableLeadTracking
to true
.
import { dubAnalytics } from "@dub/better-auth";
import { betterAuth } from "better-auth";
import { Dub } from "dub";
const dub = new Dub();
const betterAuth = betterAuth({
plugins: [
dubAnalytics({
dubClient: dub,
}),
],
});
Dub Better Auth supports OAuth for authentication. You can configure the OAuth client ID and client secret in the dubAnalytics
function.
dubAnalytics({
dubClient: dub,
oauth: {
clientId: "your-client-id",
clientSecret: "your-client-secret",
},
});
And in the client, you need to use the dubAnalyticsClient
plugin.
import { createAuthClient } from "better-auth/client"
import { dubAnalyticsClient } from "@dub/better-auth/client"
const authClient = createAuthClient({
plugins: [dubAnalyticsClient()],
});
To link account with Dub, you need to use the dub.link
.
const response = await authClient.dub.link({
callbackURL: "/dashboard", // URL to redirect to after linking
});
The Dub client instance.
Disable lead tracking for sign up events.
Event name for sign up leads.
Custom lead track function.
Dub OAuth configuration.
Client ID for Dub OAuth.
Client secret for Dub OAuth.
Enable PKCE for Dub OAuth.
MIT