From 1f1b823f60532cd1aa1a9e0501088a692936df66 Mon Sep 17 00:00:00 2001 From: smit95tpatel Date: Thu, 12 May 2022 13:22:04 +0530 Subject: [PATCH] feat: added and stored random userid in local for instrumentation --- react-frontend/src/components/App.jsx | 6 +- .../src/components/ContentHeader.jsx | 2 +- react-frontend/src/components/GroupItem.jsx | 20 +++-- react-frontend/src/components/Navbar/index.js | 27 +++--- .../src/components/ServicesPage.jsx | 2 +- react-frontend/src/utils/analytics.js | 87 ------------------- react-frontend/src/utils/helper.js | 33 ++----- react-frontend/src/utils/trackers.js | 13 ++- 8 files changed, 50 insertions(+), 140 deletions(-) delete mode 100644 react-frontend/src/utils/analytics.js diff --git a/react-frontend/src/components/App.jsx b/react-frontend/src/components/App.jsx index 4c64fb13..7264083d 100644 --- a/react-frontend/src/components/App.jsx +++ b/react-frontend/src/components/App.jsx @@ -5,11 +5,15 @@ import theme from "../theme"; import ServicesPage from "./ServicesPage"; import Navigation from "./Navbar"; import { initLumberjack } from "../utils/trackers"; +import { generateUUID, getUserId, setUerId } from "../utils/helper"; const App = () => { console.log(`Application running on ${process.env.NODE_ENV} mode.`); useEffect(() => { - console.log(navigator); + if(!getUserId()) { + setUerId(generateUUID(14)); + } + initLumberjack(); }, []) diff --git a/react-frontend/src/components/ContentHeader.jsx b/react-frontend/src/components/ContentHeader.jsx index ae7c5ffa..dd50c0c4 100644 --- a/react-frontend/src/components/ContentHeader.jsx +++ b/react-frontend/src/components/ContentHeader.jsx @@ -1,5 +1,5 @@ import React from "react"; -import { analyticsTrack } from "../utils/analytics"; +import { analyticsTrack } from "../utils/trackers"; const ContentHeader = () => { const sendAnalytics = () => { diff --git a/react-frontend/src/components/GroupItem.jsx b/react-frontend/src/components/GroupItem.jsx index d685be8e..973bdc60 100644 --- a/react-frontend/src/components/GroupItem.jsx +++ b/react-frontend/src/components/GroupItem.jsx @@ -10,7 +10,7 @@ import SubServiceCard from "./SubServiceCard"; // import ServiceLoader from "./ServiceLoader"; // import DateUtils from "../utils/DateUtils"; import infoIcon from "../static/info.svg"; -import { analyticsTrack } from "../utils/analytics"; +import { analyticsTrack } from "../utils/trackers"; const GroupItem = ({ service, showPlusButton }) => { const [collapse, setCollapse] = useState(false); @@ -31,7 +31,7 @@ const GroupItem = ({ service, showPlusButton }) => { setCollapse(true); }; - const openCollapse = () => { + const openCollapse = (event) => { if (subServices.length === 0) { setLoading(true); try { @@ -48,17 +48,23 @@ const GroupItem = ({ service, showPlusButton }) => { analyticsTrack({ objectName: 'Service Expand', actionName: 'clicked', - screen: 'Home page' + screen: 'Home page', + properties:{ + serviceName: event.target.name, + } }) }; - const closeCollapse = () => { + const closeCollapse = (event) => { setCollapse(false); analyticsTrack({ objectName: 'Service Collapse', actionName: 'clicked', - screen: 'Home page' + screen: 'Home page', + properties:{ + serviceName: event.target.name, + } }) }; @@ -76,9 +82,9 @@ const GroupItem = ({ service, showPlusButton }) => { {!loading && showPlusButton && ( <> {collapse ? ( -