From 59e994ac29942a4c19da887ffd8d852ff5b7f013 Mon Sep 17 00:00:00 2001 From: Patrick Fic <> Date: Mon, 20 Sep 2021 12:16:37 -0700 Subject: [PATCH] IO-1367 Open Replay Tracking Improvements --- client/src/App/App.container.jsx | 15 ++++++++++----- .../error-boundary/error-boundary.component.jsx | 2 ++ client/src/firebase/firebase.utils.js | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/client/src/App/App.container.jsx b/client/src/App/App.container.jsx index 8f60c0163..2f05560ef 100644 --- a/client/src/App/App.container.jsx +++ b/client/src/App/App.container.jsx @@ -11,7 +11,8 @@ import App from "./App"; import trackerGraphQL from "@openreplay/tracker-graphql"; //import trackerRedux from "@openreplay/tracker-redux"; import Tracker from "@openreplay/tracker"; -//import trackerAssist from "@openreplay/tracker-assist"; +import trackerAssist from "@openreplay/tracker-assist"; +import { getCurrentUser } from "../firebase/firebase.utils"; moment.locale("en-US"); export const tracker = new Tracker({ @@ -21,12 +22,16 @@ export const tracker = new Tracker({ ? { __DISABLE_SECURE_MODE: true } : {}), // beaconSize: 10485760, - onStart: ({ sessionID }) => console.log("ORS SESSION ", sessionID), + onStart: async ({ sessionID }) => { + const user = await getCurrentUser(); + tracker.setUserID(user.email); + console.log("ORS SESSION ", sessionID, user.email); + }, }); -// tracker.use( -// trackerAssist({ confirmText: "Technical support is about to assist you." }) -// ); // check the list of available options below +tracker.use( + trackerAssist({ confirmText: "Technical support is about to assist you." }) +); // check the list of available options below export const recordGraphQL = tracker.use(trackerGraphQL()); tracker.start(); if (process.env.NODE_ENV === "production") LogRocket.init("gvfvfw/bodyshopapp"); diff --git a/client/src/components/error-boundary/error-boundary.component.jsx b/client/src/components/error-boundary/error-boundary.component.jsx index 3f6643e1e..b317df75a 100644 --- a/client/src/components/error-boundary/error-boundary.component.jsx +++ b/client/src/components/error-boundary/error-boundary.component.jsx @@ -9,6 +9,7 @@ import { selectBodyshop, selectCurrentUser, } from "../../redux/user/user.selectors"; +import { tracker } from "../../App/App.container"; const mapStateToProps = createStructuredSelector({ currentUser: selectCurrentUser, @@ -36,6 +37,7 @@ class ErrorBoundary extends React.Component { componentDidCatch(error, info) { console.log("Exception Caught by Error Boundary.", error, info); this.setState({ ...this.state, error, info }); + tracker.event("error_boundary", error, true); } handleErrorSubmit = () => { diff --git a/client/src/firebase/firebase.utils.js b/client/src/firebase/firebase.utils.js index 67ef4ed0f..30828c71a 100644 --- a/client/src/firebase/firebase.utils.js +++ b/client/src/firebase/firebase.utils.js @@ -2,6 +2,7 @@ import { getAnalytics, logEvent } from "firebase/analytics"; import { initializeApp } from "firebase/app"; import { getAuth, updatePassword, updateProfile } from "firebase/auth"; import { getFirestore } from "firebase/firestore"; +import { tracker } from "../App/App.container"; //import { getMessaging } from "firebase/messaging"; import { store } from "../redux/store"; @@ -69,6 +70,9 @@ export const logImEXEvent = (eventName, additionalParams, stateProp = null) => { eventParams ); logEvent(analytics, eventName, eventParams); + + //Log event to OpenReplay server. + tracker.event(eventName, eventParams); }; // if (messaging) {