Merge remote-tracking branch 'origin' into 3p-moderators
* origin: filter out files with non-image mime types Send route name with Statsig events (#3194) Tweak prompt styles on mobile web (#3193)
This commit is contained in:
+9
-2
@@ -79,8 +79,8 @@ import {createNativeStackNavigatorWithAuth} from './view/shell/createNativeStack
|
|||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {i18n, MessageDescriptor} from '@lingui/core'
|
import {i18n, MessageDescriptor} from '@lingui/core'
|
||||||
import HashtagScreen from '#/screens/Hashtag'
|
import HashtagScreen from '#/screens/Hashtag'
|
||||||
import {logEvent} from './lib/statsig/statsig'
|
|
||||||
import {ProfileLabelerLikedByScreen} from '#/screens/Profile/ProfileLabelerLikedBy'
|
import {ProfileLabelerLikedByScreen} from '#/screens/Profile/ProfileLabelerLikedBy'
|
||||||
|
import {logEvent, attachRouteToLogEvents} from './lib/statsig/statsig'
|
||||||
|
|
||||||
const navigationRef = createNavigationContainerRef<AllNavigatorParams>()
|
const navigationRef = createNavigationContainerRef<AllNavigatorParams>()
|
||||||
|
|
||||||
@@ -555,6 +555,7 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
|||||||
linking={LINKING}
|
linking={LINKING}
|
||||||
theme={theme}
|
theme={theme}
|
||||||
onReady={() => {
|
onReady={() => {
|
||||||
|
attachRouteToLogEvents(getCurrentRouteName)
|
||||||
logModuleInitTime()
|
logModuleInitTime()
|
||||||
onReady()
|
onReady()
|
||||||
}}>
|
}}>
|
||||||
@@ -563,6 +564,10 @@ function RoutesContainer({children}: React.PropsWithChildren<{}>) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentRouteName() {
|
||||||
|
return navigationRef.getCurrentRoute()?.name
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These helpers can be used from outside of the RoutesContainer
|
* These helpers can be used from outside of the RoutesContainer
|
||||||
* (eg in the state models).
|
* (eg in the state models).
|
||||||
@@ -668,7 +673,9 @@ function logModuleInitTime() {
|
|||||||
performance.now() - global.__BUNDLE_START_TIME__,
|
performance.now() - global.__BUNDLE_START_TIME__,
|
||||||
)
|
)
|
||||||
console.log(`Time to first paint: ${initMs} ms`)
|
console.log(`Time to first paint: ${initMs} ms`)
|
||||||
logEvent('init', initMs)
|
logEvent('init', {
|
||||||
|
initMs,
|
||||||
|
})
|
||||||
|
|
||||||
if (__DEV__) {
|
if (__DEV__) {
|
||||||
// This log is noisy, so keep false committed
|
// This log is noisy, so keep false committed
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import {View} from 'react-native'
|
|||||||
import {msg} from '@lingui/macro'
|
import {msg} from '@lingui/macro'
|
||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {isNative} from '#/platform/detection'
|
||||||
import {useTheme, atoms as a, useBreakpoints} from '#/alf'
|
import {useTheme, atoms as a, useBreakpoints} from '#/alf'
|
||||||
import {Text} from '#/components/Typography'
|
import {Text} from '#/components/Typography'
|
||||||
import {Button, ButtonColor, ButtonText} from '#/components/Button'
|
import {Button, ButtonColor, ButtonText} from '#/components/Button'
|
||||||
@@ -84,7 +85,8 @@ export function Actions({children}: React.PropsWithChildren<{}>) {
|
|||||||
a.justify_end,
|
a.justify_end,
|
||||||
gtMobile
|
gtMobile
|
||||||
? [a.flex_row, a.flex_row_reverse, a.justify_start]
|
? [a.flex_row, a.flex_row_reverse, a.justify_start]
|
||||||
: [a.flex_col, a.pt_md, a.pb_4xl],
|
: [a.flex_col],
|
||||||
|
isNative && [a.pb_4xl],
|
||||||
]}>
|
]}>
|
||||||
{children}
|
{children}
|
||||||
</View>
|
</View>
|
||||||
|
|||||||
@@ -18,11 +18,18 @@ export async function openPicker(opts?: ImagePickerOptions) {
|
|||||||
Toast.show('You may only select up to 4 images')
|
Toast.show('You may only select up to 4 images')
|
||||||
}
|
}
|
||||||
|
|
||||||
return (response.assets ?? []).slice(0, 4).map(image => ({
|
return (response.assets ?? [])
|
||||||
mime: 'image/jpeg',
|
.slice(0, 4)
|
||||||
height: image.height,
|
.filter(asset => {
|
||||||
width: image.width,
|
if (asset.mimeType?.startsWith('image/')) return true
|
||||||
path: image.uri,
|
Toast.show('Only image files are supported')
|
||||||
size: getDataUriSize(image.uri),
|
return false
|
||||||
}))
|
})
|
||||||
|
.map(image => ({
|
||||||
|
mime: 'image/jpeg',
|
||||||
|
height: image.height,
|
||||||
|
width: image.width,
|
||||||
|
path: image.uri,
|
||||||
|
size: getDataUriSize(image.uri),
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
export type Events = {
|
||||||
|
init: {
|
||||||
|
initMs: number
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
} from 'statsig-react-native-expo'
|
} from 'statsig-react-native-expo'
|
||||||
import {useSession} from '../../state/session'
|
import {useSession} from '../../state/session'
|
||||||
import {sha256} from 'js-sha256'
|
import {sha256} from 'js-sha256'
|
||||||
|
import {Events} from './events'
|
||||||
|
|
||||||
const statsigOptions = {
|
const statsigOptions = {
|
||||||
environment: {
|
environment: {
|
||||||
@@ -17,12 +18,28 @@ const statsigOptions = {
|
|||||||
initTimeoutMs: 1,
|
initTimeoutMs: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logEvent(
|
type FlatJSONRecord = Record<
|
||||||
eventName: string,
|
string,
|
||||||
value?: string | number | null,
|
string | number | boolean | null | undefined
|
||||||
metadata?: Record<string, string> | null,
|
>
|
||||||
|
|
||||||
|
let getCurrentRouteName: () => string | null | undefined = () => null
|
||||||
|
|
||||||
|
export function attachRouteToLogEvents(
|
||||||
|
getRouteName: () => string | null | undefined,
|
||||||
) {
|
) {
|
||||||
Statsig.logEvent(eventName, value, metadata)
|
getCurrentRouteName = getRouteName
|
||||||
|
}
|
||||||
|
|
||||||
|
export function logEvent<E extends keyof Events>(
|
||||||
|
eventName: E & string,
|
||||||
|
rawMetadata?: Events[E] & FlatJSONRecord,
|
||||||
|
) {
|
||||||
|
const fullMetadata = {
|
||||||
|
...rawMetadata,
|
||||||
|
} as Record<string, string> // Statsig typings are unnecessarily strict here.
|
||||||
|
fullMetadata.routeName = getCurrentRouteName() ?? '(Uninitialized)'
|
||||||
|
Statsig.logEvent(eventName, null, fullMetadata)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function useGate(gateName: string) {
|
export function useGate(gateName: string) {
|
||||||
|
|||||||
@@ -334,7 +334,7 @@ let ProfileMenu = ({
|
|||||||
confirmButtonCta={
|
confirmButtonCta={
|
||||||
profile.viewer?.blocking ? _(msg`Unblock`) : _(msg`Block`)
|
profile.viewer?.blocking ? _(msg`Unblock`) : _(msg`Block`)
|
||||||
}
|
}
|
||||||
confirmButtonColor="negative"
|
confirmButtonColor={profile.viewer?.blocking ? undefined : 'negative'}
|
||||||
/>
|
/>
|
||||||
</EventStopper>
|
</EventStopper>
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user