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