Skip to content

Commit

Permalink
Segment followup fixes (#4712)
Browse files Browse the repository at this point in the history
Co-authored-by: Artem <Artem Slugin>
  • Loading branch information
attemka authored Aug 21, 2023
1 parent 438fc20 commit 9d66518
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ const VideoPlayerComponent: ForwardRefRenderFunction<HTMLVideoElement, VideoPlay
totalLength: video?.duration ?? -1,
fullScreen: isFullScreen,
quality: video?.mediaMetadata?.pixelHeight?.toString() ?? '1',
isNft: !!video?.nft?.id,
}),
[
videoId,
Expand All @@ -197,6 +198,7 @@ const VideoPlayerComponent: ForwardRefRenderFunction<HTMLVideoElement, VideoPlay
video?.category?.name,
video?.duration,
video?.mediaMetadata?.pixelHeight,
video?.nft?.id,
isFullScreen,
]
)
Expand Down
2 changes: 2 additions & 0 deletions packages/atlas/src/hooks/useSegmentAnalytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type videoPlaybackParams = {
totalLength: number
fullScreen: boolean
quality: string
isNft?: boolean
}

type PageViewParams = {
Expand All @@ -25,6 +26,7 @@ type PageViewParams = {
type VideoPageViewParams = {
videoId?: string
videoTitle?: string
isNft?: boolean
category?: string
}

Expand Down
10 changes: 9 additions & 1 deletion packages/atlas/src/views/studio/YppDashboard/YppDashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { atlasConfig } from '@/config'
import { useHeadTags } from '@/hooks/useHeadTags'
import { useMediaMatch } from '@/hooks/useMediaMatch'
import { useSegmentAnalytics } from '@/hooks/useSegmentAnalytics'
import { useUploadsStore } from '@/providers/uploads/uploads.store'
import { useGetYppSyncedChannels } from '@/views/global/YppLandingView/useGetYppSyncedChannels'
import { YppDashboardReferralsTab } from '@/views/studio/YppDashboard/tabs/YppDashboardReferralsTab/YppDashboardReferralsTab'

Expand All @@ -32,6 +33,7 @@ export const YppDashboard: FC = () => {
const [currentVideosTab, setCurrentVideosTab] = useState(0)
const { currentChannel, isLoading } = useGetYppSyncedChannels()
const { trackPageView } = useSegmentAnalytics()
const { processingAssets, uploads } = useUploadsStore()

const subscribersCount = currentChannel?.subscribersCount || 0
const currentTier = TIERS.reduce((prev, current, idx) => {
Expand All @@ -43,8 +45,14 @@ export const YppDashboard: FC = () => {
}, 0)

useEffect(() => {
// if user avatar is currently processing membership will be refetched when it's uploaded,
// which will trigger page view event
const avatarId = uploads.find((upload) => upload.type === 'avatar')?.id
if (avatarId && processingAssets.some((asset) => asset.id === avatarId)) {
return
}
trackPageView('YPP Dashboard', { tab: TABS[currentVideosTab] })
}, [currentVideosTab, trackPageView])
}, [currentVideosTab, processingAssets, trackPageView, uploads])

const tiersTooltip = atlasConfig.features.ypp.tiersDefinition?.tiersTooltip

Expand Down
3 changes: 2 additions & 1 deletion packages/atlas/src/views/viewer/VideoView/VideoView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,11 @@ export const VideoView: FC = () => {
trackPageView('Video', {
videoId: video.id,
videoTitle: video.title || undefined,
isNft: !!video.nft?.id,
category: video.category?.name || undefined,
})
}
}, [trackPageView, video?.category?.name, video?.id, video?.title])
}, [trackPageView, video?.category?.name, video?.id, video?.nft?.id, video?.title])

const videoMetaTags = useMemo(() => {
if (!video || !thumbnailUrls) return {}
Expand Down

0 comments on commit 9d66518

Please sign in to comment.