From 6bdfb7edacb050c74eafe7dbf49d8678d735ad91 Mon Sep 17 00:00:00 2001 From: Rajat Agrawal Date: Mon, 18 Mar 2024 11:50:13 +0530 Subject: [PATCH] =?UTF-8?q?chore:=20Remove=20analytics=20logging=20of=20JS?= =?UTF-8?q?=20functions=20as=20it=20causes=20a=20performance=20b=E2=80=A6?= =?UTF-8?q?=20(#31663)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …ottleneck Fixes #31160 ## Description > [!TIP] > _Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content team)._ > > _Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR._ Fixes #`Issue Number` _or_ Fixes `Issue URL` > [!WARNING] > _If no issue exists, please create an issue first, and check with the maintainers if the issue is valid._ ## Automation /ok-to-test tags="" ### :mag: Cypress test results > [!CAUTION] > If you modify the content in this section, you are likely to disrupt the CI result for your PR. ## Summary by CodeRabbit - **Refactor** - Improved analytics tracking by refining the analytics codebase. - Removed unused imports and functions related to analytics. - Refactored the `logDynamicTriggerExecution` function for better performance. - Eliminated the usage of `logJSFunctionExecution` function in the `handleEvalWorkerMessage`. --- .../src/ce/sagas/JSFunctionExecutionSaga.ts | 30 ------ app/client/src/ce/sagas/analyticsSaga.ts | 95 +------------------ .../src/ee/sagas/JSFunctionExecutionSaga.ts | 1 - app/client/src/sagas/EvalWorkerActionSagas.ts | 5 - 4 files changed, 1 insertion(+), 130 deletions(-) delete mode 100644 app/client/src/ce/sagas/JSFunctionExecutionSaga.ts delete mode 100644 app/client/src/ee/sagas/JSFunctionExecutionSaga.ts diff --git a/app/client/src/ce/sagas/JSFunctionExecutionSaga.ts b/app/client/src/ce/sagas/JSFunctionExecutionSaga.ts deleted file mode 100644 index 393aa788a2..0000000000 --- a/app/client/src/ce/sagas/JSFunctionExecutionSaga.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { TriggerKind } from "constants/AppsmithActionConstants/ActionConstants"; -import type { TriggerSource } from "constants/AppsmithActionConstants/ActionConstants"; -import { call } from "redux-saga/effects"; -import type { TMessage } from "utils/MessageUtil"; -import { logJSActionExecution } from "@appsmith/sagas/analyticsSaga"; - -export function* logJSFunctionExecution( - data: TMessage<{ - data: { - jsFnFullName: string; - isSuccess: boolean; - triggerMeta: { - source: TriggerSource; - triggerPropertyName: string | undefined; - triggerKind: TriggerKind | undefined; - }; - }[]; - }>, -) { - const { - body: { data: executionData }, - } = data; - - // We only care about EVENT_EXECUTION - const triggerExecutionData = executionData.filter( - (execData) => - execData.triggerMeta.triggerKind === TriggerKind.EVENT_EXECUTION, - ); - yield call(logJSActionExecution, triggerExecutionData); -} diff --git a/app/client/src/ce/sagas/analyticsSaga.ts b/app/client/src/ce/sagas/analyticsSaga.ts index 769ef7d71c..e2bbbcb537 100644 --- a/app/client/src/ce/sagas/analyticsSaga.ts +++ b/app/client/src/ce/sagas/analyticsSaga.ts @@ -8,15 +8,10 @@ import { getCurrentPageId, } from "selectors/editorSelectors"; import type { TriggerMeta } from "@appsmith/sagas/ActionExecution/ActionExecutionSagas"; -import type { TriggerSource } from "constants/AppsmithActionConstants/ActionConstants"; import { TriggerKind } from "constants/AppsmithActionConstants/ActionConstants"; import { isArray } from "lodash"; import AnalyticsUtil from "utils/AnalyticsUtil"; -import { getEntityNameAndPropertyPath } from "@appsmith/workers/Evaluation/evaluationUtils"; -import { - getAppMode, - getJSActionFromName, -} from "@appsmith/selectors/entitiesSelector"; +import { getAppMode } from "@appsmith/selectors/entitiesSelector"; import type { AppState } from "@appsmith/reducers"; import { getWidget } from "sagas/selectors"; @@ -139,91 +134,3 @@ export function* logDynamicTriggerExecution({ }, ); } - -export function* logJSActionExecution( - executionData: { - jsFnFullName: string; - isSuccess: boolean; - triggerMeta: { - source: TriggerSource; - triggerPropertyName: string | undefined; - triggerKind: TriggerKind | undefined; - }; - }[], -) { - const { - appId, - appMode, - appName, - email, - instanceId, - isExampleApp, - pageId, - source, - userId, - }: UserAndAppDetails = yield call(getUserAndAppDetails); - for (const { isSuccess, jsFnFullName, triggerMeta } of executionData) { - const { entityName: JSObjectName, propertyPath: functionName } = - getEntityNameAndPropertyPath(jsFnFullName); - const jsAction: ReturnType = yield select( - (state: AppState) => - getJSActionFromName(state, JSObjectName, functionName), - ); - const triggeredWidget: ReturnType | undefined = - yield select((state: AppState) => - getWidget(state, triggerMeta.source?.id || ""), - ); - const dynamicPropertyPathList = triggeredWidget?.dynamicPropertyPathList; - const isJSToggled = !!dynamicPropertyPathList?.find( - (property) => property.key === triggerMeta.triggerPropertyName, - ); - AnalyticsUtil.logEvent("EXECUTE_ACTION", { - type: "JS", - name: functionName, - JSObjectName, - pageId, - appId, - appMode, - appName, - isExampleApp, - actionId: jsAction?.id, - userData: { - userId, - email, - appId, - source, - }, - widgetName: triggeredWidget?.widgetName, - widgetType: triggeredWidget?.type, - propertyName: triggerMeta.triggerPropertyName, - isJSToggled, - instanceId, - }); - - AnalyticsUtil.logEvent( - isSuccess ? "EXECUTE_ACTION_SUCCESS" : "EXECUTE_ACTION_FAILURE", - { - type: "JS", - name: functionName, - JSObjectName, - pageId, - appId, - appMode, - appName, - isExampleApp, - actionId: jsAction?.id, - userData: { - userId, - email, - appId, - source, - }, - widgetName: triggeredWidget?.widgetName, - widgetType: triggeredWidget?.type, - propertyName: triggerMeta.triggerPropertyName, - isJSToggled, - instanceId, - }, - ); - } -} diff --git a/app/client/src/ee/sagas/JSFunctionExecutionSaga.ts b/app/client/src/ee/sagas/JSFunctionExecutionSaga.ts deleted file mode 100644 index f31f67abb4..0000000000 --- a/app/client/src/ee/sagas/JSFunctionExecutionSaga.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "ce/sagas/JSFunctionExecutionSaga"; diff --git a/app/client/src/sagas/EvalWorkerActionSagas.ts b/app/client/src/sagas/EvalWorkerActionSagas.ts index 47214db221..9bb61e4645 100644 --- a/app/client/src/sagas/EvalWorkerActionSagas.ts +++ b/app/client/src/sagas/EvalWorkerActionSagas.ts @@ -17,7 +17,6 @@ import { executeTriggerRequestSaga, updateDataTreeHandler, } from "../sagas/EvaluationsSaga"; -import { logJSFunctionExecution } from "@appsmith/sagas/JSFunctionExecutionSaga"; import { handleStoreOperations } from "./ActionExecution/StoreActionSaga"; import type { EvalTreeResponseData, @@ -128,10 +127,6 @@ export function* handleEvalWorkerMessage(message: TMessage) { yield call(handleStoreOperations, data); break; } - case MAIN_THREAD_ACTION.LOG_JS_FUNCTION_EXECUTION: { - yield call(logJSFunctionExecution, message); - break; - } case MAIN_THREAD_ACTION.PROCESS_BATCHED_TRIGGERS: { const batchedTriggers = data; yield all(