Merge pull request #3818 from lbryio/feat-sendLibryincTags

Feat send libryinc tags
This commit is contained in:
jessopb 2020-03-12 10:35:23 -04:00 committed by GitHub
commit 6e6c2eb8c1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 77 additions and 45 deletions

View file

@ -131,7 +131,7 @@
"imagesloaded": "^4.1.4", "imagesloaded": "^4.1.4",
"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#9009708fff61b0a7b614597ba990629421711bf4", "lbry-redux": "lbryio/lbry-redux#1dd2d4cff5b86dc9169d761198b9257227e9c11d",
"lbryinc": "lbryio/lbryinc#275f35b31ec614e2b89689f860fe19e645deee68", "lbryinc": "lbryio/lbryinc#275f35b31ec614e2b89689f860fe19e645deee68",
"lint-staged": "^7.0.2", "lint-staged": "^7.0.2",
"localforage": "^1.7.1", "localforage": "^1.7.1",

View file

@ -1027,5 +1027,11 @@
"Your video may not be the best format. Use MP4s in H264/AAC format and a friendly bitrate (720p) for more reliable streaming.": "Your video may not be the best format. Use MP4s in H264/AAC format and a friendly bitrate (720p) for more reliable streaming.", "Your video may not be the best format. Use MP4s in H264/AAC format and a friendly bitrate (720p) for more reliable streaming.": "Your video may not be the best format. Use MP4s in H264/AAC format and a friendly bitrate (720p) for more reliable streaming.",
"Your video has a bitrate over 6 mbps. We suggest transcoding to provide viewers the best experience.": "Your video has a bitrate over 6 mbps. We suggest transcoding to provide viewers the best experience.", "Your video has a bitrate over 6 mbps. We suggest transcoding to provide viewers the best experience.": "Your video has a bitrate over 6 mbps. We suggest transcoding to provide viewers the best experience.",
"Your video has a bitrate over 5 mbps. We suggest transcoding to provide viewers the best experience.": "Your video has a bitrate over 5 mbps. We suggest transcoding to provide viewers the best experience.", "Your video has a bitrate over 5 mbps. We suggest transcoding to provide viewers the best experience.": "Your video has a bitrate over 5 mbps. We suggest transcoding to provide viewers the best experience.",
"Almost there": "Almost there" "Almost there": "Almost there",
} "Comment Acknowledgement": "Comment Acknowledgement",
"A few things to know before making your comment:": "A few things to know before making your comment:",
"Commenting is in alpha. During the alpha, all comments are sent to a LBRY, Inc. server, not the LBRY network itself.": "Commenting is in alpha. During the alpha, all comments are sent to a LBRY, Inc. server, not the LBRY network itself.",
"Deleting or editing comments is not currently possible. Please be mindful of this when posting.": "Deleting or editing comments is not currently possible. Please be mindful of this when posting.",
"When the alpha ends, we will attempt to transition comments, but do not promise to do so.": "When the alpha ends, we will attempt to transition comments, but do not promise to do so.",
"More Channels": "More Channels"
}

View file

