Files
shoptime/com.twin.app.shoptime/src/api/TLogEvent.js
younghoon100.park 685bca405d [actions, api] postLogLive, TLogEvent 수정
Detail Notes :

1. postLogLive, params 수정
2. TLogEvent, 딥 링크 관련 Logic 주석 처리
2024-04-30 18:12:43 +09:00

90 lines
1.9 KiB
JavaScript

import axios from "axios";
import { getUrl } from "./apiConfig";
// import { clearLaunchParams, getLaunchParams } from "../utils/helperMethods";
import { createQueryString } from "../utils/helperMethods";
export const TLogEvent = (
dispatch,
getState,
type,
baseUrl,
urlParams = {},
params = {},
onSuccess,
onFail
) => {
const httpHeader = getState().common.httpHeader;
const appStatus = getState().common.appStatus;
const AUTHORIZATION = { headers: { ...httpHeader } };
const { cntry_cd: cntryCd, plat_cd: platCd, prod_cd: prodCd } = httpHeader;
const { deviceId: dvcId } = appStatus;
const dvcTp = "tv";
if (typeof window === "object") {
let url = Array.isArray(baseUrl)
? getUrl(getState, baseUrl[0])
: getUrl(getState, baseUrl);
if (!url) {
return;
}
if (type === "get") {
const _urlparams = createQueryString(urlParams);
url += _urlparams ? `?${_urlparams}` : "";
}
// let linkTpCd = "";
// if (httpHeader) {
// const launchParams = getLaunchParams();
// if (launchParams?.contentTarget) {
// const tokens = launchParams.contentTarget.split("_");
// if (tokens[0] === "V3") {
// linkTpCd = tokens[1];
// }
// }
// }
const model = {
...params,
cntryCd,
dvcId,
dvcTp,
// linkTpCd,
platCd,
prodCd,
};
let axiosInstance;
switch (type) {
case "get":
axiosInstance = axios.get(url, AUTHORIZATION);
break;
case "post":
axiosInstance = axios.post(url, model, AUTHORIZATION);
break;
}
if (axiosInstance) {
axiosInstance
.then((res) => {
if (onSuccess) {
onSuccess(res);
}
})
.catch((error) => {
if (onFail) {
onFail(error);
}
});
// .finally(clearLaunchParams);
}
}
};