From c72fdb81af4fb893039a672cbb2055a72abf5ddd Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 31 Oct 2022 11:27:33 -0700 Subject: [PATCH] Improved LR tracking. --- client/src/App/App.jsx | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/client/src/App/App.jsx b/client/src/App/App.jsx index ccd22f414..2d183c595 100644 --- a/client/src/App/App.jsx +++ b/client/src/App/App.jsx @@ -1,4 +1,4 @@ -import { useTreatments } from "@splitsoftware/splitio-react"; +import { useClient } from "@splitsoftware/splitio-react"; import { Button, Result } from "antd"; import LogRocket from "logrocket"; import React, { lazy, Suspense, useEffect } from "react"; @@ -51,11 +51,7 @@ export function App({ online, setOnline, }) { - const { LogRocket_Tracking } = useTreatments( - ["LogRocket_Tracking"], - {}, - bodyshop && bodyshop.imexshopid - ); + const client = useClient(); useEffect(() => { if (!navigator.onLine) { @@ -78,15 +74,15 @@ export function App({ setOnline(true); }); useEffect(() => { - if (currentUser.authorized) { - if ( - process.env.NODE_ENV === "production" && - LogRocket_Tracking.treatment === "on" - ) { + if (currentUser.authorized && bodyshop) { + console.log("Setting Attribute"); + client.setAttribute("imexshopid", bodyshop.imexshopid); + if (client.getTreatmentWithConfig("LogRocket_Tracking")) { + console.log("LR Start"); LogRocket.init("gvfvfw/bodyshopapp"); } } - }, [currentUser.authorized, LogRocket_Tracking.treatment]); + }, [bodyshop, client, currentUser.authorized]); if (currentUser.authorized === null) { return ;