diff --git a/backend/src/v4/routes/config.js b/backend/src/v4/routes/config.js index c6d2dbdc289..ddcb64bd572 100644 --- a/backend/src/v4/routes/config.js +++ b/backend/src/v4/routes/config.js @@ -90,6 +90,8 @@ function createClientConfig(serverConfig, req) { clientConfig.apiUrls = config.apiUrls; + clientConfig.hotjar = config.hotjar; + clientConfig.C = { GET_API : C.GET_API, POST_API : C.POST_API, diff --git a/frontend/package.json b/frontend/package.json index e82023da153..039f6d3c70c 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -44,6 +44,7 @@ "@fortawesome/free-solid-svg-icons": "5.6.1", "@fortawesome/react-fontawesome": "0.1.17", "@hookform/resolvers": "2.8.5", + "@hotjar/browser": "1.0.9", "@mui/icons-material": "5.4.4", "@mui/lab": "5.0.0-alpha.71", "@mui/material": "5.12.0", diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index 378173221c8..aa3dfa68d1c 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -45,6 +45,7 @@ import rootSaga from './v4/modules/sagas'; import { NotFound } from '@/v5/ui/routes/notFound'; import { AuthenticatedRoute } from './v5/services/routing/authenticatedRoute.component'; import { initializeGoogleTagManager } from './v5/services/googleTagManager'; +import { initializeHotjar } from './v5/services/hotjar'; window.UnityUtil = UnityUtil; @@ -54,6 +55,8 @@ initializeIntl(navigator.language); initializeSocket(clientConfigService.chatConfig); +initializeHotjar(); + initializeGoogleTagManager(); // Injecting the instance of socket from v5 into v4 diff --git a/frontend/src/v4/services/clientConfig.ts b/frontend/src/v4/services/clientConfig.ts index c56a1a14598..f8785994aef 100644 --- a/frontend/src/v4/services/clientConfig.ts +++ b/frontend/src/v4/services/clientConfig.ts @@ -54,6 +54,7 @@ export class ClientConfigService { public imageSizeLimit; public imageExtensions; public apiUrls; + public hotjar; private chatHost; private chatPath; private chatReconnectionAttempts; diff --git a/frontend/src/v5/services/hotjar.ts b/frontend/src/v5/services/hotjar.ts new file mode 100644 index 00000000000..f260ac46d6d --- /dev/null +++ b/frontend/src/v5/services/hotjar.ts @@ -0,0 +1,27 @@ +/** + * Copyright (C) 2023 3D Repo Ltd + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +import Hotjar from '@hotjar/browser'; +import { clientConfigService } from '../../v4/services/clientConfig'; + +export const initializeHotjar = () => { + const { development, hotjar } = clientConfigService; + + if (!development && hotjar) { + const { siteId, version } = hotjar; + Hotjar.init(siteId, version); + } +}; diff --git a/frontend/yarn.lock b/frontend/yarn.lock index e3f7275680b..2502bdf81b8 100644 --- a/frontend/yarn.lock +++ b/frontend/yarn.lock @@ -1876,6 +1876,11 @@ resolved "https://registry.yarnpkg.com/@hookform/resolvers/-/resolvers-2.8.5.tgz#25b902bd40516c1755bc857753283de740560aff" integrity sha512-n7eFm4snsejpfZVH8q2NU7YJbsGhF61IHB0TxgK11nmg08RymEr3KscnbTAZaPd9RaXa3vUPoULgBRN2nVDtMg== +"@hotjar/browser@1.0.9": + version "1.0.9" + resolved "https://registry.yarnpkg.com/@hotjar/browser/-/browser-1.0.9.tgz#769b4ded3fa7b9557b785c107f0cd76d3f83789a" + integrity sha512-n9akDMod8BLGpYEQCrHwlYWWd63c1HlhUSXNIDfClZtKYXbUjIUOFlNZNNcUxgHTCsi4l2i+SWKsGsO0t93S8w== + "@humanwhocodes/config-array@^0.11.8": version "0.11.11" resolved "https://registry.yarnpkg.com/@humanwhocodes/config-array/-/config-array-0.11.11.tgz#88a04c570dbbc7dd943e4712429c3df09bc32844"