From abf8ff73cec0f6e9111083e79abf8f54066affac Mon Sep 17 00:00:00 2001 From: dvalleri Date: Mon, 12 Aug 2024 12:14:09 +0200 Subject: [PATCH] feat(ui) : manage uuid generation about grafana session --- ui/package.json | 1 + ui/src/main.jsx | 12 +++++++----- ui/yarn.lock | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/ui/package.json b/ui/package.json index 63c72b65..0b56407d 100644 --- a/ui/package.json +++ b/ui/package.json @@ -37,6 +37,7 @@ "react-router": "^6.23.0", "react-router-dom": "^6.23.0", "react-virtuoso": "^4.7.11", + "uuid": "^10.0.0", "vite": "^5.2.0", "vite-plugin-svgr": "^4.2.0", "yup": "^1.4.0" diff --git a/ui/src/main.jsx b/ui/src/main.jsx index 7cf01d12..df08f0ce 100644 --- a/ui/src/main.jsx +++ b/ui/src/main.jsx @@ -4,6 +4,7 @@ import ReactDOM from 'react-dom/client'; import { Provider } from 'react-redux'; import { RouterProvider, createBrowserRouter } from 'react-router-dom'; import { getCookieConsentValue } from 'react-cookie-consent'; +import { v4 as uuidv4 } from 'uuid'; import { notFoundRoute } from './components/ErrorPage'; import App from './container/app'; import { modelsRoutes } from './container/models/routes'; @@ -14,16 +15,17 @@ const getGrafanaTracking = (enableGrafanaTracking) => { if (enableGrafanaTracking === 'true') { if (tracking === undefined) { + console.debug(localStorage.getItem('radicalbit_user_uuid')); + const userUUID = localStorage.getItem('radicalbit_user_uuid') === null ? uuidv4() : localStorage.getItem('radicalbit_user_uuid'); + localStorage.setItem('radicalbit_user_uuid', userUUID); + tracking = initializeFaro({ url: 'https://telemetry.oss.radicalbit.ai', apiKey: 'rbitoss-JpIYMVC677edETUbJN9Me3iLS7ngGaE2RYLzQWCOYVljUJh5JJk5o2FE', app: { name: 'radicalbit-ai-monitoring' }, - sessionTracking: { - enabled: true, - persistent: true, - maxSessionPersistenceTime: 31540000000, // 1 year - }, + sessionTracking: { enabled: true }, }); + tracking.api.setSession({ id: userUUID }); } } return tracking; diff --git a/ui/yarn.lock b/ui/yarn.lock index 538f310c..8c814ed0 100644 --- a/ui/yarn.lock +++ b/ui/yarn.lock @@ -5981,6 +5981,11 @@ util-deprecate@^1.0.2: resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" integrity sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw== +uuid@^10.0.0: + version "10.0.0" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-10.0.0.tgz#5a95aa454e6e002725c79055fd42aaba30ca6294" + integrity sha512-8XkAphELsDnEGrDxUOHB3RGvXz6TeuYSGEZBOjtTtPm2lwhGBjLgOzLHB63IUWfBpNucQjND6d3AOudO+H3RWQ== + vfile-message@^4.0.0: version "4.0.2" resolved "https://registry.yarnpkg.com/vfile-message/-/vfile-message-4.0.2.tgz#c883c9f677c72c166362fd635f21fc165a7d1181"