Skip to content

Commit

Permalink
🔒 Filter request response time logs hotfix (Joystream#50)
Browse files Browse the repository at this point in the history
* Filter request response time logs

* Improve filtering on channel videos
  • Loading branch information
ikprk committed Jun 4, 2024
1 parent a5506a8 commit 8cbe0e6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 22 deletions.
16 changes: 15 additions & 1 deletion packages/atlas/src/api/client/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@ import { GraphQLWsLink } from '@apollo/client/link/subscriptions'
import { getMainDefinition } from '@apollo/client/utilities'
import { createClient } from 'graphql-ws'

import { ORION_GRAPHQL_URL, QUERY_NODE_GRAPHQL_SUBSCRIPTION_URL } from '@/config/env'
import {
FAUCET_URL,
ORION_AUTH_URL,
ORION_GRAPHQL_URL,
QUERY_NODE_GRAPHQL_SUBSCRIPTION_URL,
YPP_FAUCET_URL,
} from '@/config/env'
import { useUserLocationStore } from '@/providers/userLocation'
import { UserEventsLogger } from '@/utils/logs'

import { cache } from './cache'

const followedRequests = [YPP_FAUCET_URL, ORION_GRAPHQL_URL, ORION_AUTH_URL, FAUCET_URL]

const initializePerformanceObserver = () => {
try {
const observer = new PerformanceObserver((list) => {
Expand All @@ -17,6 +25,12 @@ const initializePerformanceObserver = () => {
const queryString = entry.name.split('?')?.[1]
const params = new URLSearchParams(queryString)
const queryType = params.get('queryName')

// Only follow requests to Atlas infra
if (!queryType && !followedRequests.some((allowedUrl) => entry.name.includes(allowedUrl))) {
return
}

UserEventsLogger.logUserEvent('request-response-time', {
requestName: queryType ?? entry.name,
timeToComplete: entry.duration,
Expand Down
13 changes: 3 additions & 10 deletions packages/atlas/src/views/viewer/ChannelView/ChannelView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { CollectorsBox } from '@/components/_channel/CollectorsBox'
import { ContextMenu } from '@/components/_overlays/ContextMenu'
import { ReportModal } from '@/components/_overlays/ReportModal'
import { atlasConfig } from '@/config'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'
import { absoluteRoutes } from '@/config/routes'
import { NFT_SORT_OPTIONS, VIDEO_SORT_OPTIONS } from '@/config/sorting'
import { useGetAssetUrl } from '@/hooks/useGetAssetUrl'
Expand Down Expand Up @@ -92,20 +93,12 @@ export const ChannelView: FC = () => {
tab === 'Token' ? !!tab && (isChannelOwner || !!channel?.creatorToken?.token.id) : !!tab
)
const { videoCount } = useVideoCount({
where: {
where: getPublicCryptoVideoFilter({
channel: {
id_eq: id,
},
isPublic_eq: true,
createdAt_lt: USER_TIMESTAMP,
isCensored_eq: false,
thumbnailPhoto: {
isAccepted_eq: true,
},
media: {
isAccepted_eq: true,
},
},
}),
})
const { data: nftCountData } = useGetNftsCountQuery({
variables: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { EmptyFallback } from '@/components/EmptyFallback'
import { Grid } from '@/components/Grid'
import { ViewErrorFallback } from '@/components/ViewErrorFallback'
import { VideoTileViewer } from '@/components/_video/VideoTileViewer'
import { getPublicCryptoVideoFilter } from '@/config/contentFilter'
import { transitions } from '@/styles'
import { createPlaceholderData } from '@/utils/data'
import { SentryLogger } from '@/utils/logs'
Expand Down Expand Up @@ -49,21 +50,12 @@ export const ChannelVideos: FC<ChannelVideosProps> = ({
orderBy: sortVideosBy,
limit: tilesPerPage,
offset: currentPage * tilesPerPage,
where: {
where: getPublicCryptoVideoFilter({
channel: {
id_eq: channelId,
},
isPublic_eq: true,
createdAt_lt: USER_TIMESTAMP,
isCensored_eq: false,
isShort_eq: false,
thumbnailPhoto: {
isAccepted_eq: true,
},
media: {
isAccepted_eq: true,
},
},
}),
},
})

Expand Down

0 comments on commit 8cbe0e6

Please sign in to comment.