Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/client/src/entities/AppsmithConsole/logtype.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ enum LOG_TYPE {
ACTION_EXECUTION_SUCCESS,
ENTITY_DELETED,
EVAL_ERROR,
EVAL_WARNING,
ACTION_UPDATE,
}

Expand Down
142 changes: 80 additions & 62 deletions app/client/src/sagas/PostEvaluationSagas.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ENTITY_TYPE, Message } from "entities/AppsmithConsole";
import { ENTITY_TYPE, Message, Severity } from "entities/AppsmithConsole";
import { DataTree } from "entities/DataTree/dataTreeFactory";
import {
getEntityNameAndPropertyPath,
Expand Down Expand Up @@ -72,80 +72,98 @@ function getLatestEvalPropertyErrors(
entity,
getEvalValuePath(evaluatedPath, false),
);
const evalErrors = allEvalErrors.filter(
(error) => error.errorType !== PropertyEvaluationErrorType.LINT,
);
const evalErrors: EvaluationError[] = [];
const evalWarnings: EvaluationError[] = [];

for (const err of allEvalErrors) {
if (err.severity === Severity.WARNING) {
evalWarnings.push(err);
}
if (err.severity === Severity.ERROR) {
evalErrors.push(err);
}
}

const idField = isWidget(entity) ? entity.widgetId : entity.actionId;
const nameField = isWidget(entity) ? entity.widgetName : entity.name;
const entityType = isWidget(entity)
? ENTITY_TYPE.WIDGET
: ENTITY_TYPE.ACTION;
const debuggerKey = idField + "-" + propertyPath;
const debuggerKeyMap = {
[`${idField}-${propertyPath}`]: evalErrors,
[`${idField}-${propertyPath}-warning`]: evalWarnings,
};
Comment thread
vnodecg marked this conversation as resolved.
Outdated
// if dataTree has error but debugger does not -> add
// if debugger has error and data tree has error -> update error
// if debugger has error but data tree does not -> remove
// if debugger or data tree does not have an error -> no change

if (evalErrors.length) {
// TODO Rank and set the most critical error
const error = evalErrors[0];
const errorMessages = evalErrors.map((e) => ({
message: e.errorMessage,
}));
for (const [debuggerKey, errors] of Object.entries(debuggerKeyMap)) {
const isWarning = debuggerKey.endsWith("warning");
if (errors.length) {
// TODO Rank and set the most critical error
const error = errors[0];
Comment thread
vnodecg marked this conversation as resolved.
const errorMessages = errors.map((e) => ({
message: e.errorMessage,
}));

if (!(debuggerKey in updatedDebuggerErrors)) {
store.dispatch(
logDebuggerErrorAnalytics({
eventName: "DEBUGGER_NEW_ERROR",
entityId: idField,
entityName: nameField,
entityType,
propertyPath,
errorMessages,
}),
);
}
if (!isWarning && !(debuggerKey in updatedDebuggerErrors)) {
store.dispatch(
logDebuggerErrorAnalytics({
eventName: "DEBUGGER_NEW_ERROR",
entityId: idField,
entityName: nameField,
entityType,
propertyPath,
errorMessages,
}),
);
}

const analyticsData = isWidget(entity)
? {
widgetType: entity.type,
}
: {};
const analyticsData = isWidget(entity)
? {
widgetType: entity.type,
}
: {};

// Add or update
updatedDebuggerErrors[debuggerKey] = {
logType: LOG_TYPE.EVAL_ERROR,
text: PropertyEvalErrorTypeDebugMessage[error.errorType](
propertyPath,
),
messages: errorMessages,
severity: error.severity,
timestamp: moment().format("hh:mm:ss"),
source: {
id: idField,
name: nameField,
type: entityType,
propertyPath: propertyPath,
},
state: {
[propertyPath]: evaluatedValue,
},
analytics: analyticsData,
};
} else if (debuggerKey in updatedDebuggerErrors) {
store.dispatch(
logDebuggerErrorAnalytics({
eventName: "DEBUGGER_RESOLVED_ERROR",
entityId: idField,
entityName: nameField,
entityType,
propertyPath:
updatedDebuggerErrors[debuggerKey].source?.propertyPath ?? "",
errorMessages: updatedDebuggerErrors[debuggerKey].messages ?? [],
}),
);
// Remove
delete updatedDebuggerErrors[debuggerKey];
// Add or update
updatedDebuggerErrors[debuggerKey] = {
logType: isWarning ? LOG_TYPE.EVAL_WARNING : LOG_TYPE.EVAL_ERROR,
Comment thread
vnodecg marked this conversation as resolved.
text: PropertyEvalErrorTypeDebugMessage[error.errorType](
Comment thread
vnodecg marked this conversation as resolved.
Outdated
propertyPath,
),
messages: errorMessages,
severity: isWarning ? Severity.WARNING : Severity.ERROR,
Comment thread
vnodecg marked this conversation as resolved.
Outdated
timestamp: moment().format("hh:mm:ss"),
source: {
id: idField,
name: nameField,
type: entityType,
propertyPath: propertyPath,
},
state: {
[propertyPath]: evaluatedValue,
},
analytics: analyticsData,
};
} else if (debuggerKey in updatedDebuggerErrors) {
if (!isWarning) {
store.dispatch(
logDebuggerErrorAnalytics({
eventName: "DEBUGGER_RESOLVED_ERROR",
entityId: idField,
entityName: nameField,
entityType,
propertyPath:
updatedDebuggerErrors[debuggerKey].source?.propertyPath ?? "",
errorMessages:
updatedDebuggerErrors[debuggerKey].messages ?? [],
}),
);
}
// Remove
delete updatedDebuggerErrors[debuggerKey];
}
}
}
}
Expand Down