fix: revert execution instrumentation (#25163)
This commit is contained in:
parent
16d21ed1a3
commit
3df0252692
|
|
@ -1,4 +1,4 @@
|
|||
import { all, call, fork, put, spawn, take } from "redux-saga/effects";
|
||||
import { all, call, put, spawn, take } from "redux-saga/effects";
|
||||
import { ReduxActionTypes } from "@appsmith/constants/ReduxActionConstants";
|
||||
import { MAIN_THREAD_ACTION } from "@appsmith/workers/Evaluation/evalWorkerActions";
|
||||
import log from "loglevel";
|
||||
|
|
@ -30,16 +30,11 @@ import isEmpty from "lodash/isEmpty";
|
|||
import type { UnEvalTree } from "entities/DataTree/dataTreeFactory";
|
||||
import { sortJSExecutionDataByCollectionId } from "workers/Evaluation/JSObject/utils";
|
||||
import type { LintTreeSagaRequestData } from "plugins/Linting/types";
|
||||
import AnalyticsUtil from "utils/AnalyticsUtil";
|
||||
export type UpdateDataTreeMessageData = {
|
||||
workerResponse: EvalTreeResponseData;
|
||||
unevalTree: UnEvalTree;
|
||||
};
|
||||
import { logJSActionExecution } from "./analyticsSaga";
|
||||
import { uniq } from "lodash";
|
||||
import type {
|
||||
TriggerKind,
|
||||
TriggerSource,
|
||||
} from "constants/AppsmithActionConstants/ActionConstants";
|
||||
|
||||
export function* handleEvalWorkerRequestSaga(listenerChannel: Channel<any>) {
|
||||
while (true) {
|
||||
|
|
@ -111,27 +106,18 @@ export function* processTriggerHandler(message: any) {
|
|||
if (messageType === MessageType.REQUEST)
|
||||
yield call(evalWorker.respond, message.messageId, result);
|
||||
}
|
||||
export function* handleJSExecutionLog(
|
||||
data: TMessage<{
|
||||
data: {
|
||||
jsFnFullName: string;
|
||||
isSuccess: boolean;
|
||||
triggerMeta: {
|
||||
source: TriggerSource;
|
||||
triggerPropertyName: string | undefined;
|
||||
triggerKind: TriggerKind | undefined;
|
||||
};
|
||||
}[];
|
||||
}>,
|
||||
) {
|
||||
export function* handleJSExecutionLog(data: TMessage<{ data: string[] }>) {
|
||||
const {
|
||||
body: { data: executionData },
|
||||
body: { data: executedFns },
|
||||
} = data;
|
||||
const executedFns = uniq(
|
||||
executionData.map((execData) => execData.jsFnFullName),
|
||||
);
|
||||
yield fork(logJSActionExecution, executionData);
|
||||
yield call(logJSFunctionExecution, executedFns);
|
||||
|
||||
for (const executedFn of executedFns) {
|
||||
AnalyticsUtil.logEvent("EXECUTE_ACTION", {
|
||||
type: "JS",
|
||||
name: executedFn,
|
||||
});
|
||||
}
|
||||
yield call(logJSFunctionExecution, data);
|
||||
}
|
||||
|
||||
export function* handleEvalWorkerMessage(message: TMessage<any>) {
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ import { handleEvalWorkerRequestSaga } from "./EvalWorkerActionSagas";
|
|||
import { getAppsmithConfigs } from "@appsmith/configs";
|
||||
import { executeJSUpdates } from "actions/pluginActionActions";
|
||||
import { setEvaluatedActionSelectorField } from "actions/actionSelectorActions";
|
||||
import { logDynamicTriggerExecution } from "./analyticsSaga";
|
||||
|
||||
const APPSMITH_CONFIGS = getAppsmithConfigs();
|
||||
|
||||
|
|
@ -313,6 +312,7 @@ export function* evaluateAndExecuteDynamicTrigger(
|
|||
const unEvalTree: ReturnType<typeof getUnevaluatedDataTree> = yield select(
|
||||
getUnevaluatedDataTree,
|
||||
);
|
||||
// const unEvalTree = unEvalAndConfigTree.unEvalTree;
|
||||
log.debug({ execute: dynamicTrigger });
|
||||
const response: { errors: EvaluationError[]; result: unknown } = yield call(
|
||||
evalWorker.request,
|
||||
|
|
@ -328,11 +328,6 @@ export function* evaluateAndExecuteDynamicTrigger(
|
|||
);
|
||||
const { errors = [] } = response as any;
|
||||
yield call(dynamicTriggerErrorHandler, errors);
|
||||
yield fork(logDynamicTriggerExecution, {
|
||||
dynamicTrigger,
|
||||
errors,
|
||||
triggerMeta,
|
||||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,224 +0,0 @@
|
|||
import { getCurrentUser } from "selectors/usersSelectors";
|
||||
import { getInstanceId } from "@appsmith/selectors/tenantSelectors";
|
||||
import { getAppsmithConfigs } from "@appsmith/configs";
|
||||
import { call, select } from "redux-saga/effects";
|
||||
import type { APP_MODE } from "entities/App";
|
||||
import {
|
||||
getCurrentApplication,
|
||||
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 "selectors/entitiesSelector";
|
||||
import type { AppState } from "@appsmith/reducers";
|
||||
import { getWidget } from "./selectors";
|
||||
|
||||
export interface UserAndAppDetails {
|
||||
pageId: string;
|
||||
appId: string;
|
||||
appMode: APP_MODE | undefined;
|
||||
appName: string;
|
||||
isExampleApp: boolean;
|
||||
userId: string;
|
||||
email: string;
|
||||
source: string;
|
||||
instanceId: string;
|
||||
}
|
||||
|
||||
export function* getUserAndAppDetails() {
|
||||
const appMode: ReturnType<typeof getAppMode> = yield select(getAppMode);
|
||||
const currentApp: ReturnType<typeof getCurrentApplication> = yield select(
|
||||
getCurrentApplication,
|
||||
);
|
||||
const user: ReturnType<typeof getCurrentUser> = yield select(getCurrentUser);
|
||||
const instanceId: ReturnType<typeof getInstanceId> = yield select(
|
||||
getInstanceId,
|
||||
);
|
||||
const { cloudHosting } = getAppsmithConfigs();
|
||||
const source = cloudHosting ? "cloud" : "ce";
|
||||
const pageId: ReturnType<typeof getCurrentPageId> = yield select(
|
||||
getCurrentPageId,
|
||||
);
|
||||
const userAndAppDetails: UserAndAppDetails = {
|
||||
pageId,
|
||||
appId: currentApp?.id || "",
|
||||
appMode,
|
||||
appName: currentApp?.name || "",
|
||||
isExampleApp: currentApp?.appIsExample || false,
|
||||
userId: user?.username || "",
|
||||
email: user?.email || "",
|
||||
source,
|
||||
instanceId: instanceId,
|
||||
};
|
||||
|
||||
return userAndAppDetails;
|
||||
}
|
||||
export function* logDynamicTriggerExecution({
|
||||
dynamicTrigger,
|
||||
errors,
|
||||
triggerMeta,
|
||||
}: {
|
||||
dynamicTrigger: string;
|
||||
errors: unknown;
|
||||
triggerMeta: TriggerMeta;
|
||||
}) {
|
||||
if (triggerMeta.triggerKind !== TriggerKind.EVENT_EXECUTION) return;
|
||||
const isUnsuccessfulExecution = isArray(errors) && errors.length > 0;
|
||||
const {
|
||||
appId,
|
||||
appMode,
|
||||
appName,
|
||||
email,
|
||||
instanceId,
|
||||
isExampleApp,
|
||||
pageId,
|
||||
source,
|
||||
userId,
|
||||
}: UserAndAppDetails = yield call(getUserAndAppDetails);
|
||||
const widget: ReturnType<typeof getWidget> | undefined = yield select(
|
||||
(state: AppState) => getWidget(state, triggerMeta.source?.id || ""),
|
||||
);
|
||||
|
||||
const dynamicPropertyPathList = widget?.dynamicPropertyPathList;
|
||||
const isJSToggled = !!dynamicPropertyPathList?.find(
|
||||
(property) => property.key === triggerMeta.triggerPropertyName,
|
||||
);
|
||||
AnalyticsUtil.logEvent("EXECUTE_ACTION", {
|
||||
type: "JS_EXPRESSION",
|
||||
unevalValue: dynamicTrigger,
|
||||
pageId,
|
||||
appId,
|
||||
appMode,
|
||||
appName,
|
||||
isExampleApp,
|
||||
userData: {
|
||||
userId,
|
||||
email,
|
||||
appId,
|
||||
source,
|
||||
},
|
||||
widgetName: widget?.widgetName,
|
||||
widgetType: widget?.type,
|
||||
propertyName: triggerMeta.triggerPropertyName,
|
||||
instanceId,
|
||||
isJSToggled,
|
||||
});
|
||||
|
||||
AnalyticsUtil.logEvent(
|
||||
isUnsuccessfulExecution
|
||||
? "EXECUTE_ACTION_FAILURE"
|
||||
: "EXECUTE_ACTION_SUCCESS",
|
||||
{
|
||||
type: "JS_EXPRESSION",
|
||||
unevalValue: dynamicTrigger,
|
||||
pageId,
|
||||
appId,
|
||||
appMode,
|
||||
appName,
|
||||
isExampleApp,
|
||||
userData: {
|
||||
userId,
|
||||
email,
|
||||
appId,
|
||||
source,
|
||||
},
|
||||
widgetName: widget?.widgetName,
|
||||
widgetType: widget?.type,
|
||||
propertyName: triggerMeta.triggerPropertyName,
|
||||
instanceId,
|
||||
isJSToggled,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
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,
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
@ -487,24 +487,6 @@ export const getJSCollectionFromName = createSelector(
|
|||
return currentJSCollection;
|
||||
},
|
||||
);
|
||||
export const getJSActionFromName = createSelector(
|
||||
[
|
||||
(state: AppState, jsCollectionName: string) =>
|
||||
getJSCollectionFromName(state, jsCollectionName),
|
||||
(_state: AppState, jsCollectionName: string, functionName: string) => ({
|
||||
jsCollectionName,
|
||||
functionName,
|
||||
}),
|
||||
],
|
||||
(JSCollectionData, { functionName }) => {
|
||||
if (!JSCollectionData) return null;
|
||||
const jsFunction = find(
|
||||
JSCollectionData.config.actions,
|
||||
(action) => action.name === functionName,
|
||||
);
|
||||
return jsFunction || null;
|
||||
},
|
||||
);
|
||||
|
||||
export const getJSActionFromJSCollection = (
|
||||
JSCollection: JSCollectionData,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import type {
|
||||
ConfigTree,
|
||||
DataTree,
|
||||
AppsmithEntity,
|
||||
DataTreeEntity,
|
||||
} from "entities/DataTree/dataTreeFactory";
|
||||
import { EvaluationSubstitutionType } from "entities/DataTree/dataTreeFactory";
|
||||
|
|
@ -21,6 +22,7 @@ import {
|
|||
isJSAction,
|
||||
} from "@appsmith/workers/Evaluation/evaluationUtils";
|
||||
import JSObjectCollection from "./Collection";
|
||||
import type { APP_MODE } from "entities/App";
|
||||
import type {
|
||||
JSActionEntityConfig,
|
||||
JSActionEntity,
|
||||
|
|
@ -270,6 +272,11 @@ export function isJSObjectVariable(
|
|||
);
|
||||
}
|
||||
|
||||
export function getAppMode(dataTree: DataTree) {
|
||||
const appsmithObj = dataTree.appsmith as AppsmithEntity;
|
||||
return appsmithObj.mode as APP_MODE;
|
||||
}
|
||||
|
||||
export function isPromise(value: any): value is Promise<unknown> {
|
||||
return Boolean(value && typeof value.then === "function");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,10 +11,6 @@ import { get } from "lodash";
|
|||
import { getType } from "utils/TypeHelpers";
|
||||
import type { JSVarMutatedEvents } from "workers/Evaluation/types";
|
||||
import { dataTreeEvaluator } from "workers/Evaluation/handlers/evalTree";
|
||||
import type {
|
||||
TriggerKind,
|
||||
TriggerSource,
|
||||
} from "constants/AppsmithActionConstants/ActionConstants";
|
||||
|
||||
const _internalSetTimeout = self.setTimeout;
|
||||
const _internalClearTimeout = self.clearTimeout;
|
||||
|
|
@ -186,21 +182,15 @@ TriggerEmitter.on(
|
|||
jsVariableUpdatesHandlerWrapper,
|
||||
);
|
||||
|
||||
export const fnInvokeLogHandler = deferredBatchedActionHandler<{
|
||||
jsFnFullName: string;
|
||||
isSuccess: boolean;
|
||||
triggerMeta: {
|
||||
source: TriggerSource;
|
||||
triggerPropertyName: string | undefined;
|
||||
triggerKind: TriggerKind | undefined;
|
||||
};
|
||||
}>((data) => {
|
||||
const set = new Set([...data]);
|
||||
WorkerMessenger.ping({
|
||||
method: MAIN_THREAD_ACTION.LOG_JS_FUNCTION_EXECUTION,
|
||||
data: [...set],
|
||||
});
|
||||
});
|
||||
export const fnInvokeLogHandler = priorityBatchedActionHandler<string>(
|
||||
(data) => {
|
||||
const set = new Set([...data]);
|
||||
WorkerMessenger.ping({
|
||||
method: MAIN_THREAD_ACTION.LOG_JS_FUNCTION_EXECUTION,
|
||||
data: [...set],
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
TriggerEmitter.on(BatchKey.process_batched_fn_invoke_log, fnInvokeLogHandler);
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export type PostProcessorArg = {
|
|||
executionMetaData: ReturnType<typeof ExecutionMetaData.getExecutionMetaData>;
|
||||
jsFnFullName: string;
|
||||
executionResponse: unknown;
|
||||
isSuccess: boolean;
|
||||
};
|
||||
|
||||
export type PostProcessor = (args: PostProcessorArg) => void;
|
||||
|
|
@ -35,18 +34,10 @@ function saveExecutionData({
|
|||
});
|
||||
}
|
||||
|
||||
function logJSExecution({
|
||||
executionMetaData,
|
||||
isSuccess,
|
||||
jsFnFullName,
|
||||
}: PostProcessorArg) {
|
||||
function logJSExecution({ executionMetaData, jsFnFullName }: PostProcessorArg) {
|
||||
switch (executionMetaData.triggerMeta.triggerKind) {
|
||||
case TriggerKind.EVENT_EXECUTION: {
|
||||
TriggerEmitter.emit(BatchKey.process_batched_fn_invoke_log, {
|
||||
jsFnFullName,
|
||||
isSuccess,
|
||||
triggerMeta: executionMetaData.triggerMeta,
|
||||
});
|
||||
TriggerEmitter.emit(BatchKey.process_batched_fn_invoke_log, jsFnFullName);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
|
@ -75,7 +66,6 @@ export function jsObjectFunctionFactory<P extends ReadonlyArray<unknown>>(
|
|||
executionMetaData,
|
||||
jsFnFullName: name,
|
||||
executionResponse: res,
|
||||
isSuccess: true,
|
||||
}),
|
||||
);
|
||||
return res;
|
||||
|
|
@ -86,7 +76,6 @@ export function jsObjectFunctionFactory<P extends ReadonlyArray<unknown>>(
|
|||
executionMetaData,
|
||||
jsFnFullName: name,
|
||||
executionResponse: undefined,
|
||||
isSuccess: true,
|
||||
}),
|
||||
);
|
||||
throw e;
|
||||
|
|
@ -97,7 +86,6 @@ export function jsObjectFunctionFactory<P extends ReadonlyArray<unknown>>(
|
|||
executionMetaData,
|
||||
jsFnFullName: name,
|
||||
executionResponse: result,
|
||||
isSuccess: true,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
@ -108,7 +96,6 @@ export function jsObjectFunctionFactory<P extends ReadonlyArray<unknown>>(
|
|||
executionMetaData,
|
||||
jsFnFullName: name,
|
||||
executionResponse: undefined,
|
||||
isSuccess: false,
|
||||
});
|
||||
});
|
||||
throw e;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user