[Statsig] Sample noisy events (#4288)

* Sample state:background and state:foreground

* Sample feed events

* Add DEV protection against forgetting to add events to the list
This commit is contained in:
dan 2024-05-30 16:32:59 +01:00 committed by GitHub
parent 9431201026
commit d6275e98c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 41 additions and 21 deletions

View file

@ -15,7 +15,7 @@ const AnimatedPagerView = Animated.createAnimatedComponent(PagerView)
export interface PagerRef {
setPage: (
index: number,
reason: LogEvents['home:feedDisplayed']['reason'],
reason: LogEvents['home:feedDisplayed:sampled']['reason'],
) => void
}
@ -32,7 +32,7 @@ interface Props {
onPageSelected?: (index: number) => void
onPageSelecting?: (
index: number,
reason: LogEvents['home:feedDisplayed']['reason'],
reason: LogEvents['home:feedDisplayed:sampled']['reason'],
) => void
onPageScrollStateChanged?: (
scrollState: 'idle' | 'dragging' | 'settling',
@ -61,7 +61,7 @@ export const Pager = forwardRef<PagerRef, React.PropsWithChildren<Props>>(
React.useImperativeHandle(ref, () => ({
setPage: (
index: number,
reason: LogEvents['home:feedDisplayed']['reason'],
reason: LogEvents['home:feedDisplayed:sampled']['reason'],
) => {
pagerView.current?.setPage(index)
onPageSelecting?.(index, reason)

View file

@ -18,7 +18,7 @@ interface Props {
onPageSelected?: (index: number) => void
onPageSelecting?: (
index: number,
reason: LogEvents['home:feedDisplayed']['reason'],
reason: LogEvents['home:feedDisplayed:sampled']['reason'],
) => void
}
export const Pager = React.forwardRef(function PagerImpl(
@ -38,14 +38,17 @@ export const Pager = React.forwardRef(function PagerImpl(
React.useImperativeHandle(ref, () => ({
setPage: (
index: number,
reason: LogEvents['home:feedDisplayed']['reason'],
reason: LogEvents['home:feedDisplayed:sampled']['reason'],
) => {
onTabBarSelect(index, reason)
},
}))
const onTabBarSelect = React.useCallback(
(index: number, reason: LogEvents['home:feedDisplayed']['reason']) => {
(
index: number,
reason: LogEvents['home:feedDisplayed:sampled']['reason'],
) => {
const scrollY = window.scrollY
// We want to determine if the tabbar is already "sticking" at the top (in which
// case we should preserve and restore scroll), or if it is somewhere below in the