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

Retrieving name of current user in JavaScript (Notebook, Dashboard)

andreas_grabner
Dynatrace Guru
Dynatrace Guru

Hi

I am trying to get the username of the user that executes some JavaScript in either a notebook or dashboard. I assume that functionality exists in one of the SDKs but I couldnt find anything

Any help is appreciated. 

4 REPLIES 4

stefan_eggersto
Dynatrace Mentor
Dynatrace Mentor

Hi @andreas_grabner,

There is currently no SDK available to get the user info, but you can directly call a platform API with the following snippet:

export default async function() {
const response = await fetch("/platform/core/v1/user");
const json = await response.json();
return json.userName;
}

An SDK should be available in the near future.

Thanks!!

FYI - the returned user object has three properties in case anyone is interested: userName, userId, emailAddress

gilgi
DynaMight Champion
DynaMight Champion

@stefan_eggersto I would guess it is but to make sure - would the same also apply to indetify the current user running an application?

and @andreas_grabner thanks for asking this just a few hours before I stumbled upon this issue 🙂

Yes, you can use the same call to identify the app user.

Featured Posts