Fix: Fix bugs related to debugger errors (#5824)
This commit is contained in:
parent
95d5557749
commit
794ef1bbd6
|
|
@ -63,6 +63,8 @@ export interface LogActionPayload {
|
|||
source?: SourceEntity;
|
||||
// Snapshot KV pair of scope variables or state associated with this event.
|
||||
state?: Record<string, any>;
|
||||
// Any other data required for analytics
|
||||
analytics?: Record<string, any>;
|
||||
}
|
||||
|
||||
export interface Message extends LogActionPayload {
|
||||
|
|
|
|||
|
|
@ -345,7 +345,9 @@ export function* deleteActionSaga(
|
|||
try {
|
||||
const id = actionPayload.payload.id;
|
||||
const name = actionPayload.payload.name;
|
||||
const action = yield select(getAction, id);
|
||||
const action: Action | undefined = yield select(getAction, id);
|
||||
|
||||
if (!action) return;
|
||||
|
||||
const isApi = action.pluginType === PluginType.API;
|
||||
const isQuery = action.pluginType === PluginType.DB;
|
||||
|
|
@ -401,7 +403,11 @@ export function* deleteActionSaga(
|
|||
name: response.data.name,
|
||||
id: response.data.id,
|
||||
},
|
||||
analytics: {
|
||||
pluginId: action.pluginId,
|
||||
},
|
||||
});
|
||||
|
||||
yield put(deleteActionSuccess({ id }));
|
||||
}
|
||||
} catch (error) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ import {
|
|||
} from "redux-saga/effects";
|
||||
import { get, set } from "lodash";
|
||||
import { getDebuggerErrors } from "selectors/debuggerSelectors";
|
||||
import { getAction, getPlugin } from "selectors/entitiesSelector";
|
||||
import {
|
||||
getAction,
|
||||
getPlugin,
|
||||
getPluginNameFromId,
|
||||
} from "selectors/entitiesSelector";
|
||||
import { Action, PluginType } from "entities/Action";
|
||||
import LOG_TYPE from "entities/AppsmithConsole/logtype";
|
||||
import { DataTree } from "entities/DataTree/dataTreeFactory";
|
||||
|
|
@ -81,8 +85,13 @@ function* onEntityDeleteSaga(payload: Message) {
|
|||
yield put(debuggerLog(payload));
|
||||
return;
|
||||
}
|
||||
const currentPageId = yield select(getCurrentPageId);
|
||||
let pluginName: string = yield select(
|
||||
getPluginNameFromId,
|
||||
payload?.analytics?.pluginId,
|
||||
);
|
||||
|
||||
const errors = yield select(getDebuggerErrors);
|
||||
const errors: Record<string, Message> = yield select(getDebuggerErrors);
|
||||
const errorIds = Object.keys(errors);
|
||||
const updatedErrors: any = {};
|
||||
|
||||
|
|
@ -91,6 +100,29 @@ function* onEntityDeleteSaga(payload: Message) {
|
|||
|
||||
if (!includes) {
|
||||
updatedErrors[e] = errors[e];
|
||||
} else {
|
||||
// If the error is being removed here
|
||||
// need to send an analytics event for the same
|
||||
const error = errors[e];
|
||||
pluginName = pluginName.replace(/ /g, "");
|
||||
|
||||
if (source.type === ENTITY_TYPE.ACTION) {
|
||||
AnalyticsUtil.logEvent("DEBUGGER_RESOLVED_ERROR", {
|
||||
entityType: pluginName,
|
||||
propertyPath: `${pluginName}.${error.source?.propertyPath ?? ""}`,
|
||||
errorMessages: error.messages,
|
||||
pageId: currentPageId,
|
||||
});
|
||||
} else if (source.type === ENTITY_TYPE.WIDGET) {
|
||||
const widgetType = error?.analytics?.widgetType;
|
||||
|
||||
AnalyticsUtil.logEvent("DEBUGGER_RESOLVED_ERROR", {
|
||||
entityType: widgetType,
|
||||
propertyPath: `${widgetType}.${error.source?.propertyPath ?? ""}`,
|
||||
errorMessages: error.messages,
|
||||
pageId: currentPageId,
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -129,6 +129,12 @@ function getLatestEvalPropertyErrors(
|
|||
);
|
||||
}
|
||||
|
||||
const analyticsData = isWidget(entity)
|
||||
? {
|
||||
widgetType: entity.type,
|
||||
}
|
||||
: {};
|
||||
|
||||
// Add or update
|
||||
updatedDebuggerErrors[debuggerKey] = {
|
||||
logType: LOG_TYPE.EVAL_ERROR,
|
||||
|
|
@ -147,6 +153,7 @@ function getLatestEvalPropertyErrors(
|
|||
state: {
|
||||
[propertyPath]: evaluatedValue,
|
||||
},
|
||||
analytics: analyticsData,
|
||||
};
|
||||
} else if (debuggerKey in updatedDebuggerErrors) {
|
||||
store.dispatch(
|
||||
|
|
|
|||
|
|
@ -528,14 +528,16 @@ export function* deleteAllSelectedWidgetsSaga(
|
|||
setTimeout(() => {
|
||||
if (bulkDeleteKey) {
|
||||
flushDeletedWidgets(bulkDeleteKey);
|
||||
AppsmithConsole.info({
|
||||
logType: LOG_TYPE.ENTITY_DELETED,
|
||||
text: `${selectedWidgets.length} were deleted`,
|
||||
source: {
|
||||
name: "Group Delete",
|
||||
type: ENTITY_TYPE.WIDGET,
|
||||
id: bulkDeleteKey,
|
||||
},
|
||||
falttendedWidgets.map((widget: any) => {
|
||||
AppsmithConsole.info({
|
||||
logType: LOG_TYPE.ENTITY_DELETED,
|
||||
text: "Widget was deleted",
|
||||
source: {
|
||||
name: widget.widgetName,
|
||||
type: ENTITY_TYPE.WIDGET,
|
||||
id: widget.widgetId,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}, WIDGET_DELETE_UNDO_TIMEOUT);
|
||||
|
|
@ -575,7 +577,9 @@ export function* deleteSaga(deleteAction: ReduxAction<WidgetDelete>) {
|
|||
const { disallowUndo, isShortcut } = deleteAction.payload;
|
||||
|
||||
if (!widgetId) {
|
||||
const selectedWidget = yield select(getSelectedWidget);
|
||||
const selectedWidget: FlattenedWidgetProps | undefined = yield select(
|
||||
getSelectedWidget,
|
||||
);
|
||||
if (!selectedWidget) return;
|
||||
|
||||
// if widget is not deletable, don't don anything
|
||||
|
|
@ -588,7 +592,7 @@ export function* deleteSaga(deleteAction: ReduxAction<WidgetDelete>) {
|
|||
if (widgetId && parentId) {
|
||||
const stateWidgets = yield select(getWidgets);
|
||||
const widgets = { ...stateWidgets };
|
||||
const stateWidget = yield select(getWidget, widgetId);
|
||||
const stateWidget: WidgetProps = yield select(getWidget, widgetId);
|
||||
const widget = { ...stateWidget };
|
||||
|
||||
const stateParent: FlattenedWidgetProps = yield select(
|
||||
|
|
@ -641,17 +645,20 @@ export function* deleteSaga(deleteAction: ReduxAction<WidgetDelete>) {
|
|||
},
|
||||
},
|
||||
});
|
||||
|
||||
setTimeout(() => {
|
||||
if (widgetId) {
|
||||
flushDeletedWidgets(widgetId);
|
||||
AppsmithConsole.info({
|
||||
logType: LOG_TYPE.ENTITY_DELETED,
|
||||
text: "Widget was deleted",
|
||||
source: {
|
||||
name: widgetName,
|
||||
type: ENTITY_TYPE.WIDGET,
|
||||
id: widgetId,
|
||||
},
|
||||
otherWidgetsToDelete.map((widget) => {
|
||||
AppsmithConsole.info({
|
||||
logType: LOG_TYPE.ENTITY_DELETED,
|
||||
text: "Widget was deleted",
|
||||
source: {
|
||||
name: widget.widgetName,
|
||||
type: ENTITY_TYPE.WIDGET,
|
||||
id: widget.widgetId,
|
||||
},
|
||||
});
|
||||
});
|
||||
}
|
||||
}, WIDGET_DELETE_UNDO_TIMEOUT);
|
||||
|
|
|
|||
|
|
@ -80,7 +80,10 @@ export const getPluginPackageFromDatasourceId = (
|
|||
return plugin.packageName;
|
||||
};
|
||||
|
||||
export const getPluginNameFromId = (state: AppState, pluginId: string) => {
|
||||
export const getPluginNameFromId = (
|
||||
state: AppState,
|
||||
pluginId: string,
|
||||
): string => {
|
||||
const plugin = state.entities.plugins.list.find(
|
||||
(plugin) => plugin.id === pluginId,
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user