triggers api publish new on streams and channels
This commit is contained in:
parent
4f62606e22
commit
da19ff2471
4 changed files with 33 additions and 5 deletions
|
@ -16,6 +16,7 @@ type Analytics = {
|
|||
toggle: (boolean, ?boolean) => void,
|
||||
apiLogView: (string, string, string, ?number, ?() => void) => Promise<any>,
|
||||
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
|
||||
|
|
|
@ -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<Props, State> {
|
|||
createChannelError: undefined,
|
||||
});
|
||||
|
||||
const success = () => {
|
||||
const success = channelClaim => {
|
||||
this.setState({
|
||||
creatingChannel: false,
|
||||
addingChannel: false,
|
||||
});
|
||||
|
||||
analytics.apiPublishNew(channelClaim);
|
||||
onChannelChange(channelName);
|
||||
};
|
||||
|
||||
|
|
|
@ -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: {
|
||||
|
|
Loading…
Reference in a new issue