Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(ios): fetch production PostHog key from Doppler (#7702)

Peter Chinman953bf5ddda0c
diff --git a/apps/web/README.md b/apps/web/README.md
index ad6f03b5db..1e89bd51d0 100644
--- a/apps/web/README.md
+++ b/apps/web/README.md
@@ -8,11 +8,15 @@ The production application is compiled down to a static javascript bundle using
## Production analytics configuration
-For local production builds, set `VITE_POSTHOG_API_KEY` in the ignored
-`apps/web/.env.production.local`. Vite loads this file automatically; use the
-existing build commands. The shared value is stored in Doppler `web-release/prd`.
-CI continues to inject the GitHub `POSTHOG_API_KEY` secret. Keep the value out of
-tracked env files.
+`just ios-build` uses an existing `VITE_POSTHOG_API_KEY` environment variable or
+fetches it from Doppler `web-release/prd` and exports it for the build. Install
+the Doppler CLI and authenticate with read access to that config. The build
+fails if the key cannot be fetched or is empty; no env file is created.
+
+For other local production builds, set `VITE_POSTHOG_API_KEY` in the environment
+or the ignored `apps/web/.env.production.local`. Vite loads this file
+automatically. CI continues to inject the GitHub `POSTHOG_API_KEY` secret. Keep
+the value out of tracked env files.
### Toolchain Management
diff --git a/apps/web/scripts/ios-build.sh b/apps/web/scripts/ios-build.sh
index 40efd3ae4e..260a01e030 100644
--- a/apps/web/scripts/ios-build.sh
+++ b/apps/web/scripts/ios-build.sh
@@ -20,6 +20,17 @@ script_dir="$(\cd "$(dirname "$0")" && pwd)"
source "$script_dir/ios-native-env.sh"
ios_resolve_toolchain aarch64-apple-ios
+# Production analytics must be configured before Vite embeds the key.
+if [[ -z "${VITE_POSTHOG_API_KEY:-}" ]]; then
+ if ! VITE_POSTHOG_API_KEY="$(doppler secrets get VITE_POSTHOG_API_KEY \
+ --project web-release --config prd --plain --raw --no-check-version 2>/dev/null)" \
+ || [[ -z "$VITE_POSTHOG_API_KEY" ]]; then
+ echo "Unable to fetch VITE_POSTHOG_API_KEY. Install the Doppler CLI and authenticate with read access to web-release/prd, or supply VITE_POSTHOG_API_KEY in the environment." >&2
+ exit 1
+ fi
+fi
+export VITE_POSTHOG_API_KEY
+
# The web/WASM build keeps its original toolchain. Switch to Apple tools only
# for the native build, and skip Tauri's hook because it has already run here.
just build-tauri
diff --git a/apps/web/tauri/src-tauri/README.md b/apps/web/tauri/src-tauri/README.md
index 9a6abed2e9..ad5e38c1f8 100644
--- a/apps/web/tauri/src-tauri/README.md
+++ b/apps/web/tauri/src-tauri/README.md
@@ -114,10 +114,16 @@ according to `tauri.conf.json`.
From `apps/web`, use `just ios-build` for a release build or
`just ios-build --no-update` to disable automatic bundle updates.
-`just ios-build-no-update` remains a compatibility alias. Both modes build the
-frontend with the current shell's toolchain, then select Xcode's compiler,
-linker, and tools for the native build and the opened Xcode session. This avoids
-Nix's macOS compiler wrapper injecting `-mmacos-version-min` into an iOS build.
+`just ios-build-no-update` remains a compatibility alias. Both modes use
+`VITE_POSTHOG_API_KEY` from the environment, fetching it from
+Doppler `web-release/prd` if it is unset or empty. Install the Doppler CLI and
+authenticate with read access to that config, or supply the variable explicitly.
+An unavailable or empty key stops the build before frontend compilation.
+
+Both modes build the frontend with the current shell's toolchain, then select
+Xcode's compiler, linker, and tools for the native build and the opened Xcode
+session. This avoids Nix's macOS compiler wrapper injecting
+`-mmacos-version-min` into an iOS build.
The system `xcode-select` selection is used unless `DEVELOPER_DIR` explicitly
selects an Xcode installation. Keep the recipe running while building in Xcode
so Tauri's options server can supply the build configuration and tool paths.