From 7f9898a90b511e323f11e3159714917055c98e3a Mon Sep 17 00:00:00 2001 From: Gaauwe Rombouts Date: Fri, 17 Oct 2025 17:10:59 +0200 Subject: [PATCH] Add Amplitude tracking to docs (#40494) Closes #ISSUE Release Notes: - N/A *or* Added/Fixed/Improved ... --- .github/workflows/deploy_cloudflare.yml | 2 ++ crates/docs_preprocessor/src/main.rs | 2 ++ docs/theme/index.hbs | 18 +++++++++++++++++- 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/.github/workflows/deploy_cloudflare.yml b/.github/workflows/deploy_cloudflare.yml index df35d44ca9..2650cce140 100644 --- a/.github/workflows/deploy_cloudflare.yml +++ b/.github/workflows/deploy_cloudflare.yml @@ -22,6 +22,8 @@ jobs: - name: Build docs uses: ./.github/actions/build_docs + env: + DOCS_AMPLITUDE_API_KEY: ${{ secrets.DOCS_AMPLITUDE_API_KEY }} - name: Deploy Docs uses: cloudflare/wrangler-action@da0e0dfe58b7a431659754fdf3f186c529afbe65 # v3 diff --git a/crates/docs_preprocessor/src/main.rs b/crates/docs_preprocessor/src/main.rs index 2e0d9b21fb..747cb2ecdd 100644 --- a/crates/docs_preprocessor/src/main.rs +++ b/crates/docs_preprocessor/src/main.rs @@ -529,6 +529,7 @@ fn handle_postprocessing() -> Result<()> { .as_str() .expect("Default title not a string") .to_string(); + let amplitude_key = std::env::var("DOCS_AMPLITUDE_API_KEY").unwrap_or_default(); output.insert("html".to_string(), zed_html); mdbook::Renderer::render(&mdbook::renderer::HtmlHandlebars::new(), &ctx)?; @@ -597,6 +598,7 @@ fn handle_postprocessing() -> Result<()> { let meta_title = format!("{} | {}", page_title, meta_title); zlog::trace!(logger => "Updating {:?}", pretty_path(&file, &root_dir)); let contents = contents.replace("#description#", meta_description); + let contents = contents.replace("#amplitude_key#", &litude_key); let contents = title_regex() .replace(&contents, |_: ®ex::Captures| { format!("{}", meta_title) diff --git a/docs/theme/index.hbs b/docs/theme/index.hbs index 86008ed690..64ca072ef2 100644 --- a/docs/theme/index.hbs +++ b/docs/theme/index.hbs @@ -311,7 +311,23 @@ })(); - + +