Add feature gate and link validation error client event
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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': {}
|
||||
|
||||
@@ -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 []
|
||||
|
||||
Reference in New Issue
Block a user