From 508263f5bd7094e335a460993c0a93baae732775 Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Fri, 6 Dec 2024 14:50:52 +0100 Subject: [PATCH] [Turbopack] add telemetry for persistent caching usage (#73554) ### What? Report persistent caching as feature --- crates/next-api/src/project.rs | 4 ++++ crates/next-core/src/next_config.rs | 12 ++++++++++++ .../basic/__snapshots__/next-rs-api.test.ts.snap | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/crates/next-api/src/project.rs b/crates/next-api/src/project.rs index 987bfc84bb9be3..edc1cebdfb7375 100644 --- a/crates/next-api/src/project.rs +++ b/crates/next-api/src/project.rs @@ -823,6 +823,10 @@ impl Project { "skipTrailingSlashRedirect", *config.skip_trailing_slash_redirect().await?, ); + emit_event( + "persistentCaching", + *config.persistent_caching_enabled().await?, + ); let config = &config.await?; diff --git a/crates/next-core/src/next_config.rs b/crates/next-core/src/next_config.rs index 951b164d9e8275..11975bc4db3526 100644 --- a/crates/next-core/src/next_config.rs +++ b/crates/next-core/src/next_config.rs @@ -413,6 +413,7 @@ pub struct ExperimentalTurboConfig { pub tree_shaking: Option, pub module_id_strategy: Option, pub minify: Option, + pub unstable_persistent_caching: Option, } #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, TraceRawVcs)] @@ -1041,6 +1042,17 @@ impl NextConfig { Vc::cell(Some(ResolvedVc::cell(rules))) } + #[turbo_tasks::function] + pub fn persistent_caching_enabled(&self) -> Result> { + Ok(Vc::cell( + self.experimental + .turbo + .as_ref() + .and_then(|t| t.unstable_persistent_caching) + .unwrap_or_default(), + )) + } + #[turbo_tasks::function] pub fn resolve_alias_options(&self) -> Result> { let Some(resolve_alias) = self diff --git a/test/development/basic/__snapshots__/next-rs-api.test.ts.snap b/test/development/basic/__snapshots__/next-rs-api.test.ts.snap index 938bfbf52a1396..acd72d979b6ff2 100644 --- a/test/development/basic/__snapshots__/next-rs-api.test.ts.snap +++ b/test/development/basic/__snapshots__/next-rs-api.test.ts.snap @@ -65,6 +65,13 @@ exports[`next.rs api should detect the correct routes: diagnostics 1`] = ` "modularizeImports": "true", }, }, + { + "category": "NextFeatureTelemetry_category_tbd", + "name": "EVENT_BUILD_FEATURE_USAGE", + "payload": { + "persistentCaching": "false", + }, + }, { "category": "NextFeatureTelemetry_category_tbd", "name": "EVENT_BUILD_FEATURE_USAGE",