Skip to content

Commit e6006e3

Browse files
committed
Refactor hotjar setup
1 parent e4005d2 commit e6006e3

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,10 @@ module.exports = {
146146
// GA3 tracking id/GA4 tag id
147147
id: '' // UA-XXXXXXXXX-X | G-XXXXXXXXXX
148148
},
149+
hotjar: {
150+
id: '',
151+
snippetVersion : 6
152+
},
149153
themeConfig: {
150154
default: 'light',
151155
@@ -240,14 +244,15 @@ Besides tracking visitors, ezFolio will track click events on projects and blog
240244

241245
### Hotjar
242246

243-
ezProfile supports hotjar. If you do not want to use Hotjar, comment out the id property.
247+
ezProfile supports hotjar. If you do not want to use Hotjar, keep the <code>id</code> empty.
244248

245249
```js
246250
// config.js
247251
module.exports = {
248252
// ...
249253
hotjar: {
250-
//id:
254+
id: '',
255+
snippetVersion : 6
251256
},
252257
}
253258
```

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ module.exports = {
8787
id: 'G-WLLB5E14M6' // Please remove this and use your own tag id
8888
},
8989
hotjar: {
90-
id: 1234567, // Please remove this and use your own id
91-
snippetVersion : 6 // hotjar snippet version, defaults to 6
90+
id: '2617601', // Please remove this and use your own id
91+
snippetVersion : 6
9292
},
9393
themeConfig: {
9494
default: 'light',

src/helpers/setupHotjar.js

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/helpers/utils.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import config from "../config";
22
import colors from './colors.json';
3+
import { hotjar } from 'react-hotjar';
34

45
export const getInitialTheme = () => {
56
if (config.themeConfig.disableSwitch) {
@@ -67,4 +68,12 @@ export const isThemeDarkish = (theme) => {
6768
} else {
6869
return false;
6970
}
71+
}
72+
73+
export const setupHotjar = () => {
74+
if (config.hotjar?.id) {
75+
let snippetVersion = config.hotjar?.snippetVersion ? config.hotjar?.snippetVersion : 6;
76+
77+
hotjar.initialize(config.hotjar.id, snippetVersion);
78+
}
7079
}

src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import reportWebVitals from './reportWebVitals';
66
import { HelmetProvider } from 'react-helmet-async';
77
import { ThemeProvider } from './contexts/ThemeContext';
88
import { LoadingProvider } from './contexts/LoadingContext';
9-
import { setupHotjar } from './helpers/setupHotjar';
9+
import { setupHotjar } from './helpers/utils';
1010

1111
ReactDOM.render(
1212
<React.StrictMode>

0 commit comments

Comments
 (0)