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