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

User tag - Not supported JavaScript expression

Alexander_R_
Advisor

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

 

7 REPLIES 7

janusz_dabrowsk
Dynatrace Pro
Dynatrace Pro

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


AlexanderSommer
Dynatrace Pro
Dynatrace Pro

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


janusz_dabrowsk
Dynatrace Pro
Dynatrace Pro

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


skanchalwar2
Contributor

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.