From 43474fcfa187f3020a0d03ad8c9273afe37fb6d4 Mon Sep 17 00:00:00 2001 From: sneha122 Date: Fri, 8 Dec 2023 15:26:57 +0530 Subject: [PATCH] fix: analytic events added for start with data flow (#29463) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Description This PR: - Adds analytic events for start with data onboarding flow, List of events and their details can be found in this [doc](https://www.notion.so/appsmith/Analytic-Events-c326270138c046f4b29328bc18b89b2d) - There was an issue in DATASOURCE_SCHEMA_FETCH event, it was throwing misleading information when the datasource structure fetch API failed, that issue has been fixed as well #### PR fixes following issue(s) Fixes #29435 #### Media > A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video > > #### 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 - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] 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 ## Summary by CodeRabbit - **New Features** - Enhanced analytics tracking for user interactions during the onboarding process, including skipping steps. - **Refactor** - Improved internal logic for fetching and refreshing datasource structures to enhance error handling and success tracking. - **Documentation** - Updated type definitions to reflect new analytics events related to the onboarding flow. Co-authored-by: “sneha122” <“sneha@appsmith.com”> --- .../Applications/CreateNewAppsOption.tsx | 34 +++++++++++++++++-- app/client/src/ce/utils/analyticsUtilTypes.ts | 6 +++- app/client/src/sagas/DatasourcesSagas.ts | 6 +++- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx b/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx index 6673673d9e..d594937c30 100644 --- a/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx +++ b/app/client/src/ce/pages/Applications/CreateNewAppsOption.tsx @@ -235,6 +235,7 @@ const CreateNewAppsOption = ({ ); if (devEnabled) { // fetch plugins information to show list of all plugins + AnalyticsUtil.logEvent("CREATE_APP_FROM_DATA"); dispatch(fetchPlugins()); dispatch(fetchMockDatasources()); if (application?.workspaceId) { @@ -291,6 +292,35 @@ const CreateNewAppsOption = ({ } }; + const addAnalyticEventsForSkip = () => { + if (useType === START_WITH_TYPE.TEMPLATE) { + if (selectedTemplate) { + const template = getTemplateById(selectedTemplate); + if (template) { + AnalyticsUtil.logEvent( + "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_TEMPLATE_DETAILS_PAGE", + { title: template.title }, + ); + } + } else { + AnalyticsUtil.logEvent( + "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_START_FROM_TEMPLATE_PAGE", + ); + } + } else if (useType === START_WITH_TYPE.DATA) { + if (createNewAppPluginId) { + AnalyticsUtil.logEvent( + "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_DATASOURCE_FORM_PAGE", + { pluginId: createNewAppPluginId }, + ); + } else { + AnalyticsUtil.logEvent( + "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_START_FROM_DATA_PAGE", + ); + } + } + }; + const onClickSkipButton = () => { if (application) { urlBuilder.updateURLParams( @@ -312,9 +342,7 @@ const CreateNewAppsOption = ({ ); } - AnalyticsUtil.logEvent("START_FROM_TEMPLATES_CLICK_SKIP_BUTTON", { - startWithType: useType, - }); + addAnalyticEventsForSkip(); }; const onClickBackButton = () => { diff --git a/app/client/src/ce/utils/analyticsUtilTypes.ts b/app/client/src/ce/utils/analyticsUtilTypes.ts index bdf4a370e7..d4b82fbb37 100644 --- a/app/client/src/ce/utils/analyticsUtilTypes.ts +++ b/app/client/src/ce/utils/analyticsUtilTypes.ts @@ -363,7 +363,11 @@ export type ONBOARDING_FLOW_EVENTS = | "ONBOARDING_FLOW_CLICK_BACK_BUTTON_START_FROM_DATA_PAGE" | "ONBOARDING_FLOW_CLICK_BACK_BUTTON_DATASOURCE_FORM_PAGE" | "ONBOARDING_FLOW_DATASOURCE_FORM_CANCEL_CLICK" - | "CREATE_APP_FROM_DATA"; + | "CREATE_APP_FROM_DATA" + | "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_START_FROM_DATA_PAGE" + | "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_DATASOURCE_FORM_PAGE" + | "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_START_FROM_TEMPLATE_PAGE" + | "ONBOARDING_FLOW_CLICK_SKIP_BUTTON_TEMPLATE_DETAILS_PAGE"; export type DATASOURCE_SCHEMA_EVENTS = | "DATASOURCE_SCHEMA_SEARCH" diff --git a/app/client/src/sagas/DatasourcesSagas.ts b/app/client/src/sagas/DatasourcesSagas.ts index 91b0ff22c1..8099cc3878 100644 --- a/app/client/src/sagas/DatasourcesSagas.ts +++ b/app/client/src/sagas/DatasourcesSagas.ts @@ -1411,11 +1411,13 @@ function* fetchDatasourceStructureSaga( }); } if (!!(response.data as any)?.error) { + isSuccess = false; errorMessage = (response.data as any).error?.message; } } } catch (error) { errorMessage = (error as any)?.message; + isSuccess = false; yield put({ type: ReduxActionErrorTypes.FETCH_DATASOURCE_STRUCTURE_ERROR, payload: { @@ -1528,10 +1530,12 @@ function* refreshDatasourceStructure( }); } if (!!(response.data as any)?.error) { - errorMessage = (response.data as any)?.message; + isSuccess = false; + errorMessage = (response.data as any)?.error?.message; } } } catch (error) { + isSuccess = false; errorMessage = (error as any)?.message; yield put({ type: ReduxActionErrorTypes.REFRESH_DATASOURCE_STRUCTURE_ERROR,