Skip to content

Commit

Permalink
Revert "Make all referrer info sync (#4782)"
Browse files Browse the repository at this point in the history
This reverts commit 306f162.
  • Loading branch information
haileyok committed Aug 1, 2024
1 parent b0e130a commit 2f58d97
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class ExpoBlueskyReferrerModule : Module() {
activityReferrer = appContext.currentActivity?.referrer
}

Function("getReferrerInfo") {
AsyncFunction("getReferrerInfoAsync") {
val intentReferrer =
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
intent?.getParcelableExtra(Intent.EXTRA_REFERRER, Uri::class.java)
Expand All @@ -40,7 +40,7 @@ class ExpoBlueskyReferrerModule : Module() {
"hostname" to intentReferrer.host,
)
intent = null
return@Function res
return@AsyncFunction res
}

// In all other cases, we'll just record the app that sent the intent.
Expand All @@ -52,10 +52,10 @@ class ExpoBlueskyReferrerModule : Module() {
"hostname" to (activityReferrer?.host ?: ""),
)
activityReferrer = null
return@Function res
return@AsyncFunction res
}

return@Function null
return@AsyncFunction null
}

AsyncFunction("getGooglePlayReferrerInfoAsync") { promise: Promise ->
Expand Down
4 changes: 2 additions & 2 deletions modules/expo-bluesky-swiss-army/src/Referrer/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
return NativeModule.getGooglePlayReferrerInfoAsync()
}

export function getReferrerInfo(): Promise<ReferrerInfo | null> {
return NativeModule.getReferrerInfo()
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
return NativeModule.getReferrerInfoAsync()
}
4 changes: 2 additions & 2 deletions modules/expo-bluesky-swiss-army/src/Referrer/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
throw new NotImplementedError()
}

export function getReferrerInfo(): ReferrerInfo | null {
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
const referrer = SharedPrefs.getString('referrer')
if (referrer) {
SharedPrefs.removeValue('referrer')
Expand All @@ -19,7 +19,7 @@ export function getReferrerInfo(): ReferrerInfo | null {
} catch (e) {
return {
referrer,
hostname: referrer,
hostname: undefined,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/expo-bluesky-swiss-army/src/Referrer/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
throw new NotImplementedError()
}

export function getReferrerInfo(): ReferrerInfo | null {
export function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
throw new NotImplementedError()
}
2 changes: 1 addition & 1 deletion modules/expo-bluesky-swiss-army/src/Referrer/index.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function getGooglePlayReferrerInfoAsync(): Promise<GooglePlayReferrerInfo
throw new NotImplementedError()
}

export function getReferrerInfo(): ReferrerInfo | null {
export async function getReferrerInfoAsync(): Promise<ReferrerInfo | null> {
if (
Platform.OS === 'web' &&
// for ssr
Expand Down
17 changes: 9 additions & 8 deletions src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -777,14 +777,15 @@ function logModuleInitTime() {
})

if (isWeb) {
const referrerInfo = Referrer.getReferrerInfo()
if (referrerInfo && referrerInfo.hostname !== 'bsky.app') {
logEvent('deepLink:referrerReceived', {
to: window.location.href,
referrer: referrerInfo?.referrer,
hostname: referrerInfo?.hostname,
})
}
Referrer.getReferrerInfoAsync().then(info => {
if (info && info.hostname !== 'bsky.app') {
logEvent('deepLink:referrerReceived', {
to: window.location.href,
referrer: info?.referrer,
hostname: info?.hostname,
})
}
})
}

if (__DEV__) {
Expand Down
17 changes: 9 additions & 8 deletions src/lib/hooks/useIntentHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ export function useIntentHandler() {

React.useEffect(() => {
const handleIncomingURL = (url: string) => {
const referrerInfo = Referrer.getReferrerInfo()
if (referrerInfo && referrerInfo.hostname !== 'bsky.app') {
logEvent('deepLink:referrerReceived', {
to: url,
referrer: referrerInfo?.referrer,
hostname: referrerInfo?.hostname,
})
}
Referrer.getReferrerInfoAsync().then(info => {
if (info && info.hostname !== 'bsky.app') {
logEvent('deepLink:referrerReceived', {
to: url,
referrer: info?.referrer,
hostname: info?.hostname,
})
}
})

// We want to be able to support bluesky:// deeplinks. It's unnatural for someone to use a deeplink with three
// slashes, like bluesky:///intent/follow. However, supporting just two slashes causes us to have to take care
Expand Down

0 comments on commit 2f58d97

Please sign in to comment.