Skip to content

Commit 5b059e7

Browse files
committed
chore: add analytics for signin
1 parent 49f4ea4 commit 5b059e7

3 files changed

Lines changed: 15 additions & 2 deletions

File tree

apps/web/src/app/providers.tsx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,23 @@ export function PostHogAuthTracker() {
7373
is_new_user: isNewUser,
7474
});
7575

76+
// Track sign-up completed for new users
77+
if (isNewUser) {
78+
posthog.capture("sign_up_completed", {
79+
provider: provider,
80+
});
81+
}
82+
7683
if (process.env.NODE_ENV === "development") {
7784
console.log("[Analytics] Event tracked: sign_in_completed", {
7885
provider,
7986
is_new_user: isNewUser,
8087
});
88+
if (isNewUser) {
89+
console.log("[Analytics] Event tracked: sign_up_completed", {
90+
provider,
91+
});
92+
}
8193
}
8294

8395
// Clear the sign-in tracking flags

apps/web/src/components/login/SignInPage.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { Google, Github } from "../icons/icons";
66
import Image from "next/image";
77
import Overlay from "../ui/overlay";
88
import { useAnalytics } from "@/hooks/useAnalytics";
9+
import { sanitizeCallbackUrl } from "@/lib/analytics";
910

1011
const SignInPage = () => {
1112
const searchParams = useSearchParams();
@@ -35,7 +36,8 @@ const SignInPage = () => {
3536

3637
const handleSignIn = (provider: "google" | "github") => {
3738
// Sanitize callback URL to prevent leaking sensitive query params or tokens
38-
const sanitizedCallback = safeCallbackUrl.split("?")[0].split("#")[0];
39+
// Use centralized utility for consistent sanitization
40+
const sanitizedCallback = sanitizeCallbackUrl(safeCallbackUrl);
3941

4042
// Track sign-in attempt with sanitized callback (no query params or fragments)
4143
trackSignInStarted(provider, sanitizedCallback);

apps/web/src/lib/analytics.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/**
22
* Centralized Analytics Utility for PostHog
3-
* No PII (email, name) is stored - only anonymous user identifiers.
43
*/
54

65
import posthog from "posthog-js";

0 commit comments

Comments
 (0)