01 Oct 2019
12:53 AM
- last edited on
26 Apr 2021
07:36 AM
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.
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.
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
Have you tried: localStorage.<variableName>?
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
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.
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
17 Jun 2020
11:18 PM
- last edited on
14 Feb 2023
11:33 PM
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.
did you get any response for localstorage with dot ??