01 Oct 2019 08:53 AM - last edited on 26 Apr 2021 03:36 PM by MaciejNeumann
Hello community.
I can`t add JavaScript variable in user tag rule with message "Not supported JavaScript expression"
Why i can`t use JS variables from local storage?
I have no cookies, CSS selector with username. I have only this JS value. Is there any workaround without JS dtrum sdk with dtrum.identify.... to use this value?
Regards,
Alexander
Solved! Go to Solution.
01 Oct 2019 09:22 AM
With google you can easily search for how to list all global JS variables in Chrome console.
eg. you can run
for(var b in window) {
if(window.hasOwnProperty(b)) console.log(b);
}
as page below sugggest
https://stackoverflow.com/questions/2934787/view-list-of-all-javascript-variables-in-google-chrome-c...
Then use the value you need in Dynatrace
Please mind only global variables are accessible.
01 Oct 2019 09:34 AM
Hello Janusz,
My question is not "HOW". My question is "WHY it is not possible to use this value"
I use this:
(function () { var keys=Object.keys( window ); for (var i in keys) { if (typeof window[keys[i]] != 'function') console.log(keys[i], window[keys[i]]); } })(); |
I have see this value and can call from web browser console. After cleanup rules (cut usernames and symbols (.:") i will have correct login.
Regards,
Alexander
01 Oct 2019 09:31 AM
Have you tried: localStorage.<variableName>?
01 Oct 2019 10:31 AM
Hello Alexander
I can`t call localStorage.<variableName>, but i can cal localStorage["some"] - 2 string on screenshot.
You can see localStorage call in browser console on screenshot below:
Can i use localStorage variable with cleanup rules? Will it works?
Regards,
Alexander
01 Oct 2019 01:53 PM
So explanation.
Variable name contained dash so in Chrome console - format as below
localStorage.__Sxxe-Sxxxxxx-RxxxxxxService_Sxxx_Sxxxxx_RxxxxxxyService
did not work
in Chrome console - format as below
localStorage["__Sxxe-Sxxxxxx-RxxxxxxService_Sxxx_Sxxxxx_RxxxxxxyService"]
returned requested value.
Fortunatelly syntax
localStorage.__Sxxe-Sxxxxxx-RxxxxxxService_Sxxx_Sxxxxx_RxxxxxxyService
worked in Dynatrace despite dashes.
01 Oct 2019 01:55 PM
Janusz provided me solution as:
In browser console the call executed with error but in Dynatrace we have successfully defined userlogins.
Big thanks to Janusz.
Regards,
Alexander
18 Jun 2020 07:18 AM - last edited on 15 Feb 2023 07:33 AM by MaciejNeumann
I have similar problem. Pega application handles the user names via json. Dyantrace user tagging rule is unable to capture the user names from it.
Tried variable - pxUserIdentifier, pxRequestor.pxUserIdentifier but not working. Have a tkt open though.
Mean while anyone has any clue how to set this up, please let me know.
14 Feb 2023 04:34 PM
did you get any response for localstorage with dot ??