Skip to content

Commit

Permalink
📈: integrate toggle logging for sidebar and visibility button actions
Browse files Browse the repository at this point in the history
  • Loading branch information
junkisai committed Dec 19, 2024
1 parent 6c2a2d5 commit 7c75b53
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
6 changes: 6 additions & 0 deletions frontend/.changeset/ninety-llamas-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@liam-hq/erd-core": patch
"@liam-hq/cli": patch
---

📈: integrate toggle logging for sidebar and visibility button actions
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import {
getSidebarStateFromCookie,
} from '@liam-hq/ui'
import { ReactFlowProvider } from '@xyflow/react'
import type { FC } from 'react'
import { type FC, useCallback, useState } from 'react'
import { AppBar } from './AppBar'
import { ERDContent } from './ERDContent'
import styles from './ERDRenderer.module.css'
import { LeftPane } from './LeftPane'
import '@/styles/globals.css'
import { toggleLogEvent } from '@/features/gtm/utils'
import { useDBStructureStore, useUserEditingStore } from '@/stores'
// biome-ignore lint/nursery/useImportRestrictions: Fixed in the next PR.
import { Toolbar } from './ERDContent/Toolbar'
Expand All @@ -20,18 +21,32 @@ import { convertDBStructureToNodes } from './convertDBStructureToNodes'

export const ERDRenderer: FC = () => {
const defaultOpen = getSidebarStateFromCookie()
const [open, setOpen] = useState(defaultOpen)

const { showMode } = useUserEditingStore()
const dbStructure = useDBStructureStore()
const { nodes, edges } = convertDBStructureToNodes({
dbStructure,
showMode,
})

const handleChangeOpen = useCallback((open: boolean) => {
setOpen(open)
toggleLogEvent({
element: 'leftPane',
isShow: open,
})
}, [])

return (
<div className={styles.wrapper}>
<ToastProvider>
<AppBar />
<SidebarProvider defaultOpen={defaultOpen}>
<SidebarProvider
open={open}
defaultOpen={defaultOpen}
onOpenChange={handleChangeOpen}
>
<ReactFlowProvider>
<div className={styles.mainWrapper}>
<LeftPane />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { toggleLogEvent } from '@/features/gtm/utils'
import { toggleHiddenNodeId } from '@/stores'
import { Eye, EyeClosed, SidebarMenuAction } from '@liam-hq/ui'
import { type FC, type MouseEvent, useCallback } from 'react'
Expand All @@ -13,8 +14,13 @@ export const VisibilityButton: FC<Props> = ({ tableName, hidden }) => {
(event: MouseEvent) => {
event.stopPropagation()
toggleHiddenNodeId(tableName)
toggleLogEvent({
element: 'tableNameMenuButton',
isShow: !!hidden,
tableId: tableName,
})
},
[tableName],
[tableName, hidden],
)

return (
Expand Down

0 comments on commit 7c75b53

Please sign in to comment.