@ -34,6 +34,7 @@ type Analytics = {
toggleThirdParty: (boolean, ?boolean) => void, toggleThirdParty: (boolean, ?boolean) => void,
apiLogView: (string, string, string, ?number, ?() => void) => Promise<any>, apiLogView: (string, string, string, ?number, ?() => void) => Promise<any>,
apiLogPublish: (ChannelClaim | StreamClaim) => void, apiLogPublish: (ChannelClaim | StreamClaim) => void,
apiSyncTags: ({}) => void,
tagFollowEvent: (string, boolean, string) => void, tagFollowEvent: (string, boolean, string) => void,
videoStartEvent: (string, number) => void, videoStartEvent: (string, number) => void,
videoBufferEvent: (string, number) => void, videoBufferEvent: (string, number) => void,
@ -165,6 +166,12 @@ const analytics: Analytics = {
} }
}, },
apiSyncTags: params => {
if (internalAnalyticsEnabled && isProduction) {
Lbryio.call('content_tags', 'sync', params);
}
},
apiSearchFeedback: (query, vote) => { apiSearchFeedback: (query, vote) => {
if (isProduction) { if (isProduction) {
// We don't need to worry about analytics enabled here because users manually click on the button to provide feedback // We don't need to worry about analytics enabled here because users manually click on the button to provide feedback

View file

@ -19,6 +19,7 @@ import {
doSignIn, doSignIn,
doSyncWithPreferences, doSyncWithPreferences,
doGetAndPopulatePreferences, doGetAndPopulatePreferences,
doAnalyticsTagSync,
} from 'redux/actions/app'; } from 'redux/actions/app';
import App from './view'; import App from './view';
@ -37,6 +38,7 @@ const select = state => ({
}); });
const perform = dispatch => ({ const perform = dispatch => ({
analyticsTagSync: () => dispatch(doAnalyticsTagSync()),
fetchTransactions: (page, pageSize) => dispatch(doFetchTransactions(page, pageSize)), fetchTransactions: (page, pageSize) => dispatch(doFetchTransactions(page, pageSize)),
fetchAccessToken: () => dispatch(doFetchAccessToken()), fetchAccessToken: () => dispatch(doFetchAccessToken()),
fetchChannelListMine: () => dispatch(doFetchChannelListMine()), fetchChannelListMine: () => dispatch(doFetchChannelListMine()),

View file

@ -66,6 +66,7 @@ type Props = {
syncError: ?string, syncError: ?string,
rewards: Array<Reward>, rewards: Array<Reward>,
setReferrer: (string, boolean) => void, setReferrer: (string, boolean) => void,
analyticsTagSync: () => void,
}; };
function App(props: Props) { function App(props: Props) {
@ -90,6 +91,7 @@ function App(props: Props) {
updatePreferences, updatePreferences,
rewards, rewards,
setReferrer, setReferrer,
analyticsTagSync,
} = props; } = props;
const appRef = useRef(); const appRef = useRef();
@ -159,6 +161,7 @@ function App(props: Props) {
} else if (referredRewardAvailable && sanitizedReferrerParam) { } else if (referredRewardAvailable && sanitizedReferrerParam) {
setReferrer(sanitizedReferrerParam, false); setReferrer(sanitizedReferrerParam, false);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [sanitizedReferrerParam, isRewardApproved, referredRewardAvailable]); }, [sanitizedReferrerParam, isRewardApproved, referredRewardAvailable]);
useEffect(() => { useEffect(() => {
@ -182,6 +185,7 @@ function App(props: Props) {
if (!languages.includes(language)) { if (!languages.includes(language)) {
setLanguage(language); setLanguage(language);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [language, languages]); }, [language, languages]);
useEffect(() => { useEffect(() => {
@ -216,13 +220,14 @@ function App(props: Props) {
// @if TARGET='app' // @if TARGET='app'
useEffect(() => { useEffect(() => {
updatePreferences(); updatePreferences();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
// @endif // @endif
useEffect(() => { useEffect(() => {
if (hasVerifiedEmail && syncEnabled) { if (hasVerifiedEmail && syncEnabled) {
checkSync(); checkSync();
analyticsTagSync();
let syncInterval = setInterval(() => { let syncInterval = setInterval(() => {
checkSync(); checkSync();
}, SYNC_INTERVAL); }, SYNC_INTERVAL);
@ -231,12 +236,14 @@ function App(props: Props) {
clearInterval(syncInterval); clearInterval(syncInterval);
}; };
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [hasVerifiedEmail, syncEnabled, checkSync]); }, [hasVerifiedEmail, syncEnabled, checkSync]);
useEffect(() => { useEffect(() => {
if (syncError) { if (syncError) {
history.push(`/$/${PAGES.AUTH}?redirect=${pathname}`); history.push(`/$/${PAGES.AUTH}?redirect=${pathname}`);
} }
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [syncError, pathname]); }, [syncError, pathname]);
// @if TARGET='web' // @if TARGET='web'

View file

@ -3,10 +3,10 @@ import {
doClaimSearch, doClaimSearch,
selectClaimSearchByQuery, selectClaimSearchByQuery,
selectFetchingClaimSearch, selectFetchingClaimSearch,
doToggleTagFollow,
selectBlockedChannels, selectBlockedChannels,
SETTINGS, SETTINGS,
} from 'lbry-redux'; } from 'lbry-redux';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import ClaimListDiscover from './view'; import ClaimListDiscover from './view';
@ -20,7 +20,7 @@ const select = state => ({
const perform = { const perform = {
doClaimSearch, doClaimSearch,
doToggleTagFollow, doToggleTagFollowDesktop,
}; };
export default connect( export default connect(

View file

@ -20,7 +20,7 @@ type Props = {
doClaimSearch: ({}) => void, doClaimSearch: ({}) => void,
loading: boolean, loading: boolean,
personalView: boolean, personalView: boolean,
doToggleTagFollow: string => void, doToggleTagFollowDesktop: string => void,
meta?: Node, meta?: Node,
showNsfw: boolean, showNsfw: boolean,
showReposts: boolean, showReposts: boolean,
@ -101,12 +101,12 @@ function ClaimListDiscover(props: Props) {
const durationParam = urlParams.get(CS.DURATION_KEY) || null; const durationParam = urlParams.get(CS.DURATION_KEY) || null;
const showDuration = !(claimType && claimType === CS.CLAIM_CHANNEL); const showDuration = !(claimType && claimType === CS.CLAIM_CHANNEL);
const showContentType = !(claimType || streamType);
const isFiltered = () => const isFiltered = () =>
Boolean(urlParams.get(CS.FRESH_KEY) || urlParams.get(CS.CONTENT_KEY) || urlParams.get(CS.DURATION_KEY)); Boolean(urlParams.get(CS.FRESH_KEY) || urlParams.get(CS.CONTENT_KEY) || urlParams.get(CS.DURATION_KEY));
useEffect(() => { useEffect(() => {
if (isFiltered()) setExpanded(true); if (isFiltered()) setExpanded(true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []); }, []);
const options: { const options: {

View file

@ -3,10 +3,10 @@ import {
doClaimSearch, doClaimSearch,
selectClaimSearchByQuery, selectClaimSearchByQuery,
selectFetchingClaimSearch, selectFetchingClaimSearch,
doToggleTagFollow,
selectBlockedChannels, selectBlockedChannels,
SETTINGS, SETTINGS,
} from 'lbry-redux'; } from 'lbry-redux';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import ClaimListDiscover from './view'; import ClaimListDiscover from './view';
@ -20,7 +20,7 @@ const select = state => ({
const perform = { const perform = {
doClaimSearch, doClaimSearch,
doToggleTagFollow, doToggleTagFollowDesktop,
}; };
export default connect( export default connect(

View file

@ -1,12 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import { selectUnfollowedTags, selectFollowedTags, doReplaceTags, doAddTag, doDeleteTag } from 'lbry-redux';
selectUnfollowedTags, import { doToggleTagFollowDesktop } from 'redux/actions/tags';
selectFollowedTags,
doReplaceTags,
doToggleTagFollow,
doAddTag,
doDeleteTag,
} from 'lbry-redux';
import DiscoveryFirstRun from './view'; import DiscoveryFirstRun from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -17,7 +11,7 @@ const select = (state, props) => ({
export default connect( export default connect(
select, select,
{ {
doToggleTagFollow, doToggleTagFollowDesktop,
doAddTag, doAddTag,
doDeleteTag, doDeleteTag,
doReplaceTags, doReplaceTags,

View file

@ -9,7 +9,7 @@ type Props = {
tagsPassedIn: Array<Tag>, tagsPassedIn: Array<Tag>,
unfollowedTags: Array<Tag>, unfollowedTags: Array<Tag>,
followedTags: Array<Tag>, followedTags: Array<Tag>,
doToggleTagFollow: string => void, doToggleTagFollowDesktop: string => void,
doAddTag: string => void, doAddTag: string => void,
onSelect?: Tag => void, onSelect?: Tag => void,
suggestMature?: boolean, suggestMature?: boolean,
@ -33,7 +33,7 @@ export default function TagsSearch(props: Props) {
tagsPassedIn = [], tagsPassedIn = [],
unfollowedTags = [], unfollowedTags = [],
followedTags = [], followedTags = [],
doToggleTagFollow, doToggleTagFollowDesktop,
doAddTag, doAddTag,
onSelect, onSelect,
onRemove, onRemove,
@ -99,7 +99,7 @@ export default function TagsSearch(props: Props) {
} }
if (!followedTags.some(({ name }) => name === tag)) { if (!followedTags.some(({ name }) => name === tag)) {
doToggleTagFollow(tag); doToggleTagFollowDesktop(tag);
} }
}); });
} }
@ -109,7 +109,7 @@ export default function TagsSearch(props: Props) {
if (onSelect) { if (onSelect) {
onSelect([{ name: tag }]); onSelect([{ name: tag }]);
} else { } else {
doToggleTagFollow(tag); doToggleTagFollowDesktop(tag);
} }
} }
return ( return (
@ -174,8 +174,6 @@ export default function TagsSearch(props: Props) {
onClick={() => handleTagClick(tag)} onClick={() => handleTagClick(tag)}
/> />
))} ))}
{!suggestedTags.length && <p className="empty tags__empty-message">{__('No matching tags')}</p>}
</ul> </ul>
</section> </section>
</Form> </Form>

View file

@ -1,12 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import { selectUnfollowedTags, selectFollowedTags, doReplaceTags, doAddTag, doDeleteTag } from 'lbry-redux';
selectUnfollowedTags, import { doToggleTagFollowDesktop } from 'redux/actions/tags';
selectFollowedTags,
doReplaceTags,
doToggleTagFollow,
doAddTag,
doDeleteTag,
} from 'lbry-redux';
import DiscoveryFirstRun from './view'; import DiscoveryFirstRun from './view';
const select = (state, props) => ({ const select = (state, props) => ({
@ -17,7 +11,7 @@ const select = (state, props) => ({
export default connect( export default connect(
select, select,
{ {
doToggleTagFollow, doToggleTagFollowDesktop,
doAddTag, doAddTag,
doDeleteTag, doDeleteTag,
doReplaceTags, doReplaceTags,

View file

@ -11,7 +11,7 @@ import Card from 'component/common/card';
type Props = { type Props = {
showClose?: boolean, showClose?: boolean,
followedTags: Array<Tag>, followedTags: Array<Tag>,
doToggleTagFollow?: string => void, doToggleTagFollowDesktop?: string => void,
suggestMature: boolean, suggestMature: boolean,
// Overrides // Overrides
// The default component is for following tags // The default component is for following tags
@ -34,7 +34,7 @@ export default function TagsSelect(props: Props) {
const { const {
showClose, showClose,
followedTags, followedTags,
doToggleTagFollow = null, doToggleTagFollowDesktop = null,
title, title,
help, help,
tagsChosen, tagsChosen,
@ -59,8 +59,8 @@ export default function TagsSelect(props: Props) {
function handleTagClick(tag) { function handleTagClick(tag) {
if (onRemove) { if (onRemove) {
onRemove(tag); onRemove(tag);
} else if (doToggleTagFollow) { } else if (doToggleTagFollowDesktop) {
doToggleTagFollow(tag.name); doToggleTagFollowDesktop(tag.name);
const wasFollowing = followedTags.map(tag => tag.name).includes(tag.name); const wasFollowing = followedTags.map(tag => tag.name).includes(tag.name);
const nowFollowing = !wasFollowing; const nowFollowing = !wasFollowing;

View file

@ -1,5 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { selectFollowedTags, doToggleTagFollow } from 'lbry-redux'; import { selectFollowedTags } from 'lbry-redux';
import { doToggleTagFollowDesktop } from 'redux/actions/tags';
import Tags from './view'; import Tags from './view';
const select = state => ({ const select = state => ({
@ -9,6 +10,6 @@ const select = state => ({
export default connect( export default connect(
select, select,
{ {
doToggleTagFollow, doToggleTagFollowDesktop,
} }
)(Tags); )(Tags);

View file

@ -12,14 +12,14 @@ import Icon from 'component/common/icon';
type Props = { type Props = {
location: { search: string }, location: { search: string },
followedTags: Array<Tag>, followedTags: Array<Tag>,
doToggleTagFollow: string => void, doToggleTagFollowDesktop: string => void,
}; };
function TagsPage(props: Props) { function TagsPage(props: Props) {
const { const {
location: { search }, location: { search },
followedTags, followedTags,
doToggleTagFollow, doToggleTagFollowDesktop,
} = props; } = props;
const buttonRef = useRef(); const buttonRef = useRef();
const isHovering = useHover(buttonRef); const isHovering = useHover(buttonRef);
@ -39,7 +39,7 @@ function TagsPage(props: Props) {
} }
function handleFollowClick() { function handleFollowClick() {
doToggleTagFollow(tag); doToggleTagFollowDesktop(tag);
const nowFollowing = !isFollowing; const nowFollowing = !isFollowing;
analytics.tagFollowEvent(tag, nowFollowing, 'tag-page'); analytics.tagFollowEvent(tag, nowFollowing, 'tag-page');

View file

@ -19,6 +19,7 @@ import {
doPreferenceGet, doPreferenceGet,
doToast, doToast,
doClearSupport, doClearSupport,
selectFollowedTagsList,
// SHARED_PREFERENCES, // SHARED_PREFERENCES,
} from 'lbry-redux'; } from 'lbry-redux';
import Native from 'native'; import Native from 'native';
@ -435,6 +436,15 @@ export function doAnalyticsView(uri, timeToStart) {
}; };
} }
export function doAnalyticsTagSync() {
return (dispatch, getState) => {
const state = getState();
const tags = selectFollowedTagsList(state);
const stringOfTags = tags.join(',');
analytics.apiSyncTags({ content_tags: stringOfTags });
};
}
export function doSignIn() { export function doSignIn() {
return (dispatch, getState) => { return (dispatch, getState) => {
// @if TARGET='web' // @if TARGET='web'

13
ui/redux/actions/tags.js Normal file
View file

@ -0,0 +1,13 @@
// @flow
import { doToggleTagFollow, selectFollowedTagsList } from 'lbry-redux';
import analytics from 'analytics';
export const doToggleTagFollowDesktop = (name: string) => (dispatch: Dispatch, getState: GetState) => {
dispatch(doToggleTagFollow(name));
const state = getState();
const tags = selectFollowedTagsList(state);
const stringOfTags = tags.join(',');
analytics.apiSyncTags({ content_tags: stringOfTags });
};

View file

@ -7316,9 +7316,9 @@ lazy-val@^1.0.4:
yargs "^13.2.2" yargs "^13.2.2"
zstd-codec "^0.1.1" zstd-codec "^0.1.1"
lbry-redux@lbryio/lbry-redux#9009708fff61b0a7b614597ba990629421711bf4: lbry-redux@lbryio/lbry-redux#1dd2d4cff5b86dc9169d761198b9257227e9c11d:
version "0.0.1" version "0.0.1"
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/9009708fff61b0a7b614597ba990629421711bf4" resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/1dd2d4cff5b86dc9169d761198b9257227e9c11d"
dependencies: dependencies:
proxy-polyfill "0.1.6" proxy-polyfill "0.1.6"
reselect "^3.0.0" reselect "^3.0.0"