Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

UI polishing

Blue Mousea4ea87a5d9a3
diff --git a/web/app/pages/Project/View/components/Filters.tsx b/web/app/pages/Project/View/components/Filters.tsx
index 988d6b814..d04b37c84 100644
--- a/web/app/pages/Project/View/components/Filters.tsx
+++ b/web/app/pages/Project/View/components/Filters.tsx
@@ -269,7 +269,7 @@ const Filters = ({ tnMapping, className }: FiltersProps) => {
return (
<div
className={cn(
- 'mt-3 flex items-center justify-between rounded-md border border-gray-300 bg-slate-200 p-1 dark:border-slate-800/50 dark:bg-slate-800/25',
+ 'flex items-center justify-between rounded-md border border-gray-300 bg-slate-200 p-1 dark:border-slate-800/50 dark:bg-slate-800/25',
className,
)}
>
diff --git a/web/app/pages/Project/View/components/NoEvents.tsx b/web/app/pages/Project/View/components/NoEvents.tsx
index f8f59aba5..d6b359e89 100644
--- a/web/app/pages/Project/View/components/NoEvents.tsx
+++ b/web/app/pages/Project/View/components/NoEvents.tsx
@@ -21,11 +21,7 @@ const NoEvents = ({ filters }: NoEventsProps) => {
return (
<>
- {hasFilters ? (
- <div className='mt-4'>
- <Filters tnMapping={tnMapping} />
- </div>
- ) : null}
+ {hasFilters ? <Filters tnMapping={tnMapping} /> : null}
<div className='mx-auto w-full max-w-2xl py-16 text-center'>
<div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-800'>
{hasFilters ? (
diff --git a/web/app/pages/Project/tabs/AskAI/AIChart.tsx b/web/app/pages/Project/tabs/AskAI/AIChart.tsx
index 6701618ec..e5121d880 100644
--- a/web/app/pages/Project/tabs/AskAI/AIChart.tsx
+++ b/web/app/pages/Project/tabs/AskAI/AIChart.tsx
@@ -5,7 +5,7 @@ import _filter from 'lodash/filter'
import _isEmpty from 'lodash/isEmpty'
import _keys from 'lodash/keys'
import _map from 'lodash/map'
-import React, { useMemo } from 'react'
+import React, { useMemo, memo } from 'react'
import BillboardChart from '~/ui/BillboardChart'
@@ -25,7 +25,6 @@ interface AIChartProps {
chart: AIChartData
}
-// Generate nice colors for chart series
const CHART_COLORS = [
'#2563EB', // blue-600
'#16a34a', // green-600
@@ -37,7 +36,6 @@ const CHART_COLORS = [
'#db2777', // pink-600
]
-// Calculate optimal Y axis ticks
const calculateOptimalTicks = (data: number[], targetCount: number = 6): number[] => {
const validData = data.filter((n) => n !== undefined && n !== null && Number.isFinite(n))
@@ -109,7 +107,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
const chartOptions = useMemo<ChartOptions>(() => {
const isPieDonut = isPieOrDonutChart(chart.chartType)
- // For pie/donut charts, check for labels and values
if (isPieDonut) {
if (_isEmpty(chart.data) || _isEmpty(chart.data.labels) || _isEmpty(chart.data.values)) {
return {}
@@ -118,7 +115,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
const labels = chart.data.labels as string[]
const values = chart.data.values as number[]
- // Build columns for pie/donut: each column is [label, value]
const columns: any[] = labels.map((label, idx) => [label, values[idx] || 0])
const colors: Record<string, string> = {}
@@ -175,7 +171,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
}
}
- // For time-series charts (line, bar, area, spline)
if (_isEmpty(chart.data) || _isEmpty(chart.data.x)) {
return {}
}
@@ -183,7 +178,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
const xData = chart.data.x as string[]
const seriesKeys = _filter(_keys(chart.data), (key) => key !== 'x' && key !== 'labels' && key !== 'values')
- // Build columns
const columns: any[] = [['x', ..._map(xData, (el) => (dayjs(el).isValid() ? dayjs(el).toDate() : el))]]
const types: Record<string, ReturnType<typeof line | typeof bar | typeof area | typeof spline>> = {}
@@ -195,7 +189,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
colors[key] = CHART_COLORS[idx % CHART_COLORS.length]
})
- // Calculate optimal Y axis ticks from all series data
const allYValues: number[] = []
seriesKeys.forEach((key) => {
const values = chart.data[key]
@@ -210,7 +203,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
const optimalTicks = allYValues.length > 0 ? calculateOptimalTicks(allYValues) : undefined
- // Determine if x-axis looks like dates
const isDateAxis = xData.length > 0 && dayjs(xData[0]).isValid()
return {
@@ -240,7 +232,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
format: isDateAxis
? (x: Date) => {
const d = dayjs(x)
- // Auto-format based on data range
if (xData.length <= 24) {
return d.format('HH:mm')
} else if (xData.length <= 31) {
@@ -306,7 +297,6 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
const isPieDonut = isPieOrDonutChart(chart.chartType)
- // Validate data based on chart type
if (isPieDonut) {
if (_isEmpty(chart.data) || _isEmpty(chart.data.labels) || _isEmpty(chart.data.values)) {
return null
@@ -329,4 +319,7 @@ const AIChart: React.FC<AIChartProps> = ({ chart }) => {
)
}
-export default AIChart
+// Memoize to prevent re-renders during streaming when chart data hasn't changed
+export default memo(AIChart, (prevProps, nextProps) => {
+ return JSON.stringify(prevProps.chart) === JSON.stringify(nextProps.chart)
+})
diff --git a/web/app/pages/Project/tabs/AskAI/AskAIView.tsx b/web/app/pages/Project/tabs/AskAI/AskAIView.tsx
index 83304b1b4..1d2de0b72 100644
--- a/web/app/pages/Project/tabs/AskAI/AskAIView.tsx
+++ b/web/app/pages/Project/tabs/AskAI/AskAIView.tsx
@@ -21,7 +21,7 @@ import {
LinkIcon,
} from 'lucide-react'
import { marked } from 'marked'
-import React, { useState, useRef, useEffect, useCallback } from 'react'
+import React, { useState, useRef, useEffect, useCallback, useMemo } from 'react'
import { useTranslation } from 'react-i18next'
import { useSearchParams } from 'react-router'
import sanitizeHtml from 'sanitize-html'
@@ -58,13 +58,11 @@ interface AskAIViewProps {
projectId: string
}
-// Configure marked for safe rendering
marked.setOptions({
breaks: true,
gfm: true,
})
-// Parse chart JSON from AI response
const parseCharts = (content: string): { text: string; charts: any[] } => {
const charts: any[] = []
let text = content
@@ -120,7 +118,6 @@ const parseCharts = (content: string): { text: string; charts: any[] } => {
return { text: text.trim(), charts }
}
-// Render markdown safely
const renderMarkdown = (content: string): string => {
const html = marked.parse(content) as string
return sanitizeHtml(html, {
@@ -139,7 +136,6 @@ const renderMarkdown = (content: string): string => {
})
}
-// Tool name to human-readable description
const getToolInfo = (
toolName: string,
t: any,
@@ -153,15 +149,14 @@ const getToolInfo = (
return toolMap[toolName] || { label: toolName, icon: InfoIcon }
}
-// Available tools for display
const getAvailableTools = (t: any) => [
{ id: 'getData', label: t('project.askAi.tools.queryData'), icon: BarChart3Icon },
{ id: 'getGoalStats', label: t('project.askAi.tools.goalStats'), icon: TargetIcon },
{ id: 'getFunnelData', label: t('project.askAi.tools.funnelData'), icon: GitBranchIcon },
]
-// Tools tooltip content
-const ToolsTooltip = ({ t }: { t: any }) => {
+const ToolsTooltip = () => {
+ const { t } = useTranslation('common')
const AVAILABLE_TOOLS = getAvailableTools(t)
return (
<div className='space-y-1.5 py-1'>
@@ -175,12 +170,12 @@ const ToolsTooltip = ({ t }: { t: any }) => {
)
}
-// Compact tools indicator with tooltip
-const ToolsIndicator = ({ t }: { t: any }) => {
+const ToolsIndicator = () => {
+ const { t } = useTranslation('common')
const AVAILABLE_TOOLS = getAvailableTools(t)
return (
<Tooltip
- text={<ToolsTooltip t={t} />}
+ text={<ToolsTooltip />}
tooltipNode={
<span className='flex cursor-help items-center gap-1 rounded-md px-1.5 py-0.5 text-xs font-medium text-gray-500 transition-colors hover:bg-gray-100 hover:text-gray-700 dark:text-gray-400 dark:hover:bg-slate-800 dark:hover:text-gray-300'>
{t('project.askAi.tools.count', { count: AVAILABLE_TOOLS.length })}
@@ -190,73 +185,77 @@ const ToolsIndicator = ({ t }: { t: any }) => {
)
}
-// AI Capabilities tooltip content
-const AICapabilitiesTooltip = ({ t }: { t: any }) => (
- <div className='max-w-sm space-y-3 py-1 text-left'>
- <div>
- <p className='mb-1.5 font-semibold text-white'>{t('project.askAi.capabilities.title')}</p>
- <ul className='space-y-1 text-gray-300'>
- <li className='flex items-start gap-1.5'>
- <BarChart3Icon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
- <span>
- <strong className='text-white'>{t('project.askAi.capabilities.queryAnalytics')}</strong>
- </span>
- </li>
- <li className='flex items-start gap-1.5'>
- <TargetIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
- <span>
- <strong className='text-white'>{t('project.askAi.capabilities.goalStatistics')}</strong>
- </span>
- </li>
- <li className='flex items-start gap-1.5'>
- <GitBranchIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
- <span>
- <strong className='text-white'>{t('project.askAi.capabilities.funnelAnalysis')}</strong>
- </span>
- </li>
- <li className='flex items-start gap-1.5'>
- <BarChart3Icon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
- <span>
- <strong className='text-white'>{t('project.askAi.capabilities.performanceMetrics')}</strong>
- </span>
- </li>
- <li className='flex items-start gap-1.5'>
- <AlertCircleIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
- <span>
- <strong className='text-white'>{t('project.askAi.capabilities.errorTracking')}</strong>
- </span>
- </li>
- <li className='flex items-start gap-1.5'>
- <InfoIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
- <span>{t('project.askAi.capabilities.trafficPatterns')}</span>
- </li>
- </ul>
- </div>
- <div>
- <p className='mb-1.5 font-semibold text-white'>{t('project.askAi.capabilities.cannotTitle')}</p>
- <ul className='space-y-1 text-gray-300'>
- <li className='flex items-start gap-1.5'>
- <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
- <span>{t('project.askAi.capabilities.cannotBrowse')}</span>
- </li>
- <li className='flex items-start gap-1.5'>
- <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
- <span>{t('project.askAi.capabilities.cannotSeeOutside')}</span>
- </li>
- <li className='flex items-start gap-1.5'>
- <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
- <span>{t('project.askAi.capabilities.cannotGuarantee')}</span>
- </li>
- <li className='flex items-start gap-1.5'>
- <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
- <span>{t('project.askAi.capabilities.cannotModify')}</span>
- </li>
- </ul>
+const AICapabilitiesTooltip = () => {
+ const { t } = useTranslation('common')
+
+ return (
+ <div className='max-w-sm space-y-3 py-1 text-left'>
+ <div>
+ <p className='mb-1.5 font-semibold text-white'>{t('project.askAi.capabilities.title')}</p>
+ <ul className='space-y-1 text-gray-300'>
+ <li className='flex items-start gap-1.5'>
+ <BarChart3Icon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
+ <span>
+ <strong className='text-white'>{t('project.askAi.capabilities.queryAnalytics')}</strong>
+ </span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <TargetIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
+ <span>
+ <strong className='text-white'>{t('project.askAi.capabilities.goalStatistics')}</strong>
+ </span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <GitBranchIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
+ <span>
+ <strong className='text-white'>{t('project.askAi.capabilities.funnelAnalysis')}</strong>
+ </span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <BarChart3Icon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
+ <span>
+ <strong className='text-white'>{t('project.askAi.capabilities.performanceMetrics')}</strong>
+ </span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <AlertCircleIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
+ <span>
+ <strong className='text-white'>{t('project.askAi.capabilities.errorTracking')}</strong>
+ </span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <InfoIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-green-400' />
+ <span>{t('project.askAi.capabilities.trafficPatterns')}</span>
+ </li>
+ </ul>
+ </div>
+ <div>
+ <p className='mb-1.5 font-semibold text-white'>{t('project.askAi.capabilities.cannotTitle')}</p>
+ <ul className='space-y-1 text-gray-300'>
+ <li className='flex items-start gap-1.5'>
+ <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
+ <span>{t('project.askAi.capabilities.cannotBrowse')}</span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
+ <span>{t('project.askAi.capabilities.cannotSeeOutside')}</span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
+ <span>{t('project.askAi.capabilities.cannotGuarantee')}</span>
+ </li>
+ <li className='flex items-start gap-1.5'>
+ <XIcon className='mt-0.5 h-3.5 w-3.5 shrink-0 text-red-400' />
+ <span>{t('project.askAi.capabilities.cannotModify')}</span>
+ </li>
+ </ul>
+ </div>
</div>
- </div>
-)
+ )
+}
-const ThinkingIndicator = ({ t }: { t: any }) => {
+const ThinkingIndicator = () => {
+ const { t } = useTranslation('common')
return (
<div className='flex items-center gap-2 text-sm text-gray-500 dark:text-gray-400'>
<Loader2Icon className='h-4 w-4 animate-spin' />
@@ -271,16 +270,14 @@ const ThoughtProcess = ({
hasContent,
isExpanded,
onToggle,
- t,
}: {
reasoning?: string
isStreaming?: boolean
hasContent?: boolean
isExpanded: boolean
onToggle: () => void
- t: any
}) => {
- // Show thinking indicator while streaming and collecting reasoning (before content appears)
+ const { t } = useTranslation('common')
const isActivelyThinking = isStreaming && reasoning && !hasContent
if (!reasoning) return null
@@ -322,7 +319,9 @@ const ThoughtProcess = ({
)
}
-const ToolCallBadge = ({ toolName, isLoading = false, t }: { toolName: string; isLoading?: boolean; t: any }) => {
+const ToolCallBadge = ({ toolName, isLoading = false }: { toolName: string; isLoading?: boolean }) => {
+ const { t } = useTranslation('common')
+
const { label, icon: Icon } = getToolInfo(toolName, t)
return (
@@ -339,7 +338,7 @@ const ToolCallBadge = ({ toolName, isLoading = false, t }: { toolName: string; i
}
const MessageContent = ({ content, isStreaming }: { content: string; isStreaming?: boolean }) => {
- const { text, charts } = parseCharts(content)
+ const { text, charts } = useMemo(() => parseCharts(content), [content])
return (
<>
@@ -361,14 +360,11 @@ const MessageContent = ({ content, isStreaming }: { content: string; isStreaming
)
}
-const AssistantMessage = ({ message, isStreaming, t }: { message: Message; isStreaming?: boolean; t: any }) => {
+const AssistantMessage = ({ message, isStreaming }: { message: Message; isStreaming?: boolean }) => {
const [userToggled, setUserToggled] = useState(false)
const [userExpandedState, setUserExpandedState] = useState(false)
const hasContent = Boolean(message.content && message.content.trim())
- // Determine if thought should be expanded:
- // - If user has manually toggled, use their preference
- // - Otherwise, auto-expand while actively thinking (streaming + reasoning + no content yet)
const isActivelyThinking = Boolean(isStreaming && message.reasoning && !hasContent)
const isThoughtExpanded = userToggled ? userExpandedState : isActivelyThinking
@@ -385,12 +381,11 @@ const AssistantMessage = ({ message, isStreaming, t }: { message: Message; isStr
hasContent={hasContent}
isExpanded={isThoughtExpanded}
onToggle={handleToggle}
- t={t}
/>
{message.toolCalls && message.toolCalls.length > 0 ? (
<div className='mb-3 flex flex-wrap gap-2'>
{_map(message.toolCalls, (call, idx) => (
- <ToolCallBadge key={idx} toolName={call.toolName} isLoading={Boolean(isStreaming && !hasContent)} t={t} />
+ <ToolCallBadge key={idx} toolName={call.toolName} isLoading={Boolean(isStreaming && !hasContent)} />
))}
</div>
) : null}
@@ -409,15 +404,9 @@ const UserMessage = ({ content }: { content: string }) => {
)
}
-const ScrollToBottomButton = ({
- isAtBottom,
- scrollToBottom,
- t,
-}: {
- isAtBottom: boolean
- scrollToBottom: () => void
- t: any
-}) => {
+const ScrollToBottomButton = ({ isAtBottom, scrollToBottom }: { isAtBottom: boolean; scrollToBottom: () => void }) => {
+ const { t } = useTranslation('common')
+
if (isAtBottom) return null
return (
@@ -451,7 +440,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
const inputRef = useRef<HTMLTextAreaElement>(null)
const abortControllerRef = useRef<AbortController | null>(null)
- // Chat history state
const [currentChatId, setCurrentChatId] = useState<string | null>(null)
const [recentChats, setRecentChats] = useState<AIChatSummary[]>([])
const [allChats, setAllChats] = useState<AIChatSummary[]>([])
@@ -461,20 +449,17 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
const [chatToDelete, setChatToDelete] = useState<string | null>(null)
const hasInitializedRef = useRef(false)
- // Stick to bottom hook for chat auto-scroll
const { scrollRef, contentRef, isAtBottom, scrollToBottom } = useStickToBottom({
resize: 'smooth',
initial: 'smooth',
})
- // Refs to track streaming content
const streamingContentRef = useRef('')
const streamingReasoningRef = useRef('')
const streamingToolCallsRef = useRef<Array<{ toolName: string; args: unknown }>>([])
const generateMessageId = () => `msg-${Date.now()}-${Math.random().toString(36).substr(2, 9)}`
- // Load recent chats
const loadRecentChats = useCallback(async () => {
try {
const chats = await getRecentAIChats(projectId, 3)
@@ -484,7 +469,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
}
}, [projectId])
- // Load all chats for modal
const loadAllChats = useCallback(
async (skip: number = 0) => {
setIsLoadingChats(true)
@@ -505,7 +489,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
[projectId],
)
- // Load a specific chat
const loadChat = useCallback(
async (chatId: string) => {
try {
@@ -520,7 +503,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
setCurrentChatId(chatId)
} catch (err) {
console.error('Failed to load chat:', err)
- // If chat not found, clear the param and start fresh
const newParams = new URLSearchParams(searchParams)
newParams.delete('chat')
setSearchParams(newParams)
@@ -529,7 +511,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
[projectId, searchParams, setSearchParams],
)
- // Save or update chat
const saveChat = useCallback(
async (messagesToSave: Message[]) => {
const apiMessages = messagesToSave
@@ -551,7 +532,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
newParams.set('chat', chat.id)
setSearchParams(newParams, { replace: true })
}
- // Refresh recent chats
loadRecentChats()
} catch (err) {
console.error('Failed to save chat:', err)
@@ -560,7 +540,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
[projectId, currentChatId, searchParams, setSearchParams, loadRecentChats],
)
- // Initialize: load chat from URL or load recent chats
useEffect(() => {
if (hasInitializedRef.current) return
hasInitializedRef.current = true
@@ -622,18 +601,15 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
setIsLoading(true)
setIsWaitingForResponse(true)
- // Reset streaming refs
streamingContentRef.current = ''
streamingReasoningRef.current = ''
streamingToolCallsRef.current = []
- // Create abort controller for cancellation
abortControllerRef.current = new AbortController()
try {
const timezone = Intl.DateTimeFormat().resolvedOptions().timeZone
- // Filter out messages with empty content and convert to API format
const messagesToSend = _filter(newMessages, (msg) => msg.content.trim().length > 0).map((msg) => ({
role: msg.role,
content: msg.content,
@@ -695,7 +671,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
}
setMessages((prev) => {
const updatedMessages = [...prev, assistantMessage]
- // Save chat after completion
saveChat(updatedMessages)
return updatedMessages
})
@@ -755,7 +730,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
const handleQuickAction = (prompt: string) => {
setInput(prompt)
- // Focus the input after setting the prompt
inputRef.current?.focus()
}
@@ -767,7 +741,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
toast.success(t('project.askAi.linkCopied'))
}
- // Auto-resize textarea
useEffect(() => {
if (inputRef.current) {
inputRef.current.style.height = 'auto'
@@ -795,7 +768,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
return (
<div className='flex h-[calc(100vh-140px)] min-h-[600px] flex-col bg-gray-50 dark:bg-slate-900'>
- {/* Action Bar - shown when chat is active */}
{isChatActive ? (
<>
<div className='mx-auto flex w-full max-w-3xl items-center justify-between'>
@@ -820,7 +792,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
</>
) : null}
- {/* Error Banner */}
{error ? (
<div className='mx-auto w-full max-w-3xl px-4 pt-4'>
<div className='flex items-center gap-2 rounded-lg border border-red-200 bg-red-50 px-4 py-3 dark:border-red-800 dark:bg-red-900/20'>
@@ -837,7 +808,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
</div>
) : null}
- {/* Messages Area */}
<div className='relative flex-1 overflow-hidden'>
<div
ref={scrollRef}
@@ -849,12 +819,10 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
{isEmpty ? (
<div className='flex min-h-full flex-col px-4 py-8'>
<div className='flex flex-1 flex-col items-center justify-center'>
- {/* Logo */}
<div className='mb-6'>
<SwetrixLogo />
</div>
- {/* Headline */}
<Text as='h1' size='2xl' weight='semibold' colour='primary' className='mb-2'>
{t('project.askAi.welcomeTitle')}
</Text>
@@ -862,7 +830,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
{t('project.askAi.welcomeSubtitle')}
</Text>
- {/* Suggestion Cards - 2x2 grid above input */}
<div className='mb-6 grid w-full max-w-2xl grid-cols-1 gap-3 sm:grid-cols-2'>
{_map(getSuggestionPrompts(t), (prompt, idx) => (
<button
@@ -878,7 +845,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
))}
</div>
- {/* Input Area (centered for empty state) */}
<div className='w-full max-w-2xl'>
<div className='rounded-lg border border-gray-200 bg-white dark:border-slate-800/60 dark:bg-slate-800/25'>
<form onSubmit={handleSubmit} className='relative'>
@@ -893,15 +859,14 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
className='w-full resize-none border-0 bg-transparent px-4 py-3 text-sm text-gray-900 placeholder-gray-500 focus:ring-0 focus:outline-none dark:text-white dark:placeholder-gray-400'
/>
<div className='flex items-center justify-between border-t border-gray-100 px-3 py-2 dark:border-slate-800'>
- {/* Tools indicator */}
<div className='flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400'>
<Tooltip
- text={<AICapabilitiesTooltip t={t} />}
+ text={<AICapabilitiesTooltip />}
tooltipNode={
<InfoIcon className='h-4 w-4 cursor-help text-gray-400 hover:text-gray-600 dark:text-gray-500 dark:hover:text-gray-300' />
}
/>
- <ToolsIndicator t={t} />
+ <ToolsIndicator />
</div>
<button
type='submit'
@@ -925,23 +890,22 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
msg.role === 'user' ? (
<UserMessage key={msg.id} content={msg.content} />
) : (
- <AssistantMessage key={msg.id} message={msg} t={t} />
+ <AssistantMessage key={msg.id} message={msg} />
),
)}
{isWaitingForResponse ? (
<div className='py-2'>
- <ThinkingIndicator t={t} />
+ <ThinkingIndicator />
</div>
) : null}
- {streamingMessage ? <AssistantMessage message={streamingMessage} isStreaming t={t} /> : null}
+ {streamingMessage ? <AssistantMessage message={streamingMessage} isStreaming /> : null}
</div>
)}
</div>
</div>
- <ScrollToBottomButton isAtBottom={isAtBottom} scrollToBottom={scrollToBottom} t={t} />
+ <ScrollToBottomButton isAtBottom={isAtBottom} scrollToBottom={scrollToBottom} />
</div>
- {/* Input Area (only shown when chat has messages) */}
{!isEmpty ? (
<div className='border-t border-gray-200 bg-gray-50 px-4 py-4 dark:border-slate-800/60 dark:bg-slate-900'>
<div className='mx-auto max-w-3xl'>
@@ -958,7 +922,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
className='w-full resize-none border-0 bg-transparent px-4 py-3 text-sm text-gray-900 placeholder-gray-500 focus:ring-0 focus:outline-none dark:text-white dark:placeholder-gray-400'
/>
<div className='flex items-center justify-between border-t border-gray-100 px-3 py-2 dark:border-slate-800'>
- {/* Tools indicator */}
<div className='flex items-center gap-1 text-xs text-gray-500 dark:text-gray-400'>
<Tooltip
text={<AICapabilitiesTooltip />}
@@ -968,7 +931,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
/>
<ToolsIndicator />
</div>
- {/* Action buttons */}
<div className='flex items-center gap-2'>
{isLoading ? (
<button
@@ -997,7 +959,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
</div>
) : null}
- {/* Recent Chats Section - only shown when chat is not active */}
{!isChatActive && !_isEmpty(recentChats) ? (
<div className='mx-auto mt-8 w-full max-w-2xl'>
<div className='flex items-center justify-between'>
@@ -1035,7 +996,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
</div>
) : null}
- {/* View All Chats Modal */}
<Modal
isOpened={isViewAllModalOpen}
onClose={() => setIsViewAllModalOpen(false)}
@@ -1102,7 +1062,6 @@ const AskAIView = ({ projectId }: AskAIViewProps) => {
}
/>
- {/* Delete Chat Confirmation Modal */}
<Modal
isOpened={!!chatToDelete}
onClose={() => setChatToDelete(null)}
diff --git a/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx b/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx
index 265a1a8fb..f11744535 100644
--- a/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx
+++ b/web/app/pages/Project/tabs/Captcha/CaptchaView.tsx
@@ -196,18 +196,16 @@ const CaptchaView = ({ projectId }: CaptchaViewProps) => {
<div ref={ref}>
{dataLoading && hasExistingData ? <LoadingBar /> : null}
<div>
- <Filters tnMapping={tnMapping} />
+ <Filters className='mb-3' tnMapping={tnMapping} />
{chartData ? (
- <div className='mt-4'>
- <CaptchaChart
- chart={chartData}
- timeBucket={timeBucket}
- timeFormat={timeFormat}
- rotateXAxis={rotateXAxis}
- chartType={chartTypes.line}
- dataNames={dataNames}
- />
- </div>
+ <CaptchaChart
+ chart={chartData}
+ timeBucket={timeBucket}
+ timeFormat={timeFormat}
+ rotateXAxis={rotateXAxis}
+ chartType={chartTypes.line}
+ dataNames={dataNames}
+ />
) : null}
<div className='mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2'>
{!_isEmpty(panelsData.types)
diff --git a/web/app/pages/Project/tabs/Captcha/NoCaptchaEvents.tsx b/web/app/pages/Project/tabs/Captcha/NoCaptchaEvents.tsx
index 7121a992b..cd59e2c10 100644
--- a/web/app/pages/Project/tabs/Captcha/NoCaptchaEvents.tsx
+++ b/web/app/pages/Project/tabs/Captcha/NoCaptchaEvents.tsx
@@ -21,11 +21,7 @@ const NoCaptchaEvents = ({ filters }: NoCaptchaEventsProps) => {
return (
<>
- {hasFilters ? (
- <div className='mt-4'>
- <Filters tnMapping={tnMapping} />
- </div>
- ) : null}
+ {hasFilters ? <Filters tnMapping={tnMapping} /> : null}
<div className='mx-auto w-full max-w-2xl py-16 text-center'>
<div className='mx-auto mb-6 flex size-14 items-center justify-center rounded-xl bg-gray-100 dark:bg-slate-800'>
{hasFilters ? (
diff --git a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
index df8a8adcd..b24b1d39d 100644
--- a/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
+++ b/web/app/pages/Project/tabs/Errors/ErrorsView.tsx
@@ -66,7 +66,6 @@ import { getLocaleDisplayName, nFormatter } from '~/utils/generic'
const InteractiveMap = lazy(() => import('~/pages/Project/View/components/InteractiveMap'))
-// Calculate optimal Y axis ticks
const calculateOptimalTicks = (data: number[], targetCount: number = 6): number[] => {
const validData = data.filter((n) => n !== undefined && n !== null && Number.isFinite(n))
@@ -112,7 +111,6 @@ const calculateOptimalTicks = (data: number[], targetCount: number = 6): number[
return ticks
}
-// Chart settings for error trends chart
const getErrorTrendsChartSettings = (
chartData: { x: string[]; occurrences: number[]; affectedUsers: number[] },
timeBucket: string,
@@ -237,7 +235,6 @@ const getErrorTrendsChartSettings = (
}
}
-// Stat Card Component
interface StatCardProps {
icon: React.ReactNode
value: string | number
@@ -258,7 +255,6 @@ const StatCard = ({ icon, value, label }: StatCardProps) => (
</div>
)
-// Error Item Component
interface ErrorItemProps {
error: SwetrixError
}
@@ -301,7 +297,6 @@ const ErrorItem = ({ error }: ErrorItemProps) => {
const params = new URLSearchParams(location.search)
params.set('eid', error.eid)
- // Truncate long error names/messages
const maxNameLength = 80
const maxMessageLength = 150
const displayName = error.name.length > maxNameLength ? `${error.name.slice(0, maxNameLength)}...` : error.name
@@ -409,31 +404,26 @@ const ErrorsView = () => {
const tnMapping = typeNameMapping(t)
const rotateXAxis = useMemo(() => size.width > 0 && size.width < 500, [size])
- // Error filters state
const [errorOptions, setErrorOptions] = useState<Record<string, boolean>>({
[ERROR_FILTERS_MAPPING.showResolved]: false,
})
- // Overview state
const [overviewLoading, setOverviewLoading] = useState<boolean | null>(null)
const [overview, setOverview] = useState<ErrorOverviewResponse | null>(null)
const isMountedRef = useRef(true)
- // Errors list state
const [errorsLoading, setErrorsLoading] = useState<boolean | null>(null)
const [errors, setErrors] = useState<SwetrixError[]>([])
const [errorsSkip, setErrorsSkip] = useState(0)
const [canLoadMoreErrors, setCanLoadMoreErrors] = useState(false)
const errorsRequestIdRef = useRef(0)
- // Error detail state
const activeEID = useMemo(() => searchParams.get('eid'), [searchParams])
const prevActiveEIDRef = useRef<string | null>(activeEID)
const [activeError, setActiveError] = useState<{ details: SwetrixErrorDetails; [key: string]: any } | null>(null)
const [errorLoading, setErrorLoading] = useState(false)
const [errorStatusUpdating, setErrorStatusUpdating] = useState(false)
- // Error detail panel tabs
const [errorsActiveTabs, setErrorsActiveTabs] = useState<{
location: 'cc' | 'rg' | 'ct' | 'lc' | 'map'
page: 'pg' | 'host'
@@ -444,14 +434,12 @@ const ErrorsView = () => {
device: 'br',
})
- // Pure search params (without eid) for back navigation
const pureSearchParams = useMemo(() => {
const newSearchParams = new URLSearchParams(searchParams.toString())
newSearchParams.delete('eid')
return newSearchParams.toString()
}, [searchParams])
- // Cleanup on unmount
useEffect(() => {
isMountedRef.current = true
return () => {
@@ -632,7 +620,6 @@ const ErrorsView = () => {
[],
)
- // Error filters dropdown items
const errorFilters = useMemo(() => {
return [
{
@@ -697,7 +684,6 @@ const ErrorsView = () => {
const hasErrors = !_isEmpty(errors) || overview?.stats?.totalErrors
- // Filter link helper
const getFilterLink = useCallback(
(column: string, value: string | null): LinkProps['to'] => {
const isFilterActive = filters.findIndex((filter) => filter.column === column && filter.filter === value) >= 0
@@ -735,7 +721,6 @@ const ErrorsView = () => {
[searchParams],
)
- // Version data mapping for browser/OS versions
const createVersionDataMapping = useMemo(() => {
const browserDataSource = activeError?.params?.brv
const osDataSource = activeError?.params?.osv
@@ -766,7 +751,6 @@ const ErrorsView = () => {
return { browserVersions, osVersions }
}, [activeError?.params?.brv, activeError?.params?.osv])
- // Data names for chart
const dataNames = useMemo(
() => ({
occurrences: t('project.totalErrors'),
@@ -775,12 +759,10 @@ const ErrorsView = () => {
[t],
)
- // Show waiting for error data state
if (typeof project?.isErrorDataExists === 'boolean' && !project.isErrorDataExists) {
return <WaitingForAnError />
}
- // If viewing error detail
if (activeEID) {
const resolveButton =
allowedToManage && activeError && activeError?.details?.status !== 'resolved' ? (
@@ -817,7 +799,6 @@ const ErrorsView = () => {
return (
<div>
- {/* Loading bar for refreshes */}
{errorLoading && activeError ? <LoadingBar /> : null}
{errorsLoading && !_isEmpty(errors) ? <LoadingBar /> : null}
@@ -829,7 +810,8 @@ const ErrorsView = () => {
rightContent={resolveButton}
/>
- {/* Error details */}
+ <Filters className='mb-3' tnMapping={tnMapping} />
+
{activeError?.details ? (
<ErrorDetails
details={activeError.details}
@@ -841,7 +823,6 @@ const ErrorsView = () => {
/>
) : null}
- {/* Error chart */}
{activeError?.chart ? (
<div className='mt-4'>
<ErrorChart
@@ -855,10 +836,6 @@ const ErrorsView = () => {
</div>
) : null}
- {/* Filters */}
- <Filters tnMapping={tnMapping} />
-
- {/* Panels */}
<div className='mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2'>
{!_isEmpty(activeError?.params)
? _map(ERROR_PANELS_ORDER, (type: keyof typeof tnMapping) => {
@@ -1037,10 +1014,8 @@ const ErrorsView = () => {
{activeError?.metadata ? <MetadataPanel metadata={activeError.metadata} /> : null}
</div>
- {/* Loading state */}
{_isEmpty(activeError) && errorLoading ? <Loader /> : null}
- {/* No error details */}
{!errorLoading && _isEmpty(activeError) ? <NoErrorDetails /> : null}
</div>
)
@@ -1084,27 +1059,21 @@ const ErrorsView = () => {
<div>
<DashboardHeader showLiveVisitors showSearchButton={false} hideTimeBucket rightContent={filtersDropdown} />
- {/* Loading bar for refreshes */}
{(overviewLoading || errorsLoading) && (overview || !_isEmpty(errors)) ? <LoadingBar /> : null}
- {/* Filters */}
- {hasErrors ? <Filters tnMapping={tnMapping} /> : null}
+ {hasErrors ? <Filters className='mb-3' tnMapping={tnMapping} /> : null}
- {/* No errors state */}
{!hasErrors && errorsLoading === false && overviewLoading === false ? <NoEvents filters={filters} /> : null}
{hasErrors ? (
<>
- {/* Chart and Stats Row */}
<div className='flex flex-col gap-2 lg:flex-row'>
- {/* Error Trends Chart - Left side */}
{chartOptions && overview?.chart ? (
<div className='w-full rounded-xl border border-gray-200 bg-white p-4 lg:w-[65%] dark:border-slate-700 dark:bg-slate-800'>
<BillboardChart options={chartOptions} className='h-[220px]' />
</div>
) : null}
- {/* Stats Grid - Right side as 2x2 */}
<div className='grid w-full grid-cols-2 gap-2 lg:w-[35%]'>
<StatCard
icon={<BugIcon className='text-red-600' strokeWidth={1.5} />}
@@ -1129,7 +1098,6 @@ const ErrorsView = () => {
</div>
</div>
- {/* Recent Errors List */}
<div className='mt-4'>
<Text as='h3' weight='semibold' className='mb-3'>
{t('project.recentErrors')}
@@ -1150,7 +1118,6 @@ const ErrorsView = () => {
)}
</ClientOnly>
- {/* Load more button */}
{canLoadMoreErrors ? (
<button
type='button'
diff --git a/web/app/pages/Project/tabs/Performance/PerformanceView.tsx b/web/app/pages/Project/tabs/Performance/PerformanceView.tsx
index 8a0c5ec78..b15591946 100644
--- a/web/app/pages/Project/tabs/Performance/PerformanceView.tsx
+++ b/web/app/pages/Project/tabs/Performance/PerformanceView.tsx
@@ -602,6 +602,7 @@ const PerformanceView = ({ tnMapping }: PerformanceViewProps) => {
<DashboardHeader />
{dataLoading && !isPanelsDataEmpty ? <LoadingBar /> : null}
<div className={cx({ hidden: isPanelsDataEmpty || analyticsLoading })}>
+ {!isPanelsDataEmpty ? <Filters className='mb-3' tnMapping={tnMapping} /> : null}
<div className='relative overflow-hidden rounded-lg border border-gray-200 bg-white p-4 dark:border-slate-800/60 dark:bg-slate-800/25'>
<div className='mb-3 flex w-full items-center justify-end gap-2 lg:absolute lg:top-2 lg:right-2 lg:mb-0 lg:w-auto lg:justify-normal'>
<Dropdown
@@ -662,7 +663,6 @@ const PerformanceView = ({ tnMapping }: PerformanceViewProps) => {
</div>
) : null}
</div>
- {!isPanelsDataEmpty ? <Filters tnMapping={tnMapping} /> : null}
<div className='mt-3 grid grid-cols-1 gap-3 sm:grid-cols-2'>
{!_isEmpty(panelsData.types)
? _map(PERFORMANCE_PANELS_ORDER, (type: keyof typeof tnMapping) => {
diff --git a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx b/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
index 0715841c7..be87e3012 100644
--- a/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
+++ b/web/app/pages/Project/tabs/Sessions/SessionsView.tsx
@@ -294,7 +294,7 @@ const SessionsView = ({ tnMapping, rotateXAxis }: SessionsViewProps) => {
<DashboardHeader showLiveVisitors />
{sessionsLoading && !_isEmpty(sessions) ? <LoadingBar /> : null}
<div>
- {!_isEmpty(sessions) ? <Filters tnMapping={tnMapping} /> : null}
+ {!_isEmpty(sessions) ? <Filters className='mb-3' tnMapping={tnMapping} /> : null}
{(sessionsLoading === null || sessionsLoading) && _isEmpty(sessions) ? <Loader /> : null}
{typeof sessionsLoading === 'boolean' && !sessionsLoading && _isEmpty(sessions) ? (
<NoEvents filters={filters} />
diff --git a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
index b1c748221..ca12f4968 100644
--- a/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
+++ b/web/app/pages/Project/tabs/Traffic/TrafficView.tsx
@@ -938,6 +938,7 @@ const TrafficView = ({
<DashboardHeader rightContent={headerRightContent} />
{dataLoading && !isPanelsDataEmpty ? <LoadingBar /> : null}
<div className={cx({ hidden: isPanelsDataEmpty || analyticsLoading })}>
+ {!isPanelsDataEmpty ? <Filters className='mb-3' tnMapping={tnMapping} /> : null}
<div className='relative overflow-hidden rounded-lg border border-gray-200 bg-white p-4 dark:border-slate-800/60 dark:bg-slate-800/25'>
<div className='mb-3 flex w-full items-center justify-end gap-2 lg:absolute lg:top-2 lg:right-2 lg:mb-0 lg:w-auto lg:justify-normal'>
<Dropdown
@@ -1061,7 +1062,6 @@ const TrafficView = ({
</div>
) : null}
</div>
- {!isPanelsDataEmpty ? <Filters tnMapping={tnMapping} /> : null}
<CustomMetrics
metrics={customMetrics}
onRemoveMetric={(metricId) => onRemoveCustomMetric(metricId)}
diff --git a/web/app/pages/UserSettings/components/Integrations.tsx b/web/app/pages/UserSettings/components/Integrations.tsx
index a5e173e76..dd676aa2a 100644
--- a/web/app/pages/UserSettings/components/Integrations.tsx
+++ b/web/app/pages/UserSettings/components/Integrations.tsx
@@ -14,6 +14,7 @@ import Discord from '~/ui/icons/Discord'
import Slack from '~/ui/icons/Slack'
import Telegram from '~/ui/icons/Telegram'
import Input from '~/ui/Input'
+import { Text } from '~/ui/Text'
import { trackCustom } from '~/utils/analytics'
const getAvailableIntegrations = (
@@ -435,21 +436,27 @@ const Integrations = ({ handleIntegrationSave }: IntegrationsProps) => {
return (
<tr key={key} className='hover:bg-gray-50 dark:hover:bg-slate-800/50'>
<td className='px-4 py-3 text-sm text-gray-900 dark:text-gray-100'>
- <div className='flex items-center gap-3'>
+ <div className='flex items-center gap-2'>
<div className='hidden shrink-0 sm:block'>
- <Icon className='size-9' />
+ <Icon className='size-5' />
</div>
<span className='font-medium'>{name}</span>
</div>
</td>
- <td className='px-4 py-3 text-sm text-gray-700 dark:text-gray-300'>
+ <td className='px-4 py-3'>
<div className='space-y-1'>
- <p className='text-sm text-gray-700 dark:text-gray-300'>{description}</p>
+ <Text as='p' size='sm' colour='primary'>
+ {description}
+ </Text>
{id ? (
- <p className='text-sm text-gray-900 dark:text-gray-100'>
- {t('profileSettings.chatID')}
- {`: ${id}`}
- </p>
+ <div className='flex flex-wrap items-center gap-1'>
+ <Text as='p' size='sm' colour='primary'>
+ {t('profileSettings.chatID')}:
+ </Text>
+ <Text as='p' size='sm' colour='secondary' code>
+ {id}
+ </Text>
+ </div>
) : null}
</div>
</td>