send ga event with user id
This commit is contained in:
parent
e503988fdc
commit
12498b1b69
2 changed files with 18 additions and 8 deletions
|
@ -24,12 +24,14 @@ const analytics: Analytics = {
|
||||||
ReactGA.pageview(path);
|
ReactGA.pageview(path);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setUser: user => {
|
setUser: userId => {
|
||||||
// Commented out because currently there is some delay before we know the user
|
if (analyticsEnabled && userId) {
|
||||||
// We should retrieve this server side so we have it immediately
|
ReactGA.event({
|
||||||
// if (analyticsEnabled && user.id) {
|
category: 'User',
|
||||||
// ReactGA.set('userId', user.id);
|
action: 'userId',
|
||||||
// }
|
value: userId,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
toggle: (enabled: boolean): void => {
|
toggle: (enabled: boolean): void => {
|
||||||
// Always collect analytics on lbry.tv
|
// Always collect analytics on lbry.tv
|
||||||
|
@ -80,7 +82,6 @@ const analytics: Analytics = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
tagFollowEvent: (tag, following, location) => {
|
tagFollowEvent: (tag, following, location) => {
|
||||||
console.log('yep');
|
|
||||||
if (analyticsEnabled) {
|
if (analyticsEnabled) {
|
||||||
ReactGA.event({
|
ReactGA.event({
|
||||||
category: 'Tag',
|
category: 'Tag',
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
// @flow
|
// @flow
|
||||||
import React, { useEffect, useRef } from 'react';
|
import React, { useEffect, useRef } from 'react';
|
||||||
|
import analytics from 'analytics';
|
||||||
import Router from 'component/router/index';
|
import Router from 'component/router/index';
|
||||||
import ModalRouter from 'modal/modalRouter';
|
import ModalRouter from 'modal/modalRouter';
|
||||||
import ReactModal from 'react-modal';
|
import ReactModal from 'react-modal';
|
||||||
|
@ -16,15 +17,17 @@ type Props = {
|
||||||
pageTitle: ?string,
|
pageTitle: ?string,
|
||||||
language: string,
|
language: string,
|
||||||
theme: string,
|
theme: string,
|
||||||
|
user: ?{ id: string },
|
||||||
fetchRewards: () => void,
|
fetchRewards: () => void,
|
||||||
fetchRewardedContent: () => void,
|
fetchRewardedContent: () => void,
|
||||||
fetchTransactions: () => void,
|
fetchTransactions: () => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
function App(props: Props) {
|
function App(props: Props) {
|
||||||
const { theme, fetchRewards, fetchRewardedContent, fetchTransactions } = props;
|
const { theme, fetchRewards, fetchRewardedContent, fetchTransactions, user } = props;
|
||||||
const appRef = useRef();
|
const appRef = useRef();
|
||||||
const isEnhancedLayout = useKonamiListener();
|
const isEnhancedLayout = useKonamiListener();
|
||||||
|
const userId = user && user.id;
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
ReactModal.setAppElement(appRef.current);
|
ReactModal.setAppElement(appRef.current);
|
||||||
|
@ -41,6 +44,12 @@ function App(props: Props) {
|
||||||
document.documentElement.setAttribute('data-mode', theme);
|
document.documentElement.setAttribute('data-mode', theme);
|
||||||
}, [theme]);
|
}, [theme]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (userId) {
|
||||||
|
analytics.setUser(userId);
|
||||||
|
}
|
||||||
|
}, [userId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div ref={appRef} onContextMenu={e => openContextMenu(e)}>
|
<div ref={appRef} onContextMenu={e => openContextMenu(e)}>
|
||||||
<Header />
|
<Header />
|
||||||
|
|
Loading…
Add table
Reference in a new issue