Track comment bounties
This commit is contained in:
parent
ae9210c744
commit
0255b23bff
|
@ -27,6 +27,7 @@ export function AwardBountyButton(prop: {
|
||||||
awardCommentBounty(data)
|
awardCommentBounty(data)
|
||||||
.then((_) => {
|
.then((_) => {
|
||||||
console.log('success')
|
console.log('success')
|
||||||
|
track('award comment bounty', data)
|
||||||
})
|
})
|
||||||
.catch((reason) => console.log('Server error:', reason))
|
.catch((reason) => console.log('Server error:', reason))
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,10 @@ export function AddCommentBountyPanel(props: { contract: Contract }) {
|
||||||
|
|
||||||
addCommentBounty({ amount, contractId })
|
addCommentBounty({ amount, contractId })
|
||||||
.then((_) => {
|
.then((_) => {
|
||||||
|
track('offer comment bounty', {
|
||||||
|
amount,
|
||||||
|
contractId,
|
||||||
|
})
|
||||||
setIsSuccess(true)
|
setIsSuccess(true)
|
||||||
setError(undefined)
|
setError(undefined)
|
||||||
setIsLoading(false)
|
setIsLoading(false)
|
||||||
|
|
|
@ -219,28 +219,32 @@ export function ContractCommentInput(props: {
|
||||||
onSubmitComment?: () => void
|
onSubmitComment?: () => void
|
||||||
}) {
|
}) {
|
||||||
const user = useUser()
|
const user = useUser()
|
||||||
|
const { contract, parentAnswerOutcome, parentCommentId, replyTo, className } =
|
||||||
|
props
|
||||||
|
const { openCommentBounties } = contract
|
||||||
async function onSubmitComment(editor: Editor) {
|
async function onSubmitComment(editor: Editor) {
|
||||||
if (!user) {
|
if (!user) {
|
||||||
track('sign in to comment')
|
track('sign in to comment')
|
||||||
return await firebaseLogin()
|
return await firebaseLogin()
|
||||||
}
|
}
|
||||||
await createCommentOnContract(
|
await createCommentOnContract(
|
||||||
props.contract.id,
|
contract.id,
|
||||||
editor.getJSON(),
|
editor.getJSON(),
|
||||||
user,
|
user,
|
||||||
props.parentAnswerOutcome,
|
!!openCommentBounties,
|
||||||
props.parentCommentId
|
parentAnswerOutcome,
|
||||||
|
parentCommentId
|
||||||
)
|
)
|
||||||
props.onSubmitComment?.()
|
props.onSubmitComment?.()
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<CommentInput
|
<CommentInput
|
||||||
replyTo={props.replyTo}
|
replyTo={replyTo}
|
||||||
parentAnswerOutcome={props.parentAnswerOutcome}
|
parentAnswerOutcome={parentAnswerOutcome}
|
||||||
parentCommentId={props.parentCommentId}
|
parentCommentId={parentCommentId}
|
||||||
onSubmitComment={onSubmitComment}
|
onSubmitComment={onSubmitComment}
|
||||||
className={props.className}
|
className={className}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,7 @@ export async function createCommentOnContract(
|
||||||
contractId: string,
|
contractId: string,
|
||||||
content: JSONContent,
|
content: JSONContent,
|
||||||
user: User,
|
user: User,
|
||||||
|
onContractWithBounty: boolean,
|
||||||
answerOutcome?: string,
|
answerOutcome?: string,
|
||||||
replyToCommentId?: string
|
replyToCommentId?: string
|
||||||
) {
|
) {
|
||||||
|
@ -50,7 +51,8 @@ export async function createCommentOnContract(
|
||||||
content,
|
content,
|
||||||
user,
|
user,
|
||||||
ref,
|
ref,
|
||||||
replyToCommentId
|
replyToCommentId,
|
||||||
|
onContractWithBounty
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
export async function createCommentOnGroup(
|
export async function createCommentOnGroup(
|
||||||
|
@ -95,7 +97,8 @@ async function createComment(
|
||||||
content: JSONContent,
|
content: JSONContent,
|
||||||
user: User,
|
user: User,
|
||||||
ref: DocumentReference<DocumentData>,
|
ref: DocumentReference<DocumentData>,
|
||||||
replyToCommentId?: string
|
replyToCommentId?: string,
|
||||||
|
onContractWithBounty?: boolean
|
||||||
) {
|
) {
|
||||||
const comment = removeUndefinedProps({
|
const comment = removeUndefinedProps({
|
||||||
id: ref.id,
|
id: ref.id,
|
||||||
|
@ -108,13 +111,19 @@ async function createComment(
|
||||||
replyToCommentId: replyToCommentId,
|
replyToCommentId: replyToCommentId,
|
||||||
...extraFields,
|
...extraFields,
|
||||||
})
|
})
|
||||||
|
track(
|
||||||
track(`${extraFields.commentType} message`, {
|
`${extraFields.commentType} message`,
|
||||||
user,
|
removeUndefinedProps({
|
||||||
commentId: ref.id,
|
user,
|
||||||
surfaceId,
|
commentId: ref.id,
|
||||||
replyToCommentId: replyToCommentId,
|
surfaceId,
|
||||||
})
|
replyToCommentId: replyToCommentId,
|
||||||
|
onContractWithBounty:
|
||||||
|
extraFields.commentType === 'contract'
|
||||||
|
? onContractWithBounty
|
||||||
|
: undefined,
|
||||||
|
})
|
||||||
|
)
|
||||||
return await setDoc(ref, comment)
|
return await setDoc(ref, comment)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user