chore: Remove analytics logging of JS functions as it causes a performance b… (#31663)

…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=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## 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`.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
Rajat Agrawal 2024-03-18 11:50:13 +05:30 committed by GitHub
parent 1121a839bc
commit 6bdfb7edac
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 1 additions and 130 deletions

View File

@ -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);
}

View File

@ -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<typeof getJSActionFromName> = yield select(
(state: AppState) =>
getJSActionFromName(state, JSObjectName, functionName),
);
const triggeredWidget: ReturnType<typeof getWidget> | 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,
},
);
}
}

View File

@ -1 +0,0 @@
export * from "ce/sagas/JSFunctionExecutionSaga";

View File

@ -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<any>) {
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(