## Description
- This PR renames the `SAVE_QUERY` and `SAVE_API` events to a generic
`SAVE_ACTION` analytics event.
- The new event will include the following new properties
- `originalActionId` - The `originalActionId` of the action from which
this action was copied or the `id` action from which this action was
copied.
- `hash` - A unique hash of the `actionConfiguration` of this action
- `actionType` - The plugin type for this action
- This PR also fixes an issue where the `originalActionId` was not set
correctly when an action was copied
#### PR fixes following issue(s)
Fixes #25971
#### Type of change
- Chore (housekeeping or task changes that don't impact user perception)
## Testing
#### How Has This Been Tested?
- [x] Manual
- [x] Jest
- [ ] Cypress
#### Test Plan
#### Issues raised during DP testing
53 lines
1.4 KiB
TypeScript
53 lines
1.4 KiB
TypeScript
import {
|
|
ReduxActionTypes,
|
|
type ReduxActionType,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import type { Action } from "entities/Action";
|
|
import AnalyticsUtil from "utils/AnalyticsUtil";
|
|
import {
|
|
RequestPayloadAnalyticsPath,
|
|
cleanValuesInObjectForHashing,
|
|
generateHashFromString,
|
|
} from "./helper";
|
|
import get from "lodash/get";
|
|
import log from "loglevel";
|
|
|
|
export function* sendAnalyticsEventSaga(
|
|
type: ReduxActionType,
|
|
payload: unknown,
|
|
) {
|
|
try {
|
|
switch (type) {
|
|
case ReduxActionTypes.UPDATE_ACTION_INIT:
|
|
const { action, pageName } = payload as {
|
|
action: Action;
|
|
pageName: string;
|
|
};
|
|
const cleanActionConfiguration = cleanValuesInObjectForHashing(
|
|
action.actionConfiguration,
|
|
);
|
|
const actionConfigurationHash: string = yield generateHashFromString(
|
|
JSON.stringify(cleanActionConfiguration),
|
|
);
|
|
|
|
const originalActionId = get(
|
|
action,
|
|
`${RequestPayloadAnalyticsPath}.originalActionId`,
|
|
action.id,
|
|
);
|
|
|
|
AnalyticsUtil.logEvent("SAVE_ACTION", {
|
|
actionName: action.name,
|
|
pageName: pageName,
|
|
originalActionId: originalActionId,
|
|
actionId: action.id,
|
|
hash: actionConfigurationHash,
|
|
actionType: action.pluginType,
|
|
actionPlugin: action.pluginId,
|
|
});
|
|
}
|
|
} catch (e) {
|
|
log.error("Failed to send analytics event");
|
|
}
|
|
}
|