Skip to content

Commit efec6d9

Browse files
committed
fix(posthog): remove usePostHog from memo'd TemplateCard, fix copilot chat phantom workspace group
1 parent 1209cd7 commit efec6d9

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

apps/sim/app/api/copilot/chat/route.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ export async function POST(req: NextRequest) {
200200
mode,
201201
},
202202
{
203-
groups: { workspace: resolvedWorkspaceId ?? '' },
203+
groups: resolvedWorkspaceId ? { workspace: resolvedWorkspaceId } : undefined,
204204
setOnce: { first_copilot_use_at: new Date().toISOString() },
205205
}
206206
)

apps/sim/app/workspace/[workspaceId]/home/components/template-prompts/template-prompts.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { type ComponentType, memo, type SVGProps } from 'react'
44
import Image from 'next/image'
5-
import { usePostHog } from 'posthog-js/react'
65
import { AgentIcon, ScheduleIcon, StartIcon } from '@/components/icons'
76
import type { Category, ModuleTag } from './consts'
87
import { CATEGORY_META, TEMPLATES } from './consts'
@@ -350,16 +349,19 @@ interface TemplateCardProps {
350349

351350
const TemplateCard = memo(function TemplateCard({ template, onSelect }: TemplateCardProps) {
352351
const Icon = template.icon
353-
const posthog = usePostHog()
354352

355353
return (
356354
<button
357355
type='button'
358356
onClick={() => {
359-
posthog?.capture('template_used', {
360-
template_title: template.title,
361-
template_modules: template.modules.join(' '),
362-
})
357+
import('@/lib/posthog/client')
358+
.then(({ captureClientEvent }) => {
359+
captureClientEvent('template_used', {
360+
template_title: template.title,
361+
template_modules: template.modules.join(' '),
362+
})
363+
})
364+
.catch(() => {})
363365
onSelect(template.prompt)
364366
}}
365367
aria-label={`Select template: ${template.title}`}

0 commit comments

Comments
 (0)