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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -2772,11 +2772,6 @@ exports[`better eslint`] = {
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]
],
"public/app/core/mod_defs.d.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"]
],
"public/app/core/navigation/GrafanaRoute.test.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],

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) || '',