add basic analytics nag

This commit is contained in:
Sean Yesmunt 2020-02-21 15:44:58 -05:00
parent 0f57f894b2
commit c0189778d2

View file

@ -15,6 +15,7 @@ import { withRouter } from 'react-router';
import usePrevious from 'effects/use-previous'; import usePrevious from 'effects/use-previous';
import Nag from 'component/common/nag'; import Nag from 'component/common/nag';
import { rewards as REWARDS } from 'lbryinc'; import { rewards as REWARDS } from 'lbryinc';
import usePersistedState from 'effects/use-persisted-state';
// @if TARGET='web' // @if TARGET='web'
import OpenInAppLink from 'component/openInAppLink'; import OpenInAppLink from 'component/openInAppLink';
import YoutubeWelcome from 'component/youtubeWelcome'; import YoutubeWelcome from 'component/youtubeWelcome';
@ -89,6 +90,9 @@ function App(props: Props) {
const previousUserId = usePrevious(userId); const previousUserId = usePrevious(userId);
const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail); const previousHasVerifiedEmail = usePrevious(hasVerifiedEmail);
const previousRewardApproved = usePrevious(isRewardApproved); const previousRewardApproved = usePrevious(isRewardApproved);
// @if TARGET='web'
const [showAnalyticsNag, setShowAnalyticsNag] = usePersistedState('analytics-nag', true);
// @endif
const { pathname, hash, search } = props.location; const { pathname, hash, search } = props.location;
const showUpgradeButton = autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable); const showUpgradeButton = autoUpdateDownloaded || (process.platform === 'linux' && isUpgradeAvailable);
// referral claiming // referral claiming
@ -104,6 +108,12 @@ function App(props: Props) {
uri = newpath + hash; uri = newpath + hash;
} catch (e) {} } catch (e) {}
// @if TARGET='web'
function handleAnalyticsDismiss() {
setShowAnalyticsNag(false);
}
// @endif
useEffect(() => { useEffect(() => {
if (!uploadCount) return; if (!uploadCount) return;
const handleBeforeUnload = event => { const handleBeforeUnload = event => {
@ -234,6 +244,16 @@ function App(props: Props) {
<Nag message={__('An upgrade is available.')} actionText={__('Install Now')} onClick={requestDownloadUpgrade} /> <Nag message={__('An upgrade is available.')} actionText={__('Install Now')} onClick={requestDownloadUpgrade} />
)} )}
{/* @endif */} {/* @endif */}
{/* @if TARGET='web' */}
{showAnalyticsNag && (
<Nag
message={__('lbry.tv collects analytics...')}
actionText={__('Get The App')}
href="https://lbry.com/get"
onClose={handleAnalyticsDismiss}
/>
)}
{/* @endif */}
{isEnhancedLayout && <Yrbl className="yrbl--enhanced" />} {isEnhancedLayout && <Yrbl className="yrbl--enhanced" />}
</div> </div>
); );