Kibana version: 7.9.2
Elasticsearch version: 7.9.2
APM Server version: 7.9.2
APM Agent language and version: Angular 8
Hi,
I'm trying to use the Angular Rum agent for a frontend application.
It's working and sending transaction information to APM.
Now, I want to add the user information of the logged in user to the transactions with apm.setUserContext.
I'm able to do this with hardcoded variables, but when I try to get the info from a function it's empty.
This is my working app.module.ts part
export class AppModule {
userContextId = '666';
userContextName = 'TestUserName';
userContextEmail = 'testemail@foo.com';
constructor(@Inject(ApmService) service: ApmService){
const apm = service.init({
serviceName: 'Frontend Local',
environment: 'Local',
serverUrl: constants.apmURL,
distributedTracingOrigins: [constants.distributedTracingOrigins],
serviceVersion: version
})
apm.setUserContext({
'id': this.userContextId,
'username': this.userContextName,
'email': this.userContextEmail
})
}
}
How do I send real info instead of the test info?
I have an authService where the userprofile info is available, but I can't get this into the apm events.
For example with:
getUserName() {
return this._authService.authContext.userProfile.name
}
Even with the following very simple test it doesn't work:
getUserName() {
return 'MyName'
}
With of course:
apm.setUserContext({
'id': this.userContextId,
'username': this.getUserName,
'email': this.userContextEmail
})
Kind regards,
Peter