cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

User action custom properties are being reported as null (most of the time)

Tim_Abil
Newcomer

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(()=>{
reportAction('API_X',Actions.REQUEST, (id, name) => {
reportApiStatus(id, Result.SUCCESS);
});
}).catch(()=>{
reportAction('API_Y', Actions.REQUEST, (id, name) => {
reportApiStatus(id, Result.FAILURE, e);
});
})
const reportAction = (actionName: string, type: Actions, exec?: (id: number, name: string) => void): void => {
const id = window.dtrum?.enterAction(actionName, type, window.dtrum?.now()||0;

window.dtrum?.addActionProperties(id, undefined, undefined, {
api: {
value: actionName,
public: false
}
});
exec?.(id, actionName);
window.dtrum?.leaveAction(id, window.dtrum?.now());
};
const reportApiStatus = (id: number, type: Result, error?: AxiosError): void => {
window.dtrum?.addLeaveActionListener(() => {
window.dtrum?.addActionProperties(id, undefined, undefined, {
response_status: {
value: type,
public: false
}
});
});
};
1 REPLY 1

simon_schatka
Dynatrace Helper
Dynatrace Helper

Hi Tim


I tried your sample and it worked fine for me(I am assuming the missing ")" before "||0" is just a typo?)

Is this a condensed version of the code you are using? Because the reportApiStatus function seems quite unnecessary in the current form and you could just put all that code into the first "addActionProperties" call, where you are adding the api property.
If there is indeed some code missing and this code is more asynchronously executed than your snippets show, I would suggest adding a check to the function you are registering as LeaveActionListener to make sure the id of the action that is currently being left is actually the id you want to add the property to. Additionally make sure to remove the listener again, otherwise over time you will have a huge amount of listeners registered which will cause slowdown.

If this does not help you, I would suggest opening a Support Ticket, then we can more securely share details about your problems and have a closer look at it. Please also drop my name, so the support ticket is passed on directly to me.


Thanks

Simon

Featured Posts