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',
|
slug: 'bluesky',
|
||||||
scheme: 'bluesky',
|
scheme: 'bluesky',
|
||||||
owner: 'blueskysocial',
|
owner: 'blueskysocial',
|
||||||
runtimeVersion: {
|
|
||||||
policy: 'appVersion',
|
|
||||||
},
|
|
||||||
orientation: 'portrait',
|
orientation: 'portrait',
|
||||||
icon: './assets/icon.png',
|
icon: './assets/icon.png',
|
||||||
userInterfaceStyle: 'automatic',
|
userInterfaceStyle: 'automatic',
|
||||||
@@ -134,6 +131,7 @@ module.exports = function (config) {
|
|||||||
backgroundImage: './assets/icon-android-background.png',
|
backgroundImage: './assets/icon-android-background.png',
|
||||||
backgroundColor: '#1185FE',
|
backgroundColor: '#1185FE',
|
||||||
},
|
},
|
||||||
|
versionCode: 239,
|
||||||
googleServicesFile: './google-services.json',
|
googleServicesFile: './google-services.json',
|
||||||
package: 'xyz.blueskyweb.app',
|
package: 'xyz.blueskyweb.app',
|
||||||
intentFilters: [
|
intentFilters: [
|
||||||
|
|||||||
@@ -1,35 +1,47 @@
|
|||||||
import React from 'react'
|
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'
|
import GooglePlayReferrer from '../../../modules/expo-google-play-referrer'
|
||||||
|
|
||||||
export function useStarterPackEntry() {
|
export function useStarterPackEntry() {
|
||||||
const [ready, setReady] = React.useState(false)
|
const [ready, setReady] = React.useState(false)
|
||||||
|
const usedStarterPack = useUsedStarterPack()
|
||||||
const setUsedStarterPack = useSetUsedStarterPack()
|
const setUsedStarterPack = useSetUsedStarterPack()
|
||||||
|
|
||||||
React.useEffect(() => {
|
React.useEffect(() => {
|
||||||
|
if (ready) return
|
||||||
;(async () => {
|
;(async () => {
|
||||||
const res = await GooglePlayReferrer.getReferrerInfoAsync()
|
const res = await GooglePlayReferrer.getReferrerInfoAsync()
|
||||||
|
|
||||||
if (
|
if (res && res.installReferrer) {
|
||||||
res &&
|
// The `utm_content` parameter should be `starterpack-<name>-rkey>`. Let's try to get it from the parameters
|
||||||
res.installReferrer &&
|
// and create a URI for it if it's valid.
|
||||||
res.installReferrer.startsWith('https://bsky.app/start/')
|
const parts = res.installReferrer.split('&')
|
||||||
) {
|
const starterPackSource = parts
|
||||||
const [_, _start, name, rkey] = new URL(
|
.find(part => part.startsWith('utm_content='))
|
||||||
res.installReferrer,
|
?.split('=')[1]
|
||||||
).pathname.split('/')
|
const sourceParts = starterPackSource?.split('-')
|
||||||
|
|
||||||
if (name && rkey) {
|
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({
|
setUsedStarterPack({
|
||||||
uri: res.installReferrer,
|
uri: makeStarterPackLink(sourceParts[1], sourceParts[2]),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
setReady(true)
|
setReady(true)
|
||||||
})()
|
})()
|
||||||
}, [setUsedStarterPack])
|
}, [ready, setUsedStarterPack, usedStarterPack?.lastUsedUri])
|
||||||
|
|
||||||
return ready
|
return ready
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,6 +94,7 @@ export const schema = z.object({
|
|||||||
cid: z.string().optional(),
|
cid: z.string().optional(),
|
||||||
initialFeed: z.string().optional(),
|
initialFeed: z.string().optional(),
|
||||||
isClip: z.boolean().optional(),
|
isClip: z.boolean().optional(),
|
||||||
|
lastUsedUri: z.string().optional(),
|
||||||
})
|
})
|
||||||
.optional(),
|
.optional(),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -3,7 +3,13 @@ import React from 'react'
|
|||||||
import * as persisted from '#/state/persisted'
|
import * as persisted from '#/state/persisted'
|
||||||
|
|
||||||
type StateContext =
|
type StateContext =
|
||||||
| {uri: string; cid?: string; initialFeed?: string; isClip?: boolean}
|
| {
|
||||||
|
uri: string
|
||||||
|
cid?: string
|
||||||
|
initialFeed?: string
|
||||||
|
isClip?: boolean
|
||||||
|
lastUsedUri?: string
|
||||||
|
}
|
||||||
| undefined
|
| undefined
|
||||||
type SetContext = (v: StateContext) => void
|
type SetContext = (v: StateContext) => void
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user