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,
|
toggle: (boolean, ?boolean) => void,
|
||||||
apiLogView: (string, string, string, ?number, ?() => void) => Promise<any>,
|
apiLogView: (string, string, string, ?number, ?() => void) => Promise<any>,
|
||||||
apiLogPublish: () => void,
|
apiLogPublish: () => void,
|
||||||
|
apiPublishNew: (ChannelClaim | StreamClaim) => void,
|
||||||
tagFollowEvent: (string, boolean, string) => void,
|
tagFollowEvent: (string, boolean, string) => void,
|
||||||
emailProvidedEvent: () => void,
|
emailProvidedEvent: () => void,
|
||||||
emailVerifiedEvent: () => void,
|
emailVerifiedEvent: () => void,
|
||||||
|
@ -24,6 +25,13 @@ type Analytics = {
|
||||||
readyEvent: number => void,
|
readyEvent: number => void,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type PublishNewParams = {
|
||||||
|
uri?: string,
|
||||||
|
claim_id?: string,
|
||||||
|
outpoint?: string,
|
||||||
|
channel_claim_id?: string,
|
||||||
|
};
|
||||||
|
|
||||||
let analyticsEnabled: boolean = true;
|
let analyticsEnabled: boolean = true;
|
||||||
const analytics: Analytics = {
|
const analytics: Analytics = {
|
||||||
pageView: path => {
|
pageView: path => {
|
||||||
|
@ -85,6 +93,23 @@ const analytics: Analytics = {
|
||||||
Lbryio.call('event', 'publish');
|
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) => {
|
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
|
||||||
|
|
|
@ -4,6 +4,8 @@ import { isNameValid } from 'lbry-redux';
|
||||||
import { FormField } from 'component/common/form';
|
import { FormField } from 'component/common/form';
|
||||||
import BusyIndicator from 'component/common/busy-indicator';
|
import BusyIndicator from 'component/common/busy-indicator';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
|
import analytics from 'analytics';
|
||||||
|
|
||||||
import { CHANNEL_NEW, CHANNEL_ANONYMOUS, INVALID_NAME_ERROR } from 'constants/claim';
|
import { CHANNEL_NEW, CHANNEL_ANONYMOUS, INVALID_NAME_ERROR } from 'constants/claim';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -118,12 +120,12 @@ class ChannelSection extends React.PureComponent<Props, State> {
|
||||||
createChannelError: undefined,
|
createChannelError: undefined,
|
||||||
});
|
});
|
||||||
|
|
||||||
const success = () => {
|
const success = channelClaim => {
|
||||||
this.setState({
|
this.setState({
|
||||||
creatingChannel: false,
|
creatingChannel: false,
|
||||||
addingChannel: false,
|
addingChannel: false,
|
||||||
});
|
});
|
||||||
|
analytics.apiPublishNew(channelClaim);
|
||||||
onChannelChange(channelName);
|
onChannelChange(channelName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,8 @@ export const doPublishDesktop = () => (dispatch: Dispatch, getState: () => {}) =
|
||||||
analytics.apiLogPublish();
|
analytics.apiLogPublish();
|
||||||
const myClaims = selectMyClaims(state);
|
const myClaims = selectMyClaims(state);
|
||||||
const pendingClaim = successResponse.outputs[0];
|
const pendingClaim = successResponse.outputs[0];
|
||||||
const uri = pendingClaim.permanent_url;
|
analytics.apiPublishNew(pendingClaim);
|
||||||
|
const { permanent_url: url } = pendingClaim;
|
||||||
const actions = [];
|
const actions = [];
|
||||||
|
|
||||||
actions.push({
|
actions.push({
|
||||||
|
@ -29,7 +30,7 @@ export const doPublishDesktop = () => (dispatch: Dispatch, getState: () => {}) =
|
||||||
const myNewClaims = isEdit
|
const myNewClaims = isEdit
|
||||||
? myClaims.map(claim => (isMatch(claim) ? pendingClaim : claim))
|
? myClaims.map(claim => (isMatch(claim) ? pendingClaim : claim))
|
||||||
: myClaims.concat(pendingClaim);
|
: myClaims.concat(pendingClaim);
|
||||||
actions.push(doOpenModal(MODALS.PUBLISH, { uri, isEdit }));
|
actions.push(doOpenModal(MODALS.PUBLISH, { uri: url, isEdit }));
|
||||||
actions.push({
|
actions.push({
|
||||||
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
type: ACTIONS.FETCH_CLAIM_LIST_MINE_COMPLETED,
|
||||||
data: {
|
data: {
|
||||||
|
|
|
@ -819,4 +819,4 @@
|
||||||
"settings": "settings",
|
"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%",
|
||||||
"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%."
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue