Created
January 31, 2021 16:42
-
-
Save jasonLaster/cb710e9a95c871b96add386cb08bab68 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/src/ui/components/App.tsx b/src/ui/components/App.tsx | |
index 31622494..e3d8d941 100644 | |
--- a/src/ui/components/App.tsx | |
+++ b/src/ui/components/App.tsx | |
@@ -12,7 +12,6 @@ import { selectors } from "ui/reducers"; | |
import { actions } from "ui/actions"; | |
import { hasLoadingParam } from "ui/utils/environment"; | |
import ResizeObserverPolyfill from "resize-observer-polyfill"; | |
-import hooks from "ui/hooks"; | |
import LogRocket from "ui/utils/logrocket"; | |
import "styles.css"; | |
@@ -54,19 +53,10 @@ function App({ theme, recordingId, modal, updateNarrowMode }: AppProps) { | |
}, [theme]); | |
useEffect(() => { | |
- const setUserInLogRocket = async () => { | |
- if (auth.user) { | |
- const userId = await hooks.fetchUserId(auth.user.sub); | |
- LogRocket.identify(auth.user.sub, { | |
- name: auth.user.name, | |
- email: auth.user.email, | |
- id: userId, | |
- }); | |
- } | |
- }; | |
- | |
setUserInBrowserPrefs(auth.user); | |
- setUserInLogRocket(); | |
+ if (auth.user) { | |
+ LogRocket.createSession(auth); | |
+ } | |
}, [auth.user]); | |
if ((!isDeployPreview() && auth.isLoading) || hasLoadingParam()) { | |
diff --git a/src/ui/utils/bootstrap/bootstrap.tsx b/src/ui/utils/bootstrap/bootstrap.tsx | |
index e36c38d2..f16b47fe 100644 | |
--- a/src/ui/utils/bootstrap/bootstrap.tsx | |
+++ b/src/ui/utils/bootstrap/bootstrap.tsx | |
@@ -18,7 +18,7 @@ import { isDevelopment, isTest } from "../environment"; | |
import { UIStore } from "ui/actions"; | |
const skipTelemetry = isTest() || isDevelopment(); | |
-function setupLogRocket() { | |
+export function setupLogRocket() { | |
if (skipTelemetry) { | |
return; | |
} | |
@@ -79,7 +79,6 @@ function ApolloWrapper({ children }: { children: ReactNode }) { | |
export function bootstrapApp(props: AppProps, context: Record<string, any>, store: UIStore) { | |
setupSentry(context); | |
- setupLogRocket(); | |
ReactDOM.render( | |
<Router> | |
diff --git a/src/ui/utils/logrocket.ts b/src/ui/utils/logrocket.ts | |
index 25b34e6e..c86bd46d 100644 | |
--- a/src/ui/utils/logrocket.ts | |
+++ b/src/ui/utils/logrocket.ts | |
@@ -4,13 +4,17 @@ import setupLogRocketReact from "logrocket-react"; | |
let setup = false; | |
export default { | |
- init: () => { | |
+ createSession: (auth: any) => { | |
setup = true; | |
setupLogRocketReact(LogRocket); | |
LogRocket.init("4sdo4i/replay"); | |
+ LogRocket.identify(auth.user.sub, { | |
+ name: auth.user.name, | |
+ email: auth.user.email, | |
+ id: auth.user.email, | |
+ }); | |
}, | |
- identify: (uuid: string, attributes: Record<string, string | number | boolean>) => | |
- setup && LogRocket.identify(uuid, attributes), | |
+ | |
getSessionURL: (callback: (sessionUrl: string) => void) => | |
setup && LogRocket.getSessionURL(callback), | |
reduxMiddleware: () => |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment