In our SPA react application we are reporting API response statuses as user action properties. Each axios transaction is reporting a userAction and based on its the API response it attached the appropriate response details as a custom property to that userAction. (ex: SUCCESS or FAILURE). The following code must append two properties to each request action; the api name and response status. But when i query these action in USQL the api name is always present but response status is null most of the time. Sometimes it does report correctly and i see the response_status set to SUCCESS or FAILURE(a lot more rarely) but most of the time it’s just not getting appended for some reason. Note the axios calls are sitting inside a redux middleware.
axios.get(...).then(()=>{<br> reportAction('API_X',Actions.REQUEST, (id, name) => {<br> reportApiStatus(id, Result.SUCCESS);<br> });<br>}).catch(()=>{<br> reportAction('API_Y', Actions.REQUEST, (id, name) => {<br> reportApiStatus(id, Result.FAILURE, e);<br> });<br>})
const reportAction = (actionName: string, type: Actions, exec?: (id: number, name: string) => void): void => {<br> const id = window.dtrum?.enterAction(actionName, type, window.dtrum?.now()||0; <br><br>window.dtrum?.addActionProperties(id, undefined, undefined, {<br> api: {<br> value: actionName,<br> public: false<br> }<br>});<br> exec?.(id, actionName);<br> window.dtrum?.leaveAction(id, window.dtrum?.now());<br>};
const reportApiStatus = (id: number, type: Result, error?: AxiosError): void => {<br> window.dtrum?.addLeaveActionListener(() => {<br> window.dtrum?.addActionProperties(id, undefined, undefined, {<br> response_status: {<br> value: type,<br> public: false<br> }<br> });<br> });<br>};