Skip to content

Commit

Permalink
Merge pull request #26 from betagouv/maud/start_hotjar_fix
Browse files Browse the repository at this point in the history
Start hotjar with useeffect
  • Loading branch information
jillro authored Oct 31, 2024
2 parents f775df6 + 379f42b commit 466f687
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/app/StartHotjar.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
"use client";
import Hotjar from "@hotjar/browser";
import { useEffect } from "react";

const siteId: `${number}` | undefined = process.env
.NEXT_PUBLIC_HOTJAR_SITE_ID as `${number}` | undefined;
const hotjarVersion = 6;

if (siteId) {
Hotjar.init(Number(siteId), hotjarVersion);
}

export function StartHotjar() {
useEffect(() => {
if (siteId) {
Hotjar.init(Number(siteId), hotjarVersion);
}
});

return null;
}

0 comments on commit 466f687

Please sign in to comment.