Skip to content

Commit a3a9f9d

Browse files
committed
fix: custom event on signup
1 parent d9db776 commit a3a9f9d

File tree

1 file changed

+17
-0
lines changed
  • apps/dashboard/app/(auth)/register

1 file changed

+17
-0
lines changed

apps/dashboard/app/(auth)/register/page.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"use client";
22

33
import { authClient } from "@databuddy/auth/client";
4+
import { track } from "@databuddy/sdk";
45
import {
56
CaretLeftIcon,
67
CheckCircleIcon,
@@ -54,6 +55,20 @@ function RegisterPageContent() {
5455
setFormData((prev) => ({ ...prev, [name]: value }));
5556
};
5657

58+
const trackSignUp = async (
59+
method: "email" | "social",
60+
provider?: "github" | "google"
61+
) => {
62+
try {
63+
await track("signup_completed", {
64+
method: method === "social" ? `${method}_${provider}` : method,
65+
plan: selectedPlan || undefined,
66+
});
67+
} catch (error) {
68+
console.error("Failed to track sign up event:", error);
69+
}
70+
};
71+
5772
const handleAuthSuccess = () => {
5873
if (callbackUrl) {
5974
toast.success("Account created! Completing integration...");
@@ -92,6 +107,7 @@ function RegisterPageContent() {
92107
name: formData.name,
93108
fetchOptions: {
94109
onSuccess: () => {
110+
trackSignUp("email").catch(console.error);
95111
if (callbackUrl) {
96112
handleAuthSuccess();
97113
} else {
@@ -144,6 +160,7 @@ function RegisterPageContent() {
144160
callbackURL: callbackUrl || "/websites",
145161
fetchOptions: {
146162
onSuccess: () => {
163+
trackSignUp("social", provider).catch(console.error);
147164
toast.success("Registration successful!");
148165
handleAuthSuccess();
149166
},

0 commit comments

Comments
 (0)