From b5ff69e5151acfe4da3b791495603ec2b2b1af76 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 22 Jul 2025 17:17:58 -0500 Subject: [PATCH] Clean up env files --- .env.example | 51 ++++++++++++++++++++++++++++++---- src/env.ts | 77 +++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 122 insertions(+), 6 deletions(-) diff --git a/.env.example b/.env.example index a4d21ac332..844919a5be 100644 --- a/.env.example +++ b/.env.example @@ -1,8 +1,49 @@ -# Copy this to `.env` and `.env.test` files +# The env the app is running in e.g. development, testflight, production +EXPO_PUBLIC_ENV=development -BITDRIFT_API_KEY= -SENTRY_AUTH_TOKEN= -EXPO_PUBLIC_LOG_LEVEL=debug -EXPO_PUBLIC_LOG_DEBUG= +# This is the short commit hash that the current bundle was made from. EXPO_PUBLIC_BUNDLE_IDENTIFIER= + +# Should be formatted YYMMDD so that it increases for each build. EXPO_PUBLIC_BUNDLE_DATE=0 + +# Optional app view proxy DID +EXPO_PUBLIC_APPVIEW_PROXY_DID=did:web:api.cozy.bsky.dev + +# The log level for the app's logger transports +EXPO_PUBLIC_LOG_LEVEL=debug + +# Enable debug logs for specific logger instances +EXPO_PUBLIC_LOG_DEBUG=session + +# Chat service DID +EXPO_PUBLIC_CHAT_PROXY_DID= + +# +# +# Bluesky specific values +# +# + +# Sentry DSN for telemetry +SENTRY_DSN= + +# Populates the `dist` value on Sentry events. We use the full commit hash the +# current bundle was made from. +SENTRY_DIST=test + +# Populates the `release` value on Sentry events. This is the version of the +# app specified in the package.json. +SENTRY_RELEASE=dev + +# Bitdrift API key. If undefined, Bitdrift will be disabled. +BITDRIFT_API_KEY= + +# +# +# CI and build related +# +# + +# Sentry token used to authenticate source map uploads +SENTRY_AUTH_TOKEN= diff --git a/src/env.ts b/src/env.ts index 32ce70670b..5e99e31109 100644 --- a/src/env.ts +++ b/src/env.ts @@ -1,6 +1,81 @@ -export const LOG_DEBUG = process.env.EXPO_PUBLIC_LOG_DEBUG || '' +import {type Did} from '@atproto/api' + +/** + * The env the app is running in e.g. development, testflight, production + */ +export const ENV = process.env.EXPO_PUBLIC_ENV + +/** + * Indicates whether the app is running in TestFlight + */ +export const IS_TESTFLIGHT = ENV === 'testflight' + +/** + * Indicates whether the app is __DEV__ + */ +export const IS_DEV = __DEV__ + +/** + * Indicates whether the app is __DEV__ or TestFlight + */ +export const IS_INTERNAL = IS_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 || !process.env.EXPO_PUBLIC_BUNDLE_DATE + ? 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 || '' + +/** + * The DID of the chat service to proxy to + */ +export const CHAT_PROXY_DID: Did = + process.env.EXPO_PUBLIC_CHAT_PROXY_DID || 'did:web:api.bsky.chat' + +/** + * Sentry DSN for telemetry + */ +export const SENTRY_DSN: string | undefined = process.env.SENTRY_DSN + +/** + * Populates the `release` value on Sentry events. This is the version of the + * app specified in the package.json. + */ +export const SENTRY_RELEASE: string = process.env.SENTRY_RELEASE || 'dev' + +/** + * Populates the `dist` value on Sentry events. We use the full commit hash the + * current bundle was made from. + */ +export const SENTRY_DIST: string = process.env.SENTRY_DIST || 'dev' + +/** + * Bitdrift API key. If undefined, Bitdrift should be disabled. + */ +export const BITDRIFT_API_KEY: string | undefined = process.env.BITDRIFT_API_KEY