From ff749072da623eac8a8de4493ba1a9b8bb718563 Mon Sep 17 00:00:00 2001 From: Rahul Barwal Date: Wed, 4 Oct 2023 13:37:03 +0530 Subject: [PATCH] fix: Adds analytics event to log search input. (#27477) ## Description Adds analytics event to log search input. * Adds debounce to search as well. #### PR fixes following issue(s) Fixes #27449 #### Type of change - Chore (housekeeping or task changes that don't impact user perception) ## Testing > #### How Has This Been Tested? > Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration. > Delete anything that is not relevant - [x] Manual - [ ] JUnit - [ ] Jest - [ ] Cypress > > #### Test Plan > Add Testsmith test cases links that relate to this PR > > #### Issues raised during DP testing > Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR) > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [ ] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- .../Templates/Filtering/TemplatesModal_filtering_spec.ts | 1 + .../Templates/Filtering/TemplatesPage_filtering_spec.ts | 1 - app/client/cypress/support/Pages/Templates.ts | 3 ++- app/client/src/ce/utils/analyticsUtilTypes.ts | 3 ++- app/client/src/pages/Templates/index.tsx | 9 ++++++--- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesModal_filtering_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesModal_filtering_spec.ts index 41162ac0a4..99be764730 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesModal_filtering_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesModal_filtering_spec.ts @@ -12,6 +12,7 @@ describe("excludeForAirgap", "Bug 17276 - Templates modal filtering", () => { agHelper.GetText(templates.locators._resultsHeader).then((headerText) => { templates.FilterTemplatesByName(NAME_FILTER); + agHelper.Sleep(); if (typeof headerText === "string") { templates.AssertResultsHeaderText(headerText, "not.have.text"); } diff --git a/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesPage_filtering_spec.ts b/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesPage_filtering_spec.ts index 1e788b943e..fd73106449 100644 --- a/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesPage_filtering_spec.ts +++ b/app/client/cypress/e2e/Regression/ClientSide/Templates/Filtering/TemplatesPage_filtering_spec.ts @@ -38,7 +38,6 @@ describe("excludeForAirgap", "Templates page filtering", () => { .GetText(templates.locators._resultsHeader, "text") .then((headerText) => { templates.FilterTemplatesByName(NAME_FILTER); - agHelper.Sleep(); agHelper.GetNClick(templates.locators._templateCard); agHelper.GetNClick(templates.locators._templateViewGoBack); agHelper.AssertText( diff --git a/app/client/cypress/support/Pages/Templates.ts b/app/client/cypress/support/Pages/Templates.ts index ff44208ff2..aa5b958063 100644 --- a/app/client/cypress/support/Pages/Templates.ts +++ b/app/client/cypress/support/Pages/Templates.ts @@ -17,10 +17,11 @@ export class Templates { }; FilterTemplatesByName(query: string) { - return ObjectsRegistry.AggregateHelper.TypeText( + ObjectsRegistry.AggregateHelper.TypeText( this.locators._templatesSearchInput, query, ); + this.agHelper.Sleep(); } AssertResultsHeaderText( diff --git a/app/client/src/ce/utils/analyticsUtilTypes.ts b/app/client/src/ce/utils/analyticsUtilTypes.ts index cb5224418e..2400e910d2 100644 --- a/app/client/src/ce/utils/analyticsUtilTypes.ts +++ b/app/client/src/ce/utils/analyticsUtilTypes.ts @@ -335,7 +335,8 @@ export type EventName = | "COMMUNITY_TEMPLATE_PUBLISH_CLICK" | "EMAIL_VERIFICATION_SETTING_UPDATE" | "EMAIL_VERIFICATION_FAILED" - | "TIME_TO_NAVIGATE_ENTITY_EXPLORER"; + | "TIME_TO_NAVIGATE_ENTITY_EXPLORER" + | "TEMPLATES_SEARCH_INPUT_EVENT"; export type DATASOURCE_SCHEMA_EVENTS = | "DATASOURCE_SCHEMA_SEARCH" diff --git a/app/client/src/pages/Templates/index.tsx b/app/client/src/pages/Templates/index.tsx index 7a7cfe3727..af8c91cfc0 100644 --- a/app/client/src/pages/Templates/index.tsx +++ b/app/client/src/pages/Templates/index.tsx @@ -36,6 +36,8 @@ import type { Template } from "api/TemplatesApi"; import LoadingScreen from "./TemplatesModal/LoadingScreen"; import ReconnectDatasourceModal from "pages/Editor/gitSync/ReconnectDatasourceModal"; import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants"; +import { debounce } from "lodash"; +import AnalyticsUtil from "utils/AnalyticsUtil"; const SentryRoute = Sentry.withSentryRouting(Route); @@ -152,16 +154,17 @@ type TemplatesContentProps = { isForkingEnabled: boolean; filterWithAllowPageImport?: boolean; }; - +const INPUT_DEBOUNCE_TIMER = 500; export function TemplatesContent(props: TemplatesContentProps) { const templateSearchQuery = useSelector(getTemplateSearchQuery); const isFetchingApplications = useSelector(getIsFetchingApplications); const isFetchingTemplates = useSelector(isFetchingTemplatesSelector); const isLoading = isFetchingApplications || isFetchingTemplates; const dispatch = useDispatch(); - const onChange = (query: string) => { + const onChange = debounce((query: string) => { dispatch(setTemplateSearchQuery(query)); - }; + AnalyticsUtil.logEvent("TEMPLATES_SEARCH_INPUT_EVENT", { query }); + }, INPUT_DEBOUNCE_TIMER); const filterWithAllowPageImport = props.filterWithAllowPageImport || false; const templates = useSelector(getSearchedTemplateList).filter((template) => filterWithAllowPageImport ? !!template.allowPageImport : true,