From 4349c7f16d2646f2c2812e1066b4e3c5ee2e49cb Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 12 Feb 2025 16:43:00 -0600 Subject: [PATCH] Clean up env --- .env.example | 27 ++++++++++++++++++++------ src/env.ts | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 7 deletions(-) diff --git a/.env.example b/.env.example index a4d21ac332..78d7af5826 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,23 @@ -# Copy this to `.env` and `.env.test` files - -BITDRIFT_API_KEY= -SENTRY_AUTH_TOKEN= -EXPO_PUBLIC_LOG_LEVEL=debug -EXPO_PUBLIC_LOG_DEBUG= +# The env the app is running in e.g. development, testflight, production +EXPO_PUBLIC_ENV=development +# This is the commit hash that the current bundle was made from. The user can +# see the commit hash in the app's settings along with the other version info. +# Useful for debugging/reporting. EXPO_PUBLIC_BUNDLE_IDENTIFIER= +# This will always be in the format of YYMMDD, so that it always increases for +# each build. This should only be used for Statsig reporting and shouldn't be +# used to identify a specific bundle. EXPO_PUBLIC_BUNDLE_DATE=0 +# The log level for the app's logger transports +EXPO_PUBLIC_LOG_LEVEL=info +# Currently unused. Enable debug for a subset of the debug logs. +EXPO_PUBLIC_LOG_DEBUG= + +# +# Bluesky specific +# + +# Bitdrift +BITDRIFT_API_KEY= +# Sentry +SENTRY_AUTH_TOKEN= diff --git a/src/env.ts b/src/env.ts index 32ce70670b..bd1a250bd0 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,6 +1,57 @@ -export const LOG_DEBUG = process.env.EXPO_PUBLIC_LOG_DEBUG || '' +/** + * The env the app is running in e.g. development, testflight, production + */ +export const EXPO_PUBLIC_ENV = process.env.EXPO_PUBLIC_ENV + +/** + * Indicates whether the app is running in TestFlight mode + */ +export const IS_TESTFLIGHT = EXPO_PUBLIC_ENV === 'testflight' + +/** + * Indicates whether the app is __DEV__ or TestFlight + */ +export const IS_INTERNAL = __DEV__ || IS_TESTFLIGHT + +/** + * The commit hash that the current bundle was made from. The user can see the + * commit hash in the app's settings along with the other version info. Useful + * for debugging/reporting. + */ +export const BUNDLE_IDENTIFIER: string = + process.env.EXPO_PUBLIC_BUNDLE_IDENTIFIER ?? '' + +/** + * This will always be in the format of YYMMDD, so that it always increases for + * each build. This should only be used for Statsig reporting and shouldn't be + * used to identify a specific bundle. + */ +export const BUNDLE_DATE: number = IS_INTERNAL + ? 0 + : Number(process.env.EXPO_PUBLIC_BUNDLE_DATE) + +/** + * The log level for the app. + */ export const LOG_LEVEL = (process.env.EXPO_PUBLIC_LOG_LEVEL || 'info') as | 'debug' | 'info' | 'warn' | 'error' + +/** + * Currently unused. Enable debug for a subset of the debug logs. + */ +export const LOG_DEBUG: string = process.env.EXPO_PUBLIC_LOG_DEBUG || '' + +/** + * Bitdrift API key. If undefined, Bitdrift should be disabled. + */ +export const BITDRIFT_API_KEY: string | undefined = + process.env.EXPO_PUBLIC_BITDRIFT_API_KEY + +/** + * Sentry API key. If undefined, Sentry should be disabled. + */ +export const SENTRY_API_KEY: string | undefined = + process.env.EXPO_PUBLIC_SENTRY_API_KEY