:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
import { DndContextProps, useDndMonitor } from '@dnd-kit/core'
import { ReactNode } from 'react'
export function LemonTreeDndMonitor({
scope,
children,
onDragStart,
onDragOver,
onDragEnd,
onDragCancel,
}: DndContextProps & { scope: string; children: ReactNode }): JSX.Element {
useDndMonitor({
onDragStart: (event) => {
if (event.active.data.current?.treeScope === scope) {
onDragStart?.({ ...event, active: { ...event.active, id: event.active.data.current.treeId } })
}
},
onDragOver: (event) => {
if (event.active.data.current?.treeScope === scope) {
onDragOver?.(event)
}
},
onDragEnd: (event) => {
if (event.active.data.current?.treeScope === scope) {
onDragEnd?.({
...event,
active: { ...event.active, id: event.active.data.current.treeId },
over: event.over?.data.current ? { ...event.over, id: event.over.data.current.treeId } : null,
})
}
},
onDragCancel: (event) => {
if (event.active.data.current?.treeScope === scope) {
onDragCancel?.(event)
}
},
})
return <>{children}</>
}