Continuing my migration to 2.10.0 from 1.5.21. I’m noticing in some instances, more often than not, $Headers.Referer is missing when executing endpoints. I was using this variable property to see know what page actions are being performed from to track actions.
Using the developer tools I can see the referer is being sent in the request headers but doesn’t seem to be available all the time in the $Headers variable.
I went through all the variables that were available in that breakpoint but didn’t see anything that had what I was looking for.
Is there a better way to get the current page that I am on so I can pass that to my function I use to log user actions? This is the payload I build to send to azure log analytics.
I can reproduce this in certain circumstances as well. Here’s my sample. The results are consistent.
New-UDDashboard -Title 'PowerShell Universal' -Content {
# works
Show-UDToast ($Headers.Referer)
New-UDButton -Text 'Click' -OnClick {
# doesn't work
Show-UDToast ($Headers.Referer)
}
New-UDDynamic -Content {
# works
Show-UDToast ($Headers.Referer)
}
}
Can you provide any script additional examples? I’ll dig into why the button click isn’t working and it may yield a better understanding of why other circumstances wouldn’t work.
Still going through some testing, but it appears to be the -OnClick for New-UDButton that has the problem.
For UDForms, the -OnSubmit has the referer property, unless you pop up a modal, then have an additional New-UDButton in that script block.
So…