properly set the starter pack for android users
This commit is contained in:
+1
-3
@@ -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: [
|
||||
|
||||
@@ -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-<name>-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
|
||||
}
|
||||
|
||||
@@ -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(),
|
||||
})
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user