## Description Updating analytics to pass the correct source information Fixes [#32266](https://github.com/appsmithorg/appsmith/issues/32266) ## Automation /ok-to-test tags="@tag.Sanity" ### 🔍 Cypress test results <!-- This is an auto-generated comment: Cypress test results --> > [!TIP] > 🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉 > Workflow run: <https://github.com/appsmithorg/appsmith/actions/runs/8750877755> > Commit: 6fedefebd3867aee79877b7ed105c90888005cfd > Cypress dashboard url: <a href="https://internal.appsmith.com/app/cypress-dashboard/rundetails-65890b3c81d7400d08fa9ee5?branch=master&workflowId=8750877755&attempt=1" target="_blank">Click here!</a> <!-- end of auto-generated comment: Cypress test results -->
66 lines
2.1 KiB
TypeScript
66 lines
2.1 KiB
TypeScript
import { takeLatest, put, all, select } from "redux-saga/effects";
|
|
import type { ReduxAction } from "@appsmith/constants/ReduxActionConstants";
|
|
import {
|
|
ReduxActionTypes,
|
|
ReduxActionErrorTypes,
|
|
} from "@appsmith/constants/ReduxActionConstants";
|
|
import { validateResponse } from "sagas/ErrorSagas";
|
|
import type { CurlImportRequest } from "api/ImportApi";
|
|
import CurlImportApi from "api/ImportApi";
|
|
import type { ApiResponse } from "api/ApiResponses";
|
|
import AnalyticsUtil from "@appsmith/utils/AnalyticsUtil";
|
|
import { getCurrentWorkspaceId } from "@appsmith/selectors/selectedWorkspaceSelectors";
|
|
import transformCurlImport from "transformers/CurlImportTransformer";
|
|
import history from "utils/history";
|
|
import { CURL } from "constants/AppsmithActionConstants/ActionConstants";
|
|
import { apiEditorIdURL } from "@appsmith/RouteBuilder";
|
|
|
|
export function* curlImportSaga(action: ReduxAction<CurlImportRequest>) {
|
|
const { contextId, contextType, name, type } = action.payload;
|
|
let { curl } = action.payload;
|
|
try {
|
|
curl = transformCurlImport(curl);
|
|
const workspaceId: string = yield select(getCurrentWorkspaceId);
|
|
const request: CurlImportRequest = {
|
|
type,
|
|
contextId,
|
|
name,
|
|
curl,
|
|
workspaceId,
|
|
contextType,
|
|
};
|
|
|
|
const response: ApiResponse = yield CurlImportApi.curlImport(request);
|
|
const isValidResponse: boolean = yield validateResponse(response);
|
|
|
|
if (isValidResponse) {
|
|
AnalyticsUtil.logEvent("IMPORT_API", {
|
|
importSource: CURL,
|
|
});
|
|
|
|
yield put({
|
|
type: ReduxActionTypes.SUBMIT_CURL_FORM_SUCCESS,
|
|
payload: response.data,
|
|
});
|
|
|
|
history.push(
|
|
// @ts-expect-error: response.data is of type unknown
|
|
apiEditorIdURL({ parentEntityId: contextId, apiId: response.data.id }),
|
|
);
|
|
}
|
|
} catch (error) {
|
|
yield put({
|
|
type: ReduxActionErrorTypes.SUBMIT_CURL_FORM_ERROR,
|
|
payload: {
|
|
error,
|
|
},
|
|
});
|
|
}
|
|
}
|
|
|
|
export default function* curlImportSagas() {
|
|
yield all([
|
|
takeLatest(ReduxActionTypes.SUBMIT_CURL_FORM_INIT, curlImportSaga),
|
|
]);
|
|
}
|