diff --git a/index.html b/index.html
index 58472c473..f52ab99ad 100644
--- a/index.html
+++ b/index.html
@@ -3,6 +3,9 @@
+
+
+
DebateLab by Programcode | AI Debate Prep, Cases & Rebuttals
diff --git a/package-lock.json b/package-lock.json
index 7fe3c2883..8023db8b5 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -17,6 +17,7 @@
"@capacitor/keyboard": "^8.0.3",
"@capacitor/status-bar": "^8.0.2",
"@hookform/resolvers": "^3.10.0",
+ "@jam.dev/sdk": "^1.0.1",
"@radix-ui/react-accordion": "^1.2.11",
"@radix-ui/react-alert-dialog": "^1.1.14",
"@radix-ui/react-aspect-ratio": "^1.1.7",
@@ -1254,6 +1255,12 @@
"node": ">=18.0.0"
}
},
+ "node_modules/@jam.dev/sdk": {
+ "version": "1.0.1",
+ "resolved": "https://registry.npmjs.org/@jam.dev/sdk/-/sdk-1.0.1.tgz",
+ "integrity": "sha512-M7KZt079P76BnevBq/z+OaFZGPfA8KVbDSmc9+ARJhPz1t9IeTjrM0cLzbf+07H9IcVizovO65bhdMUWm9EFRQ==",
+ "license": "Apache-2.0"
+ },
"node_modules/@jridgewell/gen-mapping": {
"version": "0.3.13",
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
diff --git a/package.json b/package.json
index c41bb817e..3572f0058 100644
--- a/package.json
+++ b/package.json
@@ -32,6 +32,7 @@
"@capacitor/keyboard": "^8.0.3",
"@capacitor/status-bar": "^8.0.2",
"@hookform/resolvers": "^3.10.0",
+ "@jam.dev/sdk": "^1.0.1",
"@radix-ui/react-accordion": "^1.2.11",
"@radix-ui/react-alert-dialog": "^1.1.14",
"@radix-ui/react-aspect-ratio": "^1.1.7",
diff --git a/src/lib/jam-metadata.ts b/src/lib/jam-metadata.ts
new file mode 100644
index 000000000..26d524b7c
--- /dev/null
+++ b/src/lib/jam-metadata.ts
@@ -0,0 +1,9 @@
+import { jam } from "@jam.dev/sdk";
+
+let currentUserId: string | undefined;
+
+jam.metadata(() => ({ userId: currentUserId }));
+
+export function setJamUserId(userId: string | undefined): void {
+ currentUserId = userId;
+}
diff --git a/src/lib/supabase/AuthProvider.tsx b/src/lib/supabase/AuthProvider.tsx
index 59c888327..24773791b 100644
--- a/src/lib/supabase/AuthProvider.tsx
+++ b/src/lib/supabase/AuthProvider.tsx
@@ -5,6 +5,7 @@ import { supabase } from './client';
import { useSessionStore } from '@/lib/stores/session-store';
import { useSettingsStore } from '@/lib/stores/settings-store';
import { getOAuthRedirectUrl, openExternalUrl } from '@/lib/native';
+import { setJamUserId } from '@/lib/jam-metadata';
interface AuthContextValue {
session: Session | null;
@@ -98,6 +99,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
if (oauthSession) {
setSession(oauthSession);
currentUserIdRef.current = oauthSession.user?.id;
+ setJamUserId(oauthSession.user?.id);
setLoading(false);
hydrateStores(oauthSession.user?.id);
return;
@@ -117,6 +119,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
if (error) console.warn('[Auth] getSession error:', error.message);
setSession(data.session ?? null);
currentUserIdRef.current = data.session?.user?.id;
+ setJamUserId(data.session?.user?.id);
if (data.session) {
hydrateStores(data.session.user?.id);
}
@@ -124,6 +127,8 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
console.warn('[Auth] init failed:', err);
if (!mounted) return;
setSession(null);
+ currentUserIdRef.current = undefined;
+ setJamUserId(undefined);
} finally {
if (mounted) setLoading(false);
}
@@ -137,6 +142,7 @@ export function AuthProvider({ children }: { children: React.ReactNode }) {
const prevUserId = currentUserIdRef.current;
const nextUserId = newSession?.user?.id;
currentUserIdRef.current = nextUserId;
+ setJamUserId(nextUserId);
setSession(newSession);
setLoading(false);