Refactor hotjar setup

This commit is contained in:
MD. Ariful Alam
2021-09-23 22:34:44 +06:00
parent e4005d288d
commit e6006e387a
6 changed files with 19 additions and 16 deletions

View File

@@ -87,8 +87,8 @@ module.exports = {
id: 'G-WLLB5E14M6' // Please remove this and use your own tag id
},
hotjar: {
id: 1234567, // Please remove this and use your own id
snippetVersion : 6 // hotjar snippet version, defaults to 6
id: '2617601', // Please remove this and use your own id
snippetVersion : 6
},
themeConfig: {
default: 'light',

View File

@@ -1,10 +0,0 @@
import { hotjar } from 'react-hotjar';
import config from "./../config";
export function setupHotjar() {
if (config.hotjar?.id) {
let snippetVersion = config.hotjar?.snippetVersion ? config.hotjar?.snippetVersion : 6;
hotjar.initialize(config.hotjar.id, snippetVersion);
}
}

View File

@@ -1,5 +1,6 @@
import config from "../config";
import colors from './colors.json';
import { hotjar } from 'react-hotjar';
export const getInitialTheme = () => {
if (config.themeConfig.disableSwitch) {
@@ -67,4 +68,12 @@ export const isThemeDarkish = (theme) => {
} else {
return false;
}
}
export const setupHotjar = () => {
if (config.hotjar?.id) {
let snippetVersion = config.hotjar?.snippetVersion ? config.hotjar?.snippetVersion : 6;
hotjar.initialize(config.hotjar.id, snippetVersion);
}
}

View File

@@ -6,7 +6,7 @@ import reportWebVitals from './reportWebVitals';
import { HelmetProvider } from 'react-helmet-async';
import { ThemeProvider } from './contexts/ThemeContext';
import { LoadingProvider } from './contexts/LoadingContext';
import { setupHotjar } from './helpers/setupHotjar';
import { setupHotjar } from './helpers/utils';
ReactDOM.render(
<React.StrictMode>