Repository navigation
feat: Add developer console branding with mission statement and authentication logging (#72) #149
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| export const VAI_ASCII_ART = ` | ||
| ██╗ ██╗ █████╗ ██╗ ██╗ ██╗███████╗██╗ ██╗ | ||
| ██║ ██║██╔══██╗██║ ██║ ██║██╔════╝╚██╗██╔╝ | ||
| ██║ ██║███████║██║ ██║ ██║█████╗ ╚███╔╝ | ||
| ╚██╗ ██╔╝██╔══██║██║ ╚██╗ ██╔╝██╔══╝ ██╔██╗ | ||
| ╚████╔╝ ██║ ██║███████╗ ╚████╔╝ ███████╗██╔╝ ██╗ | ||
| ╚═══╝ ╚═╝ ╚═╝╚══════╝ ╚═══╝ ╚══════╝╚═╝ ╚═╝ | ||
| `; | ||
|
|
||
| export const MISSION_STATEMENT = ` | ||
| 🚀 Empowering AI Engineers to Build the Future | ||
|
|
||
| Join us in creating the world's most innovative AI engineering community. | ||
| Share knowledge, collaborate on projects, and advance the field of AI together. | ||
|
|
||
| 💼 Explore Career Opportunities: https://vibewith.ai/blog | ||
| 🌟 Be part of something extraordinary. | ||
| `; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| "use client"; | ||
|
|
||
| import { useUser } from "@clerk/nextjs"; | ||
| import { useEffect } from "react"; | ||
| import { useConsoleLogger } from "@/hooks/use-console-branding"; | ||
|
|
||
| export function ConsoleBranding() { | ||
| const { isSignedIn, user } = useUser(); | ||
| const { logBranding, logAuthEvent } = useConsoleLogger(); | ||
|
|
||
| // Display branding once on mount | ||
| useEffect(() => { | ||
| logBranding(); | ||
|
|
||
| // Log initial auth state | ||
| logAuthEvent("session_initialized", { | ||
| isSignedIn: !!isSignedIn, | ||
| userId: user?.id, | ||
| timestamp: new Date().toISOString(), | ||
| }); | ||
| }, [logBranding, logAuthEvent, isSignedIn, user?.id]); | ||
|
|
||
| // Log auth state changes | ||
| useEffect(() => { | ||
| if (isSignedIn) { | ||
| logAuthEvent("user_signed_in", { | ||
| isSignedIn: true, | ||
| userId: user?.id, | ||
| timestamp: new Date().toISOString(), | ||
| }); | ||
| } else { | ||
| logAuthEvent("user_signed_out", { | ||
| isSignedIn: false, | ||
| timestamp: new Date().toISOString(), | ||
| }); | ||
| } | ||
| }, [isSignedIn, user?.id, logAuthEvent]); | ||
|
|
||
| // This component only handles console output | ||
| return null; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| import { useCallback } from "react"; | ||
| import { MISSION_STATEMENT, VAI_ASCII_ART } from "@/components/ascii-art"; | ||
|
|
||
| interface AuthEventData { | ||
| timestamp: string; | ||
| isSignedIn?: boolean; | ||
| userId?: string; | ||
| event?: string; | ||
| } | ||
|
|
||
| interface TokenRefreshData { | ||
| expiresAt: string; | ||
| refreshedAt: string; | ||
| } | ||
|
|
||
| export function useConsoleLogger() { | ||
| const isDev = process.env.NODE_ENV === "development"; | ||
|
|
||
| const logBranding = useCallback(() => { | ||
| if (typeof window === "undefined") return; | ||
|
|
||
| console.log(`%c${VAI_ASCII_ART}`, "color: #3b82f6; font-weight: bold; font-family: monospace;"); | ||
| console.log(`%c${MISSION_STATEMENT}`, "color: #10b981; font-size: 14px; line-height: 1.5;"); | ||
| console.log( | ||
| "%c===== VAI-VEX Developer Console =====", | ||
| "color: #f59e0b; font-weight: bold; font-size: 16px;", | ||
| ); | ||
| console.log("%cVersion: 0.1.0", "color: #6b7280;"); | ||
| console.log(`%cEnvironment: ${process.env.NODE_ENV}`, "color: #6b7280;"); | ||
| }, []); | ||
|
|
||
| const logAuthEvent = useCallback( | ||
| (event: string, data: AuthEventData) => { | ||
| if (typeof window === "undefined") return; | ||
|
|
||
| const logLevel = isDev ? "log" : "debug"; | ||
|
|
||
| // Only include sensitive data in development | ||
| const safeData = { | ||
| timestamp: data.timestamp, | ||
| event, | ||
| isSignedIn: !!data.isSignedIn, | ||
| ...(isDev && data.userId && { userId: data.userId }), | ||
| }; | ||
|
|
||
| console[logLevel]( | ||
| `%c🔐 AUTH ${event.toUpperCase()}`, | ||
| "color: #8b5cf6; font-weight: bold;", | ||
| safeData, | ||
| ); | ||
| }, | ||
| [isDev], | ||
| ); | ||
|
|
||
| const logTokenRefresh = useCallback((tokenData: TokenRefreshData) => { | ||
| if (typeof window === "undefined") return; | ||
|
|
||
| console.log("%c🔄 TOKEN REFRESH", "color: #06b6d4; font-weight: bold;", { | ||
| timestamp: new Date().toISOString(), | ||
| expiresAt: tokenData.expiresAt, | ||
| refreshedAt: tokenData.refreshedAt, | ||
| }); | ||
| }, []); | ||
|
|
||
| return { | ||
| logBranding, | ||
| logAuthEvent, | ||
| logTokenRefresh, | ||
| }; | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Console Branding Duplicates on Auth Changes
The first
useEffectinConsoleBrandingincludesisSignedInanduser?.idin its dependency array. This causes the effect, meant to run once on mount for initial branding and session logging, to re-run whenever authentication state changes. This results in duplicate console branding and multiple "session_initialized" logs.