Fix up metrics and mutations
This commit is contained in:
+1
-1
@@ -73,7 +73,7 @@
|
|||||||
"icons:optimize": "svgo -f ./assets/icons"
|
"icons:optimize": "svgo -f ./assets/icons"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@atproto/api": "^0.18.13",
|
"@atproto/api": "^0.18.15",
|
||||||
"@bitdrift/react-native": "^0.6.8",
|
"@bitdrift/react-native": "^0.6.8",
|
||||||
"@braintree/sanitize-url": "^6.0.2",
|
"@braintree/sanitize-url": "^6.0.2",
|
||||||
"@bsky.app/alf": "^0.1.6",
|
"@bsky.app/alf": "^0.1.6",
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export function DiscoverFeedLiveEventFeedsAndTrendingBanner() {
|
|||||||
<>
|
<>
|
||||||
<View style={[a.px_lg, a.pt_md, a.pb_xs]}>
|
<View style={[a.px_lg, a.pt_md, a.pb_xs]}>
|
||||||
<View>
|
<View>
|
||||||
<LiveEventFeedCardWide feed={feed} />
|
<LiveEventFeedCardWide feed={feed} metricContext="discover" />
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
label={_(msg`Configure live event banner`)}
|
label={_(msg`Configure live event banner`)}
|
||||||
@@ -88,7 +88,11 @@ export function DiscoverFeedLiveEventFeedsAndTrendingBanner() {
|
|||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<LiveEventFeedOptionsMenu feed={feed} control={optionsMenuControl} />
|
<LiveEventFeedOptionsMenu
|
||||||
|
feed={feed}
|
||||||
|
control={optionsMenuControl}
|
||||||
|
metricContext="discover"
|
||||||
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export function ExploreScreenLiveEventFeedsBanner() {
|
|||||||
if (!feed) return null
|
if (!feed) return null
|
||||||
return (
|
return (
|
||||||
<View style={[a.p_lg, a.border_b, t.atoms.border_contrast_low]}>
|
<View style={[a.p_lg, a.border_b, t.atoms.border_contrast_low]}>
|
||||||
<LiveEventFeedCardWide feed={feed} />
|
<LiveEventFeedCardWide feed={feed} metricContext="explore" />
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,24 @@ import {msg, Trans} from '@lingui/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {isBskyCustomFeedUrl} from '#/lib/strings/url-helpers'
|
import {isBskyCustomFeedUrl} from '#/lib/strings/url-helpers'
|
||||||
|
import {logger} from '#/logger'
|
||||||
import {atoms as a, useBreakpoints, utils} from '#/alf'
|
import {atoms as a, useBreakpoints, utils} from '#/alf'
|
||||||
import {Link} from '#/components/Link'
|
import {Link} from '#/components/Link'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {type LiveEventFeed} from '#/features/liveEvents/types'
|
import {
|
||||||
|
type LiveEventFeed,
|
||||||
|
type LiveEventFeedMetricContext,
|
||||||
|
} from '#/features/liveEvents/types'
|
||||||
|
|
||||||
const roundedStyles = [a.rounded_lg, a.curve_continuous]
|
const roundedStyles = [a.rounded_lg, a.curve_continuous]
|
||||||
|
|
||||||
export function LiveEventFeedCardWide({feed}: {feed: LiveEventFeed}) {
|
export function LiveEventFeedCardWide({
|
||||||
|
feed,
|
||||||
|
metricContext,
|
||||||
|
}: {
|
||||||
|
feed: LiveEventFeed
|
||||||
|
metricContext: LiveEventFeedMetricContext
|
||||||
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {gtPhone} = useBreakpoints()
|
const {gtPhone} = useBreakpoints()
|
||||||
|
|
||||||
@@ -30,7 +40,13 @@ export function LiveEventFeedCardWide({feed}: {feed: LiveEventFeed}) {
|
|||||||
<Link
|
<Link
|
||||||
to={url}
|
to={url}
|
||||||
label={_(msg`Live event happening now: ${feed.title}`)}
|
label={_(msg`Live event happening now: ${feed.title}`)}
|
||||||
style={[a.w_full]}>
|
style={[a.w_full]}
|
||||||
|
onPress={() => {
|
||||||
|
logger.metric('liveEvents:feed:click', {
|
||||||
|
feed: feed.url,
|
||||||
|
context: metricContext,
|
||||||
|
})
|
||||||
|
}}>
|
||||||
{({hovered, pressed}) => (
|
{({hovered, pressed}) => (
|
||||||
<View style={[roundedStyles, a.shadow_md, a.w_full]}>
|
<View style={[roundedStyles, a.shadow_md, a.w_full]}>
|
||||||
<View
|
<View
|
||||||
|
|||||||
@@ -16,16 +16,21 @@ import {
|
|||||||
type LiveEventPreferencesAction,
|
type LiveEventPreferencesAction,
|
||||||
useUpdateLiveEventPreferences,
|
useUpdateLiveEventPreferences,
|
||||||
} from '#/features/liveEvents/preferences'
|
} from '#/features/liveEvents/preferences'
|
||||||
import {type LiveEventFeed} from '#/features/liveEvents/types'
|
import {
|
||||||
|
type LiveEventFeed,
|
||||||
|
type LiveEventFeedMetricContext,
|
||||||
|
} from '#/features/liveEvents/types'
|
||||||
|
|
||||||
export {useDialogControl} from '#/components/Dialog'
|
export {useDialogControl} from '#/components/Dialog'
|
||||||
|
|
||||||
export function LiveEventFeedOptionsMenu({
|
export function LiveEventFeedOptionsMenu({
|
||||||
control,
|
control,
|
||||||
feed,
|
feed,
|
||||||
|
metricContext,
|
||||||
}: {
|
}: {
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
feed: LiveEventFeed
|
feed: LiveEventFeed
|
||||||
|
metricContext: LiveEventFeedMetricContext
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
return (
|
return (
|
||||||
@@ -34,7 +39,7 @@ export function LiveEventFeedOptionsMenu({
|
|||||||
<Dialog.ScrollableInner
|
<Dialog.ScrollableInner
|
||||||
label={_(msg`Configure live event banner`)}
|
label={_(msg`Configure live event banner`)}
|
||||||
style={[web({maxWidth: 400})]}>
|
style={[web({maxWidth: 400})]}>
|
||||||
<Inner control={control} feed={feed} />
|
<Inner control={control} feed={feed} metricContext={metricContext} />
|
||||||
<Dialog.Close />
|
<Dialog.Close />
|
||||||
</Dialog.ScrollableInner>
|
</Dialog.ScrollableInner>
|
||||||
</Dialog.Outer>
|
</Dialog.Outer>
|
||||||
@@ -44,9 +49,11 @@ export function LiveEventFeedOptionsMenu({
|
|||||||
function Inner({
|
function Inner({
|
||||||
control,
|
control,
|
||||||
feed,
|
feed,
|
||||||
|
metricContext,
|
||||||
}: {
|
}: {
|
||||||
control: Dialog.DialogControlProps
|
control: Dialog.DialogControlProps
|
||||||
feed: LiveEventFeed
|
feed: LiveEventFeed
|
||||||
|
metricContext: LiveEventFeedMetricContext
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const canUndo = useRef(true)
|
const canUndo = useRef(true)
|
||||||
@@ -57,6 +64,8 @@ function Inner({
|
|||||||
error: rawError,
|
error: rawError,
|
||||||
variables,
|
variables,
|
||||||
} = useUpdateLiveEventPreferences({
|
} = useUpdateLiveEventPreferences({
|
||||||
|
feed,
|
||||||
|
metricContext,
|
||||||
onSuccess() {
|
onSuccess() {
|
||||||
toast.show(
|
toast.show(
|
||||||
<toast.Outer>
|
<toast.Outer>
|
||||||
|
|||||||
@@ -16,7 +16,9 @@ export function LiveEventFeedsSettingsToggle() {
|
|||||||
isPending,
|
isPending,
|
||||||
data: updatedPrefs,
|
data: updatedPrefs,
|
||||||
mutate: update,
|
mutate: update,
|
||||||
} = useUpdateLiveEventPreferences()
|
} = useUpdateLiveEventPreferences({
|
||||||
|
metricContext: 'settings',
|
||||||
|
})
|
||||||
const hideAllFeeds = !!(updatedPrefs || prefs)?.hideAllFeeds
|
const hideAllFeeds = !!(updatedPrefs || prefs)?.hideAllFeeds
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ import {
|
|||||||
usePreferencesQuery,
|
usePreferencesQuery,
|
||||||
} from '#/state/queries/preferences'
|
} from '#/state/queries/preferences'
|
||||||
import {useAgent} from '#/state/session'
|
import {useAgent} from '#/state/session'
|
||||||
|
import * as env from '#/env'
|
||||||
|
import {
|
||||||
|
type LiveEventFeed,
|
||||||
|
type LiveEventFeedMetricContext,
|
||||||
|
} from '#/features/liveEvents/types'
|
||||||
|
|
||||||
export type LiveEventPreferencesAction = Parameters<
|
export type LiveEventPreferencesAction = Parameters<
|
||||||
Agent['updateLiveEventPreferences']
|
Agent['updateLiveEventPreferences']
|
||||||
@@ -46,7 +51,9 @@ function useWebOnlyDebugLiveEventPreferences() {
|
|||||||
}, [agent, queryClient])
|
}, [agent, queryClient])
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useUpdateLiveEventPreferences(props?: {
|
export function useUpdateLiveEventPreferences(props: {
|
||||||
|
feed?: LiveEventFeed
|
||||||
|
metricContext: LiveEventFeedMetricContext
|
||||||
onSuccess?: () => void
|
onSuccess?: () => void
|
||||||
onError?: (error: Error) => void
|
onError?: (error: Error) => void
|
||||||
}) {
|
}) {
|
||||||
@@ -64,19 +71,37 @@ export function useUpdateLiveEventPreferences(props?: {
|
|||||||
const updated = await agent.updateLiveEventPreferences(action)
|
const updated = await agent.updateLiveEventPreferences(action)
|
||||||
|
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case 'hideFeed': {
|
case 'hideFeed':
|
||||||
logger.metric('liveEventFeeds:hideFeed', {feedId: action.id})
|
case 'unhideFeed': {
|
||||||
|
if (!props.feed) {
|
||||||
|
if (env.IS_DEV) {
|
||||||
|
throw new Error(
|
||||||
|
'props.feed is required when calling hideFeed or unhideFeed',
|
||||||
|
)
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'unhideFeed': {
|
|
||||||
logger.metric('liveEventFeeds:unhideFeed', {feedId: action.id})
|
logger.metric(
|
||||||
|
action.type === 'hideFeed'
|
||||||
|
? 'liveEvents:feed:hide'
|
||||||
|
: 'liveEvents:feed:unhide',
|
||||||
|
{
|
||||||
|
feed: props.feed.url,
|
||||||
|
context: props.metricContext,
|
||||||
|
},
|
||||||
|
)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case 'toggleHideAllFeeds': {
|
case 'toggleHideAllFeeds': {
|
||||||
if (updated!.hideAllFeeds) {
|
if (updated!.hideAllFeeds) {
|
||||||
logger.metric('liveEventFeed:hideAllFeeds', {})
|
logger.metric('liveEvents:hideAllFeeds', {
|
||||||
|
context: props.metricContext,
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
logger.metric('liveEventFeed:unhideAllFeeds', {})
|
logger.metric('liveEvents:unhideAllFeeds', {
|
||||||
|
context: props.metricContext,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export type LiveEventFeedImage = {
|
|||||||
|
|
||||||
export type LiveEventFeed = {
|
export type LiveEventFeed = {
|
||||||
id: string
|
id: string
|
||||||
|
preview: boolean
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
images: Record<LiveEventFeedImageLayout, LiveEventFeedImage>
|
images: Record<LiveEventFeedImageLayout, LiveEventFeedImage>
|
||||||
@@ -18,3 +19,9 @@ export type LiveEventFeed = {
|
|||||||
export type LiveEventsWorkerResponse = {
|
export type LiveEventsWorkerResponse = {
|
||||||
feeds: LiveEventFeed[]
|
feeds: LiveEventFeed[]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type LiveEventFeedMetricContext =
|
||||||
|
| 'explore'
|
||||||
|
| 'discover'
|
||||||
|
| 'sidebar'
|
||||||
|
| 'settings'
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ import {enabledLogLevels} from '#/logger/util'
|
|||||||
import {isNative} from '#/platform/detection'
|
import {isNative} from '#/platform/detection'
|
||||||
import {ENV} from '#/env'
|
import {ENV} from '#/env'
|
||||||
|
|
||||||
|
export {type MetricEvents as Metrics} from '#/logger/metrics'
|
||||||
|
|
||||||
const TRANSPORTS: Transport[] = (function configureTransports() {
|
const TRANSPORTS: Transport[] = (function configureTransports() {
|
||||||
switch (ENV) {
|
switch (ENV) {
|
||||||
case 'production': {
|
case 'production': {
|
||||||
|
|||||||
+19
-4
@@ -1,5 +1,6 @@
|
|||||||
import {type NotificationReason} from '#/lib/hooks/useNotificationHandler'
|
import {type NotificationReason} from '#/lib/hooks/useNotificationHandler'
|
||||||
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
import {type FeedDescriptor} from '#/state/queries/post-feed'
|
||||||
|
import {type LiveEventFeedMetricContext} from '#/features/liveEvents/types'
|
||||||
|
|
||||||
export type MetricEvents = {
|
export type MetricEvents = {
|
||||||
// App events
|
// App events
|
||||||
@@ -789,8 +790,22 @@ export type MetricEvents = {
|
|||||||
// user pressed the remove all data button
|
// user pressed the remove all data button
|
||||||
'contacts:settings:removeData': {}
|
'contacts:settings:removeData': {}
|
||||||
|
|
||||||
'liveEventFeeds:hideFeed': {feedId: string}
|
'liveEvents:feed:click': {
|
||||||
'liveEventFeeds:unhideFeed': {feedId: string}
|
feed: string
|
||||||
'liveEventFeed:hideAllFeeds': {}
|
context: LiveEventFeedMetricContext
|
||||||
'liveEventFeed:unhideAllFeeds': {}
|
}
|
||||||
|
'liveEvents:feed:hide': {
|
||||||
|
feed: string
|
||||||
|
context: LiveEventFeedMetricContext
|
||||||
|
}
|
||||||
|
'liveEvents:feed:unhide': {
|
||||||
|
feed: string
|
||||||
|
context: LiveEventFeedMetricContext
|
||||||
|
}
|
||||||
|
'liveEvents:hideAllFeeds': {
|
||||||
|
context: LiveEventFeedMetricContext
|
||||||
|
}
|
||||||
|
'liveEvents:unhideAllFeeds': {
|
||||||
|
context: LiveEventFeedMetricContext
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,4 +45,8 @@ export const DEFAULT_LOGGED_OUT_PREFERENCES: UsePreferencesQueryResponse = {
|
|||||||
verificationPrefs: {
|
verificationPrefs: {
|
||||||
hideBadges: false,
|
hideBadges: false,
|
||||||
},
|
},
|
||||||
|
liveEventPreferences: {
|
||||||
|
hideAllFeeds: false,
|
||||||
|
hiddenFeedIds: [],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,12 +82,12 @@
|
|||||||
"@atproto/xrpc" "^0.7.6"
|
"@atproto/xrpc" "^0.7.6"
|
||||||
"@atproto/xrpc-server" "^0.10.0"
|
"@atproto/xrpc-server" "^0.10.0"
|
||||||
|
|
||||||
"@atproto/api@^0.18.13":
|
"@atproto/api@^0.18.15":
|
||||||
version "0.18.13"
|
version "0.18.15"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.18.13.tgz#63eee310e6715752eb87748323cf9ab57dd91e4b"
|
resolved "https://registry.yarnpkg.com/@atproto/api/-/api-0.18.15.tgz#25ce82081216bdefbf5397220de76ac3ba9e3f5d"
|
||||||
integrity sha512-CULZ01pSJDltLS/Gc9MMrhFzB6OM3ezyZw7KoeLT/sBfwgA1ddA4mWdTh7DIRosPRigXtA05bnoiCutZbQDo+Q==
|
integrity sha512-GeaTP7HMRZa8jD6trMuTACa8t2jkFtRmcwWgrB0FT7l9jVCXrKpYupWeIeauEgWHNwWUUiaq3LmCox+HBy8ZMQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@atproto/common-web" "^0.4.11"
|
"@atproto/common-web" "^0.4.12"
|
||||||
"@atproto/lexicon" "^0.6.0"
|
"@atproto/lexicon" "^0.6.0"
|
||||||
"@atproto/syntax" "^0.4.2"
|
"@atproto/syntax" "^0.4.2"
|
||||||
"@atproto/xrpc" "^0.7.7"
|
"@atproto/xrpc" "^0.7.7"
|
||||||
@@ -208,13 +208,13 @@
|
|||||||
pino-http "^8.2.1"
|
pino-http "^8.2.1"
|
||||||
typed-emitter "^2.1.0"
|
typed-emitter "^2.1.0"
|
||||||
|
|
||||||
"@atproto/common-web@^0.4.11":
|
"@atproto/common-web@^0.4.12":
|
||||||
version "0.4.11"
|
version "0.4.12"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/common-web/-/common-web-0.4.11.tgz#eb41dc02c1ea4221388630e193d181fb098186e0"
|
resolved "https://registry.yarnpkg.com/@atproto/common-web/-/common-web-0.4.12.tgz#04135bef480d9e12cfef124ee45d8236764e7509"
|
||||||
integrity sha512-VHejNmSABU8/03VrQ3e36AmT5U3UIeio+qSUqCrO1oNgrJcWfGy1rpj0FVtUugWF8Un29+yzkukzWGZfXL70rQ==
|
integrity sha512-3aCJemqM/fkHQrVPbTCHCdiVstKFI+2LkFLvUhO6XZP0EqUZa/rg/CIZBKTFUWu9I5iYiaEiXL9VwcDRpEevSw==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@atproto/lex-data" "0.0.7"
|
"@atproto/lex-data" "0.0.8"
|
||||||
"@atproto/lex-json" "0.0.7"
|
"@atproto/lex-json" "0.0.8"
|
||||||
zod "^3.23.8"
|
zod "^3.23.8"
|
||||||
|
|
||||||
"@atproto/common-web@^0.4.4", "@atproto/common-web@^0.4.6":
|
"@atproto/common-web@^0.4.4", "@atproto/common-web@^0.4.6":
|
||||||
@@ -415,10 +415,10 @@
|
|||||||
uint8arrays "3.0.0"
|
uint8arrays "3.0.0"
|
||||||
unicode-segmenter "^0.14.0"
|
unicode-segmenter "^0.14.0"
|
||||||
|
|
||||||
"@atproto/lex-data@0.0.7":
|
"@atproto/lex-data@0.0.8":
|
||||||
version "0.0.7"
|
version "0.0.8"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/lex-data/-/lex-data-0.0.7.tgz#6aa87423f6d47849bec8ff3ca0b00ce93964adc8"
|
resolved "https://registry.yarnpkg.com/@atproto/lex-data/-/lex-data-0.0.8.tgz#46cc261efbfa6cc05bf04439d2d73cd8386b467d"
|
||||||
integrity sha512-W/Q5o9o7n2Sv3UywckChu01X5lwQUtaiiOkGJLnRsdkQTyC6813nPgY+p2sG7NwwM+82lu+FUV9fE/Ul3VqaJw==
|
integrity sha512-1Y5tz7BkS7380QuLNXaE8GW8Xba+mRWugt8BKM4BUFYjjUZdmirU8lr72iM4XlEBrzRu8Cfvj+MbsbYaZv+IgA==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@atproto/syntax" "0.4.2"
|
"@atproto/syntax" "0.4.2"
|
||||||
multiformats "^9.9.0"
|
multiformats "^9.9.0"
|
||||||
@@ -451,12 +451,12 @@
|
|||||||
"@atproto/lex-data" "0.0.3"
|
"@atproto/lex-data" "0.0.3"
|
||||||
tslib "^2.8.1"
|
tslib "^2.8.1"
|
||||||
|
|
||||||
"@atproto/lex-json@0.0.7":
|
"@atproto/lex-json@0.0.8":
|
||||||
version "0.0.7"
|
version "0.0.8"
|
||||||
resolved "https://registry.yarnpkg.com/@atproto/lex-json/-/lex-json-0.0.7.tgz#c06e1fc3e06d739bbb74694f5d846055bed37866"
|
resolved "https://registry.yarnpkg.com/@atproto/lex-json/-/lex-json-0.0.8.tgz#03290762d9368b029488ee0a0766d1a34063255c"
|
||||||
integrity sha512-bjNPD5M/MhLfjNM7tcxuls80UgXpHqxdOxDXEUouAtZQV/nIDhGjmNUvKxOmOgnDsiZRnT2g5y3onrnjH3a44g==
|
integrity sha512-w1Qmkae1QhmNz+i1Zm3xr3jp0UPPRENmdlpU0qIrdxWDo9W4Mzkeyc3eSoa+Zs+zN8xkRSQw7RLZte/B7Ipdwg==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@atproto/lex-data" "0.0.7"
|
"@atproto/lex-data" "0.0.8"
|
||||||
tslib "^2.8.1"
|
tslib "^2.8.1"
|
||||||
|
|
||||||
"@atproto/lex-resolver@0.0.5":
|
"@atproto/lex-resolver@0.0.5":
|
||||||
|
|||||||
Reference in New Issue
Block a user