From fef3a7617f374e494bcb884b9b310f7ec14e5f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20D=C3=ADaz?= Date: Wed, 31 Jan 2024 20:19:54 -0300 Subject: [PATCH] feat: Track when adding/removing components: lock and hide (#883) * feat: Add tracking components Lock/Hide * fix: Focus the canvas when adding a new asset * fix: Remove console.log --- .../src/components/Renderer/Renderer.tsx | 1 + .../components/Tree/ActionArea/ActionArea.tsx | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/packages/@dcl/inspector/src/components/Renderer/Renderer.tsx b/packages/@dcl/inspector/src/components/Renderer/Renderer.tsx index cfadb2af0..b5a994e9c 100644 --- a/packages/@dcl/inspector/src/components/Renderer/Renderer.tsx +++ b/packages/@dcl/inspector/src/components/Renderer/Renderer.tsx @@ -156,6 +156,7 @@ const Renderer: React.FC = () => { itemPath: asset.asset.src, isSmart: isSmart(asset) }) + canvasRef.current?.focus() } const importBuilderAsset = async (asset: Asset) => { diff --git a/packages/@dcl/inspector/src/components/Tree/ActionArea/ActionArea.tsx b/packages/@dcl/inspector/src/components/Tree/ActionArea/ActionArea.tsx index 284086669..604c7c7a2 100644 --- a/packages/@dcl/inspector/src/components/Tree/ActionArea/ActionArea.tsx +++ b/packages/@dcl/inspector/src/components/Tree/ActionArea/ActionArea.tsx @@ -6,6 +6,9 @@ import { Entity, LastWriteWinElementSetComponentDefinition } from '@dcl/ecs' import { WithSdkProps, withSdk } from '../../../hoc/withSdk' import { useEntityComponent } from '../../../hooks/sdk/useEntityComponent' import { SdkContextValue } from '../../../lib/sdk/context' +import { analytics, Event } from '../../../lib/logic/analytics' +import { getAssetByModel } from '../../../lib/logic/catalog' + import './ActionArea.css' type Props = { @@ -14,10 +17,12 @@ type Props = { const ActionArea: React.FC = ({ sdk, ...props }) => { const { - components: { Lock, Hide } + components: { Lock, Hide, GltfContainer } } = sdk const { entity } = props const { addComponent, removeComponent } = useEntityComponent() + const { src: gltfSrc } = GltfContainer.getOrNull(entity) ?? { src: '' } + const asset = getAssetByModel(gltfSrc) const isEntityLocked = useMemo(() => { return Lock.getOrNull(entity) !== null @@ -33,8 +38,18 @@ const ActionArea: React.FC = ({ sdk, ...props }) => { entity, Hide as unknown as LastWriteWinElementSetComponentDefinition ) + analytics.track(Event.REMOVE_COMPONENT, { + componentName: Hide.componentName, + itemId: asset?.id, + itemPath: gltfSrc + }) } else { addComponent(entity, Hide.componentId, { value: true }) + analytics.track(Event.ADD_COMPONENT, { + componentName: Hide.componentName, + itemId: asset?.id, + itemPath: gltfSrc + }) } }, [entity, sdk, isEntityHidden]) @@ -44,8 +59,18 @@ const ActionArea: React.FC = ({ sdk, ...props }) => { entity, Lock as unknown as LastWriteWinElementSetComponentDefinition ) + analytics.track(Event.REMOVE_COMPONENT, { + componentName: Lock.componentName, + itemId: asset?.id, + itemPath: gltfSrc + }) } else { addComponent(entity, Lock.componentId, { value: true }) + analytics.track(Event.ADD_COMPONENT, { + componentName: Lock.componentName, + itemId: asset?.id, + itemPath: gltfSrc + }) } }, [sdk, isEntityLocked])