diff --git a/src/analytics/metrics/types.ts b/src/analytics/metrics/types.ts index 041ca6d5a..03291f801 100644 --- a/src/analytics/metrics/types.ts +++ b/src/analytics/metrics/types.ts @@ -1252,6 +1252,9 @@ export type Events = { // user dismisses the banner 'contacts:nux:bannerDismissed': {} + 'testflightMigration:bannerDisplayed': {} + 'testflightMigration:updatePressed': {} + // user lands on the contacts step 'onboarding:contacts:presented': {} // user pressed "Import Contacts" button to begin flow diff --git a/src/components/TestFlightAppStoreMigrationBanner.test.ts b/src/components/TestFlightAppStoreMigrationBanner.test.ts new file mode 100644 index 000000000..aab43dfb6 --- /dev/null +++ b/src/components/TestFlightAppStoreMigrationBanner.test.ts @@ -0,0 +1,22 @@ +import {shouldShowTestFlightAppStoreMigrationBanner} from './TestFlightAppStoreMigrationBannerGate' + +describe('shouldShowTestFlightAppStoreMigrationBanner', () => { + it('shows on the targeted iOS TestFlight release', () => { + expect( + shouldShowTestFlightAppStoreMigrationBanner({ + isIOS: true, + isTestFlight: true, + releaseVersion: '1.127.2', + }), + ).toBe(true) + }) + + it.each([ + {isIOS: true, isTestFlight: true, releaseVersion: '1.127.1'}, + {isIOS: false, isTestFlight: true, releaseVersion: '1.127.2'}, + {isIOS: true, isTestFlight: false, releaseVersion: '1.127.2'}, + {isIOS: true, isTestFlight: true, releaseVersion: '1.130.2'}, + ])('does not show outside the targeted installs', input => { + expect(shouldShowTestFlightAppStoreMigrationBanner(input)).toBe(false) + }) +}) diff --git a/src/components/TestFlightAppStoreMigrationBanner.tsx b/src/components/TestFlightAppStoreMigrationBanner.tsx new file mode 100644 index 000000000..03a124c37 --- /dev/null +++ b/src/components/TestFlightAppStoreMigrationBanner.tsx @@ -0,0 +1,85 @@ +import {useEffect, useState} from 'react' +import {Linking, View} from 'react-native' +import {useSafeAreaInsets} from 'react-native-safe-area-context' +import {msg} from '@lingui/core/macro' +import {useLingui} from '@lingui/react' +import {Trans} from '@lingui/react/macro' + +import {atoms as a, useTheme} from '#/alf' +import {Button, ButtonText} from '#/components/Button' +import {TimesLarge_Stroke2_Corner0_Rounded as XIcon} from '#/components/icons/Times' +import {shouldShowTestFlightAppStoreMigrationBanner} from '#/components/TestFlightAppStoreMigrationBannerGate' +import {Text} from '#/components/Typography' +import {useAnalytics} from '#/analytics' +import {IS_IOS, IS_TESTFLIGHT, RELEASE_VERSION} from '#/env' + +const APP_STORE_URL = + 'https://apps.apple.com/app/blacksky-community/id6776276281' + +const isEligible = shouldShowTestFlightAppStoreMigrationBanner({ + isIOS: IS_IOS, + isTestFlight: IS_TESTFLIGHT, + releaseVersion: RELEASE_VERSION, +}) + +export function TestFlightAppStoreMigrationBanner() { + const t = useTheme() + const {_} = useLingui() + const ax = useAnalytics() + const {top} = useSafeAreaInsets() + const [dismissed, setDismissed] = useState(false) + + useEffect(() => { + if (isEligible) { + ax.metric('testflightMigration:bannerDisplayed', {}) + } + }, [ax]) + + if (!isEligible || dismissed) return null + + return ( + + + + Update to the App Store installation + + + + + + ) +} diff --git a/src/components/TestFlightAppStoreMigrationBannerGate.ts b/src/components/TestFlightAppStoreMigrationBannerGate.ts new file mode 100644 index 000000000..15ee9a5ca --- /dev/null +++ b/src/components/TestFlightAppStoreMigrationBannerGate.ts @@ -0,0 +1,13 @@ +const TARGET_RELEASE = '1.127.2' + +export function shouldShowTestFlightAppStoreMigrationBanner({ + isIOS, + isTestFlight, + releaseVersion, +}: { + isIOS: boolean + isTestFlight: boolean + releaseVersion: string +}) { + return isIOS && isTestFlight && releaseVersion === TARGET_RELEASE +} diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx index e240df080..0d2ecd81e 100644 --- a/src/view/shell/index.tsx +++ b/src/view/shell/index.tsx @@ -34,6 +34,7 @@ import {SigninDialog} from '#/components/dialogs/Signin' import {Lightbox} from '#/components/Lightbox' import {GlobalReportDialog} from '#/components/moderation/ReportDialog' import {Outlet as PortalOutlet} from '#/components/Portal' +import {TestFlightAppStoreMigrationBanner} from '#/components/TestFlightAppStoreMigrationBanner' import {PassiveAnalytics} from '#/analytics/PassiveAnalytics' import {IS_ANDROID, IS_IOS, IS_LIQUID_GLASS} from '#/env' import {RoutesContainer, TabsNavigator} from '#/Navigation' @@ -94,6 +95,7 @@ function ShellInner() { return ( <> +