Skip to content

Commit

Permalink
feat(ui) : manage uuid generation about grafana session
Browse files Browse the repository at this point in the history
  • Loading branch information
dvalleri committed Aug 12, 2024
1 parent a1180b4 commit abf8ff7
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 7 additions & 5 deletions ui/src/main.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
5 changes: 5 additions & 0 deletions ui/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit abf8ff7

Please sign in to comment.