From 54faa7e176ed2f8644ef4941c8a65522107a84c1 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Thu, 16 Nov 2023 12:53:43 -0800 Subject: Remove deprecated models and mobx usage (react-query refactor) (#1934) * Update login page to use service query * Update modal to use session instead of store * Move image sizes cache off store * Update settings to no longer use store * Update link-meta fetch to use agent instead of rootstore * Remove deprecated resolveName() * Delete deprecated link-metas cache * Delete deprecated posts cache * Delete all remaining mobx models, including the root store * Strip out unused mobx observer wrappers --- src/lib/analytics/analytics.tsx | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/lib/analytics') diff --git a/src/lib/analytics/analytics.tsx b/src/lib/analytics/analytics.tsx index 4b955b365..3a8254eb1 100644 --- a/src/lib/analytics/analytics.tsx +++ b/src/lib/analytics/analytics.tsx @@ -7,13 +7,21 @@ import { useAnalytics as useAnalyticsOrig, ClientMethods, } from '@segment/analytics-react-native' -import {AppInfo} from 'state/models/root-store' +import {z} from 'zod' import {useSession} from '#/state/session' import {sha256} from 'js-sha256' import {ScreenEvent, TrackEvent} from './types' import {logger} from '#/logger' import {listenSessionLoaded} from '#/state/events' +export const appInfo = z.object({ + build: z.string().optional(), + name: z.string().optional(), + namespace: z.string().optional(), + version: z.string().optional(), +}) +export type AppInfo = z.infer + const segmentClient = createClient({ writeKey: '8I6DsgfiSLuoONyaunGoiQM7A6y2ybdI', trackAppLifecycleEvents: false, @@ -128,7 +136,11 @@ async function writeAppInfo(value: AppInfo) { await AsyncStorage.setItem('BSKY_APP_INFO', JSON.stringify(value)) } -async function readAppInfo(): Promise | undefined> { +async function readAppInfo(): Promise { const rawData = await AsyncStorage.getItem('BSKY_APP_INFO') - return rawData ? JSON.parse(rawData) : undefined + const obj = rawData ? JSON.parse(rawData) : undefined + if (!obj || typeof obj !== 'object') { + return undefined + } + return obj } -- cgit 1.4.1