sendEvent
The analytics method to send any event through BaseHub. Flexible, scoped by block.
import { sendEvent } from 'basehub/analytics'
Parameters
Example
'use client'
import { sendEvent } from 'basehub/analytics'
import { Card, IconButton } from '@radix-ui/themes'
import { ThumbsDown, ThumbsUp } from 'lucide-react'
import * as React from 'react'
export const Feedback = ({
analyticsKey: _analyticsKey,
}: {
analyticsKey: string
}) => {
const [sentFeedback, setSentFeedback] = React.useState<
'positive' | 'negative' | null
>(null)
const handleFeedback = (type: 'positive' | 'negative') => {
if (sentFeedback === type) return
sendEvent({ _analyticsKey, name: `feedback:${type}` })
setSentFeedback(type)
}
return (
<Card variant="classic" size="3">
<IconButton onClick={() => handleFeedback('negative')}>
<ThumbsDown fill={sentFeedback === 'negative' ? 'var(--accent-12)' : 'none'} />
</IconButton>
<IconButton onClick={() => handleFeedback('positive')}>
<ThumbsUp fill={sentFeedback === 'positive' ? 'var(--accent-12)' : 'none'} />
</IconButton>
</Card>
)
}