diff --git a/.flowconfig b/.flowconfig index 1eaa4969e..c2bb89028 100644 --- a/.flowconfig +++ b/.flowconfig @@ -21,5 +21,6 @@ module.name_mapper='^rewards\(.*\)$' -> '/src/renderer/rewards\1' module.name_mapper='^modal\(.*\)$' -> '/src/renderer/modal\1' module.name_mapper='^app\(.*\)$' -> '/src/renderer/app\1' module.name_mapper='^native\(.*\)$' -> '/src/renderer/native\1' +module.name_mapper='^analytics\(.*\)$' -> '/src/renderer/analytics\1' [strict] diff --git a/src/renderer/component/fileDownloadLink/index.js b/src/renderer/component/fileDownloadLink/index.js index 22f4f0a3f..23ed6b3f7 100644 --- a/src/renderer/component/fileDownloadLink/index.js +++ b/src/renderer/component/fileDownloadLink/index.js @@ -4,6 +4,7 @@ import { makeSelectDownloadingForUri, makeSelectLoadingForUri, makeSelectCostInfoForUri, + makeSelectClaimForUri, } from 'lbry-redux'; import { doOpenFileInShell } from 'redux/actions/file'; import { doPurchaseUri, doStartDownload } from 'redux/actions/content'; @@ -16,6 +17,7 @@ const select = (state, props) => ({ downloading: makeSelectDownloadingForUri(props.uri)(state), costInfo: makeSelectCostInfoForUri(props.uri)(state), loading: makeSelectLoadingForUri(props.uri)(state), + claim: makeSelectClaimForUri(props.uri)(state), }); const perform = dispatch => ({ @@ -25,4 +27,7 @@ const perform = dispatch => ({ doPause: () => dispatch(doPause()), }); -export default connect(select, perform)(FileDownloadLink); +export default connect( + select, + perform +)(FileDownloadLink); diff --git a/src/renderer/component/fileDownloadLink/view.jsx b/src/renderer/component/fileDownloadLink/view.jsx index ccc0f2ba7..bcb352eb2 100644 --- a/src/renderer/component/fileDownloadLink/view.jsx +++ b/src/renderer/component/fileDownloadLink/view.jsx @@ -3,8 +3,11 @@ import React from 'react'; import Button from 'component/button'; import * as icons from 'constants/icons'; import ToolTip from 'component/common/tooltip'; +import analytics from 'analytics'; +import type { Claim } from 'types/claim'; type Props = { + claim: Claim, uri: string, downloading: boolean, fileInfo: ?{ @@ -48,6 +51,7 @@ class FileDownloadLink extends React.PureComponent { costInfo, loading, doPause, + claim, } = this.props; const openFile = () => { @@ -80,6 +84,12 @@ class FileDownloadLink extends React.PureComponent { iconColor="green" onClick={() => { purchaseUri(uri); + + const { name, claim_id: claimId, nout, txid } = claim; + // // ideally outpoint would exist inside of claim information + // // we can use it after https://github.com/lbryio/lbry/issues/1306 is addressed + const outpoint = `${txid}:${nout}`; + analytics.apiLogView(`${name}#${claimId}`, outpoint, claimId); }} /> diff --git a/src/renderer/component/fileViewer/internal/player.jsx b/src/renderer/component/fileViewer/internal/player.jsx index 8d3bf07b9..d76d0bcaf 100644 --- a/src/renderer/component/fileViewer/internal/player.jsx +++ b/src/renderer/component/fileViewer/internal/player.jsx @@ -46,6 +46,7 @@ class MediaPlayer extends React.PureComponent { const loadedMetadata = () => { this.setState({ hasMetadata: true, startedPlaying: true }); + if (startedPlayingCb) { startedPlayingCb(); } diff --git a/src/renderer/component/fileViewer/view.jsx b/src/renderer/component/fileViewer/view.jsx index 57cab3463..aed32f07c 100644 --- a/src/renderer/component/fileViewer/view.jsx +++ b/src/renderer/component/fileViewer/view.jsx @@ -146,7 +146,12 @@ class FileViewer extends React.PureComponent { } playContent() { - const { play, uri } = this.props; + const { play, uri, fileInfo, isDownloading, isLoading } = this.props; + + if (fileInfo || isDownloading || isLoading) { + // User may have pressed download before clicking play + this.startedPlayingCb = null; + } if (this.startedPlayingCb) { this.startTime = Date.now();