Add debugs
This commit is contained in:
@@ -10,6 +10,8 @@ export enum LogContext {
|
||||
ConversationAgent = 'conversation-agent',
|
||||
DMsAgent = 'dms-agent',
|
||||
ReportDialog = 'report-dialog',
|
||||
FeedFeedback = 'feed-feedback',
|
||||
PostSource = 'post-source',
|
||||
|
||||
/**
|
||||
* METRIC IS FOR INTERNAL USE ONLY, don't create any other loggers using this
|
||||
|
||||
@@ -12,7 +12,7 @@ import throttle from 'lodash.throttle'
|
||||
|
||||
import {FEEDBACK_FEEDS, STAGING_FEEDS} from '#/lib/constants'
|
||||
import {logEvent} from '#/lib/statsig/statsig'
|
||||
import {logger} from '#/logger'
|
||||
import {Logger} from '#/logger'
|
||||
import {
|
||||
type FeedDescriptor,
|
||||
type FeedPostSliceItem,
|
||||
@@ -20,6 +20,8 @@ import {
|
||||
import {getItemsForFeedback} from '#/view/com/posts/PostFeed'
|
||||
import {useAgent} from './session'
|
||||
|
||||
const logger = Logger.create(Logger.Context.FeedFeedback)
|
||||
|
||||
export type StateContext = {
|
||||
enabled: boolean
|
||||
onItemSeen: (item: any) => void
|
||||
@@ -89,6 +91,7 @@ export function useFeedFeedback(
|
||||
}
|
||||
sendOrAggregateInteractionsForStats(aggregatedStats.current, interactions)
|
||||
throttledFlushAggregatedStats()
|
||||
logger.debug('flushed')
|
||||
}, [agent, throttledFlushAggregatedStats, feed])
|
||||
|
||||
const sendToFeed = useMemo(
|
||||
@@ -138,6 +141,9 @@ export function useFeedFeedback(
|
||||
|
||||
const sendInteraction = useCallback(
|
||||
(interaction: AppBskyFeedDefs.Interaction) => {
|
||||
logger.debug('sendInteraction', {
|
||||
...interaction,
|
||||
})
|
||||
if (!enabled) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import {createContext, useCallback, useContext, useRef, useState} from 'react'
|
||||
import {type AppBskyFeedDefs} from '@atproto/api'
|
||||
|
||||
import {type FeedDescriptor} from './queries/post-feed'
|
||||
import {Logger} from '#/logger'
|
||||
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
||||
|
||||
const logger = Logger.create(Logger.Context.PostSource)
|
||||
|
||||
/**
|
||||
* For passing the source of the post (i.e. the original post, from the feed) to the threadview,
|
||||
@@ -15,7 +18,7 @@ type Source = {
|
||||
}
|
||||
|
||||
const SetUnstablePostSourceContext = createContext<
|
||||
(key: string, source: Source) => void
|
||||
(uri: string, source: Source) => void
|
||||
>(() => {})
|
||||
const ConsumeUnstablePostSourceContext = createContext<
|
||||
(uri: string) => Source | undefined
|
||||
@@ -24,14 +27,22 @@ const ConsumeUnstablePostSourceContext = createContext<
|
||||
export function Provider({children}: {children: React.ReactNode}) {
|
||||
const sourcesRef = useRef<Map<string, Source>>(new Map())
|
||||
|
||||
const setUnstablePostSource = useCallback((key: string, source: Source) => {
|
||||
sourcesRef.current.set(key, source)
|
||||
const setUnstablePostSource = useCallback((uri: string, source: Source) => {
|
||||
sourcesRef.current.set(uri, source)
|
||||
logger.debug('set', {
|
||||
uri,
|
||||
source,
|
||||
})
|
||||
}, [])
|
||||
|
||||
const consumeUnstablePostSource = useCallback((uri: string) => {
|
||||
const source = sourcesRef.current.get(uri)
|
||||
if (source) {
|
||||
sourcesRef.current.delete(uri)
|
||||
logger.debug('consume', {
|
||||
uri,
|
||||
source,
|
||||
})
|
||||
}
|
||||
return source
|
||||
}, [])
|
||||
|
||||
Reference in New Issue
Block a user