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 (!url) return undefined
|
||||||
|
|
||||||
if (allowedDomains.length === 0) {
|
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)
|
const urlp = new URL(url)
|
||||||
@@ -41,11 +47,21 @@ export function useLiveLinkMetaQuery(url: string | null) {
|
|||||||
domain.includes('twitch'),
|
domain.includes('twitch'),
|
||||||
)
|
)
|
||||||
if (isTwitchAttempt && !urlp.hostname.includes('twitch')) {
|
if (isTwitchAttempt && !urlp.hostname.includes('twitch')) {
|
||||||
throw new Error(
|
const error = _(msg`Only Twitch links are supported during the beta`)
|
||||||
_(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)
|
return await getLinkMeta(agent, url)
|
||||||
|
|||||||
@@ -556,6 +556,7 @@ export type MetricEvents = {
|
|||||||
'live:card:openProfile': {subject: string}
|
'live:card:openProfile': {subject: string}
|
||||||
'live:view:profile': {subject: string}
|
'live:view:profile': {subject: string}
|
||||||
'live:view:post': {subject: string; feed?: string}
|
'live:view:post': {subject: string; feed?: string}
|
||||||
|
'live:linkValidation:error': {error: string; url?: string}
|
||||||
|
|
||||||
'share:open': {context: 'feed' | 'thread'}
|
'share:open': {context: 'feed' | 'thread'}
|
||||||
'share:press:copyLink': {}
|
'share:press:copyLink': {}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ export function useLiveNowConfig() {
|
|||||||
|
|
||||||
export function useCanGoLive(did?: string) {
|
export function useCanGoLive(did?: string) {
|
||||||
const gate = useGate()
|
const gate = useGate()
|
||||||
const isInBeta = __DEV__ ? true : gate('live_now_beta')
|
const isInBeta = gate('live_now_beta')
|
||||||
|
|
||||||
if (!isInBeta || !did) {
|
if (!isInBeta || !did) {
|
||||||
return false
|
return false
|
||||||
@@ -112,7 +112,7 @@ export function useCanGoLive(did?: string) {
|
|||||||
export function useAllowedLiveDomains(did?: string): string[] {
|
export function useAllowedLiveDomains(did?: string): string[] {
|
||||||
const config = useLiveNowConfig()
|
const config = useLiveNowConfig()
|
||||||
const gate = useGate()
|
const gate = useGate()
|
||||||
const isInBeta = __DEV__ ? true : gate('live_now_beta')
|
const isInBeta = gate('live_now_beta')
|
||||||
|
|
||||||
if (!isInBeta || !did) {
|
if (!isInBeta || !did) {
|
||||||
return []
|
return []
|
||||||
|
|||||||
Reference in New Issue
Block a user