From da19ff2471c68f4980c07261804582170a5fc316 Mon Sep 17 00:00:00 2001 From: jessop Date: Fri, 11 Oct 2019 21:55:54 -0400 Subject: [PATCH] triggers api publish new on streams and channels --- src/ui/analytics.js | 25 +++++++++++++++++++++++++ src/ui/component/selectChannel/view.jsx | 6 ++++-- src/ui/redux/actions/publish.js | 5 +++-- static/app-strings.json | 2 +- 4 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/ui/analytics.js b/src/ui/analytics.js index 72c9c1a84..8d681229f 100644 --- a/src/ui/analytics.js +++ b/src/ui/analytics.js @@ -16,6 +16,7 @@ type Analytics = { toggle: (boolean, ?boolean) => void, apiLogView: (string, string, string, ?number, ?() => void) => Promise, apiLogPublish: () => void, + apiPublishNew: (ChannelClaim | StreamClaim) => void, tagFollowEvent: (string, boolean, string) => void, emailProvidedEvent: () => void, emailVerifiedEvent: () => void, @@ -24,6 +25,13 @@ type Analytics = { readyEvent: number => void, }; +type PublishNewParams = { + uri?: string, + claim_id?: string, + outpoint?: string, + channel_claim_id?: string, +}; + let analyticsEnabled: boolean = true; const analytics: Analytics = { pageView: path => { @@ -85,6 +93,23 @@ const analytics: Analytics = { Lbryio.call('event', 'publish'); } }, + + apiPublishNew: (claimResult: ChannelClaim | StreamClaim) => { + if (analyticsEnabled && isProduction) { + const { permanent_url: uri, claim_id: claimId, txid, nout, signing_channel: signingChannel } = claimResult; + let channelClaimId; + if (signingChannel) { + channelClaimId = signingChannel.claim_id; + } + const outpoint = `${txid}:${nout}`; + const params: PublishNewParams = { uri, claim_id: claimId, outpoint }; + if (channelClaimId) { + params['channel_claim_id'] = channelClaimId; + } + Lbryio.call('publish', 'new', params); + } + }, + apiSearchFeedback: (query, vote) => { if (isProduction) { // We don't need to worry about analytics enabled here because users manually click on the button to provide feedback diff --git a/src/ui/component/selectChannel/view.jsx b/src/ui/component/selectChannel/view.jsx index a5eb12c4c..7b7fa63f4 100644 --- a/src/ui/component/selectChannel/view.jsx +++ b/src/ui/component/selectChannel/view.jsx @@ -4,6 +4,8 @@ import { isNameValid } from 'lbry-redux'; import { FormField } from 'component/common/form'; import BusyIndicator from 'component/common/busy-indicator'; import Button from 'component/button'; +import analytics from 'analytics'; + import { CHANNEL_NEW, CHANNEL_ANONYMOUS, INVALID_NAME_ERROR } from 'constants/claim'; type Props = { @@ -118,12 +120,12 @@ class ChannelSection extends React.PureComponent { createChannelError: undefined, }); - const success = () => { + const success = channelClaim => { this.setState({ creatingChannel: false, addingChannel: false, }); - + analytics.apiPublishNew(channelClaim); onChannelChange(channelName); }; diff --git a/src/ui/redux/actions/publish.js b/src/ui/redux/actions/publish.js index b825f5ddc..d07c23506 100644 --- a/src/ui/redux/actions/publish.js +++ b/src/ui/redux/actions/publish.js @@ -14,7 +14,8 @@ export const doPublishDesktop = () => (dispatch: Dispatch, getState: () => {}) = analytics.apiLogPublish(); const myClaims = selectMyClaims(state); const pendingClaim = successResponse.outputs[0]; - const uri = pendingClaim.permanent_url; + analytics.apiPublishNew(pendingClaim); + const { permanent_url: url } = pendingClaim; const actions = []; actions.push({ @@ -29,7 +30,7 @@ export const doPublishDesktop = () => (dispatch: Dispatch, getState: () => {}) = const myNewClaims = isEdit ? myClaims.map(claim => (isMatch(claim) ? pendingClaim : claim)) : myClaims.concat(pendingClaim); - actions.push(doOpenModal(MODALS.PUBLISH, { uri, isEdit })); + actions.push(doOpenModal(MODALS.PUBLISH, { uri: url, isEdit })); actions.push({ type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED, data: { diff --git a/static/app-strings.json b/static/app-strings.json index d6314a530..e3f1a5549 100644 --- a/static/app-strings.json +++ b/static/app-strings.json @@ -819,4 +819,4 @@ "settings": "settings", "Content may be hidden on this %type% because of your %settings%": "Content may be hidden on this %type% because of your %settings%", "Content may be hidden on this %type% because of your %settings%.": "Content may be hidden on this %type% because of your %settings%." -} \ No newline at end of file +}