Skip to content

Commit 4a25207

Browse files
authored
Chad/fix editor outline (#14)
* fix editor outline styling * add link to discord in footer and redirect for agentsmith.dev/discord * re-order footer links * fix posthog inclusion maybe * turns out we are using 15.3.2 so we can use posthog in our instrumentation.ts * add posthog identify, adjust isEnv logic * add posthog reset to logout
1 parent ee915bd commit 4a25207

21 files changed

+157
-107
lines changed

next.config.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,15 @@ const nextConfig: NextConfig = {
6767
},
6868
];
6969
},
70+
async redirects() {
71+
return [
72+
{
73+
source: '/discord',
74+
destination: 'https://discord.gg/FbdSJZCK2h',
75+
permanent: false,
76+
},
77+
];
78+
},
7079
async headers() {
7180
const cspHeader = [
7281
`default-src ${self}`,

package-lock.json

Lines changed: 18 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@
7070
"nunjucks": "^3.2.4",
7171
"octokit": "^4.1.2",
7272
"pino": "^9.7.0",
73-
"posthog-js": "^1.215.1",
73+
"posthog-js": "^1.258.2",
7474
"prettier": "^3.3.3",
7575
"prismjs": "^1.29.0",
7676
"react": "19.0.0",

src/app/layout.tsx

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { IBM_Plex_Mono } from 'next/font/google';
33
import { ThemeProvider } from 'next-themes';
44
import { GoogleAnalytics } from '@next/third-parties/google';
55
import { Toaster } from '@/components/ui/sonner';
6-
import { PostHogProvider } from '@/providers/posthog';
76
import { isDev, isProd } from '@/utils/is-env';
7+
import { PostHogIdentify } from './posthog-identify';
88

99
const defaultUrl =
1010
isProd && process.env.NEXT_PUBLIC_SITE_URL
@@ -40,20 +40,19 @@ export default function RootLayout(props: RootLayoutProps) {
4040
<script src="https://unpkg.com/react-scan/dist/auto.global.js" />
4141
</head>
4242
)}
43-
<PostHogProvider>
44-
<GoogleAnalytics gaId="G-PZG86YG9ZZ" />
45-
<body className="bg-background text-foreground">
46-
<ThemeProvider
47-
attribute="class"
48-
defaultTheme="system"
49-
enableSystem
50-
disableTransitionOnChange
51-
>
52-
<Toaster expand visibleToasts={9} />
53-
{children}
54-
</ThemeProvider>
55-
</body>
56-
</PostHogProvider>
43+
<PostHogIdentify />
44+
<GoogleAnalytics gaId="G-PZG86YG9ZZ" />
45+
<body className="bg-background text-foreground">
46+
<ThemeProvider
47+
attribute="class"
48+
defaultTheme="system"
49+
enableSystem
50+
disableTransitionOnChange
51+
>
52+
<Toaster expand visibleToasts={9} />
53+
{children}
54+
</ThemeProvider>
55+
</body>
5756
</html>
5857
);
5958
}

src/app/posthog-identify.tsx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'use client';
2+
3+
import { useEffect } from 'react';
4+
import posthog from 'posthog-js';
5+
import { createClient } from '@/lib/supabase/client';
6+
7+
export const PostHogIdentify = () => {
8+
useEffect(() => {
9+
const initIdentify = async () => {
10+
const { data } = await createClient().auth.getSession();
11+
12+
const githubIdentity = data.session?.user.identities?.find(
13+
(identity) => identity.provider === 'github',
14+
);
15+
16+
if (data.session) {
17+
posthog.identify(data.session.user.id, {
18+
email: data.session.user.email,
19+
name: data.session.user.user_metadata.name,
20+
github_username: githubIdentity?.identity_data?.user_name,
21+
});
22+
}
23+
};
24+
25+
initIdentify();
26+
}, []);
27+
return null;
28+
};

src/components/brevo-email-subscribe/brevo-email-subscribe.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@ import './brevo-email-subscribe.css';
99
import { Input } from '@/components/ui/input';
1010
import { Label } from '@/components/ui/label';
1111
import { Checkbox } from '@/components/ui/checkbox';
12-
import { Alert, AlertDescription } from '@/components/ui/alert';
12+
import { Alert } from '@/components/ui/alert';
1313
import { Button } from '@/components/ui/button';
1414
import { CheckCircle2, AlertCircle, Loader2 } from 'lucide-react';
15-
import { usePostHog } from 'posthog-js/react';
15+
import posthog from 'posthog-js';
1616

