track embedded markets separtely
This commit is contained in:
parent
a9627bb2b6
commit
85be84071a
web
hooks
pages
|
@ -1,6 +1,6 @@
|
|||
import { useEffect, useState } from 'react'
|
||||
|
||||
function inIframe() {
|
||||
export function inIframe() {
|
||||
try {
|
||||
return window.self !== window.top
|
||||
} catch (e) {
|
||||
|
|
|
@ -1,8 +1,14 @@
|
|||
import { track } from '@amplitude/analytics-browser'
|
||||
import { useEffect } from 'react'
|
||||
import { inIframe } from './use-is-iframe'
|
||||
|
||||
export const useTracking = (eventName: string, eventProperties?: any) => {
|
||||
export const useTracking = (
|
||||
eventName: string,
|
||||
eventProperties?: any,
|
||||
excludeIframe?: boolean
|
||||
) => {
|
||||
useEffect(() => {
|
||||
if (excludeIframe && inIframe()) return
|
||||
track(eventName, eventProperties)
|
||||
}, [])
|
||||
}
|
||||
|
|
|
@ -158,11 +158,15 @@ export function ContractPageContent(
|
|||
const contract = useContractWithPreload(props.contract) ?? props.contract
|
||||
usePrefetch(user?.id)
|
||||
|
||||
useTracking('view market', {
|
||||
slug: contract.slug,
|
||||
contractId: contract.id,
|
||||
creatorId: contract.creatorId,
|
||||
})
|
||||
useTracking(
|
||||
'view market',
|
||||
{
|
||||
slug: contract.slug,
|
||||
contractId: contract.id,
|
||||
creatorId: contract.creatorId,
|
||||
},
|
||||
true
|
||||
)
|
||||
|
||||
const bets = useBets(contract.id) ?? props.bets
|
||||
const nonChallengeBets = useMemo(
|
||||
|
|
|
@ -21,6 +21,7 @@ import { SiteLink } from 'web/components/site-link'
|
|||
import { useContractWithPreload } from 'web/hooks/use-contract'
|
||||
import { useMeasureSize } from 'web/hooks/use-measure-size'
|
||||
import { fromPropz, usePropz } from 'web/hooks/use-propz'
|
||||
import { useTracking } from 'web/hooks/use-tracking'
|
||||
import { listAllBets } from 'web/lib/firebase/bets'
|
||||
import {
|
||||
contractPath,
|
||||
|
@ -82,6 +83,12 @@ export function ContractEmbed(props: { contract: Contract; bets: Bet[] }) {
|
|||
const { contract, bets } = props
|
||||
const { question, outcomeType } = contract
|
||||
|
||||
useTracking('view market embed', {
|
||||
slug: contract.slug,
|
||||
contractId: contract.id,
|
||||
creatorId: contract.creatorId,
|
||||
})
|
||||
|
||||
const isBinary = outcomeType === 'BINARY'
|
||||
const isPseudoNumeric = outcomeType === 'PSEUDO_NUMERIC'
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user