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:
@@ -18,11 +18,18 @@ export async function openPicker(opts?: ImagePickerOptions) {
|
||||
Toast.show('You may only select up to 4 images')
|
||||
}
|
||||
|
||||
return (response.assets ?? []).slice(0, 4).map(image => ({
|
||||
mime: 'image/jpeg',
|
||||
height: image.height,
|
||||
width: image.width,
|
||||
path: image.uri,
|
||||
size: getDataUriSize(image.uri),
|
||||
}))
|
||||
return (response.assets ?? [])
|
||||
.slice(0, 4)
|
||||
.filter(asset => {
|
||||
if (asset.mimeType?.startsWith('image/')) return true
|
||||
Toast.show('Only image files are supported')
|
||||
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'
|
||||
import {useSession} from '../../state/session'
|
||||
import {sha256} from 'js-sha256'
|
||||
import {Events} from './events'
|
||||
|
||||
const statsigOptions = {
|
||||
environment: {
|
||||
@@ -17,12 +18,28 @@ const statsigOptions = {
|
||||
initTimeoutMs: 1,
|
||||
}
|
||||
|
||||
export function logEvent(
|
||||
eventName: string,
|
||||
value?: string | number | null,
|
||||
metadata?: Record<string, string> | null,
|
||||
type FlatJSONRecord = Record<
|
||||
string,
|
||||
string | number | boolean | null | undefined
|
||||
>
|
||||
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user