1717
declare global {
1818
interface Window {
@@ -52,8 +52,6 @@ type BrevoEmailSubscribeProps = {
5252
};
5353

5454
export const BrevoEmailSubscribe = (props: BrevoEmailSubscribeProps) => {
55-
const posthog = usePostHog();
56-
5755
const { form, trackingLocation } = props;
5856
const formSubmitUrl = BrevoForms[form];
5957

src/components/editors/json-editor.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ export const JsonEditor = <T extends object>(props: JsonEditorProps<T>) => {
3636

3737
const [jsonText, setJsonText] = useState<string>(JSON.stringify(value, null, 2));
3838
const [jsonError, setJsonError] = useState<string | null>(null);
39+
const [isFocused, setIsFocused] = useState(false);
3940

4041
const handleJsonChange = (text: string) => {
4142
setJsonText(text);
@@ -56,6 +57,7 @@ export const JsonEditor = <T extends object>(props: JsonEditorProps<T>) => {
5657
'rounded-md border bg-background',
5758
jsonError && 'border-destructive',
5859
innerClassName,
60+
isFocused && 'border-ring ring-ring/50 ring-[1px]',
5961
)}
6062
>
6163
<Editor
@@ -65,11 +67,14 @@ export const JsonEditor = <T extends object>(props: JsonEditorProps<T>) => {
6567
disabled={readOnly}
6668
padding={16}
6769
placeholder={placeholder}
70+
onFocus={() => setIsFocused(true)}
71+
onBlur={() => setIsFocused(false)}
6872
style={{
6973
fontSize: 14,
7074
minHeight,
7175
}}
7276
className="w-full"
77+
textareaClassName="outline-none"
7378
/>
7479
</div>
7580
{jsonError && (

src/components/editors/markdown-editor.tsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'prismjs/components/prism-markdown';
66
import 'prismjs/themes/prism.css';
77
import { cn } from '@/utils/shadcn';
88
import './json-editor.css';
9+
import { useState } from 'react';
910

1011
type MarkdownEditorProps = {
1112
value: string;
@@ -28,16 +29,26 @@ export const MarkdownEditor = (props: MarkdownEditorProps) => {
2829
innerClassName,
2930
} = props;
3031

32+
const [isFocused, setIsFocused] = useState(false);
33+
3134
return (
3235
<div className={cn('space-y-2', className)}>
33-
<div className={cn('rounded-md border bg-background', innerClassName)}>
36+
<div
37+
className={cn(
38+
'rounded-md border bg-background',
39+
isFocused && 'border-ring ring-ring/50 ring-[1px]',
40+
innerClassName,
41+
)}
42+
>
3443
<Editor
3544
value={value}
3645
onValueChange={readOnly ? () => {} : onChange}
3746
highlight={(code) => highlight(code, languages.markdown, 'markdown')}
3847
disabled={readOnly}
3948
padding={16}
4049
placeholder={placeholder}
50+
onFocus={() => setIsFocused(true)}
51+
onBlur={() => setIsFocused(false)}
4152
style={{
4253
fontSize: 14,
4354
minHeight,

src/components/editors/prompt-editor.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const PromptContentEditor = (props: PromptContentEditorProps) => {
6363
const timeoutRef = useRef<NodeJS.Timeout | null>(null);
6464
const detectedVariablesRef = useRef<ParsedVariable[]>([]);
6565
const detectedIncludesRef = useRef<ParsedInclude[]>([]);
66+
const [isFocused, setIsFocused] = useState(false);
6667

6768
// Effect to detect variables when content changes
6869
useEffect(() => {
@@ -94,18 +95,22 @@ export const PromptContentEditor = (props: PromptContentEditorProps) => {
9495
'rounded-md border bg-background',
9596
templateError && 'border-destructive',
9697
readOnly && 'opacity-70',
98+
isFocused && 'border-ring ring-ring/50 ring-[1px]',
9799
)}
98100
>
99101
<Editor
100102
value={content}
101103
onValueChange={readOnly ? () => {} : onContentChange}
102104
highlight={(code) => highlight(code, languages.django, 'django')}
105+
onFocus={() => setIsFocused(true)}
106+
onBlur={() => setIsFocused(false)}
103107
padding={16}
104108
disabled={readOnly}
105109
style={{
106110
minHeight,
107111
}}
108112
className="w-full"
113+
textareaClassName="outline-none"
109114
/>
110115
</div>
111116

src/components/marketing/faq.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
AccordionItem,
77
AccordionTrigger,
88
} from '@/components/ui/accordion';
9-
import { usePostHog } from 'posthog-js/react';
9+
import posthog from 'posthog-js';
1010

1111
const faqData = [
1212
{
@@ -60,8 +60,6 @@ const faqData = [
6060
];
6161

6262
export const FAQSection = () => {
63-
const posthog = usePostHog();
64-
6563
const handleAccordionTriggerClick = (faqItem: (typeof faqData)[number]) => {
6664
posthog.capture('faq_accordion_trigger_clicked', {
6765
value: faqItem.value,

0 commit comments

Comments
 (0)