Add feature gate and link validation error client event

This commit is contained in:
Alex Benzer
2025-12-06 13:48:41 -08:00
parent 435483d31e
commit 7379dd8ca8
3 changed files with 23 additions and 6 deletions
+20 -4
View File
@@ -31,7 +31,13 @@ export function useLiveLinkMetaQuery(url: string | null) {
if (!url) return undefined
if (allowedDomains.length === 0) {
throw new Error(_(msg`You are not allowed to go live`))
const error = _(msg`You are not allowed to go live`)
logger.metric(
'live:linkValidation:error',
{error, url},
{statsig: true},
)
throw new Error(error)
}
const urlp = new URL(url)
@@ -41,11 +47,21 @@ export function useLiveLinkMetaQuery(url: string | null) {
domain.includes('twitch'),
)
if (isTwitchAttempt && !urlp.hostname.includes('twitch')) {
throw new Error(
_(msg`Only Twitch links are supported during the beta`),
const error = _(msg`Only Twitch links are supported during the beta`)
logger.metric(
'live:linkValidation:error',
{error, url},
{statsig: true},
)
throw new Error(error)
}
throw new Error(_(msg`${urlp.hostname} is not a valid URL`))
const error = _(msg`${urlp.hostname} is not a valid URL`)
logger.metric(
'live:linkValidation:error',
{error, url},
{statsig: true},
)
throw new Error(error)
}
return await getLinkMeta(agent, url)
+1
View File
@@ -556,6 +556,7 @@ export type MetricEvents = {
'live:card:openProfile': {subject: string}
'live:view:profile': {subject: string}
'live:view:post': {subject: string; feed?: string}
'live:linkValidation:error': {error: string; url?: string}
'share:open': {context: 'feed' | 'thread'}
'share:press:copyLink': {}
+2 -2
View File
@@ -95,7 +95,7 @@ export function useLiveNowConfig() {
export function useCanGoLive(did?: string) {
const gate = useGate()
const isInBeta = __DEV__ ? true : gate('live_now_beta')
const isInBeta = gate('live_now_beta')
if (!isInBeta || !did) {
return false
@@ -112,7 +112,7 @@ export function useCanGoLive(did?: string) {
export function useAllowedLiveDomains(did?: string): string[] {
const config = useLiveNowConfig()
const gate = useGate()
const isInBeta = __DEV__ ? true : gate('live_now_beta')
const isInBeta = gate('live_now_beta')
if (!isInBeta || !did) {
return []