diff --git a/app.config.js b/app.config.js index bd8598ef08..8a98065033 100644 --- a/app.config.js +++ b/app.config.js @@ -59,9 +59,6 @@ module.exports = function (config) { slug: 'bluesky', scheme: 'bluesky', owner: 'blueskysocial', - runtimeVersion: { - policy: 'appVersion', - }, orientation: 'portrait', icon: './assets/icon.png', userInterfaceStyle: 'automatic', @@ -134,6 +131,7 @@ module.exports = function (config) { backgroundImage: './assets/icon-android-background.png', backgroundColor: '#1185FE', }, + versionCode: 239, googleServicesFile: './google-services.json', package: 'xyz.blueskyweb.app', intentFilters: [ diff --git a/src/components/hooks/useStarterPackEntry.android.ts b/src/components/hooks/useStarterPackEntry.android.ts index 041d50be90..939dfd91a5 100644 --- a/src/components/hooks/useStarterPackEntry.android.ts +++ b/src/components/hooks/useStarterPackEntry.android.ts @@ -1,35 +1,47 @@ import React from 'react' -import {useSetUsedStarterPack} from 'state/preferences/starter-pack' +import {makeStarterPackLink} from 'lib/routes/links' +import { + useSetUsedStarterPack, + useUsedStarterPack, +} from 'state/preferences/starter-pack' import GooglePlayReferrer from '../../../modules/expo-google-play-referrer' export function useStarterPackEntry() { const [ready, setReady] = React.useState(false) + const usedStarterPack = useUsedStarterPack() const setUsedStarterPack = useSetUsedStarterPack() React.useEffect(() => { + if (ready) return ;(async () => { const res = await GooglePlayReferrer.getReferrerInfoAsync() - if ( - res && - res.installReferrer && - res.installReferrer.startsWith('https://bsky.app/start/') - ) { - const [_, _start, name, rkey] = new URL( - res.installReferrer, - ).pathname.split('/') + if (res && res.installReferrer) { + // The `utm_content` parameter should be `starterpack--rkey>`. Let's try to get it from the parameters + // and create a URI for it if it's valid. + const parts = res.installReferrer.split('&') + const starterPackSource = parts + .find(part => part.startsWith('utm_content=')) + ?.split('=')[1] + const sourceParts = starterPackSource?.split('-') - if (name && rkey) { - setUsedStarterPack({ - uri: res.installReferrer, - }) + if (sourceParts?.length === 3 && sourceParts[0] === 'starterpack') { + // Android doesn't clear the referrer info for a total of 90 days. We want to make sure that we don't + // retrigger this on accident. + // We won't actually set `lastUsedUri` until a _successful_ use of the starter pack, meaning a new account + // has actually completed onboarding with the given starter pack. + const uri = makeStarterPackLink(sourceParts[1], sourceParts[2]) + if (uri !== usedStarterPack?.lastUsedUri) { + setUsedStarterPack({ + uri: makeStarterPackLink(sourceParts[1], sourceParts[2]), + }) + } } } - setReady(true) })() - }, [setUsedStarterPack]) + }, [ready, setUsedStarterPack, usedStarterPack?.lastUsedUri]) return ready } diff --git a/src/state/persisted/schema.ts b/src/state/persisted/schema.ts index 06c10b2ae0..90d71e7242 100644 --- a/src/state/persisted/schema.ts +++ b/src/state/persisted/schema.ts @@ -94,6 +94,7 @@ export const schema = z.object({ cid: z.string().optional(), initialFeed: z.string().optional(), isClip: z.boolean().optional(), + lastUsedUri: z.string().optional(), }) .optional(), }) diff --git a/src/state/preferences/starter-pack.tsx b/src/state/preferences/starter-pack.tsx index 48fd4298bc..7099845a32 100644 --- a/src/state/preferences/starter-pack.tsx +++ b/src/state/preferences/starter-pack.tsx @@ -3,7 +3,13 @@ import React from 'react' import * as persisted from '#/state/persisted' type StateContext = - | {uri: string; cid?: string; initialFeed?: string; isClip?: boolean} + | { + uri: string + cid?: string + initialFeed?: string + isClip?: boolean + lastUsedUri?: string + } | undefined type SetContext = (v: StateContext) => void