-
Notifications
You must be signed in to change notification settings - Fork 4.5k
feat: side-by-side edit mode hover analytics #34185
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
6863aa8
feat: add redux for canvas analytics
alex-golovanov 8e68494
feat: add analytics canvas hover saga
alex-golovanov 3136546
feat: add hook to verify side-by-side is active and present
alex-golovanov e360f95
feat: add hover logging in side-by-side mode
alex-golovanov c40e83f
feat: add mouseleave handler for canvas hover analytics
alex-golovanov cd1bc5a
Merge branch 'release' into feat/33159-side-by-side-analytics
alex-golovanov 87c76b1
chore: revert widget name changes
alex-golovanov 83c60d7
perf: move entity segment resolution to a util
alex-golovanov 4e92f5c
chore: reverted canvas factory changes
alex-golovanov adf5f26
perf: add canvas click navigation method
alex-golovanov 94d0281
perf: move analytics wrapper to a component and attach to editor canvas
alex-golovanov 934df57
perf: add util for in side-by-side
alex-golovanov 8d7824d
perf: add saga for widget hover
alex-golovanov cdc6bce
fix: add wrapper element check
alex-golovanov 8727305
perf: add segment dependency & move logic to utility
alex-golovanov e2eca7d
chore: move hook to ide folder
alex-golovanov fd98592
test: add side-by-side hook tests
alex-golovanov 49382da
chore: move analytics redux branch to ide
alex-golovanov 8a693f8
perf: use canvas widgets selector
alex-golovanov e6ff7e1
perf: tweak event handler for fixed layout
alex-golovanov 9cec247
feat: added queries editor path
alex-golovanov File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { useIsInSideBySideEditor } from "./useIsInSideBySideEditor"; |
147 changes: 147 additions & 0 deletions
147
app/client/src/IDE/hooks/useIsInSideBySideEditor.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| import React from "react"; | ||
| import { renderHook, act } from "@testing-library/react-hooks/dom"; | ||
| import { Provider } from "react-redux"; | ||
| import { EditorViewMode } from "@appsmith/entities/IDE/constants"; | ||
| import { useIsInSideBySideEditor } from "./useIsInSideBySideEditor"; | ||
| import { getIDETestState } from "test/factories/AppIDEFactoryUtils"; | ||
| import type { AppState } from "@appsmith/reducers"; | ||
|
|
||
| import { createMemoryHistory, type MemoryHistory } from "history"; | ||
| import { Router } from "react-router"; | ||
|
|
||
| import { getIDEViewMode } from "../../selectors/ideSelectors"; | ||
| import { setIdeEditorViewMode } from "../../actions/ideActions"; | ||
| import { testStore } from "../../store"; | ||
| import type { Store } from "redux"; | ||
|
|
||
| const JS_COLLECTION_EDITOR_PATH = | ||
| "/app/app-name/page-665dd1103e4483728c9ed11a/edit/jsObjects"; | ||
| const NON_JS_COLLECTION_EDITOR_PATH = "/some-other-path"; | ||
| const FEATURE_FLAGS = { | ||
| rollout_side_by_side_enabled: true, | ||
| }; | ||
|
|
||
| const renderUseIsInSideBySideEditor = ( | ||
| history: MemoryHistory, | ||
| store: Store<AppState>, | ||
| ) => { | ||
| const wrapper: React.FC = ({ children }) => ( | ||
| <Provider store={store}> | ||
| <Router history={history}>{children}</Router> | ||
| </Provider> | ||
| ); | ||
| return renderHook(() => useIsInSideBySideEditor(), { | ||
| wrapper, | ||
| }); | ||
| }; | ||
|
|
||
| describe("useIsInSideBySideEditor", () => { | ||
| it("should enter into split screen mode", () => { | ||
| const store = testStore( | ||
| getIDETestState({ | ||
| ideView: EditorViewMode.SplitScreen, | ||
| featureFlags: FEATURE_FLAGS, | ||
| }), | ||
| ); | ||
|
|
||
| const ideViewMode = getIDEViewMode(store.getState()); | ||
| expect(ideViewMode).toBe(EditorViewMode.SplitScreen); | ||
| }); | ||
|
|
||
| it("should return false when on correct path but not in SplitScreen mode", () => { | ||
| const store = testStore( | ||
| getIDETestState({ | ||
| ideView: EditorViewMode.FullScreen, | ||
| featureFlags: FEATURE_FLAGS, | ||
| }), | ||
| ); | ||
|
|
||
| const history = createMemoryHistory({ | ||
| initialEntries: [JS_COLLECTION_EDITOR_PATH], | ||
| }); | ||
|
|
||
| const { result } = renderUseIsInSideBySideEditor(history, store); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it("should return false when pathname does not satisfy JS_COLLECTION_EDITOR_PATH", () => { | ||
| const store = testStore( | ||
| getIDETestState({ | ||
| ideView: EditorViewMode.SplitScreen, | ||
| featureFlags: FEATURE_FLAGS, | ||
| }), | ||
| ); | ||
|
|
||
| const history = createMemoryHistory({ | ||
| initialEntries: [NON_JS_COLLECTION_EDITOR_PATH], | ||
| }); | ||
|
|
||
| const { result } = renderUseIsInSideBySideEditor(history, store); | ||
|
|
||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it("should return true when in SplitScreen mode and pathname satisfies JS_COLLECTION_EDITOR_PATH", () => { | ||
| const store = testStore( | ||
| getIDETestState({ | ||
| ideView: EditorViewMode.SplitScreen, | ||
| featureFlags: FEATURE_FLAGS, | ||
| }), | ||
| ); | ||
|
|
||
| const history = createMemoryHistory({ | ||
| initialEntries: [JS_COLLECTION_EDITOR_PATH], | ||
| }); | ||
|
|
||
| const { result } = renderUseIsInSideBySideEditor(history, store); | ||
| expect(result.current).toBe(true); | ||
| }); | ||
|
|
||
| it("should update when ideViewMode changes", () => { | ||
| const store = testStore( | ||
| getIDETestState({ | ||
| ideView: EditorViewMode.SplitScreen, | ||
| featureFlags: FEATURE_FLAGS, | ||
| }), | ||
| ); | ||
|
|
||
| const history = createMemoryHistory({ | ||
| initialEntries: [JS_COLLECTION_EDITOR_PATH], | ||
| }); | ||
|
|
||
| const { rerender, result } = renderUseIsInSideBySideEditor(history, store); | ||
|
|
||
| expect(result.current).toBe(true); | ||
|
|
||
| act(() => { | ||
| store.dispatch(setIdeEditorViewMode(EditorViewMode.FullScreen)); | ||
| rerender(); | ||
| }); | ||
|
|
||
| expect(getIDEViewMode(store.getState())).toBe(EditorViewMode.FullScreen); | ||
| expect(result.current).toBe(false); | ||
| }); | ||
|
|
||
| it("should update when pathname changes", () => { | ||
| const store = testStore( | ||
| getIDETestState({ | ||
| ideView: EditorViewMode.SplitScreen, | ||
| featureFlags: FEATURE_FLAGS, | ||
| }), | ||
| ); | ||
|
|
||
| const history = createMemoryHistory({ | ||
| initialEntries: [NON_JS_COLLECTION_EDITOR_PATH], | ||
| }); | ||
|
|
||
| const { rerender, result } = renderUseIsInSideBySideEditor(history, store); | ||
| expect(result.current).toBe(false); | ||
|
|
||
| act(() => { | ||
| history.push(JS_COLLECTION_EDITOR_PATH); | ||
| rerender(); | ||
| }); | ||
|
|
||
| expect(result.current).toBe(true); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| import { useSelector } from "react-redux"; | ||
| import { useLocation } from "react-router"; | ||
|
|
||
| import { getIDEViewMode } from "../../selectors/ideSelectors"; | ||
| import { identifyEntityFromPath } from "../../navigation/FocusEntity"; | ||
| import { | ||
| getCurrentEntityInfo, | ||
| isInSideBySideEditor, | ||
| } from "../../pages/Editor/utils"; | ||
|
|
||
| /** | ||
| * Checks if current component is in side-by-side editor mode. | ||
| */ | ||
| export const useIsInSideBySideEditor = () => { | ||
| const { pathname } = useLocation(); | ||
| const viewMode = useSelector(getIDEViewMode); | ||
| const { appState, entity } = identifyEntityFromPath(pathname); | ||
| const { segment } = getCurrentEntityInfo(entity); | ||
|
|
||
| return isInSideBySideEditor({ appState, segment, viewMode }); | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
app/client/src/layoutSystems/common/AnalyticsWrapper/AnalyticsWrapper.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| import React from "react"; | ||
| import { useDispatch, useSelector } from "react-redux"; | ||
| import { LAYOUT_WRAPPER_ID } from "./constants"; | ||
| import { sendAnalyticsForSideBySideHover } from "actions/ideActions"; | ||
| import { getLayoutSystemType } from "selectors/layoutSystemSelectors"; | ||
| import { LayoutSystemTypes } from "layoutSystems/types"; | ||
| import { useIsInSideBySideEditor } from "IDE/hooks"; | ||
|
|
||
| export const AnalyticsWrapper: React.FC = ({ children }) => { | ||
| const dispatch = useDispatch(); | ||
| const isInSideBySideEditor = useIsInSideBySideEditor(); | ||
| const layoutSystemType = useSelector(getLayoutSystemType); | ||
| const isAnvil = layoutSystemType === LayoutSystemTypes.ANVIL; | ||
| const className = isAnvil ? "contents" : "h-full"; | ||
|
|
||
| const handleMouseLeave: React.MouseEventHandler<HTMLDivElement> = (e) => { | ||
| const wrapperElement = document.getElementById(LAYOUT_WRAPPER_ID); | ||
|
|
||
| if ( | ||
| isInSideBySideEditor && | ||
| (isAnvil || (wrapperElement && wrapperElement === e.target)) | ||
| ) { | ||
| dispatch(sendAnalyticsForSideBySideHover()); | ||
| } | ||
| }; | ||
| return ( | ||
| <div | ||
| className={className} | ||
| id={LAYOUT_WRAPPER_ID} | ||
| onMouseLeave={handleMouseLeave} | ||
| > | ||
| {children} | ||
| </div> | ||
| ); | ||
| }; |
3 changes: 3 additions & 0 deletions
3
app/client/src/layoutSystems/common/AnalyticsWrapper/constants.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { v4 as uuid } from "uuid"; | ||
|
|
||
| export const LAYOUT_WRAPPER_ID = uuid(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| export { AnalyticsWrapper } from "./AnalyticsWrapper"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| import { v4 as uuid } from "uuid"; | ||
|
|
||
| export const LAYOUT_WRAPPER_ID = uuid(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.