Skip to content

Commit

Permalink
track bet intent and bets in Amplitude
Browse files Browse the repository at this point in the history
Skipping the answers for now, since state wouldn't be accurate anyways

Resolves MAN-1529 part 2
  • Loading branch information
sipec committed Sep 20, 2024
1 parent b9f567f commit 461758c
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 22 deletions.
11 changes: 5 additions & 6 deletions web/components/bet/bet-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,7 @@ export function BuyPanel(props: {
setOutcome(undefined)
setIsPanelBodyVisible(false)
} else {
// TODO: Twomba tracking bet terminology
track('bet intent', { location, option: outcome })
track('bet intent', { location, option: outcome, token: contract.token })

setOutcome(choice)
setIsPanelBodyVisible(true)
Expand Down Expand Up @@ -361,12 +360,12 @@ export const BuyPanelBody = (props: {
console.log(`placed ${TRADE_TERM}. Result:`, bet)
setBetAmount(undefined)
if (onBuySuccess) onBuySuccess()
// TODO: Twomba tracking bet terminology
track(
'bet',
removeUndefinedProps({
location,
outcomeType: contract.outcomeType,
token: contract.token,
slug: contract.slug,
contractId: contract.id,
amount: betAmount,
Expand Down Expand Up @@ -482,7 +481,6 @@ export const BuyPanelBody = (props: {
.concat(result.ordersToCancel)
}
} catch (err: any) {
// TODO: Twomba tracking bet terminology
console.error('Error in calculateCpmmMultiArbitrageBet:', err)
setError(
err?.message ??
Expand Down Expand Up @@ -768,8 +766,9 @@ export const BuyPanelBody = (props: {
<Button
color={outcome === 'NO' ? 'red' : 'green'}
size="xl"
// TODO: Twomba tracking bet terminology
onClick={withTracking(firebaseLogin, 'login from bet panel')}
onClick={withTracking(firebaseLogin, 'login from bet panel', {
token: contract.token,
})}
className="flex-grow"
>
Sign up to predict
Expand Down
7 changes: 5 additions & 2 deletions web/components/bet/feed-bet-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ export function BetButton(props: {
firebaseLogin()
return
}
// TODO: Twomba tracking bet terminology
track('bet intent', { location: 'feed card', outcome })
track('bet intent', {
location: 'feed card',
outcome,
token: contract.token,
})
setDialogueThatIsOpen(outcome)
}

Expand Down
3 changes: 1 addition & 2 deletions web/components/bet/limit-order-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ export default function LimitOrderPanel(props: {
console.log(`placed ${TRADE_TERM}. Result:`, bet)
if (onBuySuccess) onBuySuccess()

// TODO: Twomba tracking bet terminology
await track('bet', {
location: 'bet panel',
outcomeType: contract.outcomeType,
Expand All @@ -237,6 +236,7 @@ export default function LimitOrderPanel(props: {
limitProb: limitProb,
isLimitOrder: true,
answerId: multiProps?.answerToBuy.id,
token: contract.token,
})
} catch (e) {
if (e instanceof APIError) {
Expand Down Expand Up @@ -275,7 +275,6 @@ export default function LimitOrderPanel(props: {
fees = result.fees
betDeps.current = result.betDeps
} catch (err: any) {
// TODO: Twomba tracking bet terminology
console.error('Error in calculateCpmmMultiArbitrageBet:', err)
setError(
err?.message ??
Expand Down
2 changes: 1 addition & 1 deletion web/components/bet/quick-limit-order-buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ export const QuickLimitOrderButtons = (props: {
setIsSubmitting(false)
})

// TODO: Twomba tracking bet terminology
await track(
'bet',
removeUndefinedProps({
location: 'quick bet panel',
outcomeType: contract.outcomeType,
token: contract.token,
slug: contract.slug,
contractId: contract.id,
amount,
Expand Down
6 changes: 4 additions & 2 deletions web/components/comments/comment-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export function CommentActions(props: {
{user && liveContract.outcomeType === 'BINARY' && !isCashContract && (
<IconButton
onClick={() => {
// TODO: Twomba tracking bet terminology
track('bet intent', { location: 'comment on contract' })
track('bet intent', {
location: 'comment on contract',
token: liveContract.token,
})
setOutcome('YES')
setShowBetModal(true)
}}
Expand Down
1 change: 0 additions & 1 deletion web/components/comments/comment-input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ export function ContractCommentInput(props: {
}
clearReply?.()
onSubmit?.(comment)
// TODO: Twomba tracking bet terminology
await track(type, {
location: trackingLocation,
replyTo: isReplyToBet
Expand Down
6 changes: 4 additions & 2 deletions web/components/contract/contract-table-action.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,10 @@ export function BetButton(props: {
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
// TODO: Twomba tracking bet terminology
track('bet intent', { location: 'contract table' })
track('bet intent', {
location: 'contract table',
token: contract.token,
})
if (!user) {
firebaseLogin()
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ export const BinaryBetButton = (props: { contract: BinaryContract }) => {
className="bg-primary-50 h-fit w-fit"
onClick={(e) => {
e.stopPropagation()
// TODO: Twomba tracking bet terminology
track('bet intent', { location: 'binary panel' })
track('bet intent', {
location: 'binary panel',
token: contract.token,
})
setOutcome('YES')
}}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -379,8 +379,10 @@ export function BinaryBetButton(props: {
onClick={(e) => {
e.preventDefault()
e.stopPropagation()
// TODO: Twomba tracking bet terminology
track('bet intent', { location: 'contract table' })
track('bet intent', {
location: 'contract table',
token: contract.token,
})
if (!user) {
firebaseLogin()
return
Expand Down
5 changes: 3 additions & 2 deletions web/components/usa-map/house-table-helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ export const BuyPanelBody = (props: {
<Button
color={outcome === 'NO' ? 'red' : 'green'}
size="xl"
// TODO: Twomba tracking bet terminology
onClick={withTracking(firebaseLogin, 'login from bet panel')}
onClick={withTracking(firebaseLogin, 'login from bet panel', {
token: contract.token,
})}
className="flex-grow"
>
Sign up to predict
Expand Down

0 comments on commit 461758c

Please sign in to comment.