JS Agent: remove user email and add session id (#55767)

This commit is contained in:
Virginia Cepeda
2022-09-27 08:59:32 -03:00
committed by GitHub
parent 701f6d5436
commit 27f022283d
3 changed files with 10 additions and 7 deletions

View File

@ -115,7 +115,6 @@ describe('GrafanaJavascriptAgentEchoBackend', () => {
expect(mockedSetUser).toHaveBeenCalledTimes(1);
expect(mockedSetUser).toHaveBeenCalledWith({
id: '504',
email: 'darth.vader@sith.glx',
attributes: {
orgId: '1',
},

View File

@ -1,6 +1,7 @@
import { BaseTransport } from '@grafana/agent-core';
import {
initializeAgent,
defaultMetas,
BrowserConfig,
ErrorsInstrumentation,
ConsoleInstrumentation,
@ -63,12 +64,20 @@ export class GrafanaJavascriptAgentBackend
'ResizeObserver loop completed',
'Non-Error exception captured with keys',
],
metas: [
...defaultMetas,
{
session: {
// new session id for every page load
id: (Math.random() + 1).toString(36).substring(2),
},
},
],
};
this.agentInstance = initializeAgent(grafanaJavaScriptAgentOptions);
if (options.user) {
this.agentInstance.api.setUser({
email: options.user.email,
id: options.user.id,
attributes: {
orgId: String(options.user.orgId) || '',