From 379f42b3f7d813b76043902f9a329f4d929cbaa3 Mon Sep 17 00:00:00 2001 From: Maud Royer Date: Thu, 31 Oct 2024 14:02:47 +0100 Subject: [PATCH] fix: start hotjar with useeffect Signed-off-by: Maud Royer --- src/app/StartHotjar.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/app/StartHotjar.tsx b/src/app/StartHotjar.tsx index 15b162a..7d45b65 100644 --- a/src/app/StartHotjar.tsx +++ b/src/app/StartHotjar.tsx @@ -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; }