Random fixes #2729

Merged
neb-b merged 12 commits from fixes into master 2019-08-15 05:11:48 +02:00
5 changed files with 64 additions and 11 deletions
Showing only changes of commit e589a87298 - Show all commits

View file

@ -126,7 +126,7 @@
"json-loader": "^0.5.4", "json-loader": "^0.5.4",
"lbry-format": "https://github.com/lbryio/lbry-format.git", "lbry-format": "https://github.com/lbryio/lbry-format.git",
"lbry-redux": "lbryio/lbry-redux#4e093983eaf3d9e7513119657d731b808ead74a6", "lbry-redux": "lbryio/lbry-redux#4e093983eaf3d9e7513119657d731b808ead74a6",
"lbryinc": "lbryio/lbryinc#a93596c51c8fb0a226cb84df04c26a6bb60a45fb", "lbryinc": "lbryio/lbryinc#1ce266b3c52654190b955e9c869b8e302aa5c585",
"lint-staged": "^7.0.2", "lint-staged": "^7.0.2",
"localforage": "^1.7.1", "localforage": "^1.7.1",
"lodash-es": "^4.17.14", "lodash-es": "^4.17.14",

View file

@ -3,6 +3,7 @@ import { Lbryio } from 'lbryinc';
import ReactGA from 'react-ga'; import ReactGA from 'react-ga';
import { history } from './store'; import { history } from './store';
// @if TARGET='app' // @if TARGET='app'
import Native from 'native';
import ElectronCookies from '@exponent/electron-cookies'; import ElectronCookies from '@exponent/electron-cookies';
// @endif // @endif
@ -15,6 +16,9 @@ type Analytics = {
apiLogView: (string, string, string, ?number, ?() => void) => void, apiLogView: (string, string, string, ?number, ?() => void) => void,
apiLogPublish: () => void, apiLogPublish: () => void,
tagFollowEvent: (string, boolean, string) => void, tagFollowEvent: (string, boolean, string) => void,
emailProvidedEvent: () => void,
emailVerifiedEvent: () => void,
rewardEligibleEvent: () => void,
}; };
let analyticsEnabled: boolean = true; let analyticsEnabled: boolean = true;
@ -26,11 +30,18 @@ const analytics: Analytics = {
}, },
setUser: userId => { setUser: userId => {
if (analyticsEnabled && userId) { if (analyticsEnabled && userId) {
ReactGA.event({ ReactGA.set({
category: 'User', userId,
action: 'userId',
value: userId,
}); });
// @if TARGET='app'
Native.getAppVersionInfo().then(({ localVersion }) => {
ReactGA.event({
category: 'Desktop-Version',
action: localVersion,
});
});
// @endif
} }
}, },
toggle: (enabled: boolean): void => { toggle: (enabled: boolean): void => {
@ -92,6 +103,30 @@ const analytics: Analytics = {
}); });
} }
}, },
emailProvidedEvent: () => {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category: 'Engagement',
action: 'Email-Provided',
});
}
},
emailVerifiedEvent: () => {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category: 'Engagement',
action: 'Email-Verified',
});
}
},
rewardEligibleEvent: () => {
if (analyticsEnabled && isProduction) {
ReactGA.event({
category: 'Engagement',
action: 'Reward-Eligible',
});
}
},
}; };
// Initialize google analytics // Initialize google analytics

View file

@ -12,6 +12,7 @@ import useKonamiListener from 'util/enhanced-layout';
import Yrbl from 'component/yrbl'; import Yrbl from 'component/yrbl';
import FileViewer from 'component/fileViewer'; import FileViewer from 'component/fileViewer';
import { withRouter } from 'react-router'; import { withRouter } from 'react-router';
import usePrevious from 'util/use-previous';
export const MAIN_WRAPPER_CLASS = 'main-wrapper'; export const MAIN_WRAPPER_CLASS = 'main-wrapper';
@ -21,7 +22,7 @@ type Props = {
language: string, language: string,
theme: string, theme: string,
accessToken: ?string, accessToken: ?string,
user: ?{ id: string, has_verified_email: boolean }, user: ?{ id: string, has_verified_email: boolean, is_reward_approved: boolean },
location: { pathname: string }, location: { pathname: string },
fetchRewards: () => void, fetchRewards: () => void,
fetchRewardedContent: () => void, fetchRewardedContent: () => void,
@ -35,7 +36,10 @@ function App(props: Props) {
const isEnhancedLayout = useKonamiListener(); const isEnhancedLayout = useKonamiListener();
const userId = user && user.id; const userId = user && user.id;
const hasVerifiedEmail = user && user.has_verified_email; const hasVerifiedEmail = user && user.has_verified_email;
const isRewardApproved = user && user.is_reward_approved;
const previousUserId = usePrevious(userId);
const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail);
const previousRewardApproved = usePrevious(isRewardApproved);
const { pathname } = props.location; const { pathname } = props.location;
const urlParts = pathname.split('/'); const urlParts = pathname.split('/');
const claimName = urlParts[1]; const claimName = urlParts[1];
@ -65,10 +69,22 @@ function App(props: Props) {
}, [theme]); }, [theme]);
useEffect(() => { useEffect(() => {
if (userId) { if (previousUserId === undefined && userId) {
analytics.setUser(userId); analytics.setUser(userId);
} }
}, [userId]); }, [previousUserId, userId]);
useEffect(() => {
if (previousHasVerifiedEmail !== undefined && hasVerifiedEmail) {
analytics.emailVerifiedEvent();
}
}, [previousHasVerifiedEmail, hasVerifiedEmail]);
useEffect(() => {
if (previousRewardApproved !== undefined && isRewardApproved) {
analytics.rewardEligibleEvent();
}
}, [previousRewardApproved, isRewardApproved]);
// @if TARGET='web' // @if TARGET='web'
useEffect(() => { useEffect(() => {

View file

@ -3,6 +3,7 @@ import * as React from 'react';
import { FormField, Form } from 'component/common/form'; import { FormField, Form } from 'component/common/form';
import Button from 'component/button'; import Button from 'component/button';
import { Lbryio } from 'lbryinc'; import { Lbryio } from 'lbryinc';
import analytics from 'analytics';
type Props = { type Props = {
cancelButton: React.Node, cancelButton: React.Node,
@ -37,6 +38,7 @@ class UserEmailNew extends React.PureComponent<Props, State> {
const { email } = this.state; const { email } = this.state;
const { addUserEmail } = this.props; const { addUserEmail } = this.props;
addUserEmail(email); addUserEmail(email);
analytics.emailProvidedEvent();
// @if TARGET='web' // @if TARGET='web'
Lbryio.call('user_tag', 'edit', { add: 'lbrytv' }); Lbryio.call('user_tag', 'edit', { add: 'lbrytv' });

View file

@ -6771,9 +6771,9 @@ lbry-redux@lbryio/lbry-redux#4e093983eaf3d9e7513119657d731b808ead74a6:
reselect "^3.0.0" reselect "^3.0.0"
uuid "^3.3.2" uuid "^3.3.2"
lbryinc@lbryio/lbryinc#a93596c51c8fb0a226cb84df04c26a6bb60a45fb: lbryinc@lbryio/lbryinc#1ce266b3c52654190b955e9c869b8e302aa5c585:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/a93596c51c8fb0a226cb84df04c26a6bb60a45fb" resolved "https://codeload.github.com/lbryio/lbryinc/tar.gz/1ce266b3c52654190b955e9c869b8e302aa5c585"
dependencies: dependencies:
reselect "^3.0.0" reselect "^3.0.